Project

General

Profile

different values of coordinates (latitude and longitude) when I convert grib2 file to netcdf file

Added by mab ab over 3 years ago

Hi, I have a problem when I convert grib2 file to netcdf file using cdo. The netcdf file has different latitude and longitude values than the original grib2 file. I attached the input grib2 file and the output netcdf file. I used this function:

cdo -f nc copy CMC_reg_SFCWRO_SFC_0_ps10km_2021010600_P012.grib2 CMC_reg_SFCWRO_SFC_0_ps10km_2021010600_P012.nc

I'm working in linux. Any help or suggestion?

thank you


Replies (1)

RE: different values of coordinates (latitude and longitude) when I convert grib2 file to netcdf file - Added by Karin Meier-Fleischer over 3 years ago

Hi Mab,

the data in the GRIB file uses Polar Stereographic projection. The x- and y-dimension have units 'm'.

cdo sinfon CMC_reg_SFCWRO_SFC_0_ps10km_2021010600_P012.grib2 

   File format : GRIB2 jpeg
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
     1 : unknown  unknown  v instant       1   1    770440   1  P9 j : sro           
   Grid coordinates :
     1 : projection               : points=770440 (935x824)
                          mapping : polar_stereographic
                                x : 0 to 9340000 by 10000 m
                                y : 0 to 8230000 by 10000 m
   Vertical coordinates :
     1 : surface                  : levels=1
   Time coordinate :  1 step
     RefTime =  2021-01-06 00:00:00  Units = hours  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
  2021-01-06 12:00:00

Using the copy operator will give you the same result stored in netCDF format.

cdo -f nc copy CMC_reg_SFCWRO_SFC_0_ps10km_2021010600_P012.grib2 o.nc
cdo sinfon o.nc

   File format : NetCDF2
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
     1 : unknown  unknown  v instant       1   1    770440   1  F32  : sro           
   Grid coordinates :
     1 : projection               : points=770440 (935x824)
                          mapping : polar_stereographic
                                x : 0 to 9340000 by 10000 m
                                y : 0 to 8230000 by 10000 m
   Vertical coordinates :
     1 : surface                  : levels=1
   Time coordinate :  1 step
     RefTime =  2021-01-06 00:00:00  Units = hours  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
  2021-01-06 12:00:00

You can remap the file to a lonlat grid, here I used a global 0.5 degree grid.

cdo -f nc -remapbil,r720x360 CMC_reg_SFCWRO_SFC_0_ps10km_2021010600_P012.grib2 o_remap.nc

cdo    remapbil: Bilinear weights from curvilinear (935x824) to lonlat (720x360) grid, with source mask (750157)

The following plot shows in the upper left plot the original data, in upper right plot the copied data to netCDF, and in the lower row plot the remapped data.

    (1-1/1)