[ncl-talk] set title name as Date

Kunal Bali kunal.bali9 at gmail.com
Wed Feb 19 01:06:00 MST 2020


oh! Thank you for the clarification.
---
Kunal





On Wed, Feb 19, 2020 at 1:31 PM Rashed Mahmood <rashidcomsis at gmail.com>
wrote:

> The function is returning year so that is why you get years as title:
> return(*year*)      ;-- return only year string
>
> You can change above inside the function getDate to;
> *return(str_date)*
>
>
> On Wed, Feb 19, 2020 at 8:49 AM Kunal Bali via ncl-talk <ncl-talk at ucar.edu>
> wrote:
>
>> Dear NCL users,
>>
>> I have a file with monthly data (24-time steps).
>> 2016-01-01 00:00:00
>> 2016-02-01 00:00:00
>> 2016-03-01 00:00:00
>> 2016-04-01 00:00:00
>> .
>> .
>> .
>> 2017-11-01 00:00:00
>> 2017-12-01 00:00:00
>>
>> I am creating 24 separate figures on the basis of the given time (no
>> problem in that).
>>
>> Now, I want to set the title (tiMainString) name of each figure according
>> to their Date e.g.
>> figure 01 with plot title as 2016-01
>> figure 02 with plot title as 2016-02
>> figure 24 with plot title as 2017-12
>>
>> here, I am providing the brief script that I am using which giving the
>> title name only year names such as (2016, 2016, 2016, 2017, 2017,2017 etc)
>>
>> I am trying as
>>
>> undef ("getDate")
>>> function getDate(time)
>>> local utc_date, year, mon, day, hours, mins, str_date
>>> begin
>>>    utc_date   = cd_calendar(time, 0)
>>>    year       = sprinti("%0.4i",tointeger(utc_date(:,0)))
>>>    mon        = sprinti("%0.2i",tointeger(utc_date(:,1)))
>>>    day        = sprinti("%0.2i",tointeger(utc_date(:,2)))
>>>    hours      = sprinti("%0.2i",tointeger(utc_date(:,3)))
>>>    mins       = sprinti("%0.2i",tointeger(utc_date(:,4)))
>>>    str_date   = year+"-"+mon+"-"+day+" "+hours+":"+mins
>>>
>>>    return(year)      ;-- return only year string
>>> end
>>>
>>> begin
>>>   a = addfile("/test.nc","r")
>>>   t   = a->km
>>>   time = a ->time
>>>
>>> ntimes = dimsizes(a->km(:,0,0))
>>>   do i=0,ntimes-1
>>>
>>> res = True
>>> *res at tiMainString =  getDate(time(i)) *
>>>
>>>
>>> plot = gsn_csm_contour_map(wks,t(0,:,:),res)
>>>
>>
>>
>>> setvalues plot at data
>>>       "sfDataArray" : (/a->km(i,:,:)/)
>>>     end setvalues
>>>
>>>   maximize_output(wks,False)
>>>  end do
>>>
>>
>>
>> ---
>> Kunal
>>
>>
>>
>> _______________________________________________
>> 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/20200219/7b76d547/attachment.html>


More information about the ncl-talk mailing list