Skip to content

Commit

Permalink
handle all-caps soil-temp stations, like Frankfurt
Browse files Browse the repository at this point in the history
  • Loading branch information
vtnate committed Jan 1, 2025
1 parent a81cb1a commit dc9e51b
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,23 @@ def to_modelica(self, scaffold):
coefs = pd.read_csv(Path(__file__).parent / "data" / "Soil_temp_coefficients.csv")
matching_rows = coefs[coefs.apply(lambda row: row.astype(str).str.contains(station_name).any(), axis=1)]
if len(matching_rows) == 0:
raise ValueError(
"No matching weather station has been found. Please check your weather file name format."
"(e.g., USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.mos)"
)
else:
template_data["surface_temp"] = matching_rows["Ts,avg, C"].iloc[0] + 273.15
template_data["first_amplitude"] = matching_rows["Ts,amplitude,1, C"].iloc[0]
template_data["second_amplitude"] = matching_rows["Ts,amplitude,2, C"].iloc[0]
template_data["first_phase_lag"] = matching_rows["PL1"].iloc[0]
template_data["second_phase_lag"] = matching_rows["PL2"].iloc[0]
# Some of the stations in the coefs df are in all caps, so try that as well.
# Also try to match only the first word of the station name.
station_name = station_name.split()[0]
matching_rows = coefs[
coefs.apply(lambda row: row.astype(str).str.contains(station_name.upper()).any(), axis=1)
]
# If still no match, raise an error
if len(matching_rows) == 0:
raise ValueError(
"No matching weather station has been found. Please check your weather file name format."
"(e.g., USA_NY_Buffalo-Greater.Buffalo.Intl.AP.725280_TMY3.mos)"
)
template_data["surface_temp"] = matching_rows["Ts,avg, C"].iloc[0] + 273.15
template_data["first_amplitude"] = matching_rows["Ts,amplitude,1, C"].iloc[0]
template_data["second_amplitude"] = matching_rows["Ts,amplitude,2, C"].iloc[0]
template_data["first_phase_lag"] = matching_rows["PL1"].iloc[0]
template_data["second_phase_lag"] = matching_rows["PL2"].iloc[0]

# create horizontal piping package paths
b_modelica_path = ModelicaPath(self.ground_coupling_name, scaffold.networks_path.files_dir, True)
Expand Down

0 comments on commit dc9e51b

Please sign in to comment.