Project

General

Profile

cdo ensmean outputs incorrect "mean"

Added by Yuhan Wang 7 days ago

Hello!

I am using cdo ensmean for computing 10-member mean at selected time & location. I hit a very weird error, and hope to ask if anyone has encountered similar issues. Here is a minimum case for reproducing it (f001.nc & f002.nc are attached; each nc file for one variable from one CESM2 ensemble member):

cdo L -seldate,2035-02-01 -sellonlatbox,20,21,20,21 f001.nc tmp_001.nc
-
> TSA = 284.5201
cdo L -seldate,2035-02-01 -sellonlatbox,20,21,20,21 f002.nc tmp_002.nc
-
> TSA = 285.2934
cdo ensmean tmp_001.nc tmp_002.nc tmp_12.nc
--> TSA = 284.9068 [correct answer]

However, if I compute their mean values by running:
cdo L ensmean -seldate,2035-02-01 f001.nc f002.nc tmp.nc
cdo -L -seldate,2035-02-01 -sellonlatbox,20,21,20,21 tmp.nc tmp_ensmean.nc
-
> TSA = 285.2585 [WRONG answer]

This may be a dumb question, but I feel so confused and hope to seek you advice. Any clues would be appreciated!

Best,
Yuhan


Replies (4)

RE: cdo ensmean outputs incorrect "mean" - Added by Yuhan Wang 7 days ago

Oops formatting errors in my prior post due to "minus L" option in codes. I am pasting again the codes without "minus L":

cdo seldate,2035-02-01 -sellonlatbox,20,21,20,21 f001.nc tmp_001.nc
> TSA = 284.5201
cdo seldate,2035-02-01 -sellonlatbox,20,21,20,21 f002.nc tmp_002.nc
> TSA = 285.2934
cdo ensmean tmp_001.nc tmp_002.nc tmp_12.nc
-> TSA = 284.9068 [correct answer]

However, if I compute their mean values by running:
cdo ensmean seldate,2035-02-01 f001.nc f002.nc tmp.nc
cdo -seldate,2035-02-01 -sellonlatbox,20,21,20,21 tmp.nc tmp_ensmean.nc
> TSA = 285.2585 [WRONG answer]

RE: cdo ensmean outputs incorrect "mean" - Added by Yuhan Wang 7 days ago

cdo -L -seldate,2035-02-01 -sellonlatbox,20,21,20,21 f001.nc tmp_001.nc
-> TSA = 284.5201
cdo -L -seldate,2035-02-01 -sellonlatbox,20,21,20,21 f002.nc tmp_002.nc
-> TSA = 285.2934
cdo ensmean tmp_001.nc tmp_002.nc tmp_12.nc
-> TSA = 284.9068 [correct answer]

However, if I compute their mean values by running:
cdo -L ensmean -seldate,2035-02-01 f001.nc f002.nc tmp.nc
cdo -L -seldate,2035-02-01 -sellonlatbox,20,21,20,21 tmp.nc tmp_ensmean.nc
-> TSA = 285.2585 [WRONG answer]

RE: cdo ensmean outputs incorrect "mean" - Added by Uwe Schulzweida 7 days ago

Most CDO functions, such as seldate and sellonlatbox, only work on a single input file.
Therefore the date 2035-02-01 is selected only from the first input file f001.nc with:

cdo -L ensmean -seldate,2035-02-01 f001.nc f002.nc tmp.nc
To select the date 2035-02-01 from all input files, the following syntax is used:
cdo -L ensmean [ -seldate,2035-02-01 : f001.nc f002.nc ] tmp.nc
Pay attention to the spaces before and after the special characters “[”, “]” and “:”.
Multiple functions can also be used here:
cdo -L ensmean [ -sellonlatbox,20,21,20,21 -seldate,2035-02-01 : f001.nc f002.nc ] tmp.nc

RE: cdo ensmean outputs incorrect "mean" - Added by Yuhan Wang 7 days ago

That makes great sense - thank you very much for the prompt response, Uwe!

Best,
Yuhan

    (1-4/4)