# Re: From hourly to daily

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 26 Aug 2009 13:35:09 -0600

There can not be a function for 'everything'. :-)

Based upon the following, a function could be created.
If you think you will be doing this type of operation regularly,

Extracted from a preexisting script, the following calculates daily
*total* prc
from 3-hrly data.

ns = 8 ; number of samples per day
prc = f->precip ; 3B42 3hrly

dimp = dimsizes(prc)
nTim = dimp(0)

pday = prc(::ns,:,:)
pday = pday@_FillValue
pknt = new ( dimsizes(pday), "integer")

; ---- v5.1.0 or previous versions ... use dimension reordering

do nt=0,nTim-1,ns
work = prc(lat|:,lon|:,time|nt:nt+ns-1) ;
convenience
pday(nt/ns,:,:) = dim_sum( work )
pknt(nt/ns,:,:) = dim_num( .not.ismissing(work) )
end do

; ---- v5.1.1 .... Use the dim*_n functions [no dim reordering]

do nt=0,nTim-1,ns
pday(nt/ns,:,:) = dim_sum_n(prc(nt:nt+ns-1,:,:), 0)
pknt(nt/ns,:,:) = dim_num_n(
.not.ismissing(prc(nt:nt+ns-1,:,:)) )
end do

pday_at_long_name = "total daily precipitation"
pday_at_units = "mm/day"

pknt_at_long_name = "number of non-missing values: max is 8"
pknt_at_usage = "may be used to mask out days having fewer
that 8 samples"
copy_VarCoords(pday, pknt)

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

louis Vonder wrote:
> dear NCL users,
>
> I downloaded TRMM (3B42) data. These data are provided each three
> hour (0000, 0300, ..., 2100).
>
> I used NCO to cut the region where I am working and to concatenate
> these hourly files in a single file.
>
> Now I want to calculate daily mean from the obtained data.
>
> Is there any NCL function which can be used directly to perform this task?
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

```--
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
```
Received on Wed Aug 26 2009 - 13:35:09 MDT

This archive was generated by hypermail 2.2.0 : Wed Sep 02 2009 - 12:24:39 MDT