<div dir="ltr"><div><div><div><div>Hi,<br><br>Two things might help:<br><br></div>i) I'd try drawing the larger, circle markers before the colored markers to get the overlay affect.<br><br></div>ii) The units for the resource gsMarkerSizeF are NDC space (normalized device coordinates, which range between zero and one). So a value of 10 is enormous. It looks like you are using the default for the colored markers, which is .007. Perhaps try a value of .01 for the outer circles. You'll like have to experiment with this.<br><br></div>Hope that helps...<br></div>Rick<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 30, 2018 at 12:35 PM, Tabish Ansari <span dir="ltr"><<a href="mailto:tabishumaransari@gmail.com" target="_blank">tabishumaransari@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Hi<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I want to plot surface station data on top of a WRF contour map. I want the polymarkers to be circled with a black border - there's no polymarker that can do this at the moment. So, I'm trying to plot gsmarker=4 type hollow markers on top of solid coloured polymarkers (gsmarker=16) but unable to achieve the desired result.<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Here's my script:<br><span style="font-family:comic sans ms,sans-serif"><i><font size="1">load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_code.ncl"<br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_csm.ncl"<br>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/wrf/WRFUserARW.ncl"<br><br>;-----------------------------<wbr>------------------------------<wbr>-----------<br>; Procedure to attach colored markers to an NCL map, given 1D<br>; data, and lat/lon arrays, a set of levels, and a color map.<br>;-----------------------------<wbr>------------------------------<wbr>-----------<br>procedure add_obs_markers_to_map(wks,<wbr>plot,levels,colormap,data_1d,<wbr>lat_1d,lon_1d)<br>local mkres, nlevels, colors, nlevels, n, ii<br>begin<br><br>;---Set resources for the markers<br> mkres = True<br> mkres@gsMarkerIndex = 16<br>;<br>; Based on the levels we had for the contour plot and the colormap used,<br>; get an array of colors that span the colormap. This uses the same<br>; algorithm that the contour used, so the colors will be identical.<br>;<br> nlevels = dimsizes(levels)<br> colors = span_color_rgba(colormap,<wbr>nlevels+1) ; Need one more color than number of levels<br><br>;<br>; Loop through each level, gather all the data values in the given level<br>; range, and add colored markers to the existing map.<br>;<br> do n=0,nlevels<br><br>;---These "if" statements are how color contours are handled in NCL.<br> if(n.eq.0) then<br> ii := ind(data_1d.lt.levels(n))<br> else if(n.eq.nlevels) then<br> ii := ind(data_1d.ge.levels(n-1))<br> else<br> ii := ind(data_1d.ge.levels(n-1).<wbr>and.data_1d.lt.levels(n))<br> end if<br> end if<br> if(any(ismissing(ii))) then<br> continue<br> end if<br><br>;---Add the markers<br> mkres@gsMarkerColor = colors(n,:) ; colors is an N x 4 array<br> plot@$unique_string("markers")<wbr>$ = gsn_add_polymarker(wks,plot,<wbr>lon_1d(ii),lat_1d(ii),mkres)<br> end do<br>end<br><br>;-----------------------------<wbr>------------------------------<wbr>-----------<br>; Main code<br>;-----------------------------<wbr>------------------------------<wbr>-----------<br>begin<br><br>;---Open WRF output file and read data<br><br> DATADir = "/data2/tabish/control-run-<wbr>so4-ECMWF/"<br>FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d03_2014-10* ")<br>numFILES = dimsizes(FILES)<br><br>s=1<br>a = addfile(FILES(0)+".nc","r"); THIS IS JUST FOR INITIALIZATION OF PM25 ARRAY, IT WILL BE SUBSTRACTED FROM THE SUM IN THE END<br>pm25init = a->PM2_5_DRY(15,0,:,:)<br>pm25sum = pm25init<br>times = wrf_user_getvar(a,"times",-1) ; get all times in the file<br>ntimes = dimsizes(times)<br>do it = 16,ntimes-1,1 ; TIME LOOP<br> s=s+1<br> print("Working on time: " + times(it) )<br> pm25sum = pm25sum + a->PM2_5_DRY(it,0,:,:)<br>end do ; END OF TIME LOOP<br><br>do ifil = 1,numFILES-2 ; FILE LOOP<br> a = addfile(FILES(ifil)+".nc","r")<wbr> ; Open the next file<br> times = wrf_user_getvar(a,"times",-1) ; get all times in the file<br> ntimes = dimsizes(times)<br> do it = 0,ntimes-1,1 ; TIME LOOP<br> s=s+1<br> print("Working on time: " + times(it) )<br> pm25sum = pm25sum + a->PM2_5_DRY(it,0,:,:)<br> end do ; END OF TIME LOOP<br>end do<br><br>a = addfile(FILES(numFILES-1)+".<wbr>nc","r") ; Open the next file<br> times = wrf_user_getvar(a,"times",-1) ; get all times in the file<br> ntimes = dimsizes(times)<br> do it = 0,16,1 ; TIME LOOP<br> s=s+1<br> print("Working on time: " + times(it) )<br> pm25sum = pm25sum + a->PM2_5_DRY(it,0,:,:)<br> end do ; END OF TIME LOOP<br><br>pm25_avg= pm25sum/s<br>;pm25_avg@description = "NO2 conc in ppbv"<br><br> lat2d = wrf_user_getvar(a,"XLAT",it) ; latitude/longitude<br> lon2d = wrf_user_getvar(a,"XLONG",it)<br><br> pm25_avg@lat2d = lat2d ; for plotting<br> pm25_avg@lon2d = lon2d<br><br>;---Will use this for contours and filled markers<br> colormap = "BlAqGrYeOrReVi200"<br> levels = ispan(0,150,15)<br>; levels = (/0,10,20,30,40,50,60,70,80,<wbr>90,100,125,150,175,200,225,<wbr>250/) * 0.01<br><br> wks = gsn_open_wks("x11","wrf_obs_<wbr>d03_12-31octmean_pm25")<br><br>;---Common resources shared by both contour plot and marker plot<br> res = True<br> res@gsnMaximize = False<br> res@gsnLeftString = ""<br> res@gsnRightString = ""<br><br> res@mpDataBaseVersion = "MediumRes"<br> ; res@mpFillOn = False<br> ; res@mpMinLatF = min(pm25_avg@lat2d)<br> ; res@mpMaxLatF = max(pm25_avg@lat2d)<br> ; res@mpMinLonF = min(pm25_avg@lon2d)<br> ; res@mpMaxLonF = max(pm25_avg@lon2d)<br> ; res@pmTickMarkDisplayMode = "Always" ; better map tickmarks<br><br> res@mpLimitMode = "Corners" ; choose range of map<br> res@mpLeftCornerLatF = 36.05806<br> res@mpLeftCornerLonF = 113.3356<br> res@mpRightCornerLatF = 42.4514<br> res@mpRightCornerLonF = 120.2583<br> res@mpProjection = "LambertConformal"<br> res@mpLambertParallel1F = 20<br> res@mpLambertParallel2F = 50<br> res@mpLambertMeridianF = 110<br><br>;---Resources for filled contour plot<br> cnres = res<br> cnres@cnFillOn = True<br> cnres@cnLevelSelectionMode = "ExplicitLevels"<br> cnres@cnLevels = levels<br> cnres@cnFillPalette = colormap<br> cnres@cnLinesOn = False<br> cnres@cnLineLabelsOn = False<br>; cnres@lbLabelBarOn = False ; will add in panel later<br> cnres@pmTitleZone = 2 ; move title down<br> cnres@gsnAddCyclic = False<br><br> cnres@mpLimitMode = "Corners" ; choose range of map<br> cnres@mpLeftCornerLatF = 36.05806<br> cnres@mpLeftCornerLonF = 113.3356<br> cnres@mpRightCornerLatF = 42.4514<br> cnres@mpRightCornerLonF = 120.2583<br> cnres@mpProjection = "LambertConformal"<br> cnres@mpLambertParallel1F = 20<br> cnres@mpLambertParallel2F = 50<br> cnres@mpLambertMeridianF = 110<br> cnres@mpFillOn <wbr> = True<br> cnres@mpOutlineDrawOrder <wbr> = "PostDraw"<br> cnres@mpFillDrawOrder <wbr> = "PreDraw"<br> ; cnres@mpOutlineBoundarySets <wbr> = "National"<br> cnres@mpOutlineBoundarySets <wbr> = "Allboundaries"<br> cnresmpNationalLineColor = "Black"<br> cnresmpGeophysicalLineColor = "Black"<br> cnres@mpUSStateLineDashPattern<wbr> = 2<br> cnres@mpOutlineOn = True<br> cnres@mpDataBaseVersion = "MediumRes"<br> cnres@mpDataSetName = "Earth..4" ; U.S. counties<br> cnres@mpGridAndLimbOn = True<br> cnres@mpGridLineColor = "Black"<br> cnres@mpFillColors = (/"transparent","transparent",<wbr>"gray","transparent"/)<br> cnres@pmTickMarkDisplayMode = "Always"<br> cnres@tiMainString = "WRF model data"<br> cnres@tiDeltaF = 3.3<br> cnres@tfDoNDCOverlay = True<br><br> cnres@gsnDraw = False ; don't draw<br> cnres@gsnFrame = False ; don't advance frame<br>print(res)<br>;---Create smooth contour plot<br> plot_wrf = gsn_csm_contour_map(wks,pm25_<wbr>avg,cnres)<br><br>;-----------------------------<wbr>------------------------------<wbr>-----------<br>; Recreate similar plot, but by using filled markers drawn over a map.<br>;-----------------------------<wbr>------------------------------<wbr>-----------<br> fname = "surfacedata_12-31_Octmean_<wbr>improved.txt"<br> lines = asciiread(fname,-1,"string")<br> lon = tofloat(str_get_field(lines(:)<wbr>,2," "))<br> lat = tofloat(str_get_field(lines(:)<wbr>,3," "))<br> pm25 = tofloat(str_get_field(lines(:)<wbr>,4," "))<br><br>;---Create a map plot for adding markers to.<br> res@gsnDraw = False<br> res@gsnFrame = False<br> res@tfPolyDrawOrder = "Draw" ; Necessary to make sure filled markers drawn *under* map outlines<br> res@tiMainString = "'Observational' data"<br><br> res@mpFillOn <wbr> = True<br> res@mpOutlineDrawOrder <wbr> = "PostDraw"<br> res@mpFillDrawOrder <wbr> = "PreDraw"<br> ; res@mpOutlineBoundarySets <wbr> = "National"<br> res@mpOutlineBoundarySets <wbr> = "Allboundaries"<br> res@mpUSStateLineDashPattern <wbr> = 2<br> res@mpOutlineOn = True<br> res@mpDataBaseVersion = "MediumRes"<br> res@mpDataSetName = "Earth..4" ; U.S. counties<br> ; res@mpGridAndLimbOn = True<br> res@mpFillColors = (/"transparent","transparent",<wbr>"gray","transparent"/)<br> res@pmTickMarkDisplayMode = "Always"<br> res@tiMainString = "Surface data"<br><br> ;plot_obs = gsn_csm_map(wks,res)<br><br>;---Add colored markers to the map<br> add_obs_markers_to_map(wks,<wbr>plot_wrf,levels,colormap,pm25,<wbr>lat,lon)<br><br>;*****************************<wbr>************<br>; add black circles over obs data<br>;*****************************<wbr>************<br> polyres = True ; poly marker mods desired<br> polyres@gsMarkerIndex = 4 ; choose circle as polymarker<br> polyres@gsMarkerSizeF = 10.0 ; select size to avoid streaking<br> polyres@gsMarkerColor = (/"black"/) ; choose color<br> gsn_polymarker(wks,plot_wrf,<wbr>lat,lon,polyres) ; draw polymarkers<br><br><br><br>;---This draws the map with the filled markers<br> draw(plot_wrf)<br> frame(wks)<br><br>end</font></i></span><br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br><br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Please let me know if that's possible.<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thanks<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Tabish<br><br clear="all"></div><div><div class="m_873158865031195519gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></div></div>
</div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>