[ncl-talk] DATES
Toni Klemm
toni-klemm at tamu.edu
Wed Apr 3 12:23:08 MDT 2019
Hi Andrea,
Could you include some of your output? That might make it easier to understand what is going wrong.
Toni
Toni Klemm, Ph.D.
Postdoctoral Research Associate
Department of Ecosystem Science and Management
College of Agriculture and Life Sciences
Texas A&M University, College Station, TX
Contributor to the Early Career Climate Forum <http://www.eccforum.org/>
www.toni-klemm.de <http://www.toni-klemm.de/> | @toniklemm <http://twitter.com/toniklemm>
> On Apr 3, 2019, at 1:19 PM, Andrea Perez <andreaperez151 at yahoo.es> wrote:
>
> HI!!
>
> I'm trying to use print dates in string format, converts UTreferenced date to Julian/Gregorian date. Dates are hourly (2004-07-09 to 2004-07-11) and in a netcdf file.
> But the hours and day are wrongs. What can I do??
>
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> f1=addfile("MMOUT_DOMAIN3_34_sigma.nc","r")
> ;
> ; Array to hold month abbreviations. Don't store anything in index
> ; '0' (i.e. let index 1=Jan, 2=Feb, ..., index 12=Dec).
> ;
> month_abbr = (/"","Jul","Aug","Sep", \
> "Oct","Nov","Dec"/)
> ;
> ; Time values and units.
> ;
> time = f1->time
> time at units = "hours since 2004-07-09 00:00:0.0"
> ;
> utc_date = ut_calendar(time, 0)
> ;
> ; Store return information into more meaningful variables.
> ;
> year = tointeger(utc_date(:,0)) ; Convert to integer for
> month = tointeger(utc_date(:,1)) ; use sprinti
> day = tointeger(utc_date(:,2))
> hour = tointeger(utc_date(:,3))
>
> ; Write out strings in the format "hhZ dd mmm yyyy".
> ;
>
> date_str = sprinti("%0.2iZ ", hour) + sprinti("%0.2i ", day) + \
> sprinti("%0.4i", year)
>
> print(date_str)
> end
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190403/e4c2f158/attachment.html>
More information about the ncl-talk
mailing list