Skip to content

Commit

Permalink
Added Wet Bulb Temperature to EPW Keys (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesramsden-bh authored Aug 12, 2024
2 parents ab8554d + c89cf82 commit 4497685
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ def diurnal(epw_file, return_file: str, data_type_key="Dry Bulb Temperature", co
try:
from ladybug.epw import EPW, AnalysisPeriod
from ladybugtools_toolkit.ladybug_extension.datacollection import collection_to_series
from ladybugtools_toolkit.ladybug_extension.epw import wet_bulb_temperature
from ladybugtools_toolkit.plot._diurnal import diurnal
from ladybug.datacollection import HourlyContinuousCollection
from ladybugtools_toolkit.plot.utilities import figure_to_base64
from ladybugtools_toolkit.bhom.wrapped.metadata.collection import collection_metadata
import matplotlib.pyplot as plt

epw = EPW(epw_file)
data_type_key = data_type_key.replace("_"," ")
coll = HourlyContinuousCollection.from_dict([a for a in epw.to_dict()["data_collections"] if a["header"]["data_type"]["name"] == data_type_key][0])
fig = diurnal(collection_to_series(coll), title=title, period=period, color=color).get_figure()

if data_type_key == "Wet Bulb Temperature":
coll = wet_bulb_temperature(epw)
else:
coll = HourlyContinuousCollection.from_dict([a for a in epw.to_dict()["data_collections"] if a["header"]["data_type"]["name"] == data_type_key][0])

fig = diurnal(collection_to_series(coll),title=title, period=period, color=color).get_figure()
return_dict = {"data": collection_metadata(coll)}

if save_path == None or save_path == "":
base64 = figure_to_base64(fig, html=False)
return_dict["figure"] = base64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ def heatmap(epw_file: str, data_type_key: str, colour_map: str, return_file: str
from ladybugtools_toolkit.plot._heatmap import heatmap
from ladybugtools_toolkit.ladybug_extension.datacollection import collection_to_series
from ladybugtools_toolkit.bhom.wrapped.metadata.collection import collection_metadata
from ladybugtools_toolkit.ladybug_extension.epw import wet_bulb_temperature
from ladybugtools_toolkit.plot.utilities import figure_to_base64
import matplotlib.pyplot as plt

if colour_map not in plt.colormaps():
colour_map = "YlGnBu"


epw = EPW(epw_file)
coll = HourlyContinuousCollection.from_dict([a for a in epw.to_dict()["data_collections"] if a["header"]["data_type"]["name"] == data_type_key][0])

if data_type_key == "Wet Bulb Temperature":
coll = wet_bulb_temperature(epw)
else:
coll = HourlyContinuousCollection.from_dict([a for a in epw.to_dict()["data_collections"] if a["header"]["data_type"]["name"] == data_type_key][0])

fig = heatmap(collection_to_series(coll), cmap=colour_map).get_figure()

return_dict = {}
Expand Down
4 changes: 4 additions & 0 deletions LadybugTools_oM/Enum/EPWKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public enum EPWKey
[DisplayText("Total Sky Cover")]
TotalSkyCover,
Visibility,
[DisplayText("Wet Bulb Temperature")]
[Description("Wet bulb temperature is a calculated property of epw data.")]
// This was added to handle calculating wet bulb temperature with c#/python interop. If utilising this enum for other purposes, ensure that this value being selected by a user is handled correctly (either by showing an appropriate error, or calculating the wet bulb temperature)
WetBulbTemperature,
[DisplayText("Wind Direction")]
WindDirection,
[DisplayText("Wind Speed")]
Expand Down

0 comments on commit 4497685

Please sign in to comment.