Project

General

Profile

Problems with setzaxis

Added by Markus Kilian almost 3 years ago

Hi everyone,

to implement MPI-ESM1-2-LR historical into WRF I need to convert the soil moisture to grb-Files and
multiply each sub-surface level with a corresponding number. To do so I first
select the year and split the levels.

I created this two files for 2 levels:
_
zaxis0000_0065:

zaxistype = depth_below_land
size = 1
name = depth
longname = depth_below_land
units = cm
levels = 3
lbounds = 0
ubounds = 6.5_

_
zaxis4134_9834:

zaxistype = depth_below_land
size = 1
name = depth
longname = depth_below_land
units = cm
levels = 698
lbounds = 413.4
ubounds = 983.4_

I run this code on mistral:

cdo -selyear,2000 /work/ik1017/CMIP6/data/CMIP6/CMIP/MPI-M/MPI-ESM1-2-LR/historical/r1i1p1f1/6hrPlevPt/mrsol/gn/v20190710/mrsol_6hrPlevPt_MPI-ESM1-2-LR_historical_r1i1p1f1_gn_199001010600-201001010000.nc mrsol_6hrPlevPt_MPI-ESM1-2-LR_historical_r1i1p1f1_gn_2000.nc

cdo splitlevel mrsol_6hrPlevPt_MPI-ESM1-2-LR_historical_r1i1p1f1_gn_2000.nc mrsol_2000_

This give me the following files:
mrsol_2000_000.03.nc mrsol_2000_000.19.nc mrsol_2000_000.78.nc mrsol_2000_002.68.nc mrsol_2000_006.98.nc

cdo sinfo for mrsol_2000_000.03.nc gives:
Vertical coordinates :
1 : depth_below_sea : levels=1
depth : 0.03 m
bounds : 0-0.065 m

cdo sinfo mrsol_2000_006.98.nc gives:
Vertical coordinates :
1 : depth_below_sea : levels=1
depth : 6.98 m
bounds : 4.134-9.834 m

Running this two line of code:

cdo -f grb setzaxis,zaxis0000_0065 mrsol_2000_000.03.nc mrsol_2000_000.03.grb

cdo -f grb setzaxis,zaxis4134_9834 mrsol_2000_006.98.nc mrsol_2000_006.98.grb

leads to this cdo sinfo output:

cdo sinfo mrsol_2000_000.03.grb
Vertical coordinates :
1 : depth_below_land : levels=1
depth : 0 cm
bounds : 0-6 cm

cdo sinfo mrsol_2000_006.98.grb
Vertical coordinates :
1 : depth_below_land : levels=1
depth : 157 cm
bounds : 157-215 cm

Actually I have no clue why the depth is changed in both grb files and
why for the file mrsol_2000_006.98.grb the values 157 and 215 occure. There is nothing
like this in the levels.

Doing this without "-f grb":
cdo setzaxis,zaxis4134_9834 mrsol_2000_006.98.nc mrsol_2000_006.98_test.nc

leads to a good results:
Vertical coordinates :
1 : depth_below_land : levels=1
depth : 698 cm
bounds : 413.4-983.4 cm

Can someone help me to solve this with grib, since I need to have the files in grb for WRF.

Thank you
Markus


Replies (5)

RE: Problems with setzaxis - Added by Karin Meier-Fleischer almost 3 years ago

Hi Markus,

I was able to reproduce the problem. But I'm not a GRIB expert. GRIB does not have real metadata like netCDF, it uses pre-defined parameter tables which IMO causes the problem.
Why do you want do use GRIB? I actually thought that WRF used netCDF/HDF.

-Karin

RE: Problems with setzaxis - Added by Markus Kilian almost 3 years ago

Hi Karin,

thanks a lot for your reply.
WRF itself uses netCDF/HDF but WPS, the WRF preprocessing system, uses GRIB files. That is
why I want to convert the netCDF coming from CMIP6 MPI-ESM to GRIB.
Inside the WPS GRIB or GRIB2 are converted to an intermediate file format which metgrid.exe can read.
Output of metgrid.exe is netCDF and is used as input for WRF. I highly want to avoid
writing own fortran code to create the intermediate files by myself. So usually cdo helps here.

Is there a way to avoid the pre-definded parameter tables or overwrite them?

RE: Problems with setzaxis - Added by Karin Meier-Fleischer almost 3 years ago

Ah, I see. But IMO, unfortunately, you can't change coordinate variables in GRIB files with CDO, you can use user-defined parameter tables only for data variables. But maybe I'm wrong.

RE: Problems with setzaxis - Added by Markus Kilian almost 3 years ago

A short update on this issue.

With Grib2 the bounds are set properly, however the depth is still set in a wrong way.

In the upper example instead of 3cm depth or 698cm the depth is set to 0 or 413.4

Is there a workaround if the bounds are set properly?

RE: Problems with setzaxis - Added by Uwe Schulzweida almost 3 years ago

Saving layers in GRIB is a bit tricky. Generally only the levels or the bounds can be saved, both together are not possible.
For GRIB1 2 bytes are available to store the values. The value range of the levels is 0 to 65535. The bounds have only one byte each, the value range is 0 to 255.
For GRIB2 the value range is larger. If the bounds are stored, then CDO uses the lower bound as the value for the level (depth).

    (1-5/5)