[ncl-talk] DATES
Andrea Perez
andreaperez151 at yahoo.es
Wed Apr 3 12:19:13 MDT 2019
HI!!
I'm trying to use print dates in string format, converts UTreferenceddate 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190403/c14ac0e0/attachment.html>
More information about the ncl-talk
mailing list