rigoudyg / climaf

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

Result of "listfiles(ensure_dataset=False)" when the ambiguity is not on period #193

Closed jypeter closed 2 years ago

jypeter commented 3 years ago

I have a script using listfiles(ensure_dataset=False), so that I can get a list of files, even if there are some holes in the periods.

This has the side effect that I get a list of realizations instead of a list of files, when there are multiple realizations. I don't know if there is an easy way to deal with this, or even what should be done...

I would maybe expect:

>>> my_query = ds(project='CMIP6', experiment='midHolocene', variable='tas', table='Amon', period='*', model='IPSL-CM6A-LR')

>>> my_query.listfiles()
error    : "This dataset is ambiguous on attribute realization='r1i1p1f*'; please choose among : ['r1i1p1f1', 'r1i1p1f2', 'r1i1p1f3', 'r1i1p1f4'] or use either 'ensure_dataset=False' (with method baseFiles or listfiles) or 'option='choices' (with method explore)"

>>> my_query.explore('choices')
{'period': [1850-2399], 'institute': 'IPSL', 'mip': 'PMIP', 'realization': ['r1i1p1f1', 'r1i1p1f2', 'r1i1p1f3', 'r1i1p1f4'], 'grid': 'gr'}

>>> my_query.listfiles()
'r1i1p1f1 r1i1p1f2 r1i1p1f3 r1i1p1f4'

>>> my_query.listfiles(force=True, ensure_dataset=True)
error    : "This dataset is ambiguous on attribute realization='r1i1p1f*'; please choose among : ['r1i1p1f1', 'r1i1p1f2', 'r1i1p1f3', 'r1i1p1f4'] or use either 'ensure_dataset=False' (with method baseFiles or listfiles) or 'option='choices' (with method explore)"

>>> my_query.listfiles(force=True, ensure_dataset=False)
'r1i1p1f1 r1i1p1f2 r1i1p1f3 r1i1p1f4'
senesis commented 3 years ago

First solution is coded and tested, and will be merged sooner or later. It provides an error message and returns None