Project

General

Profile

Converting generic grid type to lonlat gridtype

Added by Ellie Nelson almost 3 years ago

Hello,

I am trying to regrid Time_Varying_Biomes.nc (attached) to the same grid type and resolution as the observation dataset fgco2_obs.nc (attached). My aim is to use the time-varying biomes labelled 16 and 17 to extract fgco2 values from the observational data.

My issue is that the Time_Varying_Biomes.nc is on a generic grid that cdo does not recognise. The dataset contains both longitude and latitude coordinates and years for the time variable, but cdo does not recognise these variables.

Grid information for Time_Varying_Biomes.nc:

gridtype = generic
gridsize = 64800
xsize = 360
ysize = 180
xname = lon
xunits = "degrees longitude"
yname = lat
yunits = "degrees latitude"
xfirst = -179.5
xinc = 1
yfirst = -89.5
yinc = 1

Target grid (fgco2_obs.nc):
gridtype = lonlat
gridsize = 64800
datatype = float
xsize = 360
ysize = 180
xname = lon
xlongname = "longitude"
xunits = "degrees_east"
yname = lat
ylongname = "latitude"
yunits = "degrees_north"
xfirst = -179.5
xinc = 1
xbounds = -180 t0 180
ybounds = -90 to 90

I have tried to change the longitude and latitude variables by doing the following:

ncpdq -a year,lev,lat,lon Time_Varying_Biomes.nc TVB_rearranged.nc
ncatted -a coordinates,CoreBiomes,c,c,"lon lat" TVB_rearranged.nc

When trying to regrid the data after this I receive the error:
Warning (cdfInqContents): Coordinates variable lon can't be assigned!

Any advice on how to regrid this dataset would be much appreciated!

Best,

Ellie

Time_Varying_Biomes.nc (7.42 MB) Time_Varying_Biomes.nc
fgco2_obs_1.nc (261 KB) fgco2_obs_1.nc Only one timestep to reduce datasize

Replies (2)

RE: Converting generic grid type to lonlat gridtype - Added by Sarah Roffe almost 3 years ago

Hi Ellie,

I have just encountered the same issue and wonder if you have figured out a solution to this?

Kind regards,
Sarah

RE: Converting generic grid type to lonlat gridtype - Added by Karin Meier-Fleischer almost 3 years ago

Hi Ellie,

the files are not CF-conform which causes the problems. I would recommend to use Python or NCL to read the data, reorder the dimensions of the variables and do the regridding.

-Karin

    (1-2/2)