Project

General

Profile

how to move lon and lat as a dimension in Netcdf file.

Added by Serge Tom over 4 years ago

I have a data with generic grid and I have grid file with different grid depending of which variable you want analyze. I try to insert the plon plat in my data file using ncks. now I would like to change the x and y (generic grid) into plon,plat as my new dimension.
anyone can help me!!!!
find below the information of my data.

SST_NOI20C_sr10m60d52.micom.nc
File format : netCDF
-1 : Institut Source Ttype Levels Num Points Num Dtype : Parameter name
1 : unknown unknown instant 1 1 138600 1 F64 : sst
2 : unknown unknown constant 1 1 138600 1 F64 : plat
3 : unknown unknown constant 1 1 138600 1 F64 : plon
Grid coordinates :
1 : generic : points=138600 (360x385)
Vertical coordinates :
1 : surface : levels=1
Time coordinate : 1668 steps
RefTime = 0001-01-01 00:00:00 Units = days Calendar = 365_day
YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss
0557-01-17 00:00:00 0557-02-14 00:00:00 0557-03-17 00:00:00 0557-04-16 00:00:00
0557-05-17 00:00:00 0557-06-16 00:00:00 0557-07-17 00:00:00 0557-08-17 00:00:00
0557-09-16 00:00:00 0557-10-17 00:00:00 0557-11-16 00:00:00 0557-12-17 00:00:00
0558-01-17 00:00:00 0558-02-14 00:00:00 0558-03-17 00:00:00 0558-04-16 00:00:00
0558-05-17 00:00:00 0558-06-16 00:00:00 0558-07-17 00:00:00 0558-08-17 00:00:00
0558-09-16 00:00:00 0558-10-17 00:00:00 0558-11-16 00:00:00 0558-12-17 00:00:00
0559-01-17 00:00:00 0559-02-14 00:00:00 0559-03-17 00:00:00 0559-04-16 00:00:00
0559-05-17 00:00:00 0559-06-16 00:00:00 0559-07-17 00:00:00 0559-08-17 00:00:00
0559-09-16 00:00:00 0559-10-17 00:00:00 0559-11-16 00:00:00 0559-12-17 00:00:00
0560-01-17 00:00:00 0560-02-14 00:00:00 0560-03-17 00:00:00 0560-04-16 00:00:00
0560-05-17 00:00:00 0560-06-16 00:00:00 0560-07-17 00:00:00 0560-08-17 00:00:00
0560-09-16 00:00:00 0560-10-17 00:00:00 0560-11-16 00:00:00 0560-12-17 00:00:00
0561-01-17 00:00:00 0561-02-14 00:00:00 0561-03-17 00:00:00 0561-04-16 00:00:00
0561-05-17 00:00:00 0561-06-16 00:00:00 0561-07-17 00:00:00 0561-08-17 00:00:00
0561-09-16 00:00:00 0561-10-17 00:00:00 0561-11-16 00:00:00 0561-12-17 00:00:00
................................................................................


Replies (4)

RE: how to move lon and lat as a dimension in Netcdf file. - Added by Karin Meier-Fleischer over 4 years ago

Hi Serge,

be careful changing the grid! Your way to change the grid requires that the underlying grid and the grid of plon and plat has the same size.

I guess, that the new coordinates plat and plon should have 'degrees_east' and 'degrees_north' units attributes.
The variable sst needs the coordinates attribute to point to plon and plat. Because plon and plat are variables you can add the attributes using CDO's setattribute operator, too.

cdo -setattribute,plat@units="degrees_north" -setattribute,plon@units="degrees_east" -setattribute,sst@coordinates="plat plon" infile outfile

-Karin

RE: how to move lon and lat as a dimension in Netcdf file. - Added by Serge Tom over 4 years ago

thank you Karim for your response,
the new coordinate have 'degrees_east' and 'degree_north' attribute.
But when I try your command line I got operator >setattribute< not found!

RE: how to move lon and lat as a dimension in Netcdf file. - Added by Karin Meier-Fleischer over 4 years ago

Which version are you using? See https://code.mpimet.mpg.de/projects/cdo/embedded/index.html#x1-2060002.6.1

The following has to work

cdo -setattribute,sst@coordinates="plat plon" infile outfile

-Karin

RE: how to move lon and lat as a dimension in Netcdf file. - Added by Serge Tom over 4 years ago

Hi Karim,

I think is due to the version of the CDO I have. It is 1.7.0
I will update it but I found another way to do it using NCO

ncatted -a coordinates,sst,c,c,"nav_lon nav_lat" sst_data.nc
    (1-4/4)