爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 934|回复: 1

[作图] 求帮助我看看这个程序怎么回事

[复制链接]

新浪微博达人勋

发表于 2019-4-17 09:48:54 | 显示全部楼层 |阅读模式

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

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

x
; 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"

begin
; ==============================================================
; User defined parameters that specify region of globe and
; ==============================================================
  latS   =  20.
  latN   =  20.
  lonL   = 70.
  lonR   =  0.


  season = "DJF"    ;

  neof   = 3        ;
  optEOF = True      
  optEOF@jopt = 0   ;
;;optEOF@jopt = 1   ;

  optETS = False

; ==============================================================
; Open the file: Read only the user specified period
; ==============================================================
  f=addfile("lgm_c_sp.psl.nc","r")

  Sea_level_pressure = f->PSL
  printVarSummary(Sea_level_pressure)     ;
; ==============================================================
; dataset longitudes span 0=>357.5
; Because EOFs of the North Atlantic Oscillation are desired
; use the "lonFlip" (contributed.ncl) to reorder
; longitudes to span -180 to 177.5: facilitate coordinate subscripting
; ==============================================================
  slp    = lonFlip( Sea_level_pressure )
  printVarSummary(slp)                              ;

; ==============================================================
; compute desired global seasonal mean: month_to_season (contributed.ncl)
; ==============================================================
  SLP    = month_to_season (slp, season)
  nyrs   = dimsizes(SLP)
  printVarSummary(SLP)

; =================================================================
; create weights:  sqrt(cos(lat))   [or sqrt(gw) ]
; =================================================================
  rad    = 4.*atan(1.)/180.
  clat   = f->lat           
  clat   = sqrt( cos(rad*clat) )                 ;

; =================================================================
; gw for gaussian grid
; =================================================================
  wSLP   = SLP                                   ;
  wSLP   = SLP*conform(SLP, clat, 1)
  wSLP@long_name = "Wgt: "+wSLP@long_name

; =================================================================
; Reorder (lat,lon,time) the *weighted* input data
; Access the area of interest via coordinate subscripting
; =================================================================
  xw     = wSLP({lat|latS:latN},{lon|lonL:lonR})

  eof      = eofunc_Wrap(xw, neof, optEOF)      
  eof_   = eofunc_ts_Wrap (xw, eof, optETS)

  printVarSummary( eof )                         ;
  printVarSummary( eof_ts )

; =================================================================
; Normalize time series: Sum spatial weights over the area of used
; =================================================================
  dimxw  = dimsizes( xw )
  mln    = dimxw(1)
  sumWgt = mln*sum( clat({lat|latS:latN}) )
  eof_ts = eof_ts/sumWgt

; =================================================================
; Extract the YYYYMM from the time coordinate
; associated with eof_ts [same as SLP&time]
; =================================================================
; PLOTS
;============================================================
  wks = gsn_open_wks("png","eof")         ;
  plot = new(neof,graphic)                ;
                                          ;
; EOF patterns

  res                      = True         
  res@gsnDraw              = False        ;
  res@gsnFrame             = False        ;

  res@gsnAddCyclic         = False        ;

  res@mpFillOn             = False        ;
  res@mpMinLatF            = latS         ;
  res@mpMaxLatF            = latN
  res@mpMinLonF            = lonL
  res@mpMaxLonF            = lonR

  res@cnFillOn             = True         ; l
  res@cnLinesOn            = False        ;
;res@cnLineLabelsOn       = False        ;
  res@cnFillPalette        = "BlWhRe"     ;
  res@lbLabelBarOn         = False        ;

                                          ;
  symMinMaxPlt(eof, 16, False, res)       ;

      ;
  resP                     = True         ; modify the panel plot
  resP@gsnMaximize         = True         ; large format
  resP@gsnPanelLabelBar    = True         ; add common colorbar

  resP@gsnPanelMainString  = "SLP: "+"season+"

;*******************************************
; first plot
;*******************************************
  do n=0,neof-1
     res@gsnLeftString  = "EOF "+(n+1)
     res@gsnRightString = sprintf("%5.1f", eof@pcvar(n)) +"%"
     plot(n)=gsn_csm_contour_map(wks,eof(n,:,:),res)
  end do
  gsn_panel(wks,plot,(/neof,1/),resP)     ;

;*******************************************
; second plot
;*******************************************
; EOF time series  [bar form]

  rts           = True
  rts@gsnDraw   = False       ;
  rts@gsnFrame  = False       ;
  rts@gsnScale  = True        ;              

;
;

  rts@vpHeightF = 0.40        ;
  rts@vpWidthF  = 0.85
  rts@vpXF      = 0.10        ;
  rts@vpYF      = 0.75        ;


  rts@tiYAxisString = "Pa"                    ;

  rts@gsnYRefLine           = 0.              ;
  rts@gsnXYBarChart         = True            ;
  rts@gsnAboveYRefLineColor = "red"           ;
  rts@gsnBelowYRefLineColor = "blue"          ;

; panel plot only resources
  rtsP                      = True            ;
  rtsP@gsnMaximize          = True            ;
  rtsP@gsnPanelMainString   = "SLP: "+"season+"



; create individual plots
  do n=0,neof-1
     rts@gsnLeftString  = "EOF "+(n+1)
     rts@gsnRightString = sprintf("%5.1f", eof@pcvar(n)) +"%"
     plot(n) = gsn_csm_xy (wks,year,eof_ts(n,:),rts)
  end do
  gsn_panel(wks,plot,(/neof,1/),rtsP)     ;
end




错误是这个
fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:["Execute.c":8576]:Execute: Error occurred at or near line 56



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

新浪微博达人勋

 楼主| 发表于 2019-4-17 09:51:11 | 显示全部楼层
wSLP   = SLP                                 
wSLP   = SLP*conform(SLP, clat, 1)
  wSLP@long_name = "Wgt: "+wSLP@long_name
56行是中间这行
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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