Project

General

Profile

Issue with converting generic coordinate to lonlat one

Added by Beata Szabo-Takacs 10 months ago

Dear All,

I have a similar problem as in https://code.mpimet.mpg.de/boards/1/topics/3330. I have CT-NRT.2025_mergetime.nc file which has generic grid. I would like to convert it to latlon grid for using sellonlatbox. I tried the following methods:

cdo griddes CT-NRT.2025_mergetime.nc > mygrid_CT-NRT
sed -i "s/generic/lonlat/g" mygrid_CT-NRT
cdo setgrid,mygrid_CT-NRT CT-NRT.v2025_mergetime.nc CT-NRT.v2025_mergetime_fixedgrid2.nc

The result of cat mygrid_CT-NRT #
  1. gridID 1 #
    gridtype = lonlat
    gridsize = 10800
    xsize = 120
    ysize = 90
    xname = longitude
    xlongname = "longitude"
    xunits = "degrees_east"
    yname = latitude
    ylongname = "latitude"
    yunits = "degrees_north"
    xfirst = -178.5
    xinc = 3
    yfirst = -89
    yinc = 2
    scanningMode = 64 #
  2. gridID 2 #
    gridtype = lonlat
    gridsize = 6
    xsize = 6
    scanningMode = 64 #
  3. gridID 3 #
    gridtype = lonlat
    gridsize = 1
    scanningMode = 64

The result of cdo sinfo CT-NRT.v2025_mergetime_fixedgrid2.nc is:
File format : NetCDF4
-1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID
1 : unknown unknown v instant 34 1 10800 1 F32 : -1
2 : unknown unknown v instant 1 2 10800 1 F32 : -2
3 : unknown unknown v instant 1 2 6 2 I32 : -3
4 : unknown unknown v instant 34 1 10800 1 F32 : -4
5 : unknown unknown v instant 1 2 1 3 F64 : -5
6 : unknown unknown v instant 35 3 10800 1 F32 : -6
7 : unknown unknown c instant 1 2 10800 1 F32 : -7
8 : unknown unknown v instant 1 2 10800 1 F32 : -8
9 : unknown unknown v instant 35 3 10800 1 F32 : -9
10 : unknown unknown v instant 34 1 10800 1 F32 : -10
11 : unknown unknown v instant 34 1 10800 1 F32 : -11
12 : unknown unknown v instant 34 1 10800 1 F32 : -12
13 : unknown unknown v instant 34 1 10800 1 F32 : -13
Grid coordinates :
1 : lonlat : points=10800 (120x90)
longitude : -178.5 to 178.5 by 3 degrees_east circular
latitude : -89 to 89 by 2 degrees_north
2 : generic : points=6
3 : generic : points=1
Vertical coordinates :
1 : generic : levels=34
level : 1 to 34 by 1 none
2 : surface : levels=1
3 : generic : levels=35
boundary : 1 to 35 by 1 none
Time coordinate : 248 steps
RefTime = 2000-01-01 00:00:00 Units = days 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
2024-03-01 01:30:00 2024-03-01 04:30:00 2024-03-01 07:30:00 2024-03-01 10:30:00
2024-03-01 13:30:00 2024-03-01 16:30:00 2024-03-01 19:30:00 2024-03-01 22:30:00
2024-03-02 01:30:00 2024-03-02 04:30:00 2024-03-02 07:30:00 2024-03-02 10:30:00
2024-03-02 13:30:00 2024-03-02 16:30:00 2024-03-02 19:30:00 2024-03-02 22:30:00
2024-03-03 01:30:00 2024-03-03 04:30:00 2024-03-03 07:30:00 2024-03-03 10:30:00
2024-03-03 13:30:00 2024-03-03 16:30:00 2024-03-03 19:30:00 2024-03-03 22:30:00
2024-03-04 01:30:00 2024-03-04 04:30:00 2024-03-04 07:30:00 2024-03-04 10:30:00
2024-03-04 13:30:00 2024-03-04 16:30:00 2024-03-04 19:30:00 2024-03-04 22:30:00
2024-03-05 01:30:00 2024-03-05 04:30:00 2024-03-05 07:30:00 2024-03-05 10:30:00
2024-03-05 13:30:00 2024-03-05 16:30:00 2024-03-05 19:30:00 2024-03-05 22:30:00
2024-03-06 01:30:00 2024-03-06 04:30:00 2024-03-06 07:30:00 2024-03-06 10:30:00
2024-03-06 13:30:00 2024-03-06 16:30:00 2024-03-06 19:30:00 2024-03-06 22:30:00
2024-03-07 01:30:00 2024-03-07 04:30:00 2024-03-07 07:30:00 2024-03-07 10:30:00
2024-03-07 13:30:00 2024-03-07 16:30:00 2024-03-07 19:30:00 2024-03-07 22:30:00
2024-03-08 01:30:00 2024-03-08 04:30:00 2024-03-08 07:30:00 2024-03-08 10:30:00
................................................................................
.....
2024-03-24 13:30:00 2024-03-24 16:30:00 2024-03-24 19:30:00 2024-03-24 22:30:00
2024-03-25 01:30:00 2024-03-25 04:30:00 2024-03-25 07:30:00 2024-03-25 10:30:00
2024-03-25 13:30:00 2024-03-25 16:30:00 2024-03-25 19:30:00 2024-03-25 22:30:00
2024-03-26 01:30:00 2024-03-26 04:30:00 2024-03-26 07:30:00 2024-03-26 10:30:00
2024-03-26 13:30:00 2024-03-26 16:30:00 2024-03-26 19:30:00 2024-03-26 22:30:00
2024-03-27 01:30:00 2024-03-27 04:30:00 2024-03-27 07:30:00 2024-03-27 10:30:00
2024-03-27 13:30:00 2024-03-27 16:30:00 2024-03-27 19:30:00 2024-03-27 22:30:00
2024-03-28 01:30:00 2024-03-28 04:30:00 2024-03-28 07:30:00 2024-03-28 10:30:00
2024-03-28 13:30:00 2024-03-28 16:30:00 2024-03-28 19:30:00 2024-03-28 22:30:00
2024-03-29 01:30:00 2024-03-29 04:30:00 2024-03-29 07:30:00 2024-03-29 10:30:00
2024-03-29 13:30:00 2024-03-29 16:30:00 2024-03-29 19:30:00 2024-03-29 22:30:00
2024-03-30 01:30:00 2024-03-30 04:30:00 2024-03-30 07:30:00 2024-03-30 10:30:00
2024-03-30 13:30:00 2024-03-30 16:30:00 2024-03-30 19:30:00 2024-03-30 22:30:00
2024-03-31 01:30:00 2024-03-31 04:30:00 2024-03-31 07:30:00 2024-03-31 10:30:00
2024-03-31 13:30:00 2024-03-31 16:30:00 2024-03-31 19:30:00 2024-03-31 22:30:00

It seems that the setgrid did not changed the coordinates. I tried to use also remap but I got error message:
cdo remapcon,mygrid_CT-NRT CT-NRT.v2025_mergetime_fixedgrid2.nc CT-NRT.v2025_mergetime_lonlat_file.nc

cdo remapcon (Abort): Unsupported generic coordinates (Variable: calendar_components)!

I attached one CT-NRT.nc file.
Could someone suggest me a solution?


Replies (2)

RE: Issue with converting generic coordinate to lonlat one - Added by Uwe Schulzweida 10 months ago

The grid is correctly recognized as lonlat. Arrays that are not defined on the lonlat grid must be removed before interpolation. Here are two examples:

cdo remapcon,<targetgrid> -selgridname,lonlat infile outfile

cdo remapcon,<targetgrid> -delname,calendar_components,decimal_date infile outfile

RE: Issue with converting generic coordinate to lonlat one - Added by Karin Meier-Fleischer 10 months ago

And the axis attribute of the latitude variable is set to "Z" instead of "Y".

    (1-2/2)