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

Issue3484 dat generation update #3532

Merged
merged 5 commits into from
Oct 31, 2023
Merged
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
13 changes: 8 additions & 5 deletions Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env python3

def energyplus_csv_to_mos(output_list, dat_file_name, step_size, final_time):
def energyplus_csv_to_mos(output_list, dat_file_name, step_size, final_time, start_time = 0):
""" Reads `EnergyPlus/eplusout.csv` and writes `dat_file_name`
in the format required by the Modelica data reader.

:param output_list: List with outputs as written in the EnergyPlus csv output file.
:param dat_file_name: Name of `.mos` file to be written.
:param step_size: Step size in EnergyPlus output file in seconds.
:param final_time: Final time of the data that should be written to the `.mos` file.
:param start_time: Start time of the data that should be written to the `.mos` file.

"""

Expand All @@ -27,7 +28,8 @@ def energyplus_csv_to_mos(output_list, dat_file_name, step_size, final_time):
# In order to have a value at time=0, we add one time step, and
# write the results of the first time step twice to the data file.
df = pd.concat([df.head(1), df])
tot_steps = int (final_time / step_size ) + 1
tot_steps = int ((final_time - start_time) / step_size ) + 1
end_steps = int(final_time/step_size) + 1

# Step-1.0 read data into dictionary with lists
di = []
Expand All @@ -48,20 +50,21 @@ def energyplus_csv_to_mos(output_list, dat_file_name, step_size, final_time):

# Step-2.0 make timesteps, because energyplus timesteps are not in seconds
time_seconds=[]
for y in range(tot_steps):
time_seconds.append( y * step_size)
for y in range(end_steps):
time_seconds.append(y * step_size)

# Insert time in the front
di.insert(0, {"name": "Time in seconds", 'x': time_seconds})

#step-3.0 organizing data together
data=[]
start_index = int(start_time/step_size)
for i in range(tot_steps):
rowdata = []
for ele in di:
if len(rowdata) > 0:
rowdata.append(",")
rowdata.append(ele['x'][i])
rowdata.append(ele['x'][start_index + i])
data.append(rowdata)


Expand Down