def get_sim_data(): sim = SimRes('demo_results.mat') dfDymola = sim.to_pandas([ 'combiTimeTable.y[2]', 'combiTimeTable.y[3]', 'boiler_system.temperature_sensor_2.T', 'combiTimeTable.y[4]' ]) #getting list of column names: names contain the unit df_col = list(dfDymola.columns) ##extract unit from column name df_col_split = [] for x in df_col: df_col_split = df_col_split + [x.split()[0]] #rename columns without units for i in range(len(df_col)): dfDymola = dfDymola.rename(index=str, columns={df_col[i]: df_col_split[i]}) # print(dfDymola) dfDymola.index = pd.to_numeric(dfDymola.index) dfDymola["time_diff"] = dfDymola.index # dfDymola["time_diff"]=pd.to_numeric(dfDymola["time_diff"]) dfDymola["time_diff"] = (dfDymola["time_diff"].shift(-1) - dfDymola["time_diff"]) # dfDymola=dfDymola[~dfDymola.index.duplicated(keep='last')] ## dfDymola.drop_duplicates(keep='last', inplace=True) # max_range = max(dfDymola.index) + 1 # # # dfDymola = dfDymola.reindex(index=range(1, int(max_range)), method='ffill', fill_value=0) dfDymola = reindex_int(dfDymola) return dfDymola
def export(self, output_vars=None): sim = SimRes(self.mat_file) if self.csv_file is not None: self.csv_file = os.path.splitext(self.mat_file)[0] + '.csv' else: self.csv_file = self.csv_file if output_vars is not None: self.output_vars = output_vars data = sim.to_pandas(self.output_vars) else: data = sim.to_pandas() data = data.loc[~data.index.duplicated(keep='last')] data.drop(data.head(1).index, inplace=True) data.to_csv(self.csv_file, encoding='utf-8')
def check_data(filename_model, filename_results, filename_database, budo_label): sim = SimRes(filename_results) variable_name_sim = get_complete_variable_name(filename_model, budo_label) dfDymola=sim.to_pandas([variable_name_sim]) dfDymola=preprocess_sim_data(dfDymola) dfDymola=reindex_int(dfDymola) "read out of monitoring database" "(in real a specialized timeseries database)" disk_engine = create_engine('sqlite:///'+filename_database) df = pd.read_sql_query('SELECT * FROM timeseries', disk_engine) df = preprocess_monitoring_data(df) (df, dfDymola)=check_length(df, dfDymola) predicted_values = dfDymola[variable_name_sim] measured_values = df[budo_label] (iae_, rmse_, nrmse_)=calculate_values(measured_values, predicted_values) print("IAE between real and simulated data is: "+str(iae_)) print("RMSE between real and simulated data is "+str(rmse_)) print("NRMSE between real and simulated data is "+str(nrmse_))