Project

General

Profile

subsetting single variable from CFSR reanalysis data

Added by Joseph S over 4 years ago

Greetings CDO support community:

I've encountered an error (shown below) while attempting to subset a single variable from a netcdf file that contains CFSR reanalysis data. I routinely subset variables without any issues, but I think this type of nc file is creating an issue because time is also defined as a variable. I'm unsure how to proceed.

So far, I have tried multiple variations of the command shown below:

$ cdo selname,ICEC_L1 icecon.cdas1.201908.grb2.nc ICEC_L1_201908.nc
Warning (cdfCheckVars): Unsupported data type (char/string), skipped variable valid_date_time!
Warning (cdfCheckVars): Unsupported data type (char/string), skipped variable ref_date_time!
cdf_put_vara_float: name=ICEC_L1 type=NC_FLOAT minval=0.000000 maxval=0.639000

Error (cdf_put_vara_float): Operation not supported

Error (cdf_close): Operation not supported


Additional details about the file (icecon.cdas1.201908.grb2.nc) are attached to the post.

I suspect that the issue may require a defined time axis, but I tried that and it also produced an error (shown below):

$ cdo -settaxis,2019-08-01,00:00:00,1hour -selname,ICEC_L1 icecon.cdas1.201908.grb2.nc ICEC_L1_201908.nc
cdo(1) selname: Process started
Warning (cdfCheckVars): Unsupported data type (char/string), skipped variable valid_date_time!
Warning (cdfCheckVars): Unsupported data type (char/string), skipped variable ref_date_time!
cdf_put_vara_double: name=ICEC_L1 type=NC_FLOAT minval=0.000000 maxval=0.639000

Error (cdf_put_vara_double): Operation not supported

Error (cdf_close): Operation not supported


I would appreciate any suggestions regarding how to subset the ICEC_L1 variable from the file. I am using CDO version

Thanks kindly,
Joseph

icecon.cdas1.201908.grb2.nc (7.38 MB) icecon.cdas1.201908.grb2.nc icecon.cdas1.201908.grb2.nc
filedes.txt (16 Bytes) filedes.txt filedes
showtimestamp.txt (15.3 KB) showtimestamp.txt showtimestamp
showname.txt (23 Bytes) showname.txt showname
info.txt (159 KB) info.txt info
showatts.txt (396 Bytes) showatts.txt showatts
sinfo.txt (3.44 KB) sinfo.txt sinfo
ncdump.txt (6 MB) ncdump.txt ncdump
cdo_version.txt (2.17 KB) cdo_version.txt cdo_version

Replies (2)

RE: subsetting single variable from CFSR reanalysis data - Added by Karin Meier-Fleischer over 4 years ago

Hi Joseph,

the problem is the type of the variables valid_date_time and ref_date_time which is char.

ncdump -h icecon.cdas1.201908.grb2.nc

netcdf icecon.cdas1.201908.grb2 {
dimensions:
    time = UNLIMITED ; // (744 currently)
    lat = 24 ;
    lon = 108 ;
    tstrlen = 10 ;
variables:
    float time(time) ;
        time:name = "time" ;
        time:long_name = "time" ;
        time:units = "hours since 2019-08-01 00:00:00.0 +0:00" ;
        time:calendar = "standard" ;
    char valid_date_time(time, tstrlen) ;
        valid_date_time:name = "valid_date_time" ;
        valid_date_time:long_name = "valid date and time as YYYYMMDDHH" ;
    char ref_date_time(time, tstrlen) ;
        ref_date_time:name = "ref_date_time" ;
        ref_date_time:long_name = "reference date and time as YYYYMMDDHH" ;
    int forecast_hour(time) ;
        forecast_hour:long_name = "forecast hour" ;
        forecast_hour:units = "hours" ;
    float lat(lat) ;
        lat:name = "lat" ;
        lat:long_name = "latitude" ;
        lat:units = "degree_north" ;
        lat:valid_range = 69.1993f, 73.90116f ;
    float lon(lon) ;
        lon:name = "lon" ;
        lon:long_name = "longitude" ;
        lon:units = "degree_east" ;
        lon:valid_range = 199.0227f, 220.9091f ;
    float ICEC_L1(time, lat, lon) ;
        ICEC_L1:long_name = "Ice cover" ;
        ICEC_L1:product_description = "Forecast over hours" ;
        ICEC_L1:units = "fraction" ;
        ICEC_L1:level = "Ground or water surface" ;
        ICEC_L1:_FillValue = 3.4e+38f ;

// global attributes:
        :Creation\ date\ and\ time = "2019-09-14 11:36:09 -0600" ;
        :Conventions = "CF-1.5" ;
        :Creator = "NCAR - CISL RDA (dattore)" ;
}

You can delete these variables and forecast_hour if not needed with NCO's ncks

ncks -O -x -v valid_date_time,ref_date_time,forecast_hour icecon.cdas1.201908.grb2.nc ICEC_L1_201908.nc

Now, CDO can handle the file correctly

cdo sinfo ICEC_L1_201908.nc

   File format : NetCDF
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter ID
     1 : unknown  unknown  v instant       1   1      2592   1  F32  : -1            
   Grid coordinates :
     1 : lonlat                   : points=2592 (108x24)
                              lon : 199.0227 to 220.9091 by 0.2045455 degree_east
                              lat : 73.90116 to 69.1993 by -0.204429 degree_north
   Vertical coordinates :
     1 : surface                  : levels=1
   Time coordinate :  744 steps
     RefTime =  2019-08-01 00:00:00  Units = hours  Calendar = standard
  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
  2019-08-01 01:00:00  2019-08-01 02:00:00  2019-08-01 03:00:00  2019-08-01 04:00:00
  2019-08-01 05:00:00  2019-08-01 06:00:00  2019-08-01 07:00:00  2019-08-01 08:00:00
  2019-08-01 09:00:00  2019-08-01 10:00:00  2019-08-01 11:00:00  2019-08-01 12:00:00
  2019-08-01 13:00:00  2019-08-01 14:00:00  2019-08-01 15:00:00  2019-08-01 16:00:00
  2019-08-01 17:00:00  2019-08-01 18:00:00  2019-08-01 19:00:00  2019-08-01 20:00:00
  2019-08-01 21:00:00  2019-08-01 22:00:00  2019-08-01 23:00:00  2019-08-02 00:00:00
  2019-08-02 01:00:00  2019-08-02 02:00:00  2019-08-02 03:00:00  2019-08-02 04:00:00
  2019-08-02 05:00:00  2019-08-02 06:00:00  2019-08-02 07:00:00  2019-08-02 08:00:00
  2019-08-02 09:00:00  2019-08-02 10:00:00  2019-08-02 11:00:00  2019-08-02 12:00:00
  2019-08-02 13:00:00  2019-08-02 14:00:00  2019-08-02 15:00:00  2019-08-02 16:00:00
  2019-08-02 17:00:00  2019-08-02 18:00:00  2019-08-02 19:00:00  2019-08-02 20:00:00
  2019-08-02 21:00:00  2019-08-02 22:00:00  2019-08-02 23:00:00  2019-08-03 00:00:00
  2019-08-03 01:00:00  2019-08-03 02:00:00  2019-08-03 03:00:00  2019-08-03 04:00:00
  2019-08-03 05:00:00  2019-08-03 06:00:00  2019-08-03 07:00:00  2019-08-03 08:00:00
  2019-08-03 09:00:00  2019-08-03 10:00:00  2019-08-03 11:00:00  2019-08-03 12:00:00
   ................................................................................
   .......................................................
  2019-08-29 13:00:00  2019-08-29 14:00:00  2019-08-29 15:00:00  2019-08-29 16:00:00
  2019-08-29 17:00:00  2019-08-29 18:00:00  2019-08-29 19:00:00  2019-08-29 20:00:00
  2019-08-29 21:00:00  2019-08-29 22:00:00  2019-08-29 23:00:00  2019-08-30 00:00:00
  2019-08-30 01:00:00  2019-08-30 02:00:00  2019-08-30 03:00:00  2019-08-30 04:00:00
  2019-08-30 05:00:00  2019-08-30 06:00:00  2019-08-30 07:00:00  2019-08-30 08:00:00
  2019-08-30 09:00:00  2019-08-30 10:00:00  2019-08-30 11:00:00  2019-08-30 12:00:00
  2019-08-30 13:00:00  2019-08-30 14:00:00  2019-08-30 15:00:00  2019-08-30 16:00:00
  2019-08-30 17:00:00  2019-08-30 18:00:00  2019-08-30 19:00:00  2019-08-30 20:00:00
  2019-08-30 21:00:00  2019-08-30 22:00:00  2019-08-30 23:00:00  2019-08-31 00:00:00
  2019-08-31 01:00:00  2019-08-31 02:00:00  2019-08-31 03:00:00  2019-08-31 04:00:00
  2019-08-31 05:00:00  2019-08-31 06:00:00  2019-08-31 07:00:00  2019-08-31 08:00:00
  2019-08-31 09:00:00  2019-08-31 10:00:00  2019-08-31 11:00:00  2019-08-31 12:00:00
  2019-08-31 13:00:00  2019-08-31 14:00:00  2019-08-31 15:00:00  2019-08-31 16:00:00
  2019-08-31 17:00:00  2019-08-31 18:00:00  2019-08-31 19:00:00  2019-08-31 20:00:00
  2019-08-31 21:00:00  2019-08-31 22:00:00  2019-08-31 23:00:00  2019-09-01 00:00:00
cdo sinfo: Processed 1 variable over 744 timesteps [0.01s 22MB]

-Karin

RE: subsetting single variable from CFSR reanalysis data - Added by Joseph S over 4 years ago

Thank you very much for the solution, Karin. It works perfectly now. :)

Kind regards,
Joseph

    (1-2/2)