def addToCanvas(self, event): end, siteobject, start, variable_code = self._preparationToGetValues() var_codes_temp = self.get_all_selected_variable_site_codes() if len(var_codes_temp) > 1: elog.warning( "We do not support adding more then one item to the canvas at this point. We added " + var_codes_temp[0]) if variable_code is None: # no table row selected return args = dict( model_type='wof', wsdl=self.parent.api.wsdl, site=siteobject.site_code, variable=variable_code, start=start, end=end, network=siteobject.network, ) engine.addModel(**args) self.Close()
def add_netcdf_model(url, time_dimension, x_dimension, y_dimension, time_unit, start_time_as_string): args = dict(ncpath=url, tdim=time_dimension, xdim=x_dimension, ydim=y_dimension, tunit=time_unit, starttime=start_time_as_string, model_type=wrappers.Types.NETCDF) engine.addModel(**args)
def add_netcdf_model(url, time_dimension, x_dimension, y_dimension, time_unit, start_time_as_string): args = dict(ncpath=url, tdim=time_dimension, xdim=x_dimension, ydim=y_dimension, tunit=time_unit, starttime=start_time_as_string, model_type=wrappers.Types.NETCDF ) engine.addModel(**args)
def load_simulation(self, simfile): params = model_utils.parse_json(simfile) models = params['models'] if 'models' in params else [] links = params['links'] if 'links' in params else [] datamodels = params['datamodels'] if 'datamodels' in params else [] self.failed_models = 0 total = len(models) + len(datamodels) + len( self.models) + self.failed_models # start thread that will load links when once all models have been loaded waitingThread = threading.Thread(target=self.wait_for_model_loading, args=(total, links), name="load_links") self.logicCanvasThreads[waitingThread.name] = waitingThread waitingThread.start() # loop through all of the models and load each one individually for model in models: if self.is_model_netcdf(model): self.add_netcdf_model(model["params"]["ncpath"], model["params"]["tdim"], model["params"]["xdim"], model["params"]["ydim"], model["params"]["tunit"], model["params"]["starttime"]) continue mdl = model['path'] args = model_utils.parse_json(mdl) inputs = model.pop('model_inputs') args.update(model) args.update(inputs) # save these coordinates for drawing once the model is loaded self.set_model_coordinate(model['id'], x=float(model['xcoordinate']), y=float(model['ycoordinate'])) # load the model in the engine engine.addModel(**args) # draw the model wx.CallAfter(self.FloatCanvas.Draw)
def addToCanvas(self, event): end, siteobject, start, variable_code = self._preparationToGetValues() var_codes_temp = self.get_all_selected_variable_site_codes() if len(var_codes_temp) > 1: elog.warning("We do not support adding more then one item to the canvas at this point. We added " + var_codes_temp[0]) if variable_code is None: # no table row selected return args = dict(model_type='wof', wsdl=self.parent.api.wsdl, site=siteobject.site_code, variable=variable_code, start=start, end=end, network=siteobject.network, ) engine.addModel(**args) self.Close()
def load_simulation(self, simfile): params = model_utils.parse_json(simfile) models = params['models'] if 'models' in params else [] links = params['links'] if 'links' in params else [] datamodels = params['datamodels'] if 'datamodels' in params else [] self.failed_models = 0 total = len(models) + len(datamodels) + len(self.models) + self.failed_models # start thread that will load links when once all models have been loaded waitingThread = threading.Thread(target=self.wait_for_model_loading, args=(total, links), name="load_links") self.logicCanvasThreads[waitingThread.name] = waitingThread waitingThread.start() # loop through all of the models and load each one individually for model in models: if self.is_model_netcdf(model): self.add_netcdf_model(model["params"]["ncpath"], model["params"]["tdim"], model["params"]["xdim"], model["params"]["ydim"], model["params"]["tunit"], model["params"]["starttime"]) continue mdl = model['path'] args = model_utils.parse_json(mdl) inputs = model.pop('model_inputs') args.update(model) args.update(inputs) # save these coordinates for drawing once the model is loaded self.set_model_coordinate(model['id'], x=float(model['xcoordinate']), y=float(model['ycoordinate'])) # load the model in the engine engine.addModel(**args) # draw the model wx.CallAfter(self.FloatCanvas.Draw)
def addModel(self, **params): """ Adds a model to the canvas using x, y. This is useful if adding by file click/dialog :param filename: filename / path :return: None """ # generate an ID for this model uid = uuid.uuid4().hex x, y = self.get_random_canvas_coordinate() # save these coordinates for drawing once the model is loaded self.set_model_coordinate(uid, x=x, y=y) # if ext == '.mdl': sPrint('ADDING MODEL', MessageType.DEBUG) # add the model to the base level of the params dict params['type'] = 'MDL' # load the model within the engine process engine.addModel(id=uid, **params) return uid