I have a netcdf file with an hourly timestep, and with some values missing. What I want to do is, for each gridcell, set all hourly step to missing if any hourly step of that particular day is missing. Preferably in cdo
or nco
if possible.
I came up with the following cdo
based solution, which makes a mask using a gec
logical and then using the dayavg
command to get a daily mask of 1 if all timesteps are okay, or miss if any of them are missing. I can then use mul
to wipe all hourly slices where any values are missing, like this:
# low threshold in gec to ensure output is 1 for any data value
cdo dayavg -gec,-1e32 in.nc mask.nc # use avg NOT mean
cdo mul in.nc mask.nc out.nc
This works, but:
- It only works for a single day of data (there is not yet a
daymul
function in cdo, pity) so you need to extract data one day at a time in a loop, extremely slow and clunky - it feels like a big fudge using the
gec
logical with some very low threshold
so I wondering if I'm missing a neater solution in cdo
or a more concise way of doing this in nco
?
EDIT 01/2021: I thought there was a daymul
function in cdo so at least I could use the above method on multi-day timeseries, but surprisingly there wasn't. However, Uwe very kindly responded to my request to add daymul
and daydiv
functions into cdo, which will be available from version v2.0.3 in January 2021.