Hi,
There's a function SAMPLET_DATE:
yes? show function
SAMPLET_DATE(DAT_TO_SAMPLE,YR,MO,DAY,HR,MIN,SEC)
Returns data sampled by interpolating to a set of times
DAT_TO_SAMPLE: data to sample at set of times
YR: Year(s) yyyy
MO: Month(s), integer mm
DAY: Day(s) of month dd
HR: Hour(s) hh
MIN: Minute(s) mm
SEC: Second(s) ss
Here's an example. The dataset monthly_navy_winds isn't daily data,
but the function samples from whatever time axis the data is on.
Set some days-of-month, some month numbers, and year numbers. The
hours, minutes and seconds will just be zero.
yes? use monthly_navy_winds
yes? let days = {1,23,30,5,6,22}
yes? let months = {1,1,1,2,2,2}
yes? let years = {1988,1988,1988,1988,1988,1988}
yes? let zero = {0,0,0,0,0,0}
yes? list samplet_date
(uwnd[x=180,y=0],years,months,days,zero,zero,zero)
VARIABLE : SAMPLET_DATE
(UWND[X=180,Y=0],YEARS,MONTHS,DAYS,ZERO,ZERO,ZERO)
FILENAME : monthly_navy_winds.cdf
FILEPATH :
/home/users/tmap/ferret/linux/fer_dsets/data/
SUBSET : 6 points (T)
LONGITUDE: 180E
LATITUDE : 0
180E
65
1 / 1: -0.650
2 / 2: -1.651
3 / 3: -1.962
4 / 4: -2.229
5 / 5: -2.273
6 / 6: -2.583
Now, how to sample the same days for several years? We could define
a second dimension "year", and make 2D variables that repeat the
day, month every year. This uses Ferret's "conformability"
feature.
yes? define axis/t=1987:1991:1 tyear
yes? let day2d = days + 0*t[gt=tyear]
yes? list day2d
VARIABLE : DAYS + 0*T[GT=TYEAR]
SUBSET : 6 by 5 points (X-T)
1 2 3 4 5 6
1 2 3 4 5 6
1987 / 1: 1.00 23.00 30.00 5.00 6.00 22.00
1988 / 2: 1.00 23.00 30.00 5.00 6.00 22.00
1989 / 3: 1.00 23.00 30.00 5.00 6.00 22.00
1990 / 4: 1.00 23.00 30.00 5.00 6.00 22.00
1991 / 5: 1.00 23.00 30.00 5.00 6.00 22.00
yes? let mon2d = months + 0*t[gt=tyear]
yes? let zero2d = zero + 0*t[gt=tyear]
! for year, we want the year value to repeat across the rows
yes? let yr2d = zero + t[gt=tyear]
yes? list yr2d
VARIABLE : ZERO + T[GT=TYEAR]
SUBSET : 6 by 5 points (X-T)
1 2 3 4 5 6
1 2 3 4 5 6
1987 / 1: 1987. 1987. 1987. 1987. 1987. 1987.
1988 / 2: 1988. 1988. 1988. 1988. 1988. 1988.
1989 / 3: 1989. 1989. 1989. 1989. 1989. 1989.
1990 / 4: 1990. 1990. 1990. 1990. 1990. 1990.
1991 / 5: 1991. 1991. 1991. 1991. 1991. 1991.
Now to use these in calling SAMPLET_DATE, put the values into simple
lists with an XSEQUENCE function or something. The SAMPLET_DATE
function returns data on the T axis, so I'll use TSEQUENCE:
yes? let/title=month mo = tsequence(mon2d)
yes? let/title=day da = tsequence(day2d)
yes? let/title=year yr = tsequence(yr2d)
yes? let zr = tsequence(zero2d)
yes? let sampled_uwnd = samplet_date
(uwnd[x=180,y=0],yr,mo,da,zr,zr,zr)
yes? set var/title="sampled data"/units="`uwnd,return=units`" samplet_date
yes? list sampled_uwnd, yr, mo, da
DATA SET:
/home/users/tmap/ferret/linux/fer_dsets/data/monthly_navy_winds.cdf
T: 0.5 to 30.5
LONGITUDE: 180E
LATITUDE: 0
Column 1: SAMPLED_UWND is SAMPLET_DATE
(UWND[X=180,Y=0],YR,MO,DA,ZR,ZR,ZR)
Column 2: YR is year
Column 3: MO is month
Column 4: DA is day
SAMPLED_UW YR MO DA
1 / 1: -0.220 1987. 1.000 1.00
2 / 2: -0.737 1987. 1.000 23.00
3 / 3: -0.660 1987. 1.000 30.00
4 / 4: -0.594 1987. 2.000 5.00
5 / 5: -0.583 1987. 2.000 6.00
6 / 6: -0.289 1987. 2.000 22.00
7 / 7: -0.650 1988. 1.000 1.00
8 / 8: -1.651 1988. 1.000 23.00
9 / 9: -1.962 1988. 1.000 30.00
10 / 10: -2.229 1988. 2.000 5.00
11 / 11: -2.273 1988. 2.000 6.00
12 / 12: -2.583 1988. 2.000 22.00
13 / 13: -4.473 1989. 1.000 1.00
14 / 14: -3.777 1989. 1.000 23.00
15 / 15: -3.390 1989. 1.000 30.00
16 / 16: -3.058 1989. 2.000 5.00
17 / 17: -3.002 1989. 2.000 6.00
18 / 18: -2.726 1989. 2.000 22.00
19 / 19: 1.306 1990. 1.000 1.00
20 / 20: 0.278 1990. 1.000 23.00
21 / 21: 0.620 1990. 1.000 30.00
22 / 22: 0.913 1990. 2.000 5.00
23 / 23: 0.961 1990. 2.000 6.00
24 / 24: 1.131 1990. 2.000 22.00
25 / 25: -1.276 1991. 1.000 1.00
26 / 26: -3.042 1991. 1.000 23.00
27 / 27: -3.356 1991. 1.000 30.00
28 / 28: -3.626 1991. 2.000 5.00
29 / 29: -3.671 1991. 2.000 6.00
30 / 30: -3.648 1991. 2.000 22.00
On 2/25/2015 4:53 AM, Yogesh Tiwari
wrote:
Dear Ferret Users,
I am using ferret v6.72 on Linux platform.
I have a netcdf file (var1) defined on daily temporal
resolution
during year 2000 - 2010.
How to save var1 in a new netcdf file sampled on random
dates.
For example, var1, is defined as 01Jan-31dec all the
years.
I want var1 sampled on jan1, 23, 30, feb, 5, 6, 22,
24......etc.
and saved in new netcdf file.
Thanks,
Yogesh
--
Yogesh K. Tiwari (Dr.rer.nat),
Scientist,
Centre for Climate Change Research,
Indian Institute of Tropical Meteorology,
Homi Bhabha Road,
Pashan,
Pune
|