Project

General

Profile

Problems with regridding netcdf file with a land-sea mask

Added by Feng Wang over 3 years ago

Dear all,
I met some problems when regridding my netcdf data from CESM model outputs using cdo.

Here are the scripts I used to process my data:

cdo remapcon,seamask.nc example1.nc output.nc

I got:

#Warning (cdfCheckVars): Unsupported data type (char/string), skipped variable date_written!
#Warning (cdfCheckVars): Unsupported data type (char/string), skipped variable time_written!

#cdo remapcon (Abort): lonlat grid without longitude coordinates!

Although the ourput.nc can be written, no data (TREFHT) is kept.

Another option I used is:

1#cdo selname,TREFHT example1.nc example2.nc
2#cdo remapcon,seamask example2.nc example_regirdded.nc

In this way, data can be written. But I don't know why these two scripts cannot be merged like:

#cdo -L remapcon,seamask.nc selname,TREFHT example.nc example_regirdded.nc

Again if I use the following script to extract land-only data from the output I got with the second option:

#cdo setmissval,0 -mul example_regirdded.nc seamask.nc output.nc

I got error like this:

#cdo(1) mul: Process started
#cdo(1) mul: Filling up stream2 >seamask.nc< by copying the first timestep.
#cdf_get_vara_double: ncid = 65536 varid = 1

Another way is:

3#cdo -L setmissval,0 -mul -selname,TREFHT example_regirdded.nc seamask.nc output.nc

Could any one tell whether I am doing correctly with the script line 1,2, and 3 to regrid and mask my data.
And perhaps provide a way to merge script 1-2.

Thank you very much in advance.

Yours best,
Feng


Replies (2)

RE: Problems with regridding netcdf file with a land-sea mask - Added by Karin Meier-Fleischer over 3 years ago

Hi Feng,

the warnings of CDO tell you that there are variables of type string or character. In your case you can ignore it.
Using 'ncdump -h example1.nc' or 'cdo sinfon example1.nc' you would see that the example1.nc files contains several different grids whether you select the grid with '-selgrid,4' or the variable TREFHT (which uses grid number 4) with '-selname,TREFHT'.

By the way the correct naming is operator chaining to do all of it in one command line combining the operators.

cdo -L -setmissval,0 -mul seamask.nc -remapcon,seamask.nc -selname,TREFHT example1.nc output.nc

-Karin

RE: Problems with regridding netcdf file with a land-sea mask - Added by Feng Wang over 3 years ago

Thank you very much Karin! The combined script is working perfectly!

Feng

    (1-2/2)