Project

General

Profile

regrid and replace value with zero in regridded nc file

Added by Suvarna Tikle over 1 year ago

Dear All,
I am using the below command to regrid ncfile. It successfully done.

cdo remapcon,CAMS_Indore_NMVOC.nc HH_local_emission.nc HH_local_emission_regrid.nc.

CAMS file consist big area and HH_local_emission.nc consist of small area. Area has been extended in HH_local_emission_regrid.nc after regrid. I want all other values (other than this HH_local_emission.nc) "zero". Example HH_local_emission_regrid.nc with just extended domain area and values will be as original in small area and extended value of the area would be 0.

In forum, I have read cdo setvals and cdo setgridcell,value= etc used for specific values replacement and for specific points. How to do it for specific area in above case?

Best,
Suvarna


Replies (7)

RE: regrid and replace value with zero in regridded nc file - Added by Ralf Mueller over 1 year ago

Hi Survana!

Your desired behavior is very close to the default behaviour. conservative remapping created missing values for location without any source grid cell. here is an example:

  1. global_2eg.nc is a global 2 degree grid (with topography, no missing values)
    cdo -f nc -topo,global_2 global_2deg.nc
  2. in.nc is the topography of india in a box
    cdo -f nc -sellonlatbox,67,98.5,7.5,36.5 -topo in.nc
  3. in_on_global.nc is the results of
    cdo -f nc -remapcon,global_2deg.nc in.nc in_on_global.nc

So despite from missing values, it should be what you want.

cdo -setmisstoc,0 in_on_global.nc in_global_zero.nc 

RE: regrid and replace value with zero in regridded nc file - Added by Suvarna Tikle over 1 year ago

When, I did ncview zero_regridagri_LE.nc it showing "no displayable variables found!'.

RE: regrid and replace value with zero in regridded nc file - Added by Ralf Mueller over 1 year ago

please, upload the file. Cannot comment on that otherwise

RE: regrid and replace value with zero in regridded nc file - Added by Suvarna Tikle over 1 year ago

Hi,
Thank you for details with examples, I will try again. One quick question, we have to do all the process separately for different variables?

Best,
Suvarna

RE: regrid and replace value with zero in regridded nc file - Added by Ralf Mueller over 1 year ago

In general CDO calls do apply on all data variables in an input file. Hence cdo -remapcon .... does try to remap everything possible. Sometimes this causes problems, when you have zonal means or global time series together with horizontal fields in the input. In that case you need to pre-select the right variable with the selec, selname or selgrid operators.

So if your variables are all in the same file, you don't have to do anything.

RE: regrid and replace value with zero in regridded nc file - Added by Suvarna Tikle over 1 year ago

Hi,
Thanks a lot. It worked for all variables. It is really great help.

Best,
Suvarna

RE: regrid and replace value with zero in regridded nc file - Added by Ralf Mueller over 1 year ago

you're welcome. have a nice day

cheers
ralf

    (1-7/7)