In [1]:
import modelmeta
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from optparse import OptionParser
In [2]:
engine = create_engine('postgresql://httpd_meta@atlas.pcic/pcic_meta?sslmode=require')
Session = sessionmaker(bind=engine)
session = Session()
In [3]:
q = session.query(modelmeta.Ensemble)
q.count(), [x.name for x in q.all()]
Out[3]:
In [4]:
ensemble_name = 'canada_map'
mydatafilevars = session.query(modelmeta.DataFileVariable).\
join(modelmeta.EnsembleDataFileVariables).\
join(modelmeta.Ensemble).\
filter(modelmeta.Ensemble.name == ensemble_name).all()
print('Ensemble: ' + ensemble_name + ' with ' + str(len(mydatafilevars)) + ' data_file_vars')
In [5]:
myensemble = session.query(modelmeta.Ensemble).filter(modelmeta.Ensemble.name == 'canada_map').first()
print('Ensemble: ' + myensemble.name + ' with ' + str(len(myensemble.data_file_variables)) + ' data_file_vars')
In [6]:
mymodel = myensemble.data_file_variables[0].file.run.model
print(mymodel.short_name)
In [7]:
mymodel.runs[0].files[0].data_file_variables[0].ensembles[0].name
Out[7]:
In [8]:
myensemble.data_file_variables[0].\
file.run.emission.runs[0].files[0].data_file_variables[0].\
grid.data_file_variables[0].variable_alias.data_files[0].\
data_file_variables[0].ensembles[0].name
Out[8]:
In [ ]: