Skip to content

Commit 16628b7

Browse files
committed
fix(epw): Determine leap year from datetimes when flag is not present
This commit also fixes a number of PEP8 styling issues.
1 parent 6d8928a commit 16628b7

File tree

7 files changed

+8823
-11
lines changed

7 files changed

+8823
-11
lines changed

ladybug/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def _load_from_file(self, file_path):
192192
paths = json.load(cfg)
193193
except Exception as e:
194194
print('Failed to load paths from {}.\nThey will be set to defaults '
195-
'instead\n{}'.format(file_path, e))
195+
'instead\n{}'.format(file_path, e))
196196
else:
197197
for key, p in paths.items():
198198
if not key.startswith('__') and p.strip():

ladybug/datatype/volumeflowrate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import division
44

55
from .base import DataTypeBase
6-
from .volume import Volume
76
from .volumeflowrateintensity import VolumeFlowRateIntensity
87

98

ladybug/epw.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,12 @@ def _import_header(self, header_lines):
514514

515515
# parse leap year, daylight savings and comments.
516516
leap_dl_sav = header_lines[4].strip().split(',')
517-
self._is_leap_year = True if leap_dl_sav[1] == 'Yes' else False
517+
if leap_dl_sav[1] == 'Yes':
518+
self._is_leap_year = True
519+
elif leap_dl_sav[1] == 'No':
520+
self._is_leap_year = False
521+
else:
522+
self._is_leap_year = None
518523
self.daylight_savings_start = leap_dl_sav[2]
519524
self.daylight_savings_end = leap_dl_sav[3]
520525
comments_1 = header_lines[5].strip().split(',')
@@ -530,6 +535,8 @@ def _import_body(self, body_lines):
530535
"""Set all of the EPW data collections by parsing from the body lines."""
531536
# get the number of fields and make an annual analysis period
532537
self._num_of_fields = min(len(body_lines[0].strip().split(',')), 35)
538+
if self.is_leap_year is None:
539+
self._is_leap_year = True if len(body_lines) == 8784 else False
533540
analysis_period = AnalysisPeriod(is_leap_year=self.is_leap_year)
534541

535542
# create headers and an empty list for each field in epw file
@@ -1306,9 +1313,10 @@ def sky_temperature(self):
13061313
climate-calculations.html#energyplus-sky-temperature-calculation
13071314
"""
13081315
# create sky temperature header
1309-
sky_temp_header = Header(data_type=temperature.SkyTemperature(), unit='C',
1310-
analysis_period=AnalysisPeriod(),
1311-
metadata=self._metadata)
1316+
sky_temp_header = Header(
1317+
data_type=temperature.SkyTemperature(), unit='C',
1318+
analysis_period=AnalysisPeriod(is_leap_year=self.is_leap_year),
1319+
metadata=self._metadata)
13121320

13131321
# calculate sy temperature for each hour
13141322
horiz_ir = self._get_data_by_field(12).values

ladybug/monthlychart.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def _compute_hourly_lines(self):
513513
up_vals, low_vals = self._hour_y_values_stack_split(
514514
data, d_range, min_val, step, prev_y_up, prev_y_low, d_i)
515515
lines_up = self._hour_polylines(up_vals, x_dist)
516-
lines_low =self._hour_polylines(low_vals, x_dist)
516+
lines_low = self._hour_polylines(low_vals, x_dist)
517517
lines.extend(lines_up)
518518
lines.extend(lines_low)
519519
total_len = len(lines_up) + len(lines_low)
@@ -531,7 +531,7 @@ def _compute_hourly_lines(self):
531531
else:
532532
prev_y_low = low_vals
533533
lines_up = self._hour_polylines(up_vals, x_dist)
534-
lines_low =self._hour_polylines(low_vals, x_dist)
534+
lines_low = self._hour_polylines(low_vals, x_dist)
535535
lines.extend(lines_up)
536536
lines.extend(lines_low)
537537
total_len = len(lines_up) + len(lines_low)
@@ -548,7 +548,7 @@ def _compute_hourly_lines(self):
548548
low_vals = self._hour_y_values(data[0], d_range, min_val, step)
549549
up_vals = self._hour_y_values(data[-1], d_range, min_val, step)
550550
lines_up = self._hour_polylines(up_vals, x_dist)
551-
lines_low =self._hour_polylines(low_vals, x_dist)
551+
lines_low = self._hour_polylines(low_vals, x_dist)
552552
lines.extend(lines_up)
553553
lines.extend(lines_low)
554554
total_len = len(lines_up) + len(lines_low)
@@ -583,7 +583,7 @@ def _compute_monthly_per_hour_lines(self):
583583
prev_y = prev_y_up if pos else prev_y_low
584584
vals = self._hour_y_values_stack(
585585
data, d_range, min_val, step, prev_y)
586-
# set start y so the next data stacks
586+
# set start y so the next data stacks
587587
if pos:
588588
prev_y_up = vals
589589
else:

ladybug/psychchart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class PsychrometricChart(object):
103103
def __init__(self, temperature, relative_humidity, average_pressure=101325,
104104
legend_parameters=None, base_point=Point2D(), x_dim=1, y_dim=1500,
105105
min_temperature=-20, max_temperature=50, max_humidity_ratio=0.03,
106-
use_ip=False):
106+
use_ip=False):
107107
"""Initialize Psychrometric Chart."""
108108
# check and assign the temperature and humidity
109109
self._use_ip = bool(use_ip)

0 commit comments

Comments
 (0)