[ncl-talk] country border westerly shifted

LSL lslrsgis at whu.edu.cn
Thu May 9 02:35:43 MDT 2019


Dear NCL Community,


I am writing for a question on country borders. It seems that the 
land/sea, country borders were shifted westerly, not correct, strange!


The script and plot are attached. Any help is appreciated.


Thanks,


LSL

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190509/693e9a2f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: landuse.png
Type: image/png
Size: 214436 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190509/693e9a2f/attachment.png>
-------------- next part --------------
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
;  f0=addfile("/ees/users/EMG/chang/wrf/WPS/geo_em.d03.nc","r")
;  lon=f0->XLONG(0,:,:)
;  lat=f0->XLAT(0,:,:)
  f0=addfile("/home/lsl/Downloads/TEMP/geogrid_original/geo_em.d01.nc","r")
;   f0=addfile("/ees/users/EMG/zhiyong/wrfchem/3.4.1/WPS2/met_em.d01.2010-06-30_12:00:00.nc","r")
  lon=f0->XLONG_M(0,:,:)
  lat=f0->XLAT_M(0,:,:)
  lu=f0->LU_INDEX(0,:,:)
  lu at description = ""
  lu at units = ""
  lu at lat2d = lat
  lu at lon2d = lon
  printVarSummary(lon)
  printVarSummary(lat)
  printVarSummary(lu)

  info     = (/ " 1  Urban and Built-Up        ", \  ; n=0
                " 2  Dryland Cropland&Pasture  ", \
                " 3  Irrigated Cropland&Pasture", \
                " 4  Mixed Cropland and Pasture", \
                " 5  Cropland/Grassland Mosaic ", \
                " 6  Cropland/Woodland Mosaic  ", \
                " 7  Grassland                 ", \
                " 8  Shrubland                 ", \
                " 9  Mixed Shrubland/Grassland ", \
                "10  Savanna                   ", \
                "11  Deciduous Broadleaf       ", \
                "12  Deciduous Needleleaf      ", \
                "13  Evergreen Broadleaf       ", \
                "14  Evergreen Needleleaf      ", \
                "15  Mixed Forest              ", \
                "16  Water Bodies              ", \
                "17  Herbaceous Wetland        ", \
                "18  Wooded Wetland            ", \
                "19  Barren/Sparsely Vegetated ", \
                "20  Herbaceous Tundra         ", \
                "21  Wooded Tundra             ", \
                "22  Mixed Tundra              ", \
                "23  Bare Ground Tundra        ", \
                "24  Snow or Ice               "  /) ; n=23
colors     = (/ "white","black","purple", \  ; n=0
"coral", \      ;2
"coral2", \     ;3
"chocolate1", \ ;4
"lightgoldenrod1", \    ;5
"chocolate4", \         ;6
"darkolivegreen2", \                            ;7
"darkolivegreen1", \    ;8
"greenyellow", \                ;9
"darkolivegreen3", \
"green2", \
"darkkhaki", \
"darkolivegreen", \
"darkgreen", \
"limegreen", \
"blue", \ ; water; deepskyblue2
"orange1", \
"orange3", \
"gold1", \
"lightslategrey", \
"lightsteelblue2", \
"lightsteelblue1", \
"lightyellow3", \
"lightyellow1"  /) ; n=23

;************************************************
; create plot
;************************************************

  wks = gsn_open_wks("png","landuse")  

 ;colors = gsn_retrieve_colormap(wks)     ; retrieve color map for editing
 ;colors(2,:) = (/ 1.0, 1.0, 1.0 /)       ; replace 1st contour color with background
 gsn_define_colormap(wks,colors)     

  res                  = True               ; plot mods desired
  res at gsnDraw          = False
  res at gsnFrame         = False
  res at gsnMaximize      = True 
  res at gsnAddCyclic     = False              ; Don't add a cyclic point, important-zhiyong
  res at cnFillOn         = True               ; color Fill 
  res at cnFillMode       = "RasterFill"       ; Raster Mode
  res at cnLinesOn        = False              ; Turn off contour lines
  res at gsnMaximize         = True        ; must include w/ Paper Orientation

  res at cnLevelSelectionMode = "ExplicitLevels" ; set explict contour levels
  res at cnLevels         = integertobyte( ispan(2,24,1) )



  res at lbOrientation =   "vertical"          ; vertical label bar
  res at lbLabelPosition  = "Center"           ; label position
  res at lbLabelAlignment = "BoxCenters"       ; label orientation
  res at lbLabelStrings   = ispan(1,24,1)  

  res at pmLabelBarOrthogonalPosF = -0.08    ; move up smidge
  res at pmTickMarkDisplayMode = "Always"
 
  res at tmXBMode = "Automatic"
  res at tmYLMode = "Automatic"
  res at tmXTLabelsOn = False
  res at tmYRLabelsOn = False
  res at tmXTMajorLineColor  = 0
  res at tmYRMajorLineColor  = 0
 ; res at tmLabelAutoStride = True

  res at mpCenterLonF     = 0                  ; set map center
  res at mpFillOn         = False
  res at mpOutlineOn      = False              ; set default boundaries
  res at tfDoNDCOverlay   = True
;  res at mpLimitMode       = "LatLon"        ; method to zoom
  res at mpProjection      = "LambertConformal"
  res at mpLambertParallel1F = 25.0
  res at mpLambertParallel2F = 47.0
  res at mpLambertMeridianF  = 105.0        ; central meridian
  res at mpLimitMode         = "LatLon"
;  res at mpMinLatF           = min(lat)        ; map area
;  res at mpMaxLatF           = max(lat)         ; latitudes
;  res at mpMinLonF           = min(lon)       ; and
;  res at mpMaxLonF           = max(lon)        ; longitudes
;  res at mpLeftCornerLatF  = min(lat)
;  res at mpLeftCornerLonF  = min(lon)
;  res at mpRightCornerLatF = max(lat)
;  res at mpRightCornerLonF = max(lon)

 res at mpOutlineDrawOrder     = "PostDraw"  ; force map tp be drawn 1st
 res at mpGridLineDashPattern  = 2           ; lat/lon lines as dashed
 res at mpPerimOn              = True
 res at mpPerimDrawOrder       = "PostDraw"
 res at mpOutlineOn            = True
 res at mpGridAndLimbOn = True
 res at mpGridSpacingF = 10.
 res at pmTickMarkDisplayMode = "Always"
 res at tmXTLabelsOn = False
 res at tmYRLabelsOn = False

 res at mpOutlineBoundarySets = "National"
 res at mpGeophysicalLineThicknessF = 1.5
 res at mpDataBaseVersion = "MediumRes"
 res at mpDataSetName = "Earth..4"
; res at mpOutlineSpecifiers = "Australia:states"
 res at mpOutlineSpecifiers =  (/"China:states"/)


  res at sfXArray =lon
  res at sfYArray =lat
  
  res at mpMinLatF =  min(lat)
  res at mpMaxLatF =  max(lat)
  res at mpMinLonF =  min(lon)
  res at mpMaxLonF =  max(lon)
  
  res at tmXBMode = "Automatic"
  res at tmYLMode = "Automatic"
  res at tmXBLabelFontHeightF  = 0.01 

;  plot = gsn_csm_contour_map_ce(wks, lu, res) ; create plot
   plot = gsn_csm_contour_map(wks, lu, res)

;
;add text 
;
  rtxt = True
  rtxt at txJust        = "CenterLeft"
  rtxt at txFontHeightF = 0.011

                            ; 4 rows x 6 columns of text
  n  = -1
  xx = 0.05   
  do ncol=0,3
;     yy = 0.01 
      yy = 0.16
    do nrow=0,5
       n = n+1
       gsn_text_ndc (wks,info(n),xx,yy,rtxt)
       yy = yy - 1.5*rtxt at txFontHeightF
    end do
     xx = xx + 0.24 
  end do

;
;add boundaries
;
;  lonlat = asciiread("/ees/users/EMG/zhiyong/ncl/shengjie.dat",(/82750,2/),"float")
;  resp = True
;  resp at gsLineColor = "black"
;  resp at gsLineThicknessF = 1.5
;  polbou = gsn_add_polyline(wks,plot,lonlat(:,0),lonlat(:,1),resp)
;  delete(lonlat)
;  delete(resp)

;  lonlat = asciiread("/ees/users/EMG/zhiyong/ncl/diqujie.dat",(/32149,2/),"float")
;  resp = True
;  resp at gsLineColor = "black"
;  resp at gsLineThicknessF = 1.5
;  polbou2 = gsn_add_polyline(wks,plot,lonlat(:,0),lonlat(:,1),resp)
;  delete(lonlat)
;  delete(resp)

;  lonlat = asciiread("/ees/users/EMG/zhiyong/ncl/prd_boundary.dat",(/2626,2/),"float")
;  resp = True
;  resp at gsLineColor = "black"
;  resp at gsLineThicknessF = 3
;  polbou3 = gsn_add_polyline(wks,plot,lonlat(:,0),lonlat(:,1),resp)
;  delete(lonlat)
;  delete(resp)

  draw(plot)
  frame(wks)

;---------------------------------------------------------------------
; pure land/sea mask
;---------------------------------------------------------------------
;  y = lu                                     ; land sea mask
;  y = where (y.eq.integertobyte(16), integertobyte(0), integertobyte(1))
;  y = where (y.eq.17, 0, 1)                 ; this works too!

;  delete(res)

;  res                  = True                ; plot mods desired
;  res at gsnMaximize      = True 
;  res at gsnAddCyclic    = False

;  res at cnFillOn         = True               ; color Fill 
;  res at cnFillMode       = "RasterFill"       ; Raster Mode
;  res at cnLinesOn        =  False             ; Turn off contour lines

;  res at cnLevelSelectionMode = "ExplicitLevels" ; set explict contour levels
;  res at cnLevels         = (/1/)

;  res at lbLabelPosition  = "Center"           ; label position
;  res at lbLabelAlignment = "BoxCenters"       ; label orientation
;  res at lbLabelStrings   = (/ "0", "1"/)

;  res at mpCenterLonF     = 0                  ; set map center at 180
;  res at mpFillOn         = False

;  res at sfXArray =lon
;  res at sfYArray =lat

;  res at mpMinLatF = min(lat)
;  res at mpMaxLatF = max(lat)
;  res at mpMinLonF = min(lon)
;  res at mpMaxLonF = max(lon)

;  res at gsnLeftString  = "CERES: Pure Land-Sea Mask"

;  plot = gsn_csm_contour_map_ce(wks, y, res) ; create plot
;   plot = gsn_csm_contour_map(wks, y, res)
end



More information about the ncl-talk mailing list