[Thread Prev][Thread Next][Index]

Re: How to calculate the annual average



Hi Ming,
The time axis for your data must have calendar information on it after all.  You can define your yearly time axis using the attributes of the input data set:

yes? use cresum001710.sst.nc
yes? show axis `sst,return=taxis`
yes? say `sst,return=tunits`
yes? say `sst,return=tstart`

Then use the information these commands give to define your yearly axis. For example, if tstart was 5-jan-1989, then the axis might be:


yes? define axis/t=6:4800:12/units=months/t0="15-jan-1989" yearaxis


Ming Yang wrote:
Hi, Ansley
   Thank you for your reply. I try your approach, but still there are
problems. Here is what I got

yes? use cresum001710.sst.nc
yes? show data
     currently SET data sets:
    1> ./cresum001710.sst.nc  (default)
 name     title                             I         J         K        L
 SST      Sea surface temperature          1:144     1:72      ...      1:4800
yes? define axis/t=6:4800:12  yearaxis
yes? let sst_year = sst[gt=yearaxis@ave]
yes? list/file="cresum001710.sst.a.nc" sst_year
 **ERROR: regridding: only @ASN regridding between calendar and
          non-calendar axes: SST

   What this means?

Ming


On Fri, 1 Apr 2005, Ansley Manke wrote:

  
Hi Ming,
When the time series is done in terms of index value, you caon compute
the annual averages like this:

  define axis/t=6:4800:12  yearaxis
  let sst_year = sst[gt=yearaxis@ave]

The output axis is in the same units (which is just the index value, but
you can think of it as months).  I start with 6 so that the averages are
taken over the first 12 points, then 13 through 24, and so on.  To test
what this is doing, here is an example where I make up some data, where
the variable has the value of the index.

   yes? def axis/t=1:4800:1 tmonth
   yes? def axis/t=6:4800:12 tyear

   yes? let tt =  t[gt=tmonth]
   yes? let ttyear = tt[gt=tyear@ave]

   yes? list/l=1:5 ttyear
             VARIABLE : TT[GT=TYEAR@AVE]
             SUBSET   : 5 points (T)
    6    / 1:   6.26
    18   / 2:  18.00
    30   / 3:  30.00
    42   / 4:  42.00
    54   / 5:  54.00

The first value is different from the expected 6 because the first
averaging interval in T (t=1 to 12)  is taken from the start of the time
axis, 0.5,  to 12, so the weighting factor is 11.5. The start of the
axis is t=0.5 not 0. The second interval (t=12 to 24) takes the average
from 12 to 24, so the weighting is 12.

We can also see this if we compute unweighted average computed by taking
the transformation @SUM and dividing by the number of good data, @NGD:

   yes? let ttsum = tt[gt=tyear@sum]
   yes? let ttcount = tt[gt=tyear@ngd]
   yes? let ttyear = ttsum/ttcount
   yes? list/l=1:5 ttsum, ttcount, ttyear
                T: 0 to 60
    Column  1: TTSUM is TT[GT=TYEAR@SUM]
    Column  2: TTCOUNT is TT[GT=TYEAR@NGD]
    Column  3: TTYEAR is TTSUM/TTCOUNT
             TTSUM TTCOUNT TTYEAR
   6    / 1:   72.0   11.50   6.26
   18   / 2:  216.0   12.00  18.00
   30   / 3:  360.0   12.00  30.00
   42   / 4:  504.0   12.00  42.00
   54   / 5:  648.0   12.00  54.00



Ming Yang wrote:

    
Hi, Ansley
  After I reading the FAQ, I still cannot figure out how to compute the
annual average. It is probably because my data set is different from the
example listed in the FAQ. Here is the basical information of my dataset
yes? use cresum001710.sst.nc
yes? show data
    currently SET data sets:
   1> ./cresum001710.sst.nc  (default)
name     title                       I         J         K      L
SST      Sea surface temperature    1:144     1:72      ...   1:4800

  I think the difference is that in my dataset the grid is defines as
IJKL instead of XYZT. And also the L axis is not based on any calendars.
Basically what I want to do is to calculate the average values for every
12 Ls so that to the transformed data has 400 points in L axis. Do you
know what is the best way for me to do so? Thank you for your help.


Ming



      
    

  

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement