I have two .nc files data.nc and mask.nc.
Where: data.nc contain a variable called temp unmasked, while mask.nc contain the mask within a variable called tmask with (0 - 1) values.
Using NCO, how can I apply the masking for the data.nc file, such that zero mask values are set to missing, and unity mask values are retained unchanged?
NCO : Masking netcdf file using another netcdf mask file with (0 - 1) values
980 views Asked by Amr Talaat At
2
There are 2 answers
0
On
To do the same operation in cdo you could try this, which sets zero to missing in the mask first before taking the product:
cdo setctomiss,0 mask.nc maskm.nc
cdo mul data.nc maskm.nc masked_data.nc
cdo automatically repeats the mask to make it the same length in time as the data file, known as data "broadcasting".
I have a youtube video on masking here for further guidance, and other material on temporal broadcasting.
It's unclear what you wish to do with the mask. Here is a common procedure, use the mask to replace the actual values with missing values:
Documentation for
whereandget_missis in the manual.If
temphas more records thantmaskthen make thewhere()condition operate on a copy oftmaskthat has been broadcast to the size oftemp: