rigoudyg / climaf

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

ncdump(ds) should be able to handle a (string) path #202

Open jypeter opened 3 years ago

jypeter commented 3 years ago

I think it would be useful if ncdump could also be called with a string (a NetCDF file path, hopefully existing), instead of just a dataset, in order to avoid the following error:

>>> pmip_exp_anm = clim_average(pmip_exp_resolved, 'ANM')

>>> pmip_exp_anm
time_average(ds('CMIP6%%pr%1850-2399%global%/bdd%IPSL-CM6A-LR%IPSL%PMIP%Amon%midHolocene%r1i1p1f1%gr%latest'))

>>> d_anm = cfile(pmip_exp_anm)

>>> d_anm
'/data/jypmce/climafcache/a8/24b33e3d31c270a22d64f244bdafe3add84942c63819d1b775917b.nc'

>>> ncdump(d_anm)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 3, in ncdump
  File "/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V2.0.0/climaf/driver.py", line 69, in capply
    res = capply_script(climaf_operator, *operands, **parameters)
  File "/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V2.0.0/climaf/driver.py", line 146, in capply_script
    return maketree(script_name, script, *operands, **parameters)
  File "/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V2.0.0/climaf/driver.py", line 162, in maketree
    defaultVariable = classes.varOf(operands[0])
  File "/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V2.0.0/climaf/classes.py", line 2148, in varOf
    def varOf(cobject): return attributeOf(cobject, "variable")
  File "/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V2.0.0/climaf/classes.py", line 2200, in attributeOf
    raise Climaf_Classes_Error("Unknown class for argument " + repr(cobject))
climaf.utils.Climaf_Classes_Error: "Unknown class for argument '/data/jypmce/climafcache/a8/24b33e3d31c270a22d64f244bdafe3add84942c63819d1b775917b.nc'"

>>> ncdump(pmip_exp_anm)
netcdf \24b33e3d31c270a22d64f244bdafe3add84942c63819d1b775917b {
dimensions:
        time = UNLIMITED ; // (1 currently)
        bnds = 2 ;
        lon = 144 ;
        lat = 143 ;
variables:
        double time(time) ;
[...]