DamienIrving / climate-analysis

Code used for the analysis and visualisation of climate data during my PhD
MIT License
40 stars 19 forks source link

string attributes in netCDF files written by Iris #29

Open DamienIrving opened 8 years ago

DamienIrving commented 8 years ago

When using iris.save() to write iris cubes out to netCDF, some of the attributes are designated as "string". e.g:

variables:
    double thetao(time, lev, j, i) ;
        thetao:_FillValue = 1.e+20 ;
        string thetao:standard_name = "sea_water_potential_temperature" ;
        string thetao:long_name = "Sea Water Potential Temperature" ;
        thetao:units = "K" ;
        thetao:coordinates = "lat lon" ;
    double time(time) ;
        time:axis = "T" ;
        time:bounds = "time_bnds" ;
        time:units = "days since 0001-01-01" ;
        string time:standard_name = "time" ;
        string time:long_name = "time" ;
        string time:calendar = "proleptic_gregorian" ;

Iris seems to have no problem with these attributes (i.e. I can read the netCDF file with iris), but other applications (e.g. cdo) sometimes do.

DamienIrving commented 8 years ago

It turns out that this is due to a poor choice made in netCDF4-Python which has now been fixed: https://github.com/Unidata/netcdf4-python/issues/529

The short answer is that you should either downgrade netCDF4-Python to v1.1.7 or earlier or upgrade to v1.2.3 or later.