def test_load_model(self): config = os.path.realpath("./configuration.ini") params = gui.parse_config(config) m = gui.load_model(params) # todo: make sure that this class is an instance of TestModel print "done"
def test_load_model(self): config = os.path.realpath('./configuration.ini') params = gui.parse_config(config) m = gui.load_model(params) #todo: make sure that this class is an instance of TestModel print 'done'
def test_run(self): # intialize ueb mdl = '../ueb.mdl' config_params = parse_config(mdl) UEB = ueb.ueb(config_params) # run UEB.run(None) # finish UEB.save() print 'done'
def test_initialize(self): config_params = parse_config(self.mdl) # load topmodel top = topmodel.topmodel(config_params) # check input exchange items in_items = top.inputs() self.assertTrue(len(in_items.keys()) == 1) self.assertTrue('precipitation' in in_items.keys()) precip = in_items['precipitation'] # check that input geometries were created precip_geoms = precip.getGeometries2() self.assertTrue(len(precip_geoms) > 0) # check input geometry type geom_type = precip_geoms[0].GetGeometryName() self.assertTrue(geom_type == stdlib.GeomType.POLYGON)
def test_geometry_creation_and_ordering(self): # intialize ueb mdl = '../ueb.mdl' config_params = parse_config(mdl) UEB = ueb.ueb(config_params) # get the active cells (these are looped through in run) cells = UEB.activeCells # build geometries xdim = UEB.C_dimlen1.value ydim = UEB.C_dimlen2.value geoms = UEB.build_geometries(range(xdim), range(ydim)) # create point tuples from geoms pts = [ (int(g.GetX()), int(g.GetY())) for g in geoms] # make sure the ordering is correct self.assertTrue(cells == pts)
def test_geometry_creation_and_ordering(self): # intialize ueb mdl = '../ueb.mdl' config_params = parse_config(mdl) UEB = ueb.ueb(config_params) # get the active cells (these are looped through in run) cells = UEB.activeCells # build geometries xdim = UEB.C_dimlen1.value ydim = UEB.C_dimlen2.value geoms = UEB.build_geometries(range(xdim), range(ydim)) # create point tuples from geoms pts = [(int(g.GetX()), int(g.GetY())) for g in geoms] # make sure the ordering is correct self.assertTrue(cells == pts)
def test_create_simulation(self): papi = postgresdb(self.session) model_code = 'swat' sim_name = 'TonySwatSimulation' sim_description = 'My SWAT Simulation' #sim_start = dt.datetime(2014,01,01,0,0,0) #sim_end = dt.datetime(2014,02,01,0,0,0) timestepvalue = 1 timestepunitid = None # query this inputdatasetid = None # query this #startoffset=-6 #endoffset=-6 # build exchange items from file config = os.path.realpath('../../tests/test_data/configuration.ini') params = gui.parse_config(config) eitems = mdl.build_exchange_items_from_config(params) # add some data to simulate 'output' exchange items vals= [(dt.datetime(2014,1,1,0,0,0) + dt.timedelta(days=i), i) for i in range(0,100)] output_item1 = eitems['output'][0] output_item1.geometries()[0].datavalues().set_timeseries(vals) vals= [(dt.datetime(2014,1,1,0,0,0) + dt.timedelta(days=i), 2*i) for i in range(0,100)] output_item1.geometries()[1].datavalues().set_timeseries(vals) vals= [(dt.datetime(2014,1,1,0,0,0) + dt.timedelta(days=i), 2**i) for i in range(0,100)] output_item2 = eitems['output'][1] output_item2.geometries()[0].datavalues().set_timeseries(vals) outputs = [output_item1,output_item2] sim = papi.create_simulation(preferences_path='../../data/preferences', config_params=params, output_exchange_items= outputs) print 'Successfully inserted Simulation: %d'%sim.SimulationID
def setUp(self): # load the model mdl = '../weatherReader.mdl' config_params = parse_config(mdl) self.model = weather.weatherReader(config_params)
def setUp(self): # add models self.mdl = '../topmodel.mdl' config_params = parse_config(self.mdl) self.ti = config_params['model inputs'][0]['ti']
def setUp(self): # load the model mdl = "../weatherReader.mdl" config_params = parse_config(mdl) self.model = weather.weatherReader(config_params)
def set_user_preferences(self, preferences): # parse user preferences file prefs = gui.parse_config(preferences, validate=False) # create people for person in prefs['person']: # check if the person exists p = self._coreread.getPersonByName(person['firstname'],person['lastname']) if not p: # insert person p = self._corewrite.createPerson(person['firstname'],person['lastname']) # create organization organizations = prefs['organization'] while len(organizations) > 0: organization = organizations.pop(0) insert = True # make sure the parent exists in the database if organization.has_key('parentcode'): if not self._coreread.getOrganizationByCode(organization['parentcode']): # move item to back of list organizations.append(organization) insert = False if insert: # check if organization already exists org = self._coreread.getOrganizationByCode(organization['code']) if not org: # insert organization desc = organization['description'] if organization.has_key('description') else None link = organization['link'] if organization.has_key('link') else None pcode = organization['parentcode'] if organization.has_key('parentcode') else None parent = self._coreread.getOrganizationByCode(pcode).OrganizationID if pcode else None org = self._corewrite.createOrganization(organization['type'], organization['code'], organization['name'], desc,link,parent) # create affiliations for person in prefs['person']: # get the person id personid = None p = self._coreread.getPersonByName(person['firstname'],person['lastname']) if not p: raise Exception('Person Not found: %s %s' % (person['firstname'], person['lastname'])) # get the organization id orgid = None o = self._coreread.getOrganizationByCode(person['organizationcode']) if not o: raise Exception('Organization Not found: %s' % person['organizationcode']) phone = person['phone'] if person.has_key('phone') else None email = person['email'] if person.has_key('email') else None addr = person['address'] if person.has_key('address') else None affiliations = self._coreread.getAffiliationByPersonAndOrg(p.PersonFirstName, p.PersonLastName,o.OrganizationCode) if not affiliations: affiliations = self._corewrite.createAffiliation(personid=p.PersonID, organizationid=o.OrganizationID, email=email, phone=phone, address=addr) return affiliations