From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>

Date: Wed Jan 23 2013 - 18:10:16 MST

Date: Wed Jan 23 2013 - 18:10:16 MST

[1] It is surprising that you did not get errors immediately

because 'min' and 'max' are NCL builtin functions. They

can not be redefined. EG

ncl 0> timeUnits = "hours since 1997-01-01 00:00:00"

The following trys to redefine 'min' .... not allowed

ncl 1> min = ut_inv_calendar( 1999, 04, 01, 00, 00, 00, timeUnits, 0 )

fatal:syntax error: line 1 before or near =

min =

-----^

fatal:error in statement

===========================================================================

[2]

ncl 2> mint = ut_inv_calendar( 1999, 04, 01, 00, 00, 00, timeUnits, 0 )

ncl 3> maxt = ut_inv_calendar( 2008, 08, 31, 00, 00, 00, timeUnits, 0 )

[3] I have no idea why you are doing the following,

even using 'mint' and 'maxt'

time = ut_convert( fin->time({mint:maxt}), timeUnits )

[4] You could do this directly

x = short2flt(fin->sst({mint:maxt},{-30:30},:))

printVarSummary(x)

yyyymmdd = cd_convert( x&time, -3) ; information only

print( yyyymmdd )

xMonthAvg = calculate_monthly_values(x, "avg", 0, False)

printVarSummary(xMonthAvg)

xMonthClm = clmMonTLL( xMonthAvg )

printVarSummary(xMonthClm)

On 1/23/13 4:51 PM, Xi Chang wrote:

*> Thanks for all kind responses,
*

*>
*

*> I did a test something like this:
*

*>
*

*> f = addfile( sst.nc, "r" )
*

*> timeUnits = "hours since 1997-01-01 00:00:00"
*

*> min = ut_inv_calendar( 1999, 04, 01, 00, 00, 00, timeUnits, 0 )
*

*> max = ut_inv_calendar( 2008, 08, 31, 00, 00, 00, timeUnits, 0 )
*

*> time = ut_convert( fin->time({min:max}), timeUnits )
*

*> lat = fin->lat ({-30:30})
*

*> lon = fin->lon
*

*>
*

*> x = short2flt(fin->sst({min:max},{-30:30},:))
*

*> xMonthAve = calculate_monthly_values(x, "avg", 0, False)
*

*>
*

*> then, it produced this error:
*

*> *fatal:Execute: Error occurred at or near line 11768 in file
*

*> $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl*
*

*>
*

*> If I do not set the range of the time, everything is just ok.
*

*>
*

*> Xi.
*

*>
*

*>
*

*>
*

*>
*

*> On Thu, Jan 24, 2013 at 8:35 AM, Will Hobbs <Will.Hobbs@utas.edu.au> wrote:
*

*>
*

*>> Xi
*

*>>
*

*>> Obviously, if you want the monthly climatology you could just take the
*

*>> mean for each month calculated using Dennis' function.
*

*>> Or even easier, assuming you have a valid time array:
*

*>>
*

*>> > timetmp = cd_calendar(time, -5) ;timetmp is an integer array with
*

*>> (/year,month,day,hour,min,sec/) foir each time step
*

*>>
*

*>> >clim = new(12, typeof(x))
*

*>>
*

*>> > do i = 1,12
*

*>> > ii = ind(timetmp(:,1).eq.i) ;all values in month 'i'
*

*>>> clm(i-1) = avg(ii) ;monthly climatology is
*

*>> the average of all values in month 'i'
*

*>>> delete(ii)
*

*>>> end do
*

*>>
*

*>>
*

*>> Will
*

*>>
*

*>> From: Xi Chang <xi.chang01@gmail.com>
*

*>> Date: Thursday, 24 January 2013 10:19 AM
*

*>> To: "ncl-talk@ucar.edu" <ncl-talk@ucar.edu>
*

*>> Subject: Re: monthly mean climatology
*

*>>
*

*>> Thank you for the hints. It worked fine but it just simply returned the
*

*>> values from daily to monthly *not to monthly climatology*. If anyone has
*

*>> an idea how to figure it out, i'll be really appreciate it.
*

*>>
*

*>> Xi.
*

*>>
*

*>>
*

*>> On Wed, Jan 23, 2013 at 10:22 AM, Dennis Shea <shea@ucar.edu> wrote:
*

*>>
*

*>>> There are several approaches
*

*>>>
*

*>>> [1] http://www.ncl.ucar.edu/**Support/talk_archives/2012/**1256.html<http://www.ncl.ucar.edu/Support/talk_archives/2012/1256.html>
*

*>>>
*

*>>> [2] there is an unsupported and undocumented function in
*

*>>> contributed.ncl: calculate_monthly_values
*

*>>>
*

*>>> It requires a time coordinate variable associated
*

*>>> with the input variable 'x'. This time coordinate
*

*>>> variable must be udunits compatible:
*

*>>>
*

*>>> "days since ...", "hours since ...", "seconds since ..."
*

*>>>
*

*>>> See cd_calendar and cd_inv_calendar
*

*>>>
*

*>>> ;-----------------------------**----
*

*>>> ; undocumented and unsupported
*

*>>> ;-----------------------------**----
*

*>>> undef ("calculate_monthly_values")
*

*>>> function calculate_monthly_values (x:numeric, arith:string,
*

*>>> nDim[1]:integer, opt[1]:logical)
*

*>>>
*

*>>> ; calculate monthly values [avg, sum, min, max]
*

*>>> ; x: numeric array of 5D or less [eg: time,lev,lat,lon]
*

*>>> ; *must* have time coordinate recognized by cd_calendar
*

*>>> ; if 5D [case,time,lev,lat,lon]
*

*>>> ; arith: "avg" [also, "ave"], "sum","min","max" others may be added
*

*>>> later
*

*>>> ; nDim : scalar integer that specifies the 'time' dimension [generally, 0]
*

*>>> ; opt : option ... not used here
*

*>>> ;
*

*>>> ; Sample usage: x(time,lat,lon) where time are n-hrly or daily values.
*

*>>> ; xMonthAvg = calculate_monthly_values(x, "avg", 0, False)
*

*>>> ; xMonthSum = calculate_monthly_values(x, "sum", 0, False)
*

*>>> ; xMonthMin = calculate_monthly_values(x, "min", 0, False)
*

*>>> ; xMonthMax = calculate_monthly_values(x, "max", 0, False)
*

*>>> ;
*

*>>> ; It is assumed that there will be multiple elements for the dim_avg_n
*

*>>> ; calculation.
*

*>>> ;
*

*>>>
*

*>>>
*

*>>> On 1/22/13 4:32 PM, Xi Chang wrote:
*

*>>>
*

*>>>> Hallo NCL users,
*

*>>>>
*

*>>>> does anyone has a trick how to calculate monthly mean climatology from
*

*>>>> daily dataset?
*

*>>>>
*

*>>>> Thank you for the help.
*

*>>>>
*

*>>>>
*

*>>>>
*

*>>>> ______________________________**_________________
*

*>>>> ncl-talk mailing list
*

*>>>> List instructions, subscriber options, unsubscribe:
*

*>>>> http://mailman.ucar.edu/**mailman/listinfo/ncl-talk<http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
*

*>>>>
*

*>>>>
*

*>>
*

*>
*

*>
*

*>
*

*> _______________________________________________
*

*> ncl-talk mailing list
*

*> List instructions, subscriber options, unsubscribe:
*

*> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
*

*>
*

_______________________________________________

ncl-talk mailing list

List instructions, subscriber options, unsubscribe:

http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Wed Jan 23 18:10:34 2013

*
This archive was generated by hypermail 2.1.8
: Wed Jan 23 2013 - 20:38:31 MST
*