rigoudyg / climaf

CliMAF - a Climate Model Analysis Framework - doc at : http://climaf.readthedocs.org/
Other
16 stars 7 forks source link

Weird side effect when specifying a period with period='last_100y' #209

Open jypeter opened 3 years ago

jypeter commented 3 years ago

This looks more like a bug than a feature, but maybe I'm just missing the underlying logic... I have already felt that there was something not quite right with period='last_100y' and explore('choices') but I had not tried to describe my problem

If I specify the following dataset with period='*', I get several results with explore('choices'), because there are several realizations:

>>> ds_test_noperiod = ds(project='CMIP6', experiment='piControl', model='GISS-E2-1-G', variable='pr', table='Amon',
period='*')

>>> ds_test_noperiod.crs
"ds('CMIP6%%pr%*%global%/bdd%GISS-E2-1-G%*%*%Amon%piControl%r1i1p1f*%g*%latest')"

>>> pprint.pprint(ds_test_noperiod.explore('choices'))
{'grid': 'gn',
 'institute': 'NASA-GISS',
 'mip': 'CMIP',
 'period': [2900-2999, 4150-5000, 7550-7894],
 'realization': ['r1i1p1f1', 'r1i1p1f2', 'r1i1p1f3']}

I also get an error when trying to use resolve. It's good that I'm getting an error, though it would probably be more accurate to report that there are several realizations, rather than reporting that there are holes

>>> ds_test_noperiod.explore('resolve')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V2.0.0/climaf/classes.py", line 690, in explore
    raise Climaf_Classes_Error("Periods with holes are not handled %s" % val)
climaf.utils.Climaf_Classes_Error: 'Periods with holes are not handled [2900-2999, 4150-5000, 7550-7894]'

Now, if I use period='last_100y', I would expect to still get all the realizations, except maybe if one of them has less than 100y of available data. BUT one of the available realizations has been automatically selected (don't know why) and explore('choices') returns an empty dictionary

>>> ds_test_last_100y = ds(project='CMIP6', experiment='piControl', model='GISS-E2-1-G', variable='pr', table='Amon',
period='last_100y')

>>> ds_test_last_100y.crs
"ds('CMIP6%%pr%7795-7894%global%/bdd%GISS-E2-1-G%NASA-GISS%CMIP%Amon%piControl%r1i1p1f2%gn%latest')"

>>> ds_test_last_100y.explore('choices')
{}

>>> ds_test_last_100y.explore('resolve')
ds('CMIP6%%pr%7795-7894%global%/bdd%GISS-E2-1-G%NASA-GISS%CMIP%Amon%piControl%r1i1p1f2%gn%latest')

Just to be sure, I have also explicitly specified the r1i1p1f2 realization, in order to check that I'm getting the same result

>>> ds_test_r1i1p1f2_last_100y = ds(project='CMIP6', experiment='piControl', model='GISS-E2-1-G', variable='pr', table='Amon',
realization='r1i1p1f2', period='last_100y')

>>> ds_test_r1i1p1f2_last_100y.crs
"ds('CMIP6%%pr%7795-7894%global%/bdd%GISS-E2-1-G%NASA-GISS%CMIP%Amon%piControl%r1i1p1f2%gn%latest')"

>>> ds_test_r1i1p1f2_last_100y.explore('choices')
{}

>>> ds_test_r1i1p1f2_last_100y.explore('resolve')
ds('CMIP6%%pr%7795-7894%global%/bdd%GISS-E2-1-G%NASA-GISS%CMIP%Amon%piControl%r1i1p1f2%gn%latest')