[Thread Prev][Thread Next][Index]

Re: [ferret_users] mm/day to mm/month



Dear Mick, Russell, Ansley,

Thank You for your help.
I solved already the problem with a repeat and some if-then-else (not that nice, i know), but here is what i did with the suggested approaches:

1) I put my data on a truemonth axis, then used the pseudo-variable tbox. It worked, though there is a slight difference between the original data and the new one on truemonth.

yes? list/x=19/y=47/l=1:38 precipday,rt
 WARNING: Listed variables have ambiguous coordinates on axes: T
             DATA SET: ELTE-kozos/RegCM/RegCM_ECHAM_pre_6190.nc
             LONGITUDE: 19.1E(19.1)
             LATITUDE: 47N
 Column  1: PRECIPDAY[T=01-JAN-1961 00:00:01-MAR-1964 00:00] is RT[GT=TRUEMONTH]
 Column  2: RT[T=31-DEC-1960 06:45:01-MAR-1964 21:11] is Total Precipitation (mm/day)
       PRECIPD    RT
L /  1:   1.189  1.219
L /  2:   0.307  0.305
L /  3:   1.237  1.265
L /  4:   2.413  2.444
L /  5:   1.395  1.369
L /  6:   2.594  2.623
L /  7:   0.822  0.784
L /  8:   0.833  0.833
L /  9:   1.418  1.418
L / 10:   2.972  2.975
L / 11:   1.724  1.719
L / 12:   2.828  2.842
L / 13:   0.559  0.524
L / 14:   1.927  1.935
L / 15:   1.487  1.470

2) The dayspermonth script worked without changing the original data set.

Cheers, Peter




On Fri, May 22, 2009 at 9:11 PM, mick spillane <Mick.Spillane@xxxxxxxx> wrote:
Hi Peter & Ansley,

  I actually prefer Russell's DAYS_IN_MONTH approach which beats by miles the clunky things I've used at various times in the past in similar situations. There is a slight omission in not having a YEAR0 in the definition of YEAR and maybe its worth generalizing to situations where a monthly series did not begin in January.  With these thoughts in mind, I'm putting the attached DaysPerMonth.jnl script in my toolkit. Apologies to anyone whose reaction is "duh" -- though there's probably no one like that in the ferret-users group.

Mick

PS As an example of how to use it in a situation like yours Peter (but with series starting with  Feb 1960 say)

! demo of russell's days-in-month approach to mm/day --> mm/month conversion
def axis/t="15-Feb-1960":"15-JAN-1990"/npoints=360 tax ; def grid/t=tax grd
let/title="rainfall"/units="mm/day" drain=randu(t[g=grd])  ! a fake rainfall series
! generate the days/month variable for the daily rainfall variable "drain"
go dayspermonth 1960 2 drain
! and apply it to generate monthly rate
let/title="rainfall"/units="mm/month" mrain=dpm*drain
! and list some results to check dpm in leap and non-leap years
list/nohead/L=1:16 yrser,mnser,d1900,dpm,drain,mrain
15-FEB-1960 /  1:  1960.   2.00  21945.  29.00  0.6862  19.90    <== 29 days in Feb'60
16-MAR-1960 /  2:  1960.   3.00  21974.  31.00  0.6201  19.22
15-APR-1960 /  3:  1960.   4.00  22005.  30.00  0.5975  17.92
16-MAY-1960 /  4:  1960.   5.00  22035.  31.00  0.4654  14.43
15-JUN-1960 /  5:  1960.   6.00  22066.  30.00  0.6546  19.64
16-JUL-1960 /  6:  1960.   7.00  22096.  31.00  0.8547  26.50
15-AUG-1960 /  7:  1960.   8.00  22127.  31.00  0.2217   6.87
15-SEP-1960 /  8:  1960.   9.00  22158.  30.00  0.4683  14.05
15-OCT-1960 /  9:  1960.  10.00  22188.  31.00  0.8639  26.78
14-NOV-1960 / 10:  1960.  11.00  22219.  30.00  0.3296   9.89
15-DEC-1960 / 11:  1960.  12.00  22249.  31.00  0.9992  30.97
14-JAN-1961 / 12:  1961.   1.00  22280.  31.00  0.4089  12.67
14-FEB-1961 / 13:  1961.   2.00  22311.  28.00  0.7811  21.87  <== & 28 in Feb'61
16-MAR-1961 / 14:  1961.   3.00  22339.  31.00  0.4778  14.81
16-APR-1961 / 15:  1961.   4.00  22370.  30.00  0.4869  14.61
16-MAY-1961 / 16:  1961.   5.00  22400.  31.00  0.5987  18.56



! DaysPerMonth : Creates a variable "dpm" for days per month to associate with a
!                particular monthly time series. Other variables introduced may
!                be useful, eg mnser in generating monthly climatologies, d1900
!                which is days1900 for the first of the month

! Usage Example: If series "myvar" starts May 1959 then before using "dpm"
!   go DaysPerMonth 1959 5 myvar

let LVAL=L[g=$3]
let/title="Year Series"     yrser=`$1`+int((LVAL+`$2`-2)/12)
let mser0=mod(LVAL+`$2`-1,12)
let/title="Month Series"    mnser=if(mser0 eq 0)then 12 else mser0
let/title="Days1900 Series" d1900=days1900(yrser,mnser,1)
let/title="Days/Month"      dpm=d1900[L=@shf]-d1900




[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement