爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4225|回复: 1

mask出中国区域有错误

[复制链接]

新浪微博达人勋

发表于 2016-1-23 16:22:23 | 显示全部楼层 |阅读模式
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

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-1-23 16:23:29 | 显示全部楼层
不好意思,不是mask函数,是用mask的程序语句
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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