Added resolution column to dataset db table

This commit is contained in:
Matthew Dillon (diogenes) 2013-09-16 05:28:01 -08:00
parent e56a73e0de
commit 5b824432e6
3 changed files with 15 additions and 9 deletions

View file

@ -60,7 +60,7 @@ def init_db():
endyr = 2099
starttime = datetime.datetime.now()
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,
startyr, endyr)
@ -75,11 +75,12 @@ def init_db():
models.Dataset.scenario == dataset.scenario).first()
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.model,
modelnames[dataset.model],
dataset.scenario)
dataset.scenario,
dataset.resolution)
db_session.add(dataset_sql)
datasets.append((dataset.model, dataset.scenario))
db_session.commit()

View file

@ -17,6 +17,7 @@ class SNAPYearField(IntegerField):
self.validators = [validators.NumberRange(min=ymin, max=ymax),
validators.Required()]
def communities():
return Community.query.order_by('name')
@ -24,10 +25,11 @@ def datasets():
return Dataset.query.order_by('datatype', 'model', 'scenario')
def dataset_names(ds):
return "{type} - {modelname} {scenario}".format(modelname=ds.modelname,
return "{type} ({resolution}) - {modelname} {scenario}".format(modelname=ds.modelname,
scenario=ds.scenario,
type=ds.datatype.lower()\
.capitalize())
.capitalize(),
resolution=ds.resolution)
class SNAPForm(Form):
community = QuerySelectField(query_factory=communities,

View file

@ -90,18 +90,21 @@ class Dataset(Base):
model = Column(String(15), nullable=False)
modelname = Column(String(50), nullable=True)
scenario = Column(String(15), nullable=False)
resolution = Column(String(15), nullable=False)
temperatures = relationship("Temperature", backref='datasets')
def __init__(self, datatype, model, modelname, scenario):
def __init__(self, datatype, model, modelname, scenario, resolution):
self.datatype = datatype
self.model = model
self.modelname = modelname
self.scenario = scenario
self.resolution = resolution
def __repr__(self):
return "Dataset{data}".format(data=(self.datatype, self.model,
self.modelname, self.scenario))
self.modelname, self.scenario,
self.resolution))
class Temperature(Base):