rigoudyg / climaf

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

Improving the output of the cache related functions #226

Open jypeter opened 3 years ago

jypeter commented 3 years ago

I'm not too sure what would be best here, but I think there are some inconsistencies in the way the results of the clist/cls/cwc/... are returned. You can get:

I guess the initial idea is to display cache diagnostics that the user can read. It would be nice if a script could also use the results, which is not possible when the functions returns nothing (e.g NoneType)

# No result (not even an empty list), and nothing printed
>>> res_p1 = clist(age='+1', count=True)
>>> type(res_p1)
<class 'NoneType'>

# A list, and something printed
>>> res_m1 = clist(age='-1')
Filtered objects = cache content
>>> type(res_m1)
<class 'list'>
>>> len(res_m1)
624

# No result, and something printed
>>> res_m1 = clist(age='-1', count=True)
Number of files found: 624
>>> type(res_m1)
<class 'NoneType'>

# No result, and something printed
>>> cwc(age='-1')
Number of files found: 624
>>> type(cwc(age='-1'))
Number of files found: 624
<class 'NoneType'>

# No result, and some giant printed output
>>> cwc(age='-1', CRS=True)
[ lots and lots and lots of removed output ]
minus(space_average(ccdo(ccdo(llbox(ds('CMIP6%%tas%1401-1500%global%/bdd%MPI-ESM1-2-LR%MPI-M%PMIP%Amon%midHolocene%r1i1p1f1%gn%latest'),latmax=90,latmin=0,lonmax=360,lonmin=0),operator='ymonavg'),operator='timmean -seltimestep,6,7,8,9')),space_average(ccdo(ccdo(llbox(ds('CMIP6%%tas%2750-2849%global%/bdd%MPI-ESM1-2-LR%MPI-M%CMIP%Amon%piControl%r1i1p1f1%gn%latest'),latmax=90,latmin=0,lonmax=360,lonmin=0),operator='ymonavg'),operator='timmean -seltimestep,6,7,8,9')))
<class 'NoneType'>