Home > Blockchain >  How to subset netcdf variable by a constant threshold
How to subset netcdf variable by a constant threshold

Time:02-27

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.

CodePudding user response:

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.

  • Related