- 积分
- 1210
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-7-2
- 最后登录
- 1970-1-1
![[Frankie-李佳阳] 粉丝数:454 微博数:1801 新浪微博达人勋](source/plugin/sina_login/img/light.png)
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
家园的各位高手,我利用shapefile文件来做了mask,我定义了colormap为系统自带的“BlRe”,做出如下图,我想设置mask部分(箭头部分)的颜色,因为和图中的颜色太相近了,请问该如何设置呢?
代码如下,用gc_inout做的,也是家园的小伙伴指导的,希望指点一下,有什么方法可以设置?
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/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
begin
; -----------------------------------------------
; open file and read in data 整个中国版
; -----------------------------------------------
files=systemfunc("ls wrfout_d02*")
f=addfiles(files, "r")
b=addfile("./wrfout_d02_2010-01-02_00:00:00", "r")
;printVarSummary(files)
; -----------------------------------------------
; Read character variable Times; Convert to string for plots
; Read vertical coordinate for plot labels
; -----------------------------------------------
;Times = chartostring(f->Times) ; built-in function
; -----------------------------------------------
; Read 10 meter winds
; -----------------------------------------------
t=wrf_user_getvar(f, "T2", -1)
s = dim_avg_n(t, 0)
printVarSummary(s)
s@long_name = "Surface Temperature: 2m"
s=s-273.16
s@description="Surface Temperature"
s@units="C"
s@lat2d = b->XLAT(0,:,:) ; direct assignment
s@lon2d = b->XLONG(0,:,:)
s@_FillValue = 255.
; ----------------------------------------------
; Get the national boundary from a shapefile.
; We'll use this as a mask for the data.
; ----------------------------------------------
natBdry = addfile("./Mainland_of_China.shp", "r")
maskedS = new(dimsizes(s),typeof(s),s@_FillValue)
maskedS@lat2d = s@lat2d
maskedS@lon2d = s@lon2d
; Get the size of the lat/lon grid of variable "s"
sDims = dimsizes(s)
iNumLat = 96 ;这里直接用数值来确定经纬的格子
iNumLon = 69 ;每个区域的范围都是不同的
; Put data in the areas that we don't want masked.
do j=0,iNumLat-1
print("masking row " + j)
do i=0,iNumLon-1
if(gc_inout(b->XLAT(0,j,i), b->XLONG(0,j,i), natBdry->y, natBdry->x)) then
maskedS(j,i) = s(j,i)
end if
end do
end do
; -----------------------------------------------
; create plots
; -----------------------------------------------
wks = gsn_open_wks("png" ,"ncl_tempreture_mask") ; send graphics to PNG file
; We want a very specific colormap...
gsn_define_colormap(wks, "BlRe")
res = True ; plot mods desired
res@gsnFrame = False
res@gsnDraw = False
res@gsnMaximize = True
;res@cnLevelSelectionMode = "ExplicitLevels"
;res@cnLevels = (/-24,-22,-20,-18,-16,-14,-12,-10,-8,-6,-4,-2/)
;res@cnMinLevelValF = -28
;res@cnMaxLevelValF = 0
res@cnFillOn = True ; color plot desired
res@cnLinesOn = False ; turn off contour lines
res@cnLineLabelsOn = False ; turn off contour labels
; -----------------------------------------------
; Set map extent to zoom in on JJJ
; -----------------------------------------------
res@mpMinLonF = 72.
res@mpMaxLonF = 138.
res@mpMinLatF = 18.
res@mpMaxLatF = 55.
res@mpGeophysicalLineColor = 1
res@mpOceanFillColor = 2 ; color for sea
res@mpLandFillColor = 3 ; color for land outside of borders
res@mpOutlineBoundarySets = "Geophysical" ; draw coastlines for entire region
res@mpGridAndLimbOn = True
res@mpGridLineColor = (/ .25, .25, .25 /)
res@mpGridLatSpacingF = 4.0
res@mpGridLonSpacingF = 4.0
; ----------------------------------------------
; Turn on lat / lon labeling
; ----------------------------------------------
res@pmTickMarkDisplayMode = "Always" ; turn on tickmarks
res@tmXTOn = False ; turn off top labels
res@tmYROn = False ; turn off right labels
nt = 0
;;do nt=0,ntim-1 ; uncomment for loop
;; do ll=0,klev-1
;res@tiMainString = Times(nt)
res@lbLabelBarOn = True
plot = gsn_csm_contour_map(wks,maskedS(:,:),res)
;; end do
;;end do
draw(plot)
frame(wks)
end
|
-
|