Reputation: 183
I have a netcdf file with global temperature (tas, degC) data over the 1990-2001 period at daily time-steps in a 1x1deg lat-lon grid.
I am interested only in tas days > 10degC.
Is there a way I can subset with CDO the netcdf file and create a new one with only tas days > 10degC?
The gtc
operator can be related to my issue but it only creates a mask with 0s and 1s, while I need true values >10degC.
Upvotes: 0
Views: 752
Reputation: 3407
I agree with Adrian Tompkins that the workflow proposed is not overly sensible as any subsetting will throw away the grid info and essentially negate the purpose of using netCDF data in the first place. The work flow proposed would make more sense using dataframes either in R or pandas in Python.
However, if you have to do this in CDO you can use the reducegrid operator which will reduce the netCDF file to grid cells without missing values, as follows (adapated from Adrian Tompkins' answer):
cdo gtc,10 tas.nc mask1.nc
# set zeros to missing
cdo setctomiss,0 mask1.nc mask2.nc
cdo reducegrid,mask2.nc tas.nc tas_subsetted.nc
Upvotes: 2
Reputation: 8097
I'm not quite sure what you want... if you want to set all the values where T<10C to missing, then you can do that as follows:
cdo gtc,10 tas.nc mask1.nc
# set zeros to missing
cdo setctomiss,0 mask1.nc mask2.nc
cdo mul tas.nc mask2.nc tas_masked.nc
This technique is the same as one would use for a land-sea mask - see my videos on masking and creating a land sea mask for further details.
Upvotes: 2