爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5556|回复: 0

怎么把添加的地形填充成透明

[复制链接]
发表于 2017-4-13 16:25:46 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
在处理WRF的结果时,由于wrf自带的边界比较模糊,所以自己重新弄了一套边界,但是叠加上去的时候会把原来的内容覆盖掉,不知道怎么把填充的部分设置成透明,或者只填充边界呢,希望大神们可以提供帮助。下面是代码:
These files are 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/wrf/WRFUserARW.ncl"
;load "/home/xiaom/chinamap/cnmap/cnmap.ncl"

begin
;---Open WRF output file.
  dir      = "/home/xiaom/WRF/ncl_plot/"
  filename = "wrfout_d02_2011-12-10_00:00:00"
  a = addfile(dir + filename + ".nc","r")

;---Read terrain height and lat/lon off file.
  it        = 20     ; first time step
  hgt       = wrf_user_getvar(a,"V10",it)    ; Terrain elevation
  hgt@lat2d = wrf_user_getvar(a,"XLAT",it)   ; latitude/longitude
  hgt@lon2d = wrf_user_getvar(a,"XLONG",it)  ; required for plotting

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

;---Set some basic plot options
  res               = True
  res@tiMainString  = "WRF"
  res@gsnMaximize   = True   ; maximize plot in frame
  res@cnFillOn      = True  
  res@cnFillPalette = "OceanLakeLandSnow"
  res@cnLinesOn     = False

  res@mpProjection  = "CylindricalEquidistant"    ; The default

  res@gsnAddCyclic  = False


;---Zoom in on plot
  res@mpMinLatF     = min(hgt@lat2d)
  res@mpMaxLatF     = max(hgt@lat2d)
  res@mpMinLonF     = min(hgt@lon2d)
  res@mpMaxLonF     = max(hgt@lon2d)

;---Additional resources desired
  res@pmTickMarkDisplayMode = "Always"   ; nicer tickmarks

  res@mpDataBaseVersion     = "MediumRes"       ; better and more map outlines
  res@mpDataSetName         = "Earth..4"
  res@mpOutlineBoundarySets = "AllBoundaries"
  res@mpOutlineOn           = True

  res@lbOrientation         = "Vertical"
  res@tiMainOffsetYF        = -0.03           ; Move the title down

;---Change contour levels to better match the color map being used
  res@cnLevelSelectionMode = "ExplicitLevels"
  res@cnLevels = (/-10,-8,-6,-4,-2,0,2,4,6,8/)

  plot=gsn_csm_contour_map(wks,hgt,res)

;
; This is for debugging purposes only. It shows what map resources the
; wrf_map_overlays routine would have use, if you had called that routine
; to do the plotting. This can be useful if you are trying to reproduce
; an original WRF-ARW plot.
;

AttachShape= 1
  shres=True
if (AttachShape.eq.1)
  dir       ="/home/xiaom/WRF/ncl_plot/Data/"
  filenames =(/"prlPoly.shp","prl.shp"/)
  nfiles    =dimsizes(filenames)
  filenames =dir+filenames +".shp"

;set an array of fill or line color indexes for polygons or polyline
; res@gsColors="black"

  shres@gsLineColor   = "brown"
  shres@gsLineThicknessF = 0.1
  shres@gsMarkerIndex = 16
  shres@gsMarkerColor = "green"

  ; ture on line of polygons
  shres@gsEdgesOn = False
  shres@gsEdgeColor ="brown"
  shres@gsEdgeThicknessF =0.1
  shres@gsFillColor ="white"
  shres@gsFillColor =0

  print("Adding polygons...")
  poly0 = gsn_add_shapefile_polygons(wks,plot,filenames(0),shres)
  print("Adding polylines...")
  poly1 = gsn_add_shapefile_polylines(wks,plot,filenames(1),shres)
  ;print("Adding polymarkers...")
  ;poly1 = gsn_add_shapefile_polymarkers(wks,map(2),filenames(2),pres)
end if

draw(plot)
frame(wks)
end  

wrf_gsn.000002.png
wrf_gsn.000001.png
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表