National Oceanic and
Atmospheric Administration
United States Department of Commerce

Regridding a Time Series with @AVE

Regridding a Time Series with @AVE

Question:

How can I tell what weights Ferret uses in regridding with @AVE ?

Example:

We compute annual averages of the monthly_navy_winds data set.

yes? SET DATA monthly_navy_winds
yes? DEFINE AXIS/EDGES/T0=1-jan-1900/UNITS=days tann82_92 =
DAYS1900(X[i=1982:1993:1],1,1)
yes? PLOT/X=180/Y=0 uwnd
yes? PLOT/X=180/Y=0/OVER uwnd[GT=tann82_92@AVE]

Discussion: Details of weighting and of customizing time axes

Weighting of the input points into the output averages is based on thelength of each input interval that lies within each output interval. Aninput interval that spans two output intervals will contribute partialweight to each. If the input monthly data boundaries are at 00:00 on thefirst of each month then the example above would weight each month bythe number of days in that month.

As always with Ferret, the best way to be really sure how it performs acalculation is to "ask it". For any given output point the result iscomputed by SUM(weight_i * value_i)/SUM(weight_i). Thus, settingthe value at i=k to 1.0 and all others to 0.0 will give usweight_k/SUM(weight_i) for that output interval. To see the weightingused on the 2nd month of monthly_navy_winds above use

 yes? LET just_one = IF L[g=uwnd] EQ 2 THEN 1 ELSE 0
yes? LIST/X=180/Y=0 just_one[GT=tann82_92@ave]
IF L[G=UWND] EQ 2 THEN 1 ELSE 0
regrid: on T@AVE
DATA SET: /home/ja9/tmap/fer_dsets/descr/monthly_navy_winds.des
JUL-1982 / 1: 0.08353
JUL-1983 / 2: 0.00000
JUL-1984 / 3: 0.00000
JUL-1985 / 4: 0.00000
JUL-1986 / 5: 0.00000
JUL-1987 / 6: 0.00000
JUL-1988 / 7: 0.00000
JUL-1989 / 8: 0.00000
JUL-1990 / 9: 0.00000
JUL-1991 / 10: 0.00000
JUL-1992 / 11: 0.00000

and you'll see that the L=2 point was given a weight of 0.08353, as it contributed to the yearly average for 1982.

To refer to months by standard calendar notation

 yes? LET just_one = IF L[g=uwnd] EQ L[G=uwnd,t=15-feb-1982] THEN 1 ELSE 0
yes? LIST/X=180/Y=0 just_one[GT=tann82_92@ave] ! (gives the same result as above)

To see the weigts used on the 2nd month (Feb) of every year

 yes? LET just_one = IF MOD(L[g=uwnd],12) EQ 2 THEN 1 ELSE 0
yes? LIST/X=180/Y=0 just_one[GT=tann82_92@ave]
IF MOD(L[G=UWND],12) EQ 2 THEN 1 ELSE 0
regrid: on T@AVE
DATA SET: /home/ja9/tmap/fer_dsets/descr/monthly_navy_winds.des
JUL-1982 / 1: 0.08353
JUL-1983 / 2: 0.08339
JUL-1984 / 3: 0.08316
JUL-1985 / 4: 0.08339
JUL-1986 / 5: 0.08339
JUL-1987 / 6: 0.08339
JUL-1988 / 7: 0.08316
JUL-1989 / 8: 0.08339
JUL-1990 / 9: 0.08339
JUL-1991 / 10: 0.08339
JUL-1992 / 11: 0.08316

You may notice that the weightings in this example look a bit unusual.To understand why look at the encoding of the time axis in monthly_navy_winds

 yes? SH GRID/L=1:5 uwnd
GRID FNOC25
name axis # pts start end
FNOCX LONGITUDE 144mr 20E 17.5E(377.5)
FNOCY LATITUDE 73 r 90S 90N
normal Z
TIME TIME 132 r 16-JAN-1982 20:00 17-DEC-1992 03:30

L T BOX_SIZE TIME_STEP (hour)
1> 16-JAN-1982 20:00:00 730.5 17598
2> 16-FEB-1982 06:30:00 730.5 18328.5
3> 18-MAR-1982 17:00:00 730.5 19059
4> 18-APR-1982 03:30:00 730.5 19789.5
5> 18-MAY-1982 14:00:00 730.5 20520

Each month is an identical 730.5 hours long! Of course, this means that themonths do not exactly align with Jan. 1 of each year. We will look at a fix for this later, but first let's look at its effect on the average we have computed.

To see all of the weights for a period of time (example - months 1 through 12)

 yes? LET just_one = IF L[G=uwnd] EQ k THEN 1 ELSE 0
yes? LIST/X=180/Y=0/L=1:2/K=1:12 just_one[GT=tann82_92@AVE]

Here k is a dummy variable referring to times (months) in the input dataset, and /L=1:2 in the LIST command asks Ferret to list output for thefirst two years of the target yearly time series.

 yes? LIST/X=180/Y=0/L=1:2/K=1:12 just_one[GT=tann82_92@AVE]
IF L[G=UWND] EQ K THEN 1 ELSE 0
regrid: on T@AVE
DATA SET: /home/ja9/tmap/fer_dsets/descr/monthly_navy_winds.des

 1 2 3 4 5 6 7 8 9 10 11 12 
1 2 3 4 5 6 7 8 9 10 11 12
JUL-1982 / 1: 0.08353 0.08353 0.08353 0.08353 0.08353 0.08353 0.08353 0.08353 0.08353 0.08353 0.08353 0.08116
JUL-1983 / 2: 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00237

Note the weights show how far the 12th month overlaps the spilt between1982 and 1983. Month 12 of uwnd extends beyond Jan.1, 1982 and so itcontributes to 1983 as well as 1982.

To correct this problem with the alignment of January 1 of each year, we can assert that variable uwnd should be on a true monthly axis as follows:

 yes? LET mnth133 = I[i=1:133]-1 ! consecutive month counter, 
! i=1:133 because we use /EDGES for the axis
yes? LET year = 1982 + INT(mnth133/12)
yes? LET month = MOD(mnth133,12)+1
yes? DEFINE AXIS/EDGES/T0=1-jan-1900/UNITS=days tmon82_92 = DAYS1900(year,month,1)
yes? LET uwnd_true = uwnd[GT=tmon82_92@asn] ! regrid by association

Now the weights for the first 12 months are used only in computing the first year's average.

 yes? LET just_one = IF L[GT=tmon82_92] EQ k THEN 1 ELSE 0
LIST/X=180/Y=0/L=1:2/K=1:12 just_one[GT=tann82_92@ave]
IF L[GT=TMON82_92] EQ K THEN 1 ELSE 0
regrid: on T@AVE

 1 2 3 4 5 6 7 8 9 10 11 12 
1 2 3 4 5 6 7 8 9 10 11 12
JUL-1982 / 1: 0.08493 0.07671 0.08493 0.08219 0.08493 0.08219 0.08493 0.08493 0.08219 0.08493 0.08219 0.08493
JUL-1983 / 2: 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000