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

Join schedules to timeseries #465

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions buildstockbatch/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def cleanup_sim_dir(sim_dir, dest_fs, simout_ts_dir, upgrade_id, building_id):

# Convert the timeseries data to parquet
# and copy it to the results directory
timeseries_filepath = os.path.join(sim_dir, "run", "results_timeseries.csv")
output_dir = os.path.join(sim_dir, "run")
timeseries_filepath = os.path.join(output_dir, "results_timeseries.csv")
# FIXME: Allowing both names here for compatibility. Should consolidate on one timeseries filename.
if os.path.isfile(timeseries_filepath):
units_dict = read_csv(timeseries_filepath, nrows=1).transpose().to_dict()[0]
Expand All @@ -215,11 +216,10 @@ def cleanup_sim_dir(sim_dir, dest_fs, simout_ts_dir, upgrade_id, building_id):
units_dict = {}
skiprows = []

schedules_filepath = ""
if os.path.isdir(os.path.join(sim_dir, "generated_files")):
for file in os.listdir(os.path.join(sim_dir, "generated_files")):
if re.match(r".*schedules.*\.csv", file):
schedules_filepath = os.path.join(sim_dir, "generated_files", file)
schedules_filepaths = []
for file in os.listdir(output_dir):
if re.match(r"in.schedules.*\.csv", file):
schedules_filepaths.append(os.path.join(output_dir, file))

if os.path.isfile(timeseries_filepath):
# Find the time columns present in the enduse_timeseries file
Expand All @@ -233,7 +233,7 @@ def cleanup_sim_dir(sim_dir, dest_fs, simout_ts_dir, upgrade_id, building_id):
tsdf = read_csv(timeseries_filepath, parse_dates=actual_time_cols, skiprows=skiprows)
for col in actual_time_cols:
tsdf[col] = tsdf[col].astype(pd.ArrowDtype(pa.timestamp("s")))
if os.path.isfile(schedules_filepath):
for schedules_filepath in schedules_filepaths:
schedules = read_csv(schedules_filepath, dtype=np.float64)
schedules.rename(columns=lambda x: f"schedules_{x}", inplace=True)
schedules["TimeDST"] = tsdf["Time"]
Expand Down
Loading