[ncl-talk] XY plot from .ascii file

Dennis Shea shea at ucar.edu
Sun Nov 12 18:24:26 MST 2017


re: your 2nd post

You can not (well, should not) use 'yyyymmddhh'. It is *not* a continuous
variable. Think ...  ddhh=3112
What should the next number be.

You must use

 res at tmXBValues = (/ .... time .... /)
 res at tmXBLabels = (/ .... yyyymmddhh.... /)

one-to-one




On Sun, Nov 12, 2017 at 6:06 PM, Dennis Shea <shea at ucar.edu> wrote:

> Actually, the point of my reply was to illustrate a more generic approach
> to writing scripts.
> I was in a rush and did not finish.
> See attached.
>
> [1] It uses a  function. I suggest saving in in a file: (say) music.ncl
> Then
>
>      load "./music.ncl"
>
> [2] no hard-coded numbers; badd programmin practice; they ahould be placed
> in variables.
> [3] you used:
>      "days since 1-1-1 00:00:0.0"
>       Are you sure? You can not use 'just anything' units
> [4] Script uses 'elapsed time'
>
> Good Luck
>
>
>
>
>
>
> On Sun, Nov 12, 2017 at 8:57 AM, music piano <musicpianoljy at gmail.com>
> wrote:
>
>> Hi,
>>
>> Have you try something like
>>
>> res at tmXBMode = "Explicit" ; explicit labels
>> res at tmXBValues = ispan(0,18,1)
>> res at tmXBLabels =xtime(0:18)
>> time=ispan(0,18,1)
>> plot =  gsn_csm_xy(wks,time,temp,res)
>>
>>
>>
>>
>>
>> On Sat, Nov 11, 2017 at 8:39 PM, NB <nbarlow30 at gmail.com> wrote:
>>
>>> I'm running NCL 6.4.0, OpenDAP enabled, in a linux environment.
>>>
>>> I want to make a basic xy graph, using .asiii files from NCEP's NOMADS
>>> server.
>>>
>>> Here is the beginning of my script:
>>> ------------------------------------------
>>>
>>> *;Query and download for tmp2m, times, lat, lon*
>>> plot = systemfunc("wget http://nomads.ncep.noaa.gov:90
>>> 90/dods/hrrr/hrrr20171111/hrrr_sfc_23z.ascii?tmp2m[0:18][808][412] -O
>>> /usr/local/ncl/data/hrrr")
>>>
>>> *;Read .asciifile*
>>> f1 = asciiread("/usr/local/ncl/data/hrrr",-1,"float")
>>>
>>> *;Define tmp2m array*
>>> temp = f1(6:60:3)
>>> print(temp)
>>>
>>> Variable: temp
>>> Type: float
>>> Total Size: 76 bytes
>>>             19 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes:   [19]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>   _FillValue :  9.96921e+36
>>> (0)     273.0365
>>> (1)     272.9575
>>> (2)     272.2889
>>> (3)     271.8959
>>> (4)     271.7046
>>> (5)     271.8002
>>> (6)     272.0746
>>> (7)     272.3098
>>> (8)     272.1751
>>> (9)     272.0324
>>> (10)    271.9301
>>> (11)    271.9724
>>> (12)    271.9315
>>> (13)    271.8347
>>> (14)    271.7155
>>> (15)    271.5002
>>> (16)    271.3636
>>> (17)    271.5006
>>> (18)    272.4438
>>>
>>> *;Define time array*
>>> time = f1(62:80)
>>> print(time)
>>>
>>> Variable: time
>>> Type: float
>>> Total Size: 76 bytes
>>>             19 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes:   [19]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>   _FillValue :  9.96921e+36
>>> (0)     736645.9
>>> (1)     736646
>>> (2)     736646.1
>>> (3)     736646.1
>>> (4)     736646.1
>>> (5)     736646.2
>>> (6)     736646.2
>>> (7)     736646.2
>>> (8)     736646.3
>>> (9)     736646.3
>>> (10)    736646.4
>>> (11)    736646.4
>>> (12)    736646.4
>>> (13)    736646.5
>>> (14)    736646.6
>>> (15)    736646.6
>>> (16)    736646.6
>>> (17)    736646.7
>>> (18)    736646.7
>>>
>>> *;Convert Time to **YYYYMMDDHH*
>>> time at units = "days since 1-1-1 00:00:0.0"
>>> xtime = cd_calendar(time,3)
>>> print(xtime)
>>>
>>> Variable: xtime
>>> Type: double
>>> Total Size: 152 bytes
>>>             19 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes:   [19]
>>> Coordinates:
>>> Number Of Attributes: 2
>>>   _FillValue :  9.969209968386869e+36
>>>   calendar :    standard
>>> (0)     2017111122 <(201)%20711-1122>
>>> (1)     2017111200 <(201)%20711-1200>
>>> (2)     2017111201 <(201)%20711-1201>
>>> (3)     2017111201 <(201)%20711-1201>
>>> (4)     2017111203 <(201)%20711-1203>
>>> (5)     2017111204 <(201)%20711-1204>
>>> (6)     2017111204 <(201)%20711-1204>
>>> (7)     2017111206 <(201)%20711-1206>
>>> (8)     2017111207 <(201)%20711-1207>
>>> (9)     2017111207 <(201)%20711-1207>
>>> (10)    2017111209 <(201)%20711-1209>
>>> (11)    2017111210 <(201)%20711-1210>
>>> (12)    2017111210 <(201)%20711-1210>
>>> (13)    2017111212 <(201)%20711-1212>
>>> (14)    2017111213 <(201)%20711-1213>
>>> (15)    2017111213 <(201)%20711-1213>
>>> (16)    2017111215 <(201)%20711-1215>
>>> (17)    2017111216 <(201)%20711-1216>
>>> (18)    2017111216 <(201)%20711-1216>
>>> -----------------------------------------------------------
>>> I am able to make plots using gsn_csm_xy(wks,xtime,temp,res), but the
>>> x-axis tick spacing is always erratic. Sometimes, it will plot 2 values for
>>> the same time step. No  "res@" options seem to fix it.
>>>
>>> My question is - how do I deal with a time dimension like the one above?
>>> I have 2 arrays of equal size(time & temp), it seems that the coordinates
>>> should be easy to plot, but they're not. I've tried several conversion
>>> tactics via cd_calendar, but it doesn't solve it. I'd like the x-axis ticks
>>> to be "12z 11/Nov" for example.
>>>
>>>
>>>
>>> Thanks in advance,
>>>
>>> nick
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>> _______________________________________________
>> 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/20171112/a3005950/attachment.html>


More information about the ncl-talk mailing list