Thanks Ansley.
From: Ansley
Manke [mailto:Ansley.B.Manke@xxxxxxxx]
Sent: Tuesday, 3 March 2009 7:05 AM
To: Savin
Cc: oar.pmel.ferret_users@xxxxxxxx
Subject: Re: [ferret_users] Composite using separate date files
Hi Savin,
Are you saying you have a set of dates in an ascii file that look for instance
like this:
19940315
19940415
19940515
19940615
19940715
...
and you want to get that set of dates into Ferret and use them in a computation
with a dataset that has a time axis? The dates might or might not be
regularly-spaced, or match dates from the ncep data set - Ferret can handle
that.
You can read in separate variables representing the year, month, day as
follows:
yes?
file/var="yr,mo,da"/format=(f4.0,f2.0,f2.0) dates.txt
yes? list yr, mo, da
DATA SET: ./dates.txt
X:
0.5 to 9.5
Column 1: YR
Column 2: MO
Column 3: DA
YR MO DA
1 / 1: 1994. 3.00 15.00
2 / 2: 1994. 4.00 15.00
3 / 3: 1994. 5.00 15.00
4 / 4: 1994. 6.00 15.00
...
Now define a variable representing these times. Ferret
has the function DAYS1900 to convert year, month, day data into a variable
representing days since 1-jan-1990. We'll use this and then convert these
times into the time reference used by the ncep data.
yes? sh func days1900
DAYS1900(year,month,day)
days elapsed since
1-Jan-1900
yes? list days1900(yr, mo, da)
VARIABLE : DAYS1900(YR, MO, DA)
FILENAME : dates.txt
SUBSET : 9 points (X)
1 / 1: 34392.
2 / 2: 34423.
3 / 3: 34453.
4 / 4: 34484.
...
I don't know the details of the ncep reanalysis dataset
you're using - here's one I have available to me, so for example, here is the
data and its time origin and time units.
yes? use
ncep_reanalysis_monthly_stress
yes? sh dat
currently SET data
sets:
1>
/.../ncep_reanalysis_monthly_stress.cdf (default)
name
title
I J
K L
TAUX Zonal
Wind
Stress
1:160 1:100
... 1:204
TAUY Meridional Wind
Stress
1:160 1:100
... 1:204
yes? say
`taux[d=1],return=t0`
!-> MESSAGE/CONTINUE 15-JAN-1901
00:00:00
15-JAN-1901 00:00:00
yes? say `taux[d=1],return=tunits`
!-> MESSAGE/CONTINUE HOURS
HOURS
Define a time axis with the dates from the ascii file. We
will use regridding to put this data onto the time axis of the ncep data and
then create a mask that will pick out the times for the computation. (You
could use a different regridding tranformation in the second line.)
yes? define
axis/t0="1-jan-1900"/units=days my_t_axis = days1900(yr, mo, da)
yes? let tdays = t[gt=my_t_axis] ! a
variable on the time axis
yes? let t_ncep = tdays[gt=taux,d=1] ! that variable, on the
NCEP time axis
Now the variable we have created from the list of dates in
the ascii file has units of days and the NCEP time axis is in hours. Also
the variable we created has a time origin of 1-jan-1900 and NCEP is referenced
to 15-jan-1900. So, convert our variable to hours since 15-jan-1900:
yes? list DAYS1900(1901,1,15) ! The number of days between the 2
time origins.
VARIABLE : DAYS1900(1901,1,15)
379.0
yes? let compute_times = 24*(t_ncep-379) ! times in NCEP time
units
We are almost done. Create a mask which is 1 at all the
times that match the input times in the file; or missing otherwise. Multiply
this by the NCEP variable, and the result is the variable at the selected
times.
yes? let mask = if
compute_times then 1
yes? let masked_taux = taux[d=1]*mask
yes? list/t=1-jan-1994:1-jan-1995 t[gt=taux,d=1], compute_times,
mask, taux[d=1,x=180,y=0], masked_taux[x=180,y=0]
DATA SET:
/home/raid1/data/jaguar_data/ja10/data/f2/data/ncep_reanalysis_monthly_stress.cdf
NCEP Reanalysis Monthly Wind Stress
TIME: 01-JAN-1994 00:00 to 01-JAN-1995 00:00
LONGITUDE: ???
LATITUDE: ???
Column 1: T is T (axis TAX)
Column 2: COMPUTE_TIMES is 24*(T_NCEP-379)
Column 3: MASK is IF COMPUTE_TIMES THEN 1
Column 4: TAUX is Zonal Wind Stress (dyne/cm**2)
Column 5: MASKED_TAUX is TAUX[D=ncep_reanalysis_monthly_stress]*MASK
T COMPUTE_ MASK TAUX MASKED_TAUX
15-JAN-1994 / 181: 815250. ....
.... -0.3323 ....
15-FEB-1994 / 182: 815980. ....
.... -0.2561 ....
17-MAR-1994 / 183: 816711. 816711. 1.000 -0.2233 -0.2233
17-APR-1994 / 184: 817442. 817442. 1.000 -0.1726 -0.1726
17-MAY-1994 / 185: 818172. 818172. 1.000 -0.1809 -0.1809
16-JUN-1994 / 186: 818902. 818902. 1.000 -0.1358 -0.1358
17-JUL-1994 / 187: 819633. 819633. 1.000 -0.1124 -0.1124
16-AUG-1994 / 188: 820364. 820364. 1.000 -0.0587 -0.0587
16-SEP-1994 / 189: 821094. 821094. 1.000 -0.1575 -0.1575
16-OCT-1994 / 190: 821824. 821824. 1.000 -0.0583 -0.0583
16-NOV-1994 / 191: 822555. ....
.... 0.0692 ....
16-DEC-1994 / 192: 823286. ....
.... 0.0653 ....
16-JAN-1995 / 193: 824016. ....
.... -0.0897 ....
Savin wrote:
Dear ferret users,
I have a separate date file (say in the format yyyymmdd). I
want to create a composites (say e.g., relative vorticity from NCEP reanalysis
data) using dates from this file in FERRET.
Any suggestions how I can do it.
Help will be very much appreciated.
Thanks.
Savin