[ncl-talk] XY plot from .ascii file

Dennis Shea shea at ucar.edu
Sun Nov 12 08:40:22 MST 2017


A matter of book keeping.
Try the attached. print statements can be removed, if desired.

Good luck

On Sat, Nov 11, 2017 at 6: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:
> 9090/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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171112/ed7a9096/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nomads.ncl
Type: application/octet-stream
Size: 1590 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171112/ed7a9096/attachment.obj>


More information about the ncl-talk mailing list