Project

General

Profile

Unable to convert to GRIB2

Added by Oriol Ciurana about 5 years ago

I'm trying to convert a netcdf file from CMEMS (Marine Copernicus) to GRIB2 format without success. I have been able to convert other CMEMS netcdf files to GRIB2 without any problem so I suspect than this netcdf file (I attach it) has some kind of peculiarity that I'm missing out.

Previous to the conversion, I filter the desired variable (thetao) and vertical level (depth) with NCKS:

ncks -O -h -v thetao -d depth,0,0 metoffice_foam1_amm15_NWS_TMB_TEM_b20190212_hi20190212.nc filtered.nc

The resulted file "filtered.nc":

netcdf filtered {
dimensions:
        depth = 1 ;
        lat = 1240 ;
        lon = 958 ;
        time = UNLIMITED ; // (24 currently)
variables:
        float depth(depth) ;
                depth:units = "1" ;
                depth:positive = "down" ;
                depth:standard_name = "ocean_s_coordinate" ;
                depth:long_name = "Model levels at surface, mid water column and near bed" ;
                depth:axis = "Z" ;
        float lat(lat) ;
                lat:nav_model = "grid_T" ;
                lat:long_name = "latitude" ;
                lat:standard_name = "latitude" ;
                lat:cell_methods = "longitude: mean" ;
                lat:units = "degrees_north" ;
                lat:axis = "Y" ;
        float lon(lon) ;
                lon:nav_model = "grid_T" ;
                lon:long_name = "longitude" ;
                lon:standard_name = "longitude" ;
                lon:cell_methods = "latitude: mean" ;
                lon:units = "degrees_east" ;
                lon:axis = "X" ;
        short thetao(time, depth, lat, lon) ;
                thetao:_FillValue = -32768s ;
                thetao:long_name = "Sea Water Potential Temperature" ;
                thetao:standard_name = "sea_water_potential_temperature" ;
                thetao:scale_factor = 0.001 ;
                thetao:units = "degrees_C" ;
                thetao:missing_value = -32768s ;
                thetao:valid_max = 30000s ;
                thetao:valid_min = -30000s ;
                thetao:add_offset = 25. ;
        double time(time) ;
                time:units = "seconds since 2019-02-10 00:00:00" ;
                time:long_name = "Validity time" ;
                time:standard_name = "time" ;
                time:calendar = "Gregorian" ;
                time:axis = "T" ;

// global attributes:
                :grid_resolution = "Lat-lon 1.5 km" ;
                :stop_time = "23:59Z" ;
                :title = "hourly-instantaneous potential temperature " ;
                :model_version = "AMM15v1" ;
                :file_quality_index = "0s" ;
                :start_time = "00:00Z" ;
                :product_version = "1.0" ;
                :Conventions = "CF-1.0" ;
                :source = "UK Met Office Operational Suite, Atlantic Margin Model FOAM 1.5 km (tidal) run 2019-02-12" ;
                :contact = "servicedesk.cmems@mercator-ocean.eu" ;
                :netcdf-version-id = "netCDF-4" ;
                :start_date = "2019-02-12" ;
                :stop_date = "2019-02-12" ;
                :references = "http://marine.copernicus.eu/" ;
                :creation_date = "2019-02-12 00:00Z" ;
                :institution = "UK Met Office" ;
                :history = "See source and creation_date attributes" ;
}

And then, I do the conversion to GRIB2 with CDO with apparently no errors:

cdo -f grb2 -setparam,0.3.10 -setltype,1 -setlevel,0 filtered.nc filtered.grb2

cdo setparam: Started child process "setltype,1 -setlevel,0 filtered.nc (pipe1.1)".
cdo(2) setltype: Started child process "setlevel,0 filtered.nc (pipe2.1)".
cdo(3) setlevel: Processed 28510080 values from 1 variable over 24 timesteps ( 0.89s )
cdo(2) setltype: Processed 28510080 values from 1 variable over 24 timesteps ( 0.89s )
cdo setparam: Processed 28510080 values from 1 variable over 24 timesteps ( 0.89s 70MB )

The resulted GRIB2 file:

cdo sinfo filtered.grb2

   File format : GRIB2
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter ID
     1 : unknown  unknown  v instant       1   1   1187920   1  P16  : 0.3.10
   Grid coordinates :
     1 : lonlat                   : points=1187920 (958x1240)
                              lon : 344 to 373 by 0.030303 degrees_east
                              lat : 46 to 62.74385 by 0.013514 degrees_north
   Vertical coordinates :
     1 : surface                  : levels=1
   Time coordinate :  unlimited steps
     RefTime =  2019-02-10 00:00:00  Units = seconds  Calendar = proleptic_gregorian
  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-02-12 00:30:00  2019-02-12 01:30:00  2019-02-12 02:30:00  2019-02-12 03:30:00
  2019-02-12 04:30:00  2019-02-12 05:30:00  2019-02-12 06:30:00  2019-02-12 07:30:00
  2019-02-12 08:30:00  2019-02-12 09:30:00  2019-02-12 10:30:00  2019-02-12 11:30:00
  2019-02-12 12:30:00  2019-02-12 13:30:00  2019-02-12 14:30:00  2019-02-12 15:30:00
  2019-02-12 16:30:00  2019-02-12 17:30:00  2019-02-12 18:30:00  2019-02-12 19:30:00
  2019-02-12 20:30:00  2019-02-12 21:30:00  2019-02-12 22:30:00  2019-02-12 23:30:00
cdo sinfo: Processed 1 variable over 24 timesteps ( 0.04s 21MB )

cdo info filtered.grb2

    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter ID
     1 : 2019-02-12 00:30:00       0  1187920 1187920 :                     nan             : 0.3.10
     2 : 2019-02-12 01:30:00       0  1187920 1187920 :                     nan             : 0.3.10
     3 : 2019-02-12 02:30:00       0  1187920 1187920 :                     nan             : 0.3.10
     4 : 2019-02-12 03:30:00       0  1187920 1187920 :                     nan             : 0.3.10
     5 : 2019-02-12 04:30:00       0  1187920 1187920 :                     nan             : 0.3.10
     6 : 2019-02-12 05:30:00       0  1187920 1187920 :                     nan             : 0.3.10
     7 : 2019-02-12 06:30:00       0  1187920 1187920 :                     nan             : 0.3.10
     8 : 2019-02-12 07:30:00       0  1187920 1187920 :                     nan             : 0.3.10
     9 : 2019-02-12 08:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    10 : 2019-02-12 09:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    11 : 2019-02-12 10:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    12 : 2019-02-12 11:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    13 : 2019-02-12 12:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    14 : 2019-02-12 13:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    15 : 2019-02-12 14:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    16 : 2019-02-12 15:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    17 : 2019-02-12 16:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    18 : 2019-02-12 17:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    19 : 2019-02-12 18:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    20 : 2019-02-12 19:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    21 : 2019-02-12 20:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    22 : 2019-02-12 21:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    23 : 2019-02-12 22:30:00       0  1187920 1187920 :                     nan             : 0.3.10
    24 : 2019-02-12 23:30:00       0  1187920 1187920 :                     nan             : 0.3.10
cdo info: Processed 28510080 values from 1 variable over 24 timesteps ( 0.15s 31MB )

When I inspect the resulted GRIB2 file, all values appear as missing, but file has 3.5MB size so it seems to have the data.
What's happening?

Thanks in advance,

Oriol


Replies (3)

RE: Unable to convert to GRIB2 - Added by Karin Meier-Fleischer about 5 years ago

Hi Oriol,

I can't reproduce the output results above. Which version of CDO do you use? I used version 1.9.5.

You don't have to use ncks first because CDO can do it at once:

cdo -f grb2 -setparam,0.3.10 -setltype,1 -sellevel,0 metoffice_foam1_amm15_NWS_TMB_TEM_b20190212_hi20190212.nc filtered.grb2

The only warning I've got due to your parameter setting is

gribapiEncode     : *** GRIB2 shortName does not correspond to chosen variable name: "sst" ("thetao").
cdo infon filtered.grb2
    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
     1 : 2019-02-12 00:30:00       0  1187920  469720 :   0.0030000      8.8154      13.481 : sst           
     2 : 2019-02-12 01:30:00       0  1187920  469720 :   0.0080000      8.8146      13.476 : sst           
     3 : 2019-02-12 02:30:00       0  1187920  469720 :    0.014000      8.8130      13.473 : sst           
     4 : 2019-02-12 03:30:00       0  1187920  469720 :    0.020000      8.8111      13.469 : sst           
     5 : 2019-02-12 04:30:00       0  1187920  469720 :    0.026000      8.8091      13.462 : sst           
     6 : 2019-02-12 05:30:00       0  1187920  469720 :    0.034000      8.8072      13.452 : sst           
     7 : 2019-02-12 06:30:00       0  1187920  469720 :    0.041000      8.8061      13.449 : sst           
     8 : 2019-02-12 07:30:00       0  1187920  469720 :    0.050000      8.8061      13.446 : sst           
     9 : 2019-02-12 08:30:00       0  1187920  469720 :    0.053000      8.8085      13.446 : sst           
    10 : 2019-02-12 09:30:00       0  1187920  469720 :    0.062000      8.8130      13.447 : sst           
    11 : 2019-02-12 10:30:00       0  1187920  469720 :    0.073000      8.8196      13.449 : sst           
    12 : 2019-02-12 11:30:00       0  1187920  469720 :    0.087000      8.8264      13.452 : sst           
    13 : 2019-02-12 12:30:00       0  1187920  469720 :    0.099000      8.8332      13.456 : sst           
    14 : 2019-02-12 13:30:00       0  1187920  469720 :     0.11300      8.8393      13.459 : sst           
    15 : 2019-02-12 14:30:00       0  1187920  469720 :     0.11900      8.8416      13.462 : sst           
    16 : 2019-02-12 15:30:00       0  1187920  469720 :     0.12400      8.8408      13.468 : sst           
    17 : 2019-02-12 16:30:00       0  1187920  469720 :     0.12400      8.8379      13.469 : sst           
    18 : 2019-02-12 17:30:00       0  1187920  469720 :     0.12700      8.8343      13.469 : sst           
    19 : 2019-02-12 18:30:00       0  1187920  469720 :     0.12500      8.8305      13.468 : sst           
    20 : 2019-02-12 19:30:00       0  1187920  469720 :    0.083000      8.8270      13.467 : sst           
    21 : 2019-02-12 20:30:00       0  1187920  469720 :    0.018000      8.8243      13.467 : sst           
    22 : 2019-02-12 21:30:00       0  1187920  469720 :   -0.017000      8.8223      13.467 : sst           
    23 : 2019-02-12 22:30:00       0  1187920  469720 :   -0.027000      8.8212      13.465 : sst           
    24 : 2019-02-12 23:30:00       0  1187920  469720 :   -0.042000      8.8209      13.457 : sst           
cdo infon: Processed 28510080 values from 1 variable over 24 timesteps [0.39s 47MB]
-Karin

RE: Unable to convert to GRIB2 - Added by Oriol Ciurana about 5 years ago

I'm using cdo 1.9.2.
I'm gonna try it with the last cdo version and I will give you feedback.

Thank you!

RE: Unable to convert to GRIB2 - Added by Oriol Ciurana about 5 years ago

Hi Karin,

In cdo 1.9.5 the conversion works as expected, so it seems to be a problem of the version 1.9.2.
Thank you for your time,

Oriol

    (1-3/3)