cdo not broadcasting with monthly data, subtracting a yearly average.
Added by Adrian Tompkins about 3 years ago
I have a file with 12 monthly timesteps for one year.
If I take the timemean, and then subtract this from the original series:
cdo timmean sst_1979_f32.nc tm.nc
cdo sub sst_1979_f32.nc tm.nc anom.nc
...I get the message that CDO is broadcasting by repeating the first timestep of the file tm.nc as expected, but the resulting anom.nc file only has one timestep! I was expecting the broadcasting to result in the identical output to that I get using
cdo yearsub sst_1979_f32.nc tm.nc anom.nc
This gives me the expected result of 12 monthly anomalies around the year mean. I'm a bit confused as to what sub is doing in this instance, it is not doing what I expected.
The file is here... http://clima-dods.ictp.it/Users/tompkins/sst/sst_1979_f32.nc it is just a SST dataset downloaded from the CDS.
Replies (3)
RE: cdo not broadcasting with monthly data, subtracting a yearly average. - Added by Karin Meier-Fleischer about 3 years ago
Hi Adrian,
I am not able to reproduce the problem. The file anom.nc has 12 timesteps as you expected.
cdo info sst_1979_f32.nc -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter ID 1 : 1979-01-01 00:00:00 0 1038240 351876 : 270.25 286.76 305.08 : -1 2 : 1979-02-01 00:00:00 0 1038240 351876 : 270.11 286.86 305.14 : -1 3 : 1979-03-01 00:00:00 0 1038240 351876 : 269.66 286.84 305.52 : -1 4 : 1979-04-01 00:00:00 0 1038240 351876 : 269.31 286.75 305.69 : -1 5 : 1979-05-01 00:00:00 0 1038240 351876 : 270.37 286.63 305.70 : -1 6 : 1979-06-01 00:00:00 0 1038240 351876 : 271.27 286.69 305.39 : -1 7 : 1979-07-01 00:00:00 0 1038240 351876 : 270.54 286.82 306.34 : -1 8 : 1979-08-01 00:00:00 0 1038240 351876 : 270.76 286.95 306.41 : -1 9 : 1979-09-01 00:00:00 0 1038240 351876 : 271.03 286.90 306.37 : -1 10 : 1979-10-01 00:00:00 0 1038240 351876 : 270.93 286.62 305.48 : -1 11 : 1979-11-01 00:00:00 0 1038240 351876 : 269.57 286.54 304.67 : -1 12 : 1979-12-01 00:00:00 0 1038240 351876 : 270.51 286.63 305.56 : -1
cdo timmean sst_1979_f32.nc tm.nc cdo info tm.nc -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter ID 1 : 1979-06-16 00:00:00 0 1038240 351876 : 270.99 286.75 303.87 : -1
cdo sub sst_1979_f32.nc tm.nc anom.nc cdo info anom.nc -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter ID 1 : 1979-01-01 00:00:00 0 1038240 351876 : -13.767 0.0073826 9.5533 : -1 2 : 1979-02-01 00:00:00 0 1038240 351876 : -15.047 0.11169 7.6749 : -1 3 : 1979-03-01 00:00:00 0 1038240 351876 : -13.318 0.090561 5.5959 : -1 4 : 1979-04-01 00:00:00 0 1038240 351876 : -10.084 0.0030771 4.0244 : -1 5 : 1979-05-01 00:00:00 0 1038240 351876 : -7.0541 -0.12235 10.100 : -1 6 : 1979-06-01 00:00:00 0 1038240 351876 : -8.5793 -0.060474 14.592 : -1 7 : 1979-07-01 00:00:00 0 1038240 351876 : -8.7915 0.070009 17.671 : -1 8 : 1979-08-01 00:00:00 0 1038240 351876 : -7.2498 0.20416 14.700 : -1 9 : 1979-09-01 00:00:00 0 1038240 351876 : -6.8351 0.14888 13.006 : -1 10 : 1979-10-01 00:00:00 0 1038240 351876 : -4.3911 -0.12693 8.1466 : -1 11 : 1979-11-01 00:00:00 0 1038240 351876 : -10.030 -0.20688 5.0573 : -1 12 : 1979-12-01 00:00:00 0 1038240 351876 : -12.318 -0.11911 6.3359 : -1
cdo yearsub sst_1979_f32.nc tm.nc anom2.nc cdo info anom2.nc -1 : Date Time Level Gridsize Miss : Minimum Mean Maximum : Parameter ID 1 : 1979-01-01 00:00:00 0 1038240 351876 : -13.767 0.0073826 9.5533 : -1 2 : 1979-02-01 00:00:00 0 1038240 351876 : -15.047 0.11169 7.6749 : -1 3 : 1979-03-01 00:00:00 0 1038240 351876 : -13.318 0.090561 5.5959 : -1 4 : 1979-04-01 00:00:00 0 1038240 351876 : -10.084 0.0030771 4.0244 : -1 5 : 1979-05-01 00:00:00 0 1038240 351876 : -7.0541 -0.12235 10.100 : -1 6 : 1979-06-01 00:00:00 0 1038240 351876 : -8.5793 -0.060474 14.592 : -1 7 : 1979-07-01 00:00:00 0 1038240 351876 : -8.7915 0.070009 17.671 : -1 8 : 1979-08-01 00:00:00 0 1038240 351876 : -7.2498 0.20416 14.700 : -1 9 : 1979-09-01 00:00:00 0 1038240 351876 : -6.8351 0.14888 13.006 : -1 10 : 1979-10-01 00:00:00 0 1038240 351876 : -4.3911 -0.12693 8.1466 : -1 11 : 1979-11-01 00:00:00 0 1038240 351876 : -10.030 -0.20688 5.0573 : -1 12 : 1979-12-01 00:00:00 0 1038240 351876 : -12.318 -0.11911 6.3359 : -1
In your case there is no difference between anom.nc and anom2.nc.
cdo diff anom.nc anom2.nc cdo diff: Processed 24917760 values from 2 variables over 24 timesteps [0.14s 15MB].
Which CDO version are you using?
-Karin
RE: cdo not broadcasting with monthly data, subtracting a yearly average. - Added by Uwe Schulzweida about 3 years ago
This is a bug in CDO 2.0.0. The problem is fixed in CDO release 2.0.2.
RE: cdo not broadcasting with monthly data, subtracting a yearly average. - Added by Adrian Tompkins about 3 years ago
Ah, that explains it - I'll update my laptop version immediately, thank you! (and sorry, I should have checked the bug reports before posting).