rigoudyg / climaf

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

DRAFT (not to worry for the moment...) Use of set_variable (climaf.driver) : multiple variable datasets #178

Open jservonnat opened 4 years ago

jservonnat commented 4 years ago

@rigoudyg @senesis I have recently experienced errors coming from set_variable (climaf.driver) because CliMAF found multiple variables in the netcdf file (which produces an error). The other variable found is called crs (although it has nothing to do with our CRS):

    int crs ;
        crs:grid_mapping_name = "latitude_longitude" ;
        crs:epsg_code = "EPSG:4326" ;
        crs:longitude_of_prime_meridian = 0.f ;
        crs:semi_major_axis = 6378137.f ;
        crs:inverse_flattening = 298.2572f ;

It consists of informations about the grid, and it is recognized as a variable. I've temporarily added this string to the list of variables that should not be recognized as variables in varsOfFile, but we might have to deal with similar problems in future files.

The question is: do we really need only one variable?

jservonnat commented 4 years ago
        info     : Done in 7235.9 s with script computation for ccdo(ds('CMIP6%%so%1980-2005%global%/bdd%IPSL-CM6A-LR%*%*%Omon%historical%r2i1p1f1%gn%latest'),add_variable='so200',operator='intlevel,200') (command was :/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V1.2.13_post/climaf/../scripts/mcdo.py --operator="intlevel,200" --output_file="/data/jservon/climafcache/58/501a6cf528d47549b5e7f5f2ed0b7b508b1afea8cd92ecc93c9898_34455.nc" --var="so" --period="1980-01-01T00:00:00,2005-12-31T23:59:00" --region="" --alias="" --units="" --vm="" /bdd/CMIP6/CMIP/IPSL/IPSL-CM6A-LR/historical/r2i1p1f1/Omon/so/gn/latest/so_Omon_IPSL-CM6A-LR_historical_r2i1p1f1_gn_195001-201412.nc )
    debug    : succeeded in evaluating derived variable so200 as ccdo(ds('CMIP6%%so%1980-2005%global%/bdd%IPSL-CM6A-LR%*%*%Omon%historical%r2i1p1f1%gn%latest'),add_variable='so200',operator='intlevel,200')
    debug    : Got multiple variables ([u'area', u'so']) and no direction to choose  - File is /data/jservon/climafcache/58/501a6cf528d47549b5e7f5f2ed0b7b508b1afea8cd92ecc93c9898.nc
    error    : 'Cannot set variable name for a multi-variable dataset'
---------------------------------------------------------------------------
Climaf_Driver_Error                       Traceback (most recent call last)
<ipython-input-3-59bba9e48f72> in <module>()
----> 1 cfile(test)

/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V1.2.13_post/climaf/driver.pyc in cfile(object, target, ln, hard, deep)
    937     #
    938     # -- Evaluate the CliMAF object
--> 939     result = ceval(object, format='file', deep=deep)
    940     #
    941     end_time = datetime.now()

/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V1.2.13_post/climaf/driver.pyc in ceval(cobject, userflags, format, deep, derived_list, recurse_list)
    227                 if derived_value:
    228                     clogger.debug("succeeded in evaluating derived variable %s as %s" % (ds.variable, repr(derived)))
--> 229                     set_variable(derived_value, ds.variable, format=format)
    230                 cdedent()
    231                 return derived_value

/ciclad-home/jservon/Evaluation/CliMAF/climaf_installs/climaf_V1.2.13_post/climaf/driver.pyc in set_variable(obj, varname, format)
    849         oldvarname = varOfFile(obj)
    850         if not oldvarname:
--> 851             raise Climaf_Driver_Error("Cannot set variable name for a multi-variable dataset")
    852         if oldvarname != varname:
    853             command = "ncrename -v %s,%s %s >/dev/null 2>&1" % (oldvarname, varname, obj)

Climaf_Driver_Error: 'Cannot set variable name for a multi-variable dataset'