Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 4G result data #7

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
41 changes: 35 additions & 6 deletions urbanopt_des/modelica_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,22 @@ def resample_and_convert_to_df(
ghx_pump = self.retrieve_variable_data("pumSto.P", len(time1))
distribution_pump = self.retrieve_variable_data("pumDis.P", len(time1))

# chillers
chiller_data: dict[str, list[float]] = {}
# 1. get the variables of all the chillers
chiller_vars = self.modelica_data.varNames("cooPla_.*mulChiSys.P.*")
# 2. get the data for all the chillers
if len(chiller_vars) > 0:
for chiller_id, chiller_var in enumerate(chiller_vars):
chiller_energy = self.retrieve_variable_data(chiller_var, len(time1))
chiller_data[f"Chiller {chiller_id+1}"] = chiller_energy
else:
chiller_data["Chiller"] = [0] * len(time1)

# for n_c in range(1, len(chiller_data.keys()) + 1):
# agg_columns["ETS Pump Electricity Total"].append(f"Chiller {n_c}")
# building_data[f"Chiller {n_c}"] = chiller_data[f"Chiller {n_c}"]

# building related data
building_data: dict[str, list[float]] = {}

Expand Down Expand Up @@ -260,6 +276,11 @@ def resample_and_convert_to_df(
building_data[f"ETS Thermal Cooling Building {building_id}"] = ets_q_cooling
building_data[f"ETS Thermal Heating Building {building_id}"] = ets_q_heating

# Add in chiller aggregations
agg_columns["Chillers Total"] = []
vtnate marked this conversation as resolved.
Show resolved Hide resolved
for n_c in range(1, len(chiller_data.keys()) + 1):
agg_columns["Chillers Total"].append(f"Chiller {n_c}")

# convert time to timestamps for pandas
time = [datetime(year_of_data, 1, 1, 0, 0, 0) + timedelta(seconds=int(t)) for t in time1]

Expand All @@ -271,12 +292,16 @@ def resample_and_convert_to_df(
df_energy.index.name = "datetime"

# all data combined
data = {
"datetime": time,
"Sewer Pump Electricity": sewer_pump,
"GHX Pump Electricity": ghx_pump,
"Distribution Pump Electricity": distribution_pump,
} | building_data
data = (
{
Comment on lines +380 to +381
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the new parentheses? What is that doing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of the pipes combining the data. But maybe they aren't needed?

"datetime": time,
"Sewer Pump Electricity": sewer_pump,
"GHX Pump Electricity": ghx_pump,
"Distribution Pump Electricity": distribution_pump,
}
| building_data
| chiller_data
)

# add in the 'other variables' if they exist
if other_vars is not None:
Expand All @@ -287,6 +312,9 @@ def resample_and_convert_to_df(

df_power = pd.pandas.DataFrame(data)
Copy link
Contributor

@vtnate vtnate Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pd.pandas.dataframe? 😱

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, I should fix this and do import pandas as pd.... oof..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already did! 😆


# create aggregation columns for chillers
df_power["Total Chillers"] = df_power[agg_columns["Chillers Total"]].sum(axis=1)

# create aggregation columns for total pumps, total heat pumps, and total
df_power["ETS Pump Electricity Total"] = df_power[agg_columns["ETS Pump Electricity Total"]].sum(axis=1)
df_power["ETS Heat Pump Electricity Total"] = df_power[agg_columns["ETS Heat Pump Electricity Total"]].sum(axis=1)
Expand All @@ -308,6 +336,7 @@ def resample_and_convert_to_df(
"Sewer Pump Electricity",
"GHX Pump Electricity",
"Distribution Pump Electricity",
"Total Chillers",
]
df_power["Total DES Electricity"] = df_power[column_names].sum(axis=1)

Expand Down
Loading