Mask to 0 (or a constant) for a selected region
Added by Bidyut Goswami almost 5 years ago
I have a file of dimension Lat x Lon x Time. I want to mask all values to zero except for a region, for all time steps. Or other way around, mask all values to zero only for a particular region, for all time step. Please suggest. Thanks.
Replies (7)
RE: Mask to 0 (or a constant) for a selected region - Added by Bidyut Goswami almost 5 years ago
I have tried masklonlatbox, maskindexbox, setclonlatbox and maskregion. But I am getting the error "(Abort): Too many different grids!". I am using CDO version 1.9.3.
RE: Mask to 0 (or a constant) for a selected region - Added by Ralf Mueller almost 5 years ago
hi!
Please upload some sample data for further investigation
cheers
ralf
RE: Mask to 0 (or a constant) for a selected region - Added by Bidyut Goswami almost 5 years ago
Please find the attached input file. I am using the command
cdo -masklonlatbox,50,100,0,30 sst_HadOIBl_bc_0.9x1.25_2000climo_c180511.nc test.nc
sst_HadOIBl_bc_0.9x1.25_2000climo_c180511.nc (10.1 MB) sst_HadOIBl_bc_0.9x1.25_2000climo_c180511.nc | Input file |
RE: Mask to 0 (or a constant) for a selected region - Added by Ralf Mueller almost 5 years ago
hi!
there are variables on a single gridpoint in your input, that's why masking does not work for all of them. for your file, you can select the variables on a horizontally distributed grid with
-select,'name=ice*,SST*'or
-selgrid,1
Basically CDO gets confused by your date-related variables
cdo sinfov sst_HadOIBl_bc_0.9x1.25_2000climo_c180511.nc File format : NetCDF -1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter name 1 : unknown unknown v instant 1 1 1 1 I32 : date 2 : unknown unknown v instant 1 1 1 1 I32 : datesec 3 : unknown unknown v instant 1 1 55296 2 F32 : ice_cov 4 : unknown unknown v instant 1 1 55296 2 F32 : ice_cov_prediddle 5 : unknown unknown v instant 1 1 55296 2 F32 : SST_cpl 6 : unknown unknown v instant 1 1 55296 2 F32 : SST_cpl_prediddle Grid coordinates : 1 : generic : points=1 2 : lonlat : points=55296 (288x192) lon : 0 to 358.75 by 1.25 degrees_east circular lat : -90 to 90 by 0.9424084 degrees_north Vertical coordinates : 1 : surface : levels=1 Time coordinate : 12 steps RefTime = 0000-01-01 00:00:00 Units = days Calendar = 365_day YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss YYYY-MM-DD hh:mm:ss 0000-01-16 12:00:00 0000-02-15 00:00:00 0000-03-16 12:00:00 0000-04-16 00:00:00 0000-05-16 12:00:00 0000-06-16 00:00:00 0000-07-16 12:00:00 0000-08-16 12:00:00 0000-09-16 00:00:00 0000-10-16 12:00:00 0000-11-16 00:00:00 0000-12-16 12:00:00the reference date wrong and the variables
date
and datesec
are not CF-conform and get ignored.
hth
ralf
RE: Mask to 0 (or a constant) for a selected region - Added by Bidyut Goswami almost 5 years ago
Hi Ralf,
Thanks for your reply. Did you mean:
cdo -select,name=SST_cpl -masklonlatbox,50,100,0,30 sst_HadOIBl_bc_0.9x1.25_2000climo_c180511.nc test.nc
But I am still getting the same error.
Kindly suggest.
RE: Mask to 0 (or a constant) for a selected region - Added by Ralf Mueller almost 5 years ago
CDO commands are evaluated from right to left. selection needs to be done before the masking:
cdo -masklonlatbox,50,100,0,30 -select,name=SST_cpl sst_HadOIBl_bc_0.9x1.25_2000climo_c180511.nc test.nc
hth
ralf
RE: Mask to 0 (or a constant) for a selected region - Added by Bidyut Goswami almost 5 years ago
Thanks Ralf. It works perfectly.