In [6]:
from ARCCSSive import CMIP5
In [7]:
db=CMIP5.connect()
Pass to the session "outputs" method some arguments to search for data
In [9]:
results = db.outputs(experiment='historical',mip='day')
The "outputs" method returns the corresponding rows from the Instance table as result. We use the count() method to check how many Instances we got back
In [10]:
results.count()
Out[10]:
NB the search is very fast no matter how many rows we get back or how many fields we use as arguments. This is because we are not actually accessing the instance objects yet.
In [11]:
results = db.outputs(experiment='rcp45',model='CNRM-CM5',mip='Amon',variable='tas', ensemble='r1i1p1')
results.count()
Out[11]:
We loop through the result object to find out the available versions and other Instance fields
In [12]:
for o in results:
print("Available versions for ensemble " + str(o.ensemble))
print("")
for v in o.versions:
print(str(v.version) + " from " + str(v.path))
print("")
print("drstree path is " + str(o.drstree_path()))
Another search this time without specifying the model
In [13]:
results = db.outputs(experiment='rcp45',mip='Amon',variable='clt')
results.count()
Out[13]:
Which models?
In [14]:
models=set()
In [15]:
for o in results:
models.add(str(o.model))
In [16]:
print(sorted(models))
In [18]:
from ARCCSSive.CMIP5.Model import Instance, Version
In [19]:
new_results=results.filter(Instance.model=='MIROC5').filter(Version.path.contains("/data1"))
In [20]:
for o in new_results:
for v in o.versions:
print(v.version,"is latest? ",v.is_latest,"last checked on",v.checked_on)
print("")
if v==o.latest()[0]:
print("Latest available version on raijin is")
print("")
print(v.path)
print("")
print(v.filenames())
print("")
f=v.files[0]
print(f.filename,f.tracking_id)
print("")
In [ ]: