[ncl-talk] Failed to mask a province of China

wyp wyp__mj at 126.com
Tue Aug 3 20:10:15 MDT 2021


Dear all:
I have failed to draw a color filled contour field  over the area specified in mpFillAreaSpecifiers,  but i can't figure out the reason.Please help me,thank you very much.


;*************************************************
; This file is loaded by default in NCL V6.2.0 and newer
  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"  
;************************************************
begin
;************************************************
; read in txt file
;************************************************
  fname = "./20210725_1200.txt"
  lines  = asciiread(fname,-1,"string")
  lon=stringtofloat(str_get_field(lines(0:),1," "))
  lat=stringtofloat(str_get_field(lines(0:),2," "))
  pre=stringtofloat(str_get_field(lines(0:),3," "))


;************************************************
; plotting parameters
;************************************************
  wks = gsn_open_wks("png","pre-19")             ; send graphics to PNG file
  gsn_define_colormap(wks,"WhViBlGrYeOrReWh")


  
  res                 = True 
  res at gsnDraw        = False
  res at gsnFrame       = False 
  res at gsnMaximize    = True 


;  res at gsnLeftString  = ""
;  res at gsnRightString = ""                 


;----map---------------------  
  res at mpMinLatF           = 30.                  
  res at mpMaxLatF           = 45.
  res at mpMinLonF           = 90.
  res at mpMaxLonF           = 110.


  res at mpFillOn                   = True
  res at mpDataSetName               = "Earth..4"
  res at mpDataBaseVersion           = "MediumRes"
  res at mpAreaMaskingOn            = True
  res at mpMaskAreaSpecifiers       = (/"China:states"/)
  res at mpOutlineSpecifiers        = (/"China:states"/)
    
  res at mpLandFillColor            = "white"
  res at mpInlandWaterFillColor     = "white"
  res at mpOceanFillColor           = "white"
  res at mpFillBoundarySets         = "NoBoundaries"
  res at mpOutlineBoundarySets      = "NoBoundaries"
  res at mpNationalLineColor        = "black"
  res at mpProvincialLineColor      = "black"
  res at mpGeophysicalLineColor     = "black"
  res at mpNationalLineThicknessF   = 2
  res at mpProvincialLineThicknessF = 1


;--contour------------------------
 
  res at cnFillOn                   = True
  res at cnFillDrawOrder            = "PreDraw"
  res at cnLinesOn                  = False
  res at cnLineLabelsOn             = False
  res at sfXArray            =lon
  res at sfYArray            =lat
  res at cnLevelSelectionMode = "ExplicitLevels"
  res at cnLevels             = (/0.1,1.0,5.0,10.0,20.0,30.0,40,50/)
  res at cnFillColors = (/"White","DarkOliveGreen1", \
                       "Chartreuse3","Green", \
                       "Yellow","Orange","Red","Violet"/)


  res at lbLabelAutoStride          = True
  res at pmTickMarkDisplayMode      = "Always"
  res at gsnRightString             = "mm"


;--full map-----------------------
  res at gsnLeftString              = "Precipitation"
  map = gsn_csm_contour_map(wks,pre,res) 
  draw(map)
  frame(wks)                                           
;--gansu-------------------------- 
  res at mpMaskAreaSpecifiers       = "Gansu"
  res at gsnLeftString              = "Precipitation"
  map2 = gsn_csm_contour_map(wks,pre,res) 
  draw(map2)
  frame(wks)
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210804/3ee3e205/attachment.html>


More information about the ncl-talk mailing list