Added resolution column to dataset db table
This commit is contained in:
parent
e56a73e0de
commit
5b824432e6
3 changed files with 15 additions and 9 deletions
|
@ -60,7 +60,7 @@ def init_db():
|
||||||
endyr = 2099
|
endyr = 2099
|
||||||
starttime = datetime.datetime.now()
|
starttime = datetime.datetime.now()
|
||||||
print datetime.datetime.now().strftime('%m-%d-%Y %I:%M%p')
|
print datetime.datetime.now().strftime('%m-%d-%Y %I:%M%p')
|
||||||
print filename, startyr, endyr, dataset.model, dataset.scenario
|
print filename, startyr, endyr, dataset.model, dataset.scenario, dataset.resolution
|
||||||
|
|
||||||
extracted_temps = dataset.extract_points(northings, eastings,
|
extracted_temps = dataset.extract_points(northings, eastings,
|
||||||
startyr, endyr)
|
startyr, endyr)
|
||||||
|
@ -75,11 +75,12 @@ def init_db():
|
||||||
models.Dataset.scenario == dataset.scenario).first()
|
models.Dataset.scenario == dataset.scenario).first()
|
||||||
|
|
||||||
if dataset_sql is None:
|
if dataset_sql is None:
|
||||||
print "not in dataset...", (dataset.model, dataset.scenario)
|
print "not in dataset table...", (dataset.model, dataset.scenario)
|
||||||
dataset_sql = models.Dataset(datasetType,
|
dataset_sql = models.Dataset(datasetType,
|
||||||
dataset.model,
|
dataset.model,
|
||||||
modelnames[dataset.model],
|
modelnames[dataset.model],
|
||||||
dataset.scenario)
|
dataset.scenario,
|
||||||
|
dataset.resolution)
|
||||||
db_session.add(dataset_sql)
|
db_session.add(dataset_sql)
|
||||||
datasets.append((dataset.model, dataset.scenario))
|
datasets.append((dataset.model, dataset.scenario))
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
|
|
|
@ -17,6 +17,7 @@ class SNAPYearField(IntegerField):
|
||||||
self.validators = [validators.NumberRange(min=ymin, max=ymax),
|
self.validators = [validators.NumberRange(min=ymin, max=ymax),
|
||||||
validators.Required()]
|
validators.Required()]
|
||||||
|
|
||||||
|
|
||||||
def communities():
|
def communities():
|
||||||
return Community.query.order_by('name')
|
return Community.query.order_by('name')
|
||||||
|
|
||||||
|
@ -24,10 +25,11 @@ def datasets():
|
||||||
return Dataset.query.order_by('datatype', 'model', 'scenario')
|
return Dataset.query.order_by('datatype', 'model', 'scenario')
|
||||||
|
|
||||||
def dataset_names(ds):
|
def dataset_names(ds):
|
||||||
return "{type} - {modelname} {scenario}".format(modelname=ds.modelname,
|
return "{type} ({resolution}) - {modelname} {scenario}".format(modelname=ds.modelname,
|
||||||
scenario=ds.scenario,
|
scenario=ds.scenario,
|
||||||
type=ds.datatype.lower()\
|
type=ds.datatype.lower()\
|
||||||
.capitalize())
|
.capitalize(),
|
||||||
|
resolution=ds.resolution)
|
||||||
|
|
||||||
class SNAPForm(Form):
|
class SNAPForm(Form):
|
||||||
community = QuerySelectField(query_factory=communities,
|
community = QuerySelectField(query_factory=communities,
|
||||||
|
|
|
@ -90,18 +90,21 @@ class Dataset(Base):
|
||||||
model = Column(String(15), nullable=False)
|
model = Column(String(15), nullable=False)
|
||||||
modelname = Column(String(50), nullable=True)
|
modelname = Column(String(50), nullable=True)
|
||||||
scenario = Column(String(15), nullable=False)
|
scenario = Column(String(15), nullable=False)
|
||||||
|
resolution = Column(String(15), nullable=False)
|
||||||
|
|
||||||
temperatures = relationship("Temperature", backref='datasets')
|
temperatures = relationship("Temperature", backref='datasets')
|
||||||
|
|
||||||
def __init__(self, datatype, model, modelname, scenario):
|
def __init__(self, datatype, model, modelname, scenario, resolution):
|
||||||
self.datatype = datatype
|
self.datatype = datatype
|
||||||
self.model = model
|
self.model = model
|
||||||
self.modelname = modelname
|
self.modelname = modelname
|
||||||
self.scenario = scenario
|
self.scenario = scenario
|
||||||
|
self.resolution = resolution
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "Dataset{data}".format(data=(self.datatype, self.model,
|
return "Dataset{data}".format(data=(self.datatype, self.model,
|
||||||
self.modelname, self.scenario))
|
self.modelname, self.scenario,
|
||||||
|
self.resolution))
|
||||||
|
|
||||||
|
|
||||||
class Temperature(Base):
|
class Temperature(Base):
|
||||||
|
|
Loading…
Add table
Reference in a new issue