Project

General

Profile

Wrong results in yearlysum

Added by Noam Chomsky over 3 years ago

I have the following file

dimensions:
time_counter = UNLIMITED ; // (10950 currently)
bnds = 2 ;
lon = 180 ;
lat = 90 ;
veget = 13 ;
variables:
double time_counter(time_counter) ;
time_counter:standard_name = "time" ;
time_counter:long_name = "Time axis" ;
time_counter:bounds = "time_counter_bnds" ;
time_counter:units = "seconds since 1901-01-01 00:00:00" ;
time_counter:calendar = "365_day" ;
time_counter:axis = "T" ;
double time_counter_bnds(time_counter, bnds) ;
float lon(lon) ;
lon:standard_name = "longitude" ;
lon:long_name = "Longitude" ;
lon:units = "degrees_east" ;
lon:axis = "X" ;
float lat(lat) ;
lat:standard_name = "latitude" ;
lat:long_name = "Latitude" ;
lat:units = "degrees_north" ;
lat:axis = "Y" ;
float veget(veget) ;
veget:long_name = "Vegetation types" ;
veget:units = "1" ;
veget:axis = "Z" ;
veget:name = "veget" ;
veget:standard_name = "model_level_number" ;
float LEAF_TURN(time_counter, veget, lat, lon) ;
LEAF_TURN:long_name = "Leaf turnover" ;
LEAF_TURN:units = "gC/m^2/day " ;
LEAF_TURN:_FillValue = 9.96921e+36f ;
LEAF_TURN:missing_value = 9.96921e+36f ;
LEAF_TURN:interval_write = "1 d" ;
LEAF_TURN:cell_methods = "time: mean (interval: 1800 s)" ;
cdo showyear myfile.nc
1902 1903 1904 1905 1906 1907 1908 1909 1910 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1901

cdo yearsum myfile.nc out.nc

I have tried also NCO
ncra --mro -d time_counter,,,365,365 -y sum myfile.nc test.nc

And I am trying to calculate the yearly sum of LEAF_TURN for each year during the whole period which is 30 years. The resulting netcdf contains 30 time steps, as expected, but the results are magnitude of orders larger than. Typical daily values are 0.3 so a yearly sum should be around 100 but the yearly results are around 20000. My years are repeated but I don't think that's the problem, since I get the same results in nco. In ferret I get the correct results.

Any idea why this might happen?

Thanks


Replies (3)

RE: Wrong results in yearlysum - Added by Karin Meier-Fleischer over 3 years ago

Hi Noam,

without the data file it is hard to say what to do. And also in this case, the file is not COARDS/netCDF CF conform.

What irritates me most, however, are the years from above that are not continuously increasing.

cdo showyear myfile.nc
1902 1903 1904 1905 1906 1907 1908 1909 1910 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1901

This seems to be an failure which makes a reset after 10 years to 1901 when writing the time. This will give a much higher sum as expected for the repeating years.

-Karin

RE: Wrong results in yearlysum - Added by Noam Chomsky over 3 years ago

thank you Karin for your reply. You are right that the years numbers are not correctly formatted could be part of the problem. But the result is still 4 or 5 orders of magnitude larger, so it might contribute to the issue but it cannot be the cause.

Is there a quick way to rename the years so I can test again?

RE: Wrong results in yearlysum - Added by Karin Meier-Fleischer over 3 years ago

You can write a shell script that do the shifting, e.g.

#!/bin/ksh

infile=infile.nc

ntime=$(cdo -s -ntime $infile)

integer k=1
integer i=3285
integer j=$i+365

while (( j <= $ntime ))
do
   cdo -shifttime,10year -seltimestep,$i/$j $infile tmp_$k.nc
   i=j+1
   j=j+365
   k=k+1
done

cdo -O -mergetime tmp_*.nc outfile.nc
    (1-3/3)