Project

General

Profile

cdo selyear

Added by Chao Liu about 4 years ago

Hi, all

I found a weird thing when I use the cdo selyear command.

I calculated monthly nino3.4 index with NCL and wrote it to a netcdf file ('n34.mon.nc'), there is no missing values in it.

Then I used 'cdo selyear,1988,1989 n34.mon.nc n34.sel.nc' and found that the outputed file 'n34.sel.nc' contains missing values.

The related files are attached. Did anyone have any suggestions for this?

My cdo version is
Climate Data Operators version 1.9.8 (https://mpimet.mpg.de/cdo)
System: x86_64-pc-linux-gnu
CXX Compiler: /usr/bin/g++ -g -O2 -fopenmp
CXX version : unknown
C Compiler: /usr/bin/gcc -g -O2 -fopenmp
C version : gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
F77 Compiler: f77 -g -O2
F77 version : unknown
Features: 11GB 4threads C++14 Fortran DATA PTHREADS OpenMP NC4/HDF5 OPeNDAP SSE2
Libraries:
Filetypes: srv ext ieg grb1 nc1 nc2 nc4 nc4c nc5
CDI library version : 1.9.8
cgribex library version : 1.9.4
NetCDF library version : 4.6.0 of Feb 9 2018 19:21:24 $
hdf5 library version : library undefined
exse library version : 1.4.1
FILE library version : 1.8.3

n34.mon.nc (6.86 KB) n34.mon.nc monthly n34 index file generated by ncl
n34.sel.nc (1.34 KB) n34.sel.nc file generated by cdo

Replies (4)

RE: cdo selyear - Added by Karin Meier-Fleischer about 4 years ago

Hi Chao,

please take a closer look at your data! The monthly values have NaNs and therefore also the output file.

cdo infon n34.mon.nc

...
   129 : 1988-09-01 00:00:00       0        1       0 :                -0.98624             : n34           
   130 : 1988-10-01 00:00:00       0        1       1 :                     nan             : n34           
   131 : 1988-11-01 00:00:00       0        1       1 :                     nan             : n34           
   132 : 1988-12-01 00:00:00       0        1       1 :                     nan             : n34           
   133 : 1989-01-01 00:00:00       0        1       1 :                     nan             : n34           
   134 : 1989-02-01 00:00:00       0        1       0 :                 -1.4279             : n34      
...

cdo infon n34.sel.nc


    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter name
     1 : 1988-01-01 00:00:00       0        1       0 :                 0.93059             : n34           
     2 : 1988-02-01 00:00:00       0        1       0 :                 0.31776             : n34           
     3 : 1988-03-01 00:00:00       0        1       0 :                 0.16428             : n34           
     4 : 1988-04-01 00:00:00       0        1       0 :                -0.32817             : n34           
     5 : 1988-05-01 00:00:00       0        1       0 :                 -1.1337             : n34           
     6 : 1988-06-01 00:00:00       0        1       0 :                 -1.6255             : n34           
     7 : 1988-07-01 00:00:00       0        1       0 :                 -1.6236             : n34           
     8 : 1988-08-01 00:00:00       0        1       0 :                 -1.1330             : n34           
     9 : 1988-09-01 00:00:00       0        1       0 :                -0.98624             : n34           
    10 : 1988-10-01 00:00:00       0        1       1 :                     nan             : n34           
    11 : 1988-11-01 00:00:00       0        1       1 :                     nan             : n34           
    12 : 1988-12-01 00:00:00       0        1       1 :                     nan             : n34           
    13 : 1989-01-01 00:00:00       0        1       1 :                     nan             : n34           
    14 : 1989-02-01 00:00:00       0        1       0 :                 -1.4279             : n34           
    15 : 1989-03-01 00:00:00       0        1       0 :                 -1.1393             : n34           
    16 : 1989-04-01 00:00:00       0        1       0 :                -0.95910             : n34           
    17 : 1989-05-01 00:00:00       0        1       0 :                -0.75524             : n34           
    18 : 1989-06-01 00:00:00       0        1       0 :                -0.47652             : n34           
    19 : 1989-07-01 00:00:00       0        1       0 :                -0.46899             : n34           
    20 : 1989-08-01 00:00:00       0        1       0 :                -0.47788             : n34           
    21 : 1989-09-01 00:00:00       0        1       0 :                -0.29324             : n34           
    22 : 1989-10-01 00:00:00       0        1       0 :                -0.37437             : n34           
    23 : 1989-11-01 00:00:00       0        1       0 :                -0.41672             : n34           
    24 : 1989-12-01 00:00:00       0        1       0 :                -0.13896             : n34  

-Karin

RE: cdo selyear - Added by Chao Liu about 4 years ago

Hi Karin

Thanks for your reply!

I checked my ncfile with ncdump/cdo ninfo/ncl and found different results. The ncdump and ncl show no nan/missing values while the cdo ninfo shows 4 nan values from 198810-198901

#1 cdo ninfo n34.mon.nc
!!
129 : 1988-09-01 00:00:00 0 1 0 : -0.98624 : n34
130 : 1988-10-01 00:00:00 0 1 1 : nan : n34
131 : 1988-11-01 00:00:00 0 1 1 : nan : n34
132 : 1988-12-01 00:00:00 0 1 1 : nan : n34
133 : 1989-01-01 00:00:00 0 1 1 : nan : n34
134 : 1989-02-01 00:00:00 0 1 0 : -1.4279 : n34

#2 ncdump n34.mon.nc
!!
-1.133658, -1.625497, -1.623623, -1.133031, -0.9862447, *-1.860546,
-2.004839, -1.958909, -1.929645*, -1.427925, -1.139314, -0.9590977,

#3 ncl n34.ncl
!!
(8) ymd = 198809 n34 = -0.986245
(9) ymd = 198810 n34 = -1.86055
(10) ymd = 198811 n34 = -2.00484
(11) ymd = 198812 n34 = -1.95891
(12) ymd = 198901 n34 = -1.92965
(13) ymd = 198902 n34 = -1.42792

So, can it be a bug of cdo or somemthing else?

I also post the related codes of ncl.

cdo ninfo.png (43.2 KB) cdo ninfo.png cdo ninfo result picture
ncdump.png (45.6 KB) ncdump.png ncdump result picture
ncl.png (82.2 KB) ncl.png ncl result picture
ncl-related codes.png (78.6 KB) ncl-related codes.png ncl-related codes

RE: cdo selyear - Added by Uwe Schulzweida about 4 years ago

The attribute valid_range is used in your netcdf file:

    float n34(time) ;
        n34:_FillValue = -9.96921e+36f ;
        n34:anomaly_op_ncl = "Annual Cycle Removed: rmMonAnnCycTLL: contributed.ncl" ;
        n34:valid_range = -1.8f, 45.f ;
That means values less than -1.8 and greater than 45. are invalid. CDO sets these values to missing values.
You have to delete this attribute if you do not want this behavior.

RE: cdo selyear - Added by Chao Liu about 4 years ago

Okay, I see.

I didn't know this cdo feature before. This vaild_range is really too dangerous for the nino3.4 index.

Thanks for your suggestions!

Best Regrads

    (1-4/4)