[ncl-talk] time (integer) array to calendar
Dennis Shea
shea at ucar.edu
Mon Apr 26 18:20:00 MDT 2021
*2019081503* is of the form yyyymmddhh
===
*http://www.ncl.ucar.edu/Document/Functions/*
<http://www.ncl.ucar.edu/Document/Functions/>
Click "*Date*"
You will see a large number of 'time/date' related functions.
The *cd_inv_calendar*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_inv_calendar.shtml>
function can take yyyy, mm, dd, hh and convert to a common reference time.
yyyymmddhh = 2019081503
yyyy = yyyymmddhh/1000000
mdh = yyyymmddhh%1000000
mm = mdh/10000
dh = mdh%10000
dd = dh/100
hh = dh-dd*100
; create arrays [*] of required size
mn = dd ;create array same size as dd
sc = dd
mn = 0 set arrays to 0
sc = 0
; user specified
units = "hours since 1900-01-01 00:00:00" ; "seconds/hours/days since ...."
; do *NOT* use "months since ...."
time = *cd_inv_calendar*(yyyy,mm,dd,hh,mn,sc,units, 0)
time!0 = "time"
*print* <http://www.ncl.ucar.edu/Document/Functions/Built-in/print.shtml>(time)
yyyymm = yyyy*100 + mm
yyyymmdd = yyyymm*100 + dd
yyyyddd = *yyyymmdd_to_yyyyddd*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/yyyymmdd_to_yyyyddd.shtml>(
yyyymmdd )
Now you have time information in different formats. These can be used
as input to NCL's climatological functions:
*http://www.ncl.ucar.edu/Document/Functions/climo.shtml*
<http://www.ncl.ucar.edu/Document/Functions/climo.shtml>
On Fri, Apr 23, 2021 at 8:24 PM Jayant via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:
> Hi! I am reading binary files and extracting date from the file name (GFCT
> *2019081503*.out) and creating the time dimension:
> tim=new(ntim,integer)
> tim!0 = "time"
> tim at long_name = "time"
> tim at units = "hours"
> tim&time = tim
> my time dimension is an integer array (yyyymmddhh) :
> 2019081503
> 2019081506
> 2019081509
> ...
> 2019093012
> Is it possible to convert it to calendar time so as to perform
> daily/weekly/monthly/seasonal average? How can it be done?
> Please advise.
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210426/e9427ba5/attachment.html>
More information about the ncl-talk
mailing list