Skip to content

Commit 3e8d78e

Browse files
tg359Fraser Greenroyd
authored andcommitted
minor bugfix to avoid breaking when calling certain methods
1 parent 0fb0cfc commit 3e8d78e

2 files changed

Lines changed: 25 additions & 9 deletions

File tree

LadybugTools_Engine/Python/src/ladybugtools_toolkit/ladybug_extension/datacollection.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ def to_hourly(
552552
HourlyContinuousCollection:
553553
A Ladybug HourlyContinuousCollection object.
554554
"""
555-
556555
if method is None:
557556
method = "smooth"
558557

LadybugTools_Engine/Python/src/ladybugtools_toolkit/ladybug_extension/epw.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from ladybug.wea import Wea
3535
from ladybug_comfort.degreetime import cooling_degree_time, heating_degree_time
3636

37+
from ..external_comfort.ground_temperature import hourly_ground_temperature
3738
from ..helpers import (
3839
air_pressure_at_height,
3940
radiation_at_height,
@@ -49,14 +50,22 @@
4950
from .location import location_to_string as location_to_string
5051

5152

52-
def epw_to_dataframe(epw: EPW, include_additional: bool = False) -> pd.DataFrame:
53+
def epw_to_dataframe(
54+
epw: EPW, include_additional: bool = False, **kwargs
55+
) -> pd.DataFrame:
5356
"""Create a Pandas DataFrame from an EPW object, with option for including additional metrics.
5457
5558
Args:
5659
epw (EPW):
5760
An EPW object.
5861
include_additional (bool, optional):
5962
Set to False to not include additional calculated properties. Default is False.
63+
**kwargs:
64+
Additional keyword arguments to be passed to the to_dataframe method.
65+
ground_temperature_depth (float):
66+
The depth in m at which to calculate ground temperatures. Default is 0.5.
67+
soil_diffusivity (float):
68+
The soil diffusivity in m2/s. Default is 3.1e-7.
6069
6170
Returns:
6271
pd.DataFrame:
@@ -128,6 +137,13 @@ def epw_to_dataframe(epw: EPW, include_additional: bool = False) -> pd.DataFrame
128137
ent = enthalpy(epw, hr)
129138
wbt = wet_bulb_temperature(epw)
130139

140+
# Calculate ground temperatures
141+
ground_temp = hourly_ground_temperature(
142+
epw,
143+
depth=kwargs.pop("ground_temperature_depth", 0.5),
144+
soil_diffusivity=kwargs.pop("soil_diffusivity", 3.1e-7),
145+
)
146+
131147
# Add properties to DataFrame
132148
for collection in [
133149
eot,
@@ -143,6 +159,7 @@ def epw_to_dataframe(epw: EPW, include_additional: bool = False) -> pd.DataFrame
143159
hr,
144160
ent,
145161
wbt,
162+
ground_temp,
146163
]:
147164
s = collection_to_series(collection)
148165
s.rename((Path(epw.file_path).stem, "EPW", s.name), inplace=True)
@@ -946,16 +963,16 @@ def seasonality_from_day_length_location(
946963
)
947964

948965
shortest_day_length = timedelta_tostring(sun_times.day_length.min())
949-
shortest_day = sun_times.day_length.idxmin()
966+
_shortest_day = sun_times.day_length.idxmin()
950967
middlest_day_length = timedelta_tostring(sun_times.day_length.mean())
951968
longest_day_length = timedelta_tostring(sun_times.day_length.max())
952-
longest_day = sun_times.day_length.idxmax()
969+
_longest_day = sun_times.day_length.idxmax()
953970

954971
months = pd.Timedelta(days=3 * 30)
955972

956-
if (longest_day + months).year != longest_day.year:
957-
spring_equinox = shortest_day + months
958-
autumn_equinox = shortest_day - months
973+
if (_longest_day + months).year != _longest_day.year:
974+
spring_equinox = _shortest_day + months
975+
autumn_equinox = _shortest_day - months
959976

960977
autumn_right = autumn_equinox + (months / 2)
961978
autumn_left = autumn_equinox - (months / 2)
@@ -968,8 +985,8 @@ def seasonality_from_day_length_location(
968985
winter_mask = (idx > autumn_right) & (idx <= spring_left)
969986

970987
else:
971-
spring_equinox = longest_day - months
972-
autumn_equinox = longest_day + months
988+
spring_equinox = _longest_day - months
989+
autumn_equinox = _longest_day + months
973990

974991
autumn_right = autumn_equinox + (months / 2)
975992
autumn_left = autumn_equinox - (months / 2)

0 commit comments

Comments
 (0)