def init_models(self, use_ukf, use_fmu_mpc, use_fmu_emu):
     print("Initialising models")
     #self.emu = systems.RealFromCSV(self.meas_file,self.meas_vars,self.		meas_varmap, tz_name = self.weather.tz_name)
     if use_fmu_emu == 0:
         print(
             "%%%%%%%%%%%%%%%%% Compiling new FMUs for emulation %%%%%%%%%%%%%%%%"
         )
         self.emu = systems.EmulationFromFMU(
             self.meas_vars,
             moinfo=self.moinfo_emu,
             weather_data=self.weather.data,
             control_data=self.control.data,
             other_inputs=self.other_input.data,
             tz_name=self.weather.tz_name)
     else:
         print(
             "%%%%%%%%%%%%%% Using existing FMUs for emulation %%%%%%%%%%%%%%%%%%%%%%%"
         )
         print("Emulation FMU: " + str(self.fmupath_emu))
         self.emu = systems.EmulationFromFMU(
             self.meas_vars,
             fmupath=self.fmupath_emu,
             weather_data=self.weather.data,
             control_data=self.control.data,
             other_inputs=self.other_input.data,
             tz_name=self.weather.tz_name)
         #self.emu.collect_measurements(self.sim_start, self.sim_end)
     if use_ukf == 1:
         if use_fmu_mpc == 1:
             print(
                 "%%%%%%%%%%%%%% Using existing MPC FMUs %%%%%%%%%%%%%%%%%%%%%%%"
             )
             print("MPC FMU: " + str(self.fmupath_mpc))
             self.mpc = models.Modelica(models.UKF,
                                        models.RMSE,
                                        self.emu.measurements,
                                        fmupath=self.fmupath_mpc,
                                        parameter_data=self.parameters.data,
                                        weather_data=self.weather.data,
                                        control_data=self.control.data,
                                        other_inputs=self.other_input.data,
                                        tz_name=self.weather.tz_name,
                                        version='1.0')
             self.mpc.moinfo = self.moinfo_mpc
         else:
             print("%%%%%%%%%%%%%%%%% Compiling new FMUs %%%%%%%%%%%%%%%%")
             self.mpc = models.Modelica(models.UKF,
                                        models.RMSE,
                                        self.emu.measurements,
                                        moinfo=self.moinfo_mpc,
                                        parameter_data=self.parameters.data,
                                        weather_data=self.weather.data,
                                        control_data=self.control.data,
                                        other_inputs=self.other_input.data,
                                        tz_name=self.weather.tz_name,
                                        version='1.0')
     else:
         if use_fmu_mpc == 1:
             print(
                 "%%%%%%%%%%%%%% Using existing MPC FMUs %%%%%%%%%%%%%%%%%%%%%%%"
             )
             print("MPC FMU: " + str(self.fmupath_mpc))
             self.mpc = models.Modelica(
                 models.JModelica,
                 models.RMSE,
                 self.emu.measurements,
                 fmupath=self.fmupath_mpc,
                 parameter_data=self.parameters.data,
                 weather_data=self.weather.data,
                 control_data=self.control.data,
                 other_inputs=self.other_input.data,
                 tz_name=self.weather.tz_name,
             )
             self.mpc.moinfo = self.moinfo_mpc
         else:
             print(
                 "%%%%%%%%%%%%%%%%% Compiling new MPC FMUs %%%%%%%%%%%%%%%%"
             )
             self.mpc = models.Modelica(models.JModelica,
                                        models.RMSE,
                                        self.emu.measurements,
                                        moinfo=self.moinfo_mpc,
                                        parameter_data=self.parameters.data,
                                        weather_data=self.weather.data,
                                        control_data=self.control.data,
                                        other_inputs=self.other_input.data,
                                        tz_name=self.weather.tz_name)
                    print(
                        '%%%%%%%%%%%%%%%%%% Failed, trying again! %%%%%%%%%%%%%%%%%%%%%%'
                    )
                    continue

            while True:
                try:

                    if (simtime.minute % 20 == 0) and (simtime.second == 0):
                        print('Time to Kalman Filter!!')
                        Emu.mpc = models.Modelica(
                            models.UKF,
                            models.RMSE,
                            Emu.mpc.measurements,
                            moinfo=Emu.moinfo_mpc,
                            parameter_data=Emu.parameters.data,
                            weather_data=Emu.weather.data,
                            control_data=Emu.control.data,
                            other_inputs=Emu.other_input.data,
                            tz_name=Emu.weather.tz_name,
                            version='1.0')

                        Emu.id_start = opt_start_str
                        Emu.id_end = emu_end_str

                        Emu.sys_id()
                        Emu.parameters.data = Emu.mpc.parameter_data

                        kalman_flag = 1
                    else:
                        kalman_flag = 0