def _init_from_model_run(self, model_run, debug_data): self._model_run = model_run self._debug_data = debug_data log_time(self._timings, 'model_run_creation') self._model_data_original = build_model_data(model_run) log_time(self._timings, 'model_data_original_creation') random_seed = self._model_run.get_key('model.random_seed', None) if random_seed: np.random.seed(seed=random_seed) # After setting the random seed, time clustering can take place time_config = model_run.model.get('time', None) if not time_config: _model_data = self._model_data_original else: _model_data = apply_time_clustering(self._model_data_original, model_run) self._model_data = final_timedimension_processing(_model_data) log_time(self._timings, 'model_data_creation', time_since_start=True) for var in self._model_data.data_vars: self._model_data[var].attrs['is_result'] = 0 self.inputs = self._model_data.filter_by_attrs(is_result=0)
def _init_from_model_run(self, model_run, debug_data): self._model_run = model_run self._debug_data = debug_data log_time(self._timings, 'model_run_creation', comment='Model: preprocessing stage 1 (model_run)') self._model_data_original = build_model_data(model_run) log_time(self._timings, 'model_data_original_creation', comment='Model: preprocessing stage 2 (model_data)') random_seed = self._model_run.get_key('model.random_seed', None) if random_seed: np.random.seed(seed=random_seed) # After setting the random seed, time clustering can take place time_config = model_run.model.get('time', None) if not time_config: _model_data = self._model_data_original else: _model_data = apply_time_clustering( self._model_data_original, model_run ) self._model_data = final_timedimension_processing(_model_data) log_time( self._timings, 'model_data_creation', comment='Model: preprocessing complete', time_since_start=True ) for var in self._model_data.data_vars: self._model_data[var].attrs['is_result'] = 0 self.inputs = self._model_data.filter_by_attrs(is_result=0)
def _init_from_model_run(self, model_run, debug_data): self._model_run = model_run self._debug_data = debug_data log_time(logger, self._timings, 'model_run_creation', comment='Model: preprocessing stage 1 (model_run)') self._model_data_original = build_model_data(model_run) log_time(logger, self._timings, 'model_data_original_creation', comment='Model: preprocessing stage 2 (model_data)') random_seed = self._model_run.get_key('model.random_seed', None) if random_seed: np.random.seed(seed=random_seed) # After setting the random seed, time clustering can take place time_config = model_run.model.get('time', None) if not time_config: _model_data = self._model_data_original else: _model_data = apply_time_clustering(self._model_data_original, model_run) self._model_data = final_timedimension_processing(_model_data) log_time(logger, self._timings, 'model_data_creation', comment='Model: preprocessing complete') # Ensure model and run attributes of _model_data update themselves for var in self._model_data.data_vars: self._model_data[var].attrs['is_result'] = 0 self.inputs = self._model_data.filter_by_attrs(is_result=0) model_config = { k: v for k, v in model_run.get('model', {}).items() if k != 'file_allowed' } self.model_config = UpdateObserverDict(initial_dict=model_config, name='model_config', observer=self._model_data) self.run_config = UpdateObserverDict(initial_dict=model_run.get( 'run', {}), name='run_config', observer=self._model_data)