From 6bed9cae2bac44d1a33a260f8b98358050b83c0c Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Tue, 22 Sep 2026 10:02:35 -0700 Subject: [PATCH] fix(epw): Patch issue I won't name who is at fault here but it seems there is a vendor of EPWs who would rather write an essay defending the contradiction of data in the files they sell rather than just making their software better or listening to their customers. Hopefully, this patch to accommodate their invalid files does not make it more difficult for us to accept EPWs from the valid sources in the industry. --- ladybug/epw.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ladybug/epw.py b/ladybug/epw.py index b906bd44..1f9a9906 100644 --- a/ladybug/epw.py +++ b/ladybug/epw.py @@ -536,7 +536,7 @@ def _import_body(self, body_lines): """Set all of the EPW data collections by parsing from the body lines.""" # get the number of fields and make an annual analysis period self._num_of_fields = min(len(body_lines[0].strip().split(',')), 35) - if self.is_leap_year is None: + if not self.is_leap_year: self._is_leap_year = True if len(body_lines) == 8784 else False analysis_period = AnalysisPeriod(is_leap_year=self.is_leap_year) @@ -1516,8 +1516,11 @@ def approximate_design_day(self, day_type='SummerDesignDay', percentile=0.4): # get the date as the 21st of the hottest month date_obj = Date(avg_mon_temp.highest_values(1)[1][0] + 1, 21) # compute the daily range of temperature from the days of the hottest month - hot_mon_db = self.dry_bulb_temperature.filter_by_analysis_period( - AnalysisPeriod(st_month=date_obj.month, end_month=date_obj.month)) + ha_per = AnalysisPeriod( + st_month=date_obj.month, end_month=date_obj.month, + is_leap_year=self.is_leap_year + ) + hot_mon_db = self.dry_bulb_temperature.filter_by_analysis_period(ha_per) temp_ranges = [] for day in hot_mon_db.group_by_day().values(): if day != []: