Project

General

Profile

how to create mask with cdo

Added by pooran khedri almost 6 years ago

Hi everbody,

I have downloaded the Ecmwf data and then I need to create the land-sea mask for this file , my file contains seven variables(temperature wind,mean sea level,precipitation,...). Is there a way to create land-sea mask for this file with cdo command ?
I would be grateful if you could explain to me hoe to do it.
looking forward to any suggestions.

Best regards,
Pooran


Replies (10)

RE: how to create mask with cdo - Added by pooran khedri almost 6 years ago

pooran khedri wrote:

Hi everbody,

I have downloaded the Ecmwf data and then I need to create the land-sea mask for this file , my file contains seven variables(temperature wind,mean sea level,precipitation,...). Is there a way to create land-sea mask for this file with cdo command ?
I would be grateful if you could explain to me hoe to do it.
looking forward to any suggestions.

Best regards,
Pooran

I could solve my problem about this problem, Now I have another problem, I need to interpolate and extrapolate the ecmwf file on my grid, could you please explain how to do it with cdo?
THank you in advance

RE: how to create mask with cdo - Added by Ralf Mueller almost 6 years ago

docu on interpolation is pretty extensive, just have a look into this starting at page 149, you will find the chapter about interpolation

hth
ralf

RE: how to create mask with cdo - Added by pooran khedri almost 6 years ago

Ralf Mueller wrote:

docu on interpolation is pretty extensive, just have a look into this starting at page 149, you will find the chapter about interpolation

hth
ralf

Hi,
Thank you so much for your reply, I studied the manual and tried some commands, but I got unusual results. I was wondering if you could explain to me with more details because I am new to use Cdo.
I would really appreciate any suggestions in advance.

Best Regards,
Pooran

RE: how to create mask with cdo - Added by Ralf Mueller almost 6 years ago

it depends on your input data and your target grid. if possible you might upload some stuff

RE: how to create mask with cdo - Added by pooran khedri almost 6 years ago

Ralf Mueller wrote:

it depends on your input data and your target grid. if possible you might upload some stuff

RE: how to create mask with cdo - Added by pooran khedri almost 6 years ago

pooran khedri wrote:

Ralf Mueller wrote:

it depends on your input data and your target grid. if possible you might upload some stuff

Hi,
I would really appreciate for quick reply.
I have attached the files that you requested. one of the files is the Ecmwf data and another is the grid file,
I used the Ecmwf data to create forcing file for ocean model, but I got the unusual results, I think I have to extrapolate before interpolation.
I would be grateful if you could tell me the appropriate command about it.

Thank you so much.
Best regards,

RE: how to create mask with cdo - Added by Ralf Mueller almost 6 years ago

I used bilinear interpolation like this

cdo remapbil,ocn_roms_grid.nc atm_regcm.nc atm_regcm_roms_grid_remapbil.nc

output is uploaded on ftp://ftp.mpimet.mpg.de:/outgoing/ram/atm_regcm_roms_grid_remapbil.nc (1.2GB)

This interpolated the fields from atm_regcm.nc on the grid defined in ocn_roms_grid.nc.

hope, that's what you were looking for ;-) in case bilinerar is not what you wanted, just take anthother remaping operators.

RE: how to create mask with cdo - Added by pooran khedri almost 6 years ago

Ralf Mueller wrote:

I used bilinear interpolation like this[...]

output is uploaded on ftp://ftp.mpimet.mpg.de:/outgoing/ram/atm_regcm_roms_grid_remapbil.nc (1.2GB)

This interpolated the fields from atm_regcm.nc on the grid defined in ocn_roms_grid.nc.

hope, that's what you were looking for ;-) in case bilinerar is not what you wanted, just take another remaining operators.

Thank you so much for all your help, but I need to do different work, I got unusual temperature result near coast in ocean model, someone said to me, " This looks to me like you are interpolating zero values from the ECMWF land mask into your coastal ocean. You instead need to be extrapolating ocean values into the land areas before you do any interpolation."
I am looking for a way to extrapolate.
I would really appreciate to tell me how to do it with cdo.
Best regards,
Pooran

RE: how to create mask with cdo - Added by Ralf Mueller almost 6 years ago

Problem looks like this:

ECMWD land-see-mask is different from your ocean-land-see-mask

Hence locations which are on land at within the ECMWF context can be open water in the target ocean grid. Esp. for wind stress components this can lead to strange errors. Here is how we handle this issue

  1. create a 0-1-lsm file from the ECMWF source with something like
    cdo gtc,1.0e-4 land_sea_mask.ECMWF.nc ${lsmFile}
    • I expect land_sea_mask.ECMWF.nc to hold some kind if orography valid for the ECMWF dataset you use
  2. create the target interpolation weights with filling the missing value in-between:
    cdo -P ${THREADS} ${remapOperator},${targetGrid} -fillmiss -ifnotthen ${lsmFile} -seltimestep,1 ${test_data} ${targetWeight}
    
    • remapOperators should be selected by you, good candidates are genbil or gencon - these operators for not interpolate data, but create the interpolation weights. Those can be appplied afterwards with the remap operator
    • targetGrid is your ocean grid
    • THREADS can be upto the number of cores of your machine - if unsure, leave out the
      -P ${THREADS}
      part - will slow down stuff, but not change the results
    • test_data is your input from ECMWF
    • targetWeight will be the file holding the interpolation weights
  3. mask your input with the land-see-mask of ECMWF - this is importent, because here, the wrong values are removed from the input fields and replaced by something different
    cdo -fillmiss -ifnotthen ${lsmFile}  $file ${_oFile}
    • file is the complete ECMWF input you want to interpolate
    • _oFile is temporary output - set is as you like - it's just temporary
  4. remap the input fields with
    cdo remap,${targetGrid},${targetWeight} ${_oFile} ${oFile}
    • ofile is the real output file you want to use

The key in this processing is how the missing values are filled. in this example the fillmiss operator is used, but there are other options, have a look onto slide 14 of https://code.mpimet.mpg.de/attachments/download/13557/CDO_Seminar_20161206.pdf. setmisstonn is the most general solution, but fillmiss and fillmiss2 might also work because you use more less regular grids.

This workflow is designed for have many files to be interpolated. That's why the weights are create first. Applying them can be parallelized over the input files. Since you might have only a single file, you might drop the weights creation and do the remapping in a single step like (for bilinear interpolation)

cdo -P 4 remapbil ${targetGrid} -fillmiss -ifnotthen ${lsmFile} ${inputFile} ${outputFile}
Again: please choose the correct operator for filling up missing values according to your needs.

hth
ralf

RE: how to create mask with cdo - Added by pooran khedri almost 6 years ago

Dear,
I would really appreciate all your help and your time, I am trying to do these steps.

Kind regards,
Pooran

    (1-10/10)