NCL Home > Documentation > Functions > Climatology

clmDayHourTLLL

Calculates climatological day-hour means at user specified hours for each day of the year.

Prototype

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  ; This library is automatically loaded
                                                             ; from NCL V6.2.0 onward.
                                                             ; No need for user to explicitly load.

	function clmDayHourTLLL (
		x [*][*][*][*] : float or double,  
		yyyydddhh  [*] : integer,          
		hour       [*] : integer,          
		opt_shape  [1] : logical           
	)

	return_val [366*dimsizes(hour)][*][*][*] :  typeof(x)

Arguments

x

A four-dimensional array (time, lev,lat, lon) containing day-hour data.

yyyydddhh

A one-dimensional array (same size as the "time" dimension of x) containing values of the form yyyydddhh [ie: yyyy*100000 + ddd*100 + hh]. yyyy [eg: 1993]; ddd is the sequential day of the current year [eg: Jan01=>1, Feb01=>32, etc.); and, hh is the hour of the day.

By default, this function assumes that the gregorian calendar is being used. To correcly handle other calendars, the calendar attribute must be associated with the yyyyddd argument. The user may have to be explicitly perform the assignment.

hour

User specified hours. Typically: (/0,6,12,18/) , (/0,12/) , ispan(0,23,1). However, they can be unequally spaced: (/2,7,13,16,22/)

opt_shape

Specifies how the user wants the results shaped. opt_shape=True returns (366,nhrs,lev,lat,lon). opt_shape=False returns (366*nhrs,lev,lat,lon).

Return value

A climatological time series where the leftmost dimension refers to the sequential day of the year. See: opt_shape description

Description

Calculate the mean annual cycle from day-hour data. The return array will give the raw day-hour climatology at each grid point


       x(time,lev,lat,lon)  <==== input dimension order

non-Leap  yyyydddhh
       190500100 =>  Jan  1, 1905, 00Z
       190503206 =>  Feb  1, 1905, 06Z
       190505915 =>  Feb 28, 1905, 15Z
       190506018 =>  Mar  1, 1905, 18Z
       190536521 =>  Dec 31, 1905, 21Z

Leap      yyyydddhh
       190500100 =>  Jan  1, 1905, 00Z
       190503206 =>  Feb  1, 1905, 06Z
       190505915 =>  Feb 28, 1905, 15Z
       190506118 =>  Mar  1, 1905, 18Z
       190536621 =>  Dec 31, 1905, 21Z

See Also

cd_calendar, clmDayTLLL, calculate_daily_values

Examples

Example 1 Compute the day-hour climatologies. The input is 4x-daily height at twp pressure levels spanning 5-years: 2010-2014.


   dir    = "./"
   fil    = systemfunc("cd "+dir+" ; ls Height*nc")

   f      = addfiles(dir+fil, "r")
   x      = f[:]->HGT         
   printVarSummary(x)                         ; [time | 7304] x [lev | 2] x [lat | 73] x [lon | 144]

   HOUR = (/0,6,12,18/)                       ; user specified hours
  
   time    = fCDC[:]->time                    ; time:units = "hours since ?-?-? 00:00:0.0"                               
   TIME    = cd_calendar(time, 0)             ; type float 
   year    = toint( TIME(:,0) )               ; toint strips meta data
   month   = toint( TIME(:,1) )
   day     = toint( TIME(:,2) )               ; day of month 
   hour    = toint( TIME(:,3) )               ; hour of day
                                                                 ; check for calendar attribute
   if (isatt(time,"calendar")) then           ; default is gregorian
       year@calendar = time@calendar         
   end if

   ddd     = day_of_year(year, month, day) 
   if (isatt(time,"calendar")) then           ; default is gregorian
       ddd@calendar = time@calendar  
   end if

   yyyydddhh = year*100000 + ddd*100 + hour                       ; needed for input
   if (isatt(time,"calendar")) then 
       yyyydddhh@calendar = time@calendar  
   end if

   opt_shape  = False                                            ; 3D         
   clmDayHour = clmDayHourTLLL (x, yyyydddhh, HOUR, opt_shape)
   printVarSummary(clmDayHour)                ; [dddhh | 1464] x [lev | 2] x [lat | 73] x [lon | 144]
   printMinMax(clmDayHour,0)
   print("=========================")
   if (opt_shape) then
       print(clmDayHour(:,:,{40},{255}))
       printMinMax(clmDayHour(:,:,{40},{255}),0)
   else
       print(clmDayHour(:,{40},{255}))
       printMinMax(clmDayHour(:,{40},{255}),0)
   end if

The input variable is:

     Variable: x                        <=== data
     Type: float
     Total Size: 307118592 bytes
                 76779648 values
     Number of Dimensions: 3
     Dimensions and sizes:   [time | 7304] x [lev | 2] x [lat | 73] x [lon | 144]
     Coordinates: 
                 time: [1840824..1884642]
                 lev: [200..1000]
                 lat: [90..-90]
                 lon: [ 0..357.5]
     Number Of Attributes: 15
       long_name :   4xDaily height
       units :       gpm
       _FillValue :  -9.96921e+36


The (edited) results with opt_shape=False 


     Variable: clmDayHour
     Type: float
     Total Size: 61558272 bytes
                 15389568 values
     Number of Dimensions: 3
     Dimensions and sizes:   [dddhh | 1464] x [lev | 2] x [lat | 73] x [lon | 144]
     Coordinates: 
                 dddhh: [100..36618]
                 lev: [200..1000]
                 lat: [90..-90]
                 lon: [ 0..357.5]
     Number Of Attributes: 6
       hour_day :    0
       long_name :   Day-Hour Climatology: 4xDaily height
       units :       kg/m^2
       NCL_tag :     clmDayHourTLLL
     (0)     Day-Hour Climatology: 4xDaily Height (gpm) : min=        max=      

The (edited) results with opt_shape=True

     Variable: clmDayHour
     Type: float
     Total Size: 61558272 bytes
                 15389568 values
     Number of Dimensions: 4
     Dimensions and sizes:   [year_day | 366] x [hour_day | 4]  x [lev | 2] x [lat | 73] x [lon | 144]
     Coordinates: 
                 year_day: [1..366]
                 hour_day: [0..18]
                 lev: [200..1000]
                 lat: [90..-90]
                 lon: [ 0..357.5]
     Number Of Attributes: 6
       long_name :   Day-Hour Climatology: 4xDaily Height
       units :       gpm
     (0)     Day-Hour Climatology: 4xDaily Height (gpm) : min=        max=      

The results for individual grid points are not shown (too long).