0

I have files with monthly data only for September, October and November (filtered in a previous step) and I want to compute seasonal averages (one value for each trimester of each year). I'm using ncra --mro -d time,,,3,3 (average on the record dimension, from start to finish, jumping every tree records and each subcycle is 3 records) but the result is not an average of the tree months but just the value of each September.

I can confirm that by using ncks -d time,,,3 to select only the first month of each year (September in my case) and when I read both results using an external tool, they are exactly the same.

Here are the commands that I ran along with comments on the results. All the files can be here.

# Try to make a seasonal average from the orignal file
# It gets :
# ncra: WARNING Subcycle argument is only supported for the record dimension on ncra and ncrcat operations
ncra --mro -d time,,,3,3 original.nc4 average.nc4

# Select only the first month of the season
ncks -d time,,,3 original.nc4 sampled.nc4

# When I read both files (using an external tool) I see that both files are identical. That is, 
# the first command didn't actually compute an average, it just selected the first value
# of each season. 

# Perhaps it's related to the warning about the record dimension. 
# Ok, let's make sure time is a record dimension I guess?
ncks --mk_rec_dmn time original.nc4 record.nc4

# And now again try to compute seasonal average
ncra --mro -d time,,,3,3 record.nc4 record_average.nc4

# Now this new file is too small (77kb vs 928kb) and I cannot read it with any tool 

ncks --version returns: NCO netCDF Operators version "4.6.3" built by buildd on binet at Dec 23 2016 22:34:40 ncks version "4.6.3"

Elio Campitelli
  • 1,408
  • 1
  • 10
  • 20

1 Answers1

1

Your commands look correct to me (good job!). Below is a demonstration that your commands work with the latest version of NCO. Your version is > 5 years old! I can only surmise that something was broken in that version. Please upgrade. Charlie

zender@firn:~$ ncrcat -O -v FSNT,area -p ${DATA}/ne30/raw 20180129.DECKv1b_piControl.ne30_oEC.edison.cam.h0.0001-09.nc 20180129.DECKv1b_piControl.ne30_oEC.edison.cam.h0.0001-10.nc 20180129.DECKv1b_piControl.ne30_oEC.edison.cam.h0.0001-11.nc 20180129.DECKv1b_piControl.ne30_oEC.edison.cam.h0.0002-09.nc 20180129.DECKv1b_piControl.ne30_oEC.edison.cam.h0.0002-10.nc 20180129.DECKv1b_piControl.ne30_oEC.edison.cam.h0.0002-11.nc ~/FSNT_000109_000211.nc
zender@firn:~$ ncks --cal -v time -C  ~/FSNT_000109_000211.nc
netcdf FSNT_000109_000211 {
  dimensions:
    time = UNLIMITED ; // (6 currently)

  variables:
    double time(time) ;
      time:long_name = "time" ;
      time:units = "days since 0001-01-01 00:00:00" ;
      time:calendar = "noleap" ;
      time:bounds = "time_bnds" ;
      time:cell_methods = "time: mean" ;

  data:
    time = "0001-10-01", "0001-11-01", "0001-12-01", "0002-10-01", "0002-11-01", "0002-12-01" ;

} // group /
zender@firn:~$ ncra -O --mro -d time,,,3,3 ~/FSNT_000109_000211.nc ~/FSNT_SON_000109_000211.nc
zender@firn:~$ ncwa -O -w area -a ncol ~/FSNT_000109_000211.nc ~/FSNT_glb_avg.nc
zender@firn:~$ ncwa -O -w area -a ncol ~/FSNT_SON_000109_000211.nc ~/FSNT_SON_glb_avg.nc
zender@firn:~$ ncks -H -v FSNT -C ~/FSNT_glb_avg.nc
netcdf FSNT_glb_avg {
  dimensions:
    time = UNLIMITED ; // (6 currently)

  variables:
    float FSNT(time) ;

  data:
    FSNT = 241.5002, 242.7969, 244.3921, 241.2065, 242.6262, 242.8979 ;

} // group /
zender@firn:~$ ncks -H -v FSNT -C ~/FSNT_SON_glb_avg.nc
netcdf FSNT_SON_glb_avg {
  dimensions:
    time = UNLIMITED ; // (2 currently)

  variables:
    float FSNT(time) ;

  data:
    FSNT = 242.8964, 242.2435 ;

} // group /
zender@firn:~$ 
Charlie Zender
  • 5,929
  • 14
  • 19
  • I did update the version (on my local machine since I don't have admin privileges on the server I'm running this) by compiling the thing myself and I sill had the same issues. Did you test it on the file I linked to on my post just to be sure that is not an issue with bad files? – Elio Campitelli Dec 03 '21 at 22:23
  • 1
    Sorry, I do not have the time to download and debug what may be occuring with your files. Hopefully with the above as guide, your can simplify your files (e.g., one variable, one lat/lon point) until it becomes apparent where/why things are going wrong. – Charlie Zender Dec 04 '21 at 23:09