- 积分
- 51
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-4-12
- 最后登录
- 1970-1-1
|
NCL
系统平台: |
|
问题截图: |
|
问题概况: |
用mask函数mask出中国区域,其他区域赋值缺测,程序运行无错误无warning,但是运行出来的nc文件用ncview查看,结果如图。想请教一下mask那里出错的原因,谢谢! |
我看过提问的智慧: |
看过 |
自己思考时长(天): |
5 |
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
完整程序:
;********************************************************
; Load NCL scripts
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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/skewt_func.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/wind_rose.ncl"
load "$GEODIAG_ROOT/geodiag.ncl"
; load语句载入了NCL常用的几个外部程序,建议以后自己写脚本时也保留这6行的内容。
;********************************************************
begin
latS = -90.
latN = 90.
lonL = 0.
lonR = 360.
ymStrt=199608
ymLast=200007
zmStrt=200410
zmLast=201507
system("rm -f /public/home/lzh/zm/AI/AI_mask_BC_199608-200007_200410-200507.nc")
fo = addfile ("/public/home/lzh/zm/AI/AI_mask_BC_199608-200007_200410-200507.nc", "c")
f = addfile ("/public/home/lzh/zm/AI/AI197811-200007_200410-201507_and-R-monthly.nc", "r")
time1 = f->time
lat = f->lat
lon = f->lon
AI = new((/178,180,288/),"float")
yStrt = ind(time1.eq.ymStrt)
yLast = ind(time1.eq.ymLast)
zStrt = ind(time1.eq.zmStrt)
zLast = ind(time1.eq.zmLast)
AI(0:47,:,:) = f->AI3D(yStrt:yLast,:,:)
AI(48:177,:,:) = f->AI3D(zStrt:zLast,:,:)
AI@long_name = "AI_mask_BC_199608-200007_200410-200507"
time = new(178,float)
time(0:47) = time1(yStrt:yLast)
time(48:177) = time1(zStrt:zLast)
;============MASK of China =====================================================
f = addfile("/public/home/lzh/zm/AI/EOF/china_map/china_outline_inland.shp", "r")
mrb_lon = f->x
mrb_lat = f->y
print(mrb_lon)
nmrb = dimsizes(mrb_lon)
min_mrb_lat = min(mrb_lat)
max_mrb_lat = max(mrb_lat)
min_mrb_lon = min(mrb_lon)
max_mrb_lon = max(mrb_lon)
; Get the approximate index values that contain the area of interest.
; This will make our gc_inout loop below go faster, because we're
; not checking every single lat/lon point to see if it's within
; the area of interest.
ilt_mn = ind(min_mrb_lat.gt.lat(:))
ilt_mx = ind(max_mrb_lat.lt.lat(:))
iln_mn = ind(min_mrb_lon.gt.lon(:))
iln_mx = ind(max_mrb_lon.lt.lon(:))
ilt1 = ilt_mn(dimsizes(ilt_mn)-1) ; Start of lat box
iln1 = iln_mn(dimsizes(iln_mn)-1) ; Start of lon box
ilt2 = ilt_mx(0) ; End of lat box
iln2 = iln_mx(0) ; End of lon box
;---set zero in the areas(as shape files refered to) we want to be masked.
do ilm=0,129
do ilt=ilt1,ilt2
do iln=iln1,iln2
if(.not.(gc_inout(lat(ilt),lon(iln),mrb_lat,mrb_lon))) then
AI (ilm,ilt,iln) =AI@_FillValue
end if
end do
end do
end do
;outpout the data
;***********************************************************
fo->AI = AI(:,:,:)
fo->lat = lat
fo->lon = lon
fo->time = time
end
|
|