polymarker on contour

From: Alexander Cohan <cohan_at_nyahnyahspammersnyahnyah>
Date: Mon Oct 07 2013 - 15:04:57 MDT

Hello NCL,

I am having trouble adding a polymarker to a contour plot. I am
using gsn_csm_contour_map and gsn_add_polymarker. I have NCL version
6.1.2. The contour plot displays with no polymarker. My ncl script is
below. Any idea why this is not working?

Thanks!
Alex

;*******************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
begin
;********************************************
; get environment variables
;********************************************
  PT = getenv("PNT")
  contmax = getenv("CMAX")
  dcont = getenv("CDEL")
  plat = stringtofloat(getenv("CLAT"))
  plon = stringtofloat(getenv("CLON"))

;*******************************************
; open file and read in data
;*******************************************
  fname = new((/3/),string)
  txt2 = new((/3/),string)
  skipl = new((/3/),integer)
  ncols = new((/3/),integer)
  ndat = new((/3/),integer)

  fname(0) = "../CAMx/DDM.8hrO3.ILSCREEN_DDM_" + PT + ".txt"
  fname(1) = "../HDDM/O3IMPACT_" + PT + "_HDDM.dat"
  fname(2) = "../MODEL/DATA/O3IMPACT_" + PT + "_22.dat"

  skipl(0) = 6
  skipl(1) = 0
  skipl(2) = 0

  ncols(0) = 11
  ncols(1) = 3
  ncols(2) = 3

  ndat(0) = 3
  ndat(1) = 2
  ndat(2) = 2

  fname2 = "IL_4KMb.DOM"
  nlines2 = stringtointeger(systemfunc("awk 'END{print NR}' < " + fname2
+""))
  lines2 = readAsciiTable(fname2, 6, "float", 0)

  O3 = new((/nlines2/),float)
  lat = new((/nlines2/),float)
  lon = new((/nlines2/),float)

  do i=0,nlines2-1
   lat(i)=lines2(i,4)
   lon(i)=lines2(i,5)
  end do

  delete(lines2)
  delete(fname2)

; sig figures
  N1 = 1000.
  N2 = 10.

;
;set res
;
wks_type = "pdf"
;wks_type = "png"
;wks_type@wkOrientation = "landscape"

  wks = gsn_open_wks (wks_type, "8hrO3.CONTOUR.ALL." + PT + "")
; gsn_define_colormap (wks,"abby") ; choose color map
  gsn_define_colormap(wks,"WhViBlGrYeOrRe")
; gsn_reverse_colormap(wks)

  map = new(3,graphic)
  mark = new(3,graphic)
  mark2 = new(3,graphic)
  dummy = new(1,graphic)

  res = True ; plot mods desired
  res@gsnDraw = False
  res@gsnFrame = False
  res@mpDataBaseVersion = "Ncarg4_1"
  res@mpOutlineOn = True
  res@mpOutlineBoundarySets = "GeophysicalandUSStates"

  res@gsnSpreadColors = True
  res@gsnSpreadColorEnd = 90
  res@pmTickMarkDisplayMode = "Always"

  res@cnLineLabelPlacementMode = "Constant"
  res@cnLineDashSegLenF = 0.3

  res@cnLevelSelectionMode = "ManualLevels"
  res@cnMinLevelValF = dcont
  res@cnMaxLevelValF = contmax
  res@cnLevelSpacingF = dcont

  res@cnFillOn = True ; color fill
  res@cnLinesOn = False ; no contour lines
  res@cnLineLabelsOn = False ; no contour labels

  res@cnInfoLabelOn = False ; no contour info label

  res@sfXArray = lat
  res@sfYArray = lon

; !!!!! any plot of data that is on a native grid, must use the "corners"
; method of zooming in on map.

  lat1=min(lat)
  lat2=max(lat)
  lon1=min(lon)
  lon2=max(lon)

  res@mpLimitMode = "Corners" ; choose range of map
  res@mpLeftCornerLatF = lat1+DDY
  res@mpLeftCornerLonF = lon1+DDX
  res@mpRightCornerLatF = lat2-DDY
  res@mpRightCornerLonF = lon2-DDX

  res@mpFillOn = False

; The following 4 pieces of information are REQUIRED to properly display
; data on a native lambert conformal grid. This data should be specified
; somewhere in the model itself.

  res@mpProjection = "LambertConformal"
  res@mpLambertParallel1F = 33.
  res@mpLambertParallel2F = 45.
  res@mpLambertMeridianF = -97.
  res@tfDoNDCOverlay = True

  res@lbLabelBarOn = False ; turn off individual cb's

;marker info
  pmres = True
; pmres@gsMarkerIndex = 1
  pmres@gsMarkerIndex = 5
  pmres@gsMarkerColor = (/"black"/)
; pmres@gsMarkerColor = (/"red"/)
  pmres@gsMarkerSizeF = 5.
  pmres@gsLineThicknessF = 10.0
  pmres@gsFillColor = "Black"
  pmres@txFontHeightF = 10

  pmres@mpProjection = "LambertConformal"
  pmres@mpLambertParallel1F = 33.
  pmres@mpLambertParallel2F = 45.
  pmres@mpLambertMeridianF = -97.
; pmres@tfDoNDCOverlay = True

;
; begin main loop
;
  do III=0,2

  nlines = stringtointeger(systemfunc("awk 'END{print NR}' < " + fname(III)
+""))
  nlines2 = nlines - skipl(III)

  dat = readAsciiTable(fname(III), ncols(III), "float", skipl(III))

  do i=0,nlines2-1
   O3(i)=dat(i,ndat(III))
  end do

  MO3=max(O3)
  IIII=maxind(O3)
  MLAT=lat(IIII)
  MLON=lon(IIII)
  MMO3=inttoshort(floattoint(MO3*N1))/N1
  MMLAT=inttoshort(floattoint(MLAT*N2))/N2
  MMLON=inttoshort(floattoint(MLON*N2))/N2

  txt2(III) = "O~B~3~N~ 8-hr Max Source Impact "+MMO3+" ppb ("+MMLAT+",
"+MMLON+")"

  delete(dat)

;*******************************************
; plot data
;*******************************************

  map(III) = gsn_csm_contour_map(wks,O3,res)
  mark(III) = gsn_add_polymarker(wks, map(III), plat, plon, pmres)

  end do

;*************************************************
; create panel
;*************************************************
  resP = True ; modify the panel plot
  resP@gsnFrame = False ; don't advance panel plot
  resP@gsnPanelLabelBar = True ; add common colorbar
  resP@lbLabelFontHeightF = 0.01
  resP@gsnPanelBottom = 0.02
  resP@txFontHeightF = 0.015
  resP@gsnPanelBottom = 0.05 ; add space at bottom

  gsn_panel(wks,map,(/1,3/),resP) ; now draw as one plot

  txt = "O~B~3~N~ 8-hr Max Impact (ppb)"
  txres = True
  txres@txFontHeightF = 0.02
  gsn_text_ndc(wks,txt,0.5,.25,txres)

  txres@txFontHeightF = 0.0085
  ZZZ=0.801
  gsn_text_ndc(wks,txt2(0),1./6.,ZZZ,txres)
  gsn_text_ndc(wks,txt2(1),1./2.,ZZZ,txres)
  gsn_text_ndc(wks,txt2(2),5./6.,ZZZ,txres)

; drawNDCGrid(wks)

  frame(wks)

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Oct 7 15:05:28 2013

This archive was generated by hypermail 2.1.8 : Tue Oct 22 2013 - 10:35:27 MDT