How to remove a "redundant" dimension with CDO (climate data operators)?

1.8k views Asked by At

The ERA5 climate dataset is, in general, defined as a [lat, lon, time] matrix. Except for recent data, where it adds the exp_ver variable that indicate if the data is provisory (recent data, up to 3 months until the present, coded as "05") or old (stable version, coded as "01"), so the matrix are defined [lat, lon, time, exp_ver] only for recent data.

The exp_ver variable only has two values: "01" (old data) and "05" (recent data), and if there is data in "01" so the corresponding time has missing values in the "05" field, and viceversa. I'm looking for merge both "01" and "05" in a unique [lat, lon, time] matrix (so, remove the exp_ver variable), but I dont' know how to conduct this procedure. This is maybe an option:

A. Split the file with cdo splitlevel obtaining the "01" and "05" exp_ver separate files.

B. Remove the missing values segment, or only select the segment with data, from both files (I don't know how to to this!)

C. Remove the redundant variable "exp_ver" from both files (with cdo reduce_dim)

Any help with this? Thank you in advance!

Diego

1

There are 1 answers

5
ClimateUnboxed On

Can you use ncwa to average over and remove the dimension in step two and then use merge time?

cdo splitlevel # as you were suggesting

ncwa -a exp_ver v1.nc v1rd.nc
ncwa -a exp_ver v5.nc v5rd.nc 

cdo mergetime v1rd.nc v5rd.nc out.nc

Or thinking about it what if you use ncwa directly on the original file? It averages over that dimension. I don't recall how missing+value is handled though.

ncwa -a exp_ver era5.nc out.nc

Check out this link too which could be relevant Can ncwa (NCO) understand missing_value

( Preliminary answer posted from phone, will revise tomorrow)