From cc18bb7bb16c6ec648393b95a2d84911d02610a4 Mon Sep 17 00:00:00 2001 From: Devaprasad Date: Sun, 27 Aug 2023 16:51:08 -0700 Subject: [PATCH 1/3] Added new argument to DAT generation script for start time of DAT file --- .../Scripts/EnergyPlus/energyplus_csv_to_mos.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py b/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py index b6f7fa7fac0..53171ab7530 100644 --- a/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py +++ b/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py @@ -1,6 +1,6 @@ #!/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:int = 0): """ Reads `EnergyPlus/eplusout.csv` and writes `dat_file_name` in the format required by the Modelica data reader. @@ -8,6 +8,7 @@ def energyplus_csv_to_mos(output_list, dat_file_name, step_size, final_time): :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. """ @@ -27,7 +28,7 @@ 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 # Step-1.0 read data into dictionary with lists di = [] @@ -49,19 +50,20 @@ 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) + time_seconds.append(start_time + 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 = 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) From b2315751e0bed1295ca648b8a93ef257d190dfbf Mon Sep 17 00:00:00 2001 From: Devaprasad Date: Sun, 27 Aug 2023 18:21:57 -0700 Subject: [PATCH 2/3] Implemented fixes to DAT generation script --- .../Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py b/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py index 53171ab7530..e570ee4818c 100644 --- a/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py +++ b/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py @@ -29,6 +29,7 @@ def energyplus_csv_to_mos(output_list, dat_file_name, step_size, final_time, sta # 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 - start_time) / step_size ) + 1 + end_steps = int(final_time/step_size) + 1 # Step-1.0 read data into dictionary with lists di = [] @@ -49,15 +50,15 @@ def energyplus_csv_to_mos(output_list, dat_file_name, step_size, final_time, sta # Step-2.0 make timesteps, because energyplus timesteps are not in seconds time_seconds=[] - for y in range(tot_steps): - time_seconds.append(start_time + 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 = start_time/step_size + start_index = int(start_time/step_size) for i in range(tot_steps): rowdata = [] for ele in di: From d80ed4d12a25e269c336691e2a2c2d7af2e28fe5 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Wed, 4 Oct 2023 07:13:33 -0700 Subject: [PATCH 3/3] Removed type declaration --- Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py b/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py index e570ee4818c..4e3cf8ee242 100644 --- a/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py +++ b/Buildings/Resources/Scripts/EnergyPlus/energyplus_csv_to_mos.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -def energyplus_csv_to_mos(output_list, dat_file_name, step_size, final_time, start_time:int = 0): +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.