[ncl-talk] Plotting average station values on map
Bassill, Nicholas
nbassill at albany.edu
Tue Nov 28 11:35:48 MST 2017
Hi Emma,
I think you're trying to do something similar to what I try to do in real-time - maps like: <http://operations.nysmesonet.org/~nbassill/climate/index.php?climate=daily> http://operations.nysmesonet.org/~nbassill/climate/index.php?climate=weekly
Skipping to just the relevant parts of that code, it's something like (where delim = ","):
sitefile = "weekly.dat"
sitedata = asciiread(sitefile,-1,"string")
sitelats = tofloat(str_get_field(sitedata,1,delim))
sitelons = tofloat(str_get_field(sitedata,2,delim))
siteanom = tofloat(str_get_field(sitedata,3,delim))
size = dimsizes(sitelons)
<other stuff - maybe put your map stuff here>
;;;;;;;;;;;; this part tells the marker what color to be based on the anomaly
markercolors = new(size(0),"integer")
do n=0,size(0)-1,1
markercolors(n) = round((siteanom(n)*10),3)+127
end do
markercolors=where((markercolors.lt.17),17,markercolors)
markercolors=where((markercolors.gt.255),237,markercolors)
stationmarker = new(size(0),graphic)
do n=0,size(0)-1,1
mres = True ; marker resources for best track
mres at gsMarkerIndex = 16 ; marker style (filled circle)
mres at gsMarkerSizeF = 23.0 ; marker size
mres at gsMarkerColor = markercolors(n) ; marker color
mres at tfPolyDrawOrder= "PostDraw"
stationmarker(n) = gsn_add_polymarker(wks,plot,sitelons(n),sitelats(n),mres)
tres = True ; text mods desired
tres at tfPolyDrawOrder = "PostDraw"
tres at txFont = "helvetica-bold"
tres at txFontHeightF = 0.014
if any(siteanom.lt.-9.5)
tres at txFontHeightF = 0.011
end if
stationtext = gsn_add_text(wks,plot,round(siteanom(n),3),sitelons(n),sitelats(n),tres)
end do
<other stuff, like colorbar, text, etc.>
draw(plot)
This loops through and plots a color-coded dot, then adds the raw value on top of it later. Here, there's some trial and error involved when I calculate the markercolor for each station - it's an arbitrary (value*10 + 127), which fits in well with the color scheme, but it could just as easily be anything else.
Nick Bassill, PhD
Modeler & Meteorologist, New York State Mesonet
LC SB-28, 1400 Washington Ave.,
SUNY, University at Albany, NY 12222
(518) 442-6375
http://nysmesonet.org/
________________________________
From: ncl-talk <ncl-talk-bounces at ucar.edu> on behalf of Emma Nelson <enelson23 at wisc.edu>
Sent: Tuesday, November 28, 2017 1:07 PM
To: ncl-talk at ucar.edu
Subject: [ncl-talk] Plotting average station values on map
Hi,
I have monthly averages of ozone data and am trying to figure out how to plot them with different colors given a certain range. The only examples I can find are using dummy data, and I'm having trouble figuring out how to apply this to actual data.
My averages are:
average1 = 37.62
average2 = 39.49
average3 = 36.36
I want to display these values as different colors. For example, I want one color for values less than 37, one between 37 and 39, and one greater than 39. Here is what I've tried:
arr = (/0.,37.,39./)
do i = 0, num_distinct_markers-1
if (i.eq.0) then
indexes = ind(average3.lt.arr(37))
labels(i) = "x < " + arr(37)
end if
if (i.eq.num_distinct_markers-1) then
indexes = ind(average2.gt.arr(39))
labels(i) = "x > " + arr(39)
end if
if (i.gt.arr(37).and.i.lt.arr(39)) then
indexes = ind(average1.gt.arr(37).and.average1.lt.arr(39))
labels(i) = arr(37) + "< x < " + arr(39)
end if
end do
I'm pretty sure most of this is wrong, but I don't know what a lot of the functions mean, so any help would be appreciated!
Thanks,
Emma Nelson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171128/d591dc16/attachment.html>
More information about the ncl-talk
mailing list