爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6585|回复: 7

ncl运行请教

[复制链接]
发表于 2015-11-10 20:04:59 | 显示全部楼层 |阅读模式

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

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

x
ncl脚本运行遇到一些问题,终端提示如下
K_RO8RA_53GM74KJ9DQN3.png
不知哪位大神可以提示一下原因以及解决办法。
脚本如下(ps:该脚本为pop程序的脚本,如有做过pop的可否帮忙看看程序,谢谢!)
; ==============================================================
; POPanalysis: Calculate POPs
;              This is a user donated script.
;             *It is NOT supported software.
; ==============================================================
; Calculate POPs from SST data
; ==============================================================
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 "/home/gyy/pop/PrnOscPat_driver.ncl"    ; creates the POPs from EOFs
load "/home/gyy/pop/pltEofPop.ncl"      ; plot EOF/POP
load "/home/gyy/pop/pltClim.ncl"        ; plot climatology
; ==============================================================
;                      MAIN
; ==============================================================
  wcStrt = systemfunc("date")
  netCDF  = True                        ; create nc for POP
  dirNC   = "/home/gyy/pop/"                        ; dir for output nc
  pltDir  = "/home/gyy/pop/"                        ; dir for plots
  pltEOF  = True
  pltPOP  = True
  pltCLIM = True   
  
  pltType = "ps"
  pltName = "POP"
; ==============================================================
; User defined parameters that specify region of globe and time period
; ==============================================================
  latS   = 29.75   ; spatial domain
  latN   = 29.75
  lonL   = 30.25
  lonR   = 119.75

  kPOP   = 1    ; decide which POP we want to look at
  POPphase = (/"precursor","peak"/) ; (/ 0, 1/)
  yrStrt = 1958
  yrLast = 2008
  neof   = 10                           ; number of EOFs
  nPOP   = 2                         ; number of POPs
  optEOF = True      
  optETS = False
                              
  REDUCE = False                         ; reduce spatial density
  nskip  =  2                            ; only when REDUCE=True
  mskip  =  2
; ==============================================================
; Open the file
; ==============================================================
  patho  = "/home/gyy/pop/"                                         ; path for output  
  pathi  = "/home/gyy/pop/"                                         ; path to source
  ifile  = "SODA_SST.nc"
  varname= "temp"     ; variable name
  f      = addfile (pathi+ifile, "r")   ; entire file
; ==============================================================
; Read only the user specified period and region
; ==============================================================
  TIME   = f->time                                     ; ALL time on file
  YYYY   = cd_calendar(TIME,-1)/100   ; ALL years
  iYYYY  = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)  ; indices of year subset
  nTIME  = dimsizes(iYYYY)
                                                        ; read full year subset
  if (getfilevartypes(f, varname).eq."short") then      ; clarity
      DATA = short2flt(f->$varname$(iYYYY,:,:,:))         
  else
      DATA = f->$varname$(iYYYY,:,:,:)
  end if
  printVarSummary(DATA)                             ; variable overview
; ==============================================================
; If dataset longitudes are -180=>180, flip to (nominally) span 0=>360   
; Only if both'lonL' and 'lonR' are positive.
; ==============================================================
  if (lonL.ge.0 .and. lonR.gt.0 .and. DATA&lon(0).lt.0) then
      DATA    = lonFlip(DATA)    ; flip longitudes
     ;printVarSummary(DATA)  
  end if
; ==============================================================
; Subset to the time period (full years) and region of interest
; Optionally: reduce the grid point density for less memory.
; ==============================================================
  if (REDUCE) then
      data  = DATA(:,::nskip,{lonL:lonR:mskip})
  else
      data  = DATA(:,:,{lonL:lonR})
  end if
  delete(DATA)                                         ; reduce memory
  printVarSummary(data)                                ; data to be used
  
; ==============================================================
; Remove annual cycle from the data: create anomalies
; .  use only full years to find annual cycle
; ==============================================================  
  clim  = clmMonTLL(data)    ; calculcate climatology
;printVarSummary(clim)
  data  = calcMonAnomTLL(data, clim)   ; remove annual cycle
;printVarSummary(data)                                ; variable overview
  ntim  = dimsizes(data&time)   
; =================================================================
; remove linear trend in time:  data(time,lat,lon): time is dimension # 0)
; =================================================================
  data = dtrend_n(data, False, 0)
; =================================================================
; normalize data at each gridpoint by local standard deviation at each grid pt
; =================================================================
  data = dim_standardize_n(data,1,0)
; =================================================================
; low pass (lp) filter
; remove short time scale variance (everything shorter than 18 months)
; =================================================================
  ihp   = 0      ; lowpass filter
  sigma = 1
  nWgt  = 37      ; loose 18 months each end
  fca   = 1./18.     ; 18 months
  wgt  = filwgts_lanczos(nWgt,ihp,fca,data@_FillValue,sigma)
  datalp= wgt_runave_n_Wrap(data,wgt,0,0)               ; running average (time)
  datalp@long_name = "Low Pass: "+data@long_name
  printVarSummary(datalp)                               ; (time,lat,lon)
; =================================================================
; Reorder (lat,lon,time) the input data so time is rightmost dimension.
; This is the order expected by the 'eofunc'
; =================================================================
  xlp   = datalp(lat|:,lon|:,time|:)   
  delete(datalp)                                        ; no longer needed
; =================================================================
; find EOFs: no weighting is performed here due to limited lat range
; =================================================================
  eof    = eofunc_Wrap(xlp, neof, optEOF)               ; find first neof EOFs
  eof_ts = eofunc_ts_Wrap (xlp, eof, optETS)  ; time series
  
  printVarSummary( eof )    ; examine EOF variables
  printVarSummary( eof_ts )
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; A driver for the POP matrix operations.      
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  pop_results  = PrnOscPat_driver(eof, eof_ts, kPOP)   ; returns a list
  print(pop_results)                                   ; containing variables
   
; =================================================================
; For convenience & clarity extract each of the two elements
;     and place them into separate variables reather than acces
;     via 'list' syntax.
; =================================================================
            
  pop_ts    = pop_results[0]     ; POP time series  (nEOF,time)
  printVarSummary(pop_ts)
;print("pop_ts: min="+min(pop_ts)+"   max="+max(pop_ts))
  pop_pat   = pop_results[1]     ; POP patterns     (nEOF,lat,lon)
  printVarSummary(pop_pat)
;print("pop_pat: min="+min(pop_pat)+"   max="+max(pop_pat))
  delete(pop_results)            ; no longer needed
; ===========================================================
; Miscellaneous for file creation and plots
; ===========================================================
  sfx    = get_file_suffix(ifile, 0)
  froot  = sfx@fBase
  yyyymm = cd_calendar(eof_ts&time,-2)/100  
  yrfrac = yyyymm_to_yyyyfrac(yyyymm, 0.0)   
  yyyymm!0 = "time"
  yrfrac!0 = "time"
  yyyymm&time = eof_ts&time
  yrfrac&time = eof_ts&time
if (netCDF) then
; ===========================================================
; NETCDF: write POP data to file: Use simple method of writing netCDF
; ===========================================================
  pathNC = dirNC+"POP_"+froot+".nc"
  system("/bin/rm -f " + pathNC)    ; remove file if exists
  fout = addfile(pathNC,"c")
  setfileoption(fout,"DefineMode",True)
; create global attributes
  fileAtt  = True
  fileAtt@creation_date = systemfunc("date")
  fileattdef(fout,fileAtt)
  fout->yyyymm      = yyyymm   
  fout->yrfrac      = yrfrac   
  fout->POP_TS      = pop_ts
  fout->POP_PATTERN = pop_pat
  fout->EOF_TS      = eof_ts
  fout->EOF         = eof
end if
;============================================================
; PLOTS
;============================================================
if (pltEOF) then
  pltEofPop(eof_ts, eof, yrfrac, froot, pltType, "EOF", "BlueYellowRed")
end if    ; pltEOF
if (pltPOP) then
  pltEofPop(pop_ts, pop_pat, yrfrac, froot, pltType, "POP", "BlueYellowRed")
end if    ; pltPOP
if (pltCLIM) then
    pltClim(clim, froot, pltType, "CLIM", "BlAqGrYeOrReVi200")
end if    ; pltCLIM

wallClockElapseTime(wcStrt, "POPanalysis", 0)
密码修改失败请联系微信:mofangbao
发表于 2015-11-10 20:52:05 | 显示全部楼层
脚本中有很多printVarSummary,根据其输出先找到出错的行。
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-11-10 21:21:38 | 显示全部楼层
刚接触ncl,问个小白问题,希望不要介意!图中的显示是不是表示printVarSummary(DATA)       这一行之前的对了而错误在这一行后面?
密码修改失败请联系微信:mofangbao
发表于 2015-11-11 08:11:04 | 显示全部楼层
不是很懂   飘过
密码修改失败请联系微信:mofangbao
发表于 2015-11-11 10:36:30 | 显示全部楼层
估计是内存不够,数据太大,可以尝试缩短数据的时间或者范围
密码修改失败请联系微信:mofangbao
发表于 2015-11-11 11:47:46 | 显示全部楼层
islandowner 发表于 2015-11-10 21:21
刚接触ncl,问个小白问题,希望不要介意!图中的显示是不是表示printVarSummary(DATA)       这一行之前的 ...

嗯,是这个意思!
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2015-11-11 23:10:27 | 显示全部楼层
尽头的尽头 发表于 2015-11-11 10:36
估计是内存不够,数据太大,可以尝试缩短数据的时间或者范围

谢谢回复!不是内存问题,但又发现一个问题,时间改成1958-1959竟然是11个月,而改成1958-1961是48,想知道为什么1958-1959的会缺一个月
密码修改失败请联系微信:mofangbao
发表于 2015-11-12 09:56:48 | 显示全部楼层
islandowner 发表于 2015-11-11 23:10
谢谢回复!不是内存问题,但又发现一个问题,时间改成1958-1959竟然是11个月,而改成1958-1961是48,想知 ...

那你可以看看数据的起始和终止时间,是不是缺少了一个月
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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