Project

General

Profile

Add in missing timesteps (months, years) as missing values

Added by Kira Rehfeld about 7 years ago

Hi,

I have a long file of monthly values with a couple of months missing in between, or sometimes a whole year missing. I want to do annual sums (and multiplying with other variables), but the missing months skew the result. I want the resulting annual value to be missing (NA, or -999), but all timesteps need to exist.

Wrong annual sums:
cdo yearsum infile.nc outfile.nc

--> results e.g. in a time series of 120,5,120,114,24,125 (made that up, but basically the 2nd and 5th year were missing parts of the month and the sum is wrong, and possibly the 5th year is missing completely. What I want is 120, NA, 120, 114,NA, NA, 125.

How could this be done?
  • find all years with less than 12 months
  • find all years that are missing completely
  • add in the timesteps that are missing completely between the start and end date
  • set all of these years values to missing value
  • compute the yearsum, which results in a missing value for any year that has a missing value
What operators could be used?
  • splityear (with a bash script)
  • nmon
  • setctomiss
  • something like "enlarge" for the time dimension would already be half the solution, if the yearavg/yearsum of a year with missing values yields a missing value (which I assume).

Ideas?

An extract of the netCDF file with missing parts and a missing year is attached.

Thanks!

Kira

infile_8yrs_missing_comb.nc (4.8 MB) infile_8yrs_missing_comb.nc file with missing values

Replies (1)

RE: Add in missing timesteps (months, years) as missing values - Added by Ralf Mueller about 7 years ago

Hi Kira!
I'd try something like this:

  1. create a data set with same variabels but a consecutive time axis
  2. you delete every timestep, which is present in your uploaded data file
  3. use merge this result file with your initial file with the mergetime operator

hth
ralf

    (1-1/1)