Hi Ansley...
I got it done using @xact transformation.
Thank you once again for your sugessions.
Rahul
Date: Fri, 13 Aug 2010 08:04:02 +0000 From: rahul_sivan@xxxxxxxxxxx Subject: RE: [ferret_users] monthly average To: ansley.b.manke@xxxxxxxx CC: oar.pmel.ferret_users@xxxxxxxx
Hi Ansley
First of all, thank you for the help. I got correct values using the second method you have suggested, (Only thing I had to do was to add edges qualifier in the index months definition). In the first method, @asn does not work for the purpose, it just puts all the values in the defined axis, ie 2-jan contains 1-feb values of original axis.
Removing calendar did the trick, but curious to know (as I tried a lot) if there is any way to regrid the data to regular time axis, so that whereever data is available it will be there, else undefined.
. Thanks a lot
Rahul
Date: Wed, 11 Aug 2010 11:44:11 -0700 From: ansley.b.manke@xxxxxxxx Subject: Re: [ferret_users] monthly average To: rahul_sivan@xxxxxxxxxxx CC: oar.pmel.ferret_users@xxxxxxxx
Hi Raul,
What's happening is that your original dataset with its
unequally-spaced
time axis, has grid cell sizes of 3 hours for the first 8 time steps,
then a large grid cell between 1-jan-1989:21:00 and 1-feb-1989:00, and
so forth. The
@SUM regridding transformation is not as you might think a simple sum
of the data at the coordinate locations but instead is a
length-weighted computation. It computes sum of the points from the
source grid that fall within each destination grid cell, weighted by
the portion of the source grid cell that overlaps the destination grid
cell. This means that the @SUM works the same way that @AVE does,
taking data from that large grid cell through the latter part of
January and putting it into each day of January in your first
regridding step.
One thing you could do here is first put the data onto a 3-hour grid
with
missing data where there is no data, and then follow the steps you have
tried. So,
DEFINE AXIS/t="1-jan-1989:00":"1-jan-2010
00:00":3/edges/units=hours/calendar=gregorian t3hours
LET data_all_hours = lw[gt=t3hours@asn]
This variable would have the original data and missing data at all the
timesteps outside day1 of the month. and then proceed as you've done.
That's a lot of timesteps and could be a large computation, depending
on the size of the other dimensions in your grid.
In fact, I have one more idea. What you want is first the average of
the first 8 time steps, then the average of the second 8 time steps,
and so on. It's the calendar-axis that is making this difficult. So
first just make it an abstract axis in time, L=1,2, ... and average in
blocks of 8. Something like this - the details of the index_months
axis, and the regridding to that axis probably need a bit more thinking
about, but work with this idea:
LET nt = `lw,RETURN=Lsize`
DEFINE AXIS/L=1:`nt`:1 tindex
LET lw_index = lw[gt=tindex@ASN]
DEFINE AXIS/L=4:`nt`:8 index_months
LET lw_imonth = lw_index[gt=index_months@AVE]
! Now define the output calendar monthly axis
...
DEFINE AXIS/UNITS=days/T0=1-jan-1900/edges truemonth =
DAYS1900(year,month,1)
LET/units="`lw,return=units`"/title="`lw,return=title" lw_month =
lw_imonth[gt=truemonth@ASN]
On 8/11/2010 12:06 AM, rahul s wrote:
I have monthly averages of some dataset for each time record in a day
in a time axis as shown below,
list/l=1:10/x=75/y=-10 lw
VARIABLE : STR/(60*60*3)
FILENAME : lw_new.nc
SUBSET : 10 points (TIME)
LONGITUDE: 75E
LATITUDE : 10.5S
75E
51
01-JAN-1989 00:00 / 1: -51.5
01-JAN-1989 03:00 / 2: -103.5
01-JAN-1989 06:00 / 3: -155.0
01-JAN-1989 09:00 / 4: -205.6
01-JAN-1989 12:00 / 5: -49.8
01-JAN-1989 15:00 / 6: -100.0
01-JAN-1989 18:00 / 7: -151.5
01-JAN-1989 21:00 / 8: -204.1
01-FEB-1989 00:00 / 9: -50.1
01-FEB-1989 03:00 / 10: -100.5
I want to average each month's values and get it in a monthly calendar
I first tried with a daily calendar to get the sum, thinking that all
days other than
first day of a month will be undefined as there in no data in there....
but I got something like this
define axis/t="1-jan-1989 00:00":"1-jan-2010
00:00":1/edges/units=days/calendar=gregorian tdaily
let lw_mon=lw[gt=tdaily@sum]
LET lw=STR/(60*60*3)
LET lw_mon=lw[gt=tdaily@sum]
LIST/l=1:8/x=75/y=-10 lw
VARIABLE : STR/(60*60*3)
FILENAME : lw_new.nc
SUBSET : 8 points (TIME)
LONGITUDE: 75E
LATITUDE : 10.5S
75E
51
01-JAN-1989 00:00 / 1: -51.5
01-JAN-1989 03:00 / 2: -103.5
01-JAN-1989 06:00 / 3: -155.0
01-JAN-1989 09:00 / 4: -205.6
01-JAN-1989 12:00 / 5: -49.8
01-JAN-1989 15:00 / 6: -100.0
01-JAN-1989 18:00 / 7: -151.5
01-JAN-1989 21:00 / 8: -204.1
LIST/l=1:5/x=75/y=-10 lw_mon
VARIABLE : LW[GT=TDAILY@SUM]
FILENAME : lw_new.nc
SUBSET : 5 points (TIME)
LONGITUDE: 75E
LATITUDE : 10.5S
75E
51
01-JAN-1989 12 / 1: -793.7
02-JAN-1989 12 / 2: -13.5
03-JAN-1989 12 / 3: -13.5
04-JAN-1989 12 / 4: -13.5
05-JAN-1989 12 / 5: -13.5
I should get 1024 as sum for 1-jan 1989, and the other days showing
some values too.
Why is it coming so and Where I am doing wrong???
I tried with a monthly axis also, where results were better but not
exact
LET start_year = 1989
LET nyears = 20
LET indices = L[L=1:`nyears*12`]
LET month = MOD(indices-1,12)+1
LET year = start_year + INT((indices-1)/12)
DEFINE AXIS/UNITS=days/T0=1-jan-1900/edges truemonth =
DAYS1900(year,month,1)
LET lw_mon=lw[gt=truemonth@sum]
LIST/l=1:5/x=75/y=-10 lw_mon
VARIABLE : LW[GT=TRUEMONTH@SUM]
FILENAME : lw_new.nc
SUBSET : 5 points (TIME)
LONGITUDE: 75E
LATITUDE : 10.5S
75E
51
16-JAN-1989 12 / 1: -1045.
15-FEB-1989 00 / 2: -989.
16-MAR-1989 12 / 3: -1033.
16-APR-1989 00 / 4: -982.
16-MAY-1989 12 / 5: -1039.
when I removed edges in axis defenition I was getting almost correct
values except for first time step. But I couldn't understand why this
is happening.
Is there any better way to get this done ?
Thanks in advance...
Rahul
Research Fellow
Indian Institute of Tropical Meteorology
Pune, India
|