爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 15363|回复: 10

[作图] ncl用月平均海温资料求年平均画eof,month_to_annual报错存在缺省值

[复制链接]
发表于 2019-12-2 11:31:04 | 显示全部楼层 |阅读模式

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

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

x
利用月平均资料算年平均,用的是month_to_annual。为啥出现缺省值报错,如果只画冬季的话是可以的。求大神解答!!!
begin
latS            =-30
latN            =30
lonL            =120
lonR            =290
yrStrt          =1950
yrLast          =2017
neof            =3
optEOF          =True
optETS          =False
diri="D:\"
fili="sj\now\sst-195001-201712.nc"
f=addfile(diri+fili,"r")
TIME = f->time
YYYY =cd_calendar(TIME, -1)/100
iYYYY=ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
sst  = f->sst(iYYYY,:,:)
SST  =month_to_annual(sst, 1)
nyrs =dimsizes(SST&time)                                                ;;;;;;;;;;;;;;;;;;;23行在这里
xw  =SST(time|:,{rlat|latS:latN},{rlon|lonL:lonR})
;EOF==========================
eof  =eofunc_n_Wrap(xw, neof, optEOF,0)
eof_ts =eofunc_ts_n_Wrap(xw, eof, optETS,0)
yyyymm  =cd_calendar(eof_ts&time,-2)/100
;============================================================
; PLOTS
;============================================================
wks = gsn_open_wks("png","eof")
plot = new(neof,graphic)
res                      = True   
res@mpCenterLonF         =180      
res@gsnDraw              = False        ; don't draw yet
res@gsnFrame             = False        ; don't advance frame yet
res@gsnAddCyclic         = False        ; plotted dataa are not cyclic
res@mpFillOn             = False        ; turn off map fill
  res@mpMinLatF            = latS         ; zoom in on map
  res@mpMaxLatF            = latN
  res@mpMinLonF            = lonL
  res@mpMaxLonF            = lonR
  res@vpHeightF            =0.4
  res@vpWidthF             =0.7
        
res@cnFillOn             = True         ; turn on color fill
res@cnLinesOn            = False        ; True is default
;res@cnLineLabelsOn       = False        ; True is default
res@cnFillPalette        = "BlWhRe"     ; set color map
res@lbLabelBarOn         = False        ; turn off individual lb's
symMinMaxPlt(eof, 16, False, res)
; panel plot only resources
  resP                     = True         ; modify the panel plot
  resP@gsnMaximize         = True         ; large format
  resP@gsnPanelLabelBar    = True         ; add common colorbar
  yStrt                    = yyyymm(0)/100
  yLast                    = yyyymm(nyrs-1)/100
  resP@gsnPanelMainString  = "1950-2017"
  ;*******************************************
; 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)     ; now draw as one plot
  ;==================================================================
  ; EOF time series  [bar form]
   eof_ts@long_name = "Amplitude"
  rts           = True
  rts@gsnDraw   = False       ; don't draw yet
  rts@gsnFrame  = False       ; don't advance frame yet
;rts@gsnScale  = True        ; force text scaling               
; these four resources allow the user to stretch the plot size, and
; decide exactly where on the page to draw it.
  rts@vpHeightF = 0.40        ; Changes the aspect ratio
  rts@vpWidthF  = 0.85
  rts@vpXF      = 0.10        ; change start locations
  rts@vpYF      = 0.75        ; the plot
  rts@gsnYRefLine           = 0.              ; reference line   
  rts@gsnAboveYRefLineColor = "red"           ; above ref line fill red
  rts@gsnBelowYRefLineColor = "blue"          ; below ref line fill blue
; panel plot only resources
  rtsP                     = True             ; modify the panel plot
  rtsP@gsnMaximize         = True             ; large format
      year  =yyyymm/100
  resP@gsnPanelMainString  = "SCRIPPS: Pierce"
  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)        ; draw all 'neof' as one plot
end

报错的地方如下
(0)     month_to_annual: some grid points have missing data: nt=0 nyr=0  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=12 nyr=1  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=24 nyr=2  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=36 nyr=3  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=48 nyr=4  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=60 nyr=5  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=72 nyr=6  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=84 nyr=7  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=96 nyr=8  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=108 nyr=9  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=120 nyr=10  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=132 nyr=11  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=144 nyr=12  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=156 nyr=13  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=168 nyr=14  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=180 nyr=15  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=192 nyr=16  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=204 nyr=17  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=216 nyr=18  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=228 nyr=19  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=240 nyr=20  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=252 nyr=21  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=264 nyr=22  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=276 nyr=23  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=288 nyr=24  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=300 nyr=25  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=312 nyr=26  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=324 nyr=27  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=336 nyr=28  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=348 nyr=29  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=360 nyr=30  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=372 nyr=31  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=384 nyr=32  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=396 nyr=33  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=408 nyr=34  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=420 nyr=35  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=432 nyr=36  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=444 nyr=37  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=456 nyr=38  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=468 nyr=39  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=480 nyr=40  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=492 nyr=41  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=504 nyr=42  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=516 nyr=43  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=528 nyr=44  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=540 nyr=45  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=552 nyr=46  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=564 nyr=47  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=576 nyr=48  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=588 nyr=49  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=600 nyr=50  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=612 nyr=51  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=624 nyr=52  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=636 nyr=53  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=648 nyr=54  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=660 nyr=55  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=672 nyr=56  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=684 nyr=57  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=696 nyr=58  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=708 nyr=59  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=720 nyr=60  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=732 nyr=61  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=744 nyr=62  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=756 nyr=63  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=768 nyr=64  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=780 nyr=65  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=792 nyr=66  num(nGood)=10988
(0)     month_to_annual: some grid points have missing data: nt=804 nyr=67  num(nGood)=10988
fatal:(time) is not a named dimension in variable (SST).
fatal:["Execute.c":8638]:Execute: Error occurred at or near line 23






密码修改失败请联系微信:mofangbao
发表于 2019-12-21 20:39:06 | 显示全部楼层
楼主问题解决了吗?我也遇到这种问题了
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2019-12-22 20:41:44 | 显示全部楼层
有缺省值正常,陆地上为缺省值。

错的地方在最后,已经告诉你了,(time) is not a named dimension in variable (SST).
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-12-25 09:29:06 | 显示全部楼层
stepdance 发表于 2019-12-22 20:41
有缺省值正常,陆地上为缺省值。

错的地方在最后,已经告诉你了,(time) is not a named dimension in v ...

是因为22行,month_to_annual这一步就运算不了才导致的23行的错误,但是不知道为什么22行那里就开始运行不了
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2019-12-25 10:11:50 | 显示全部楼层
杰西卡·芬 发表于 2019-12-25 09:29
是因为22行,month_to_annual这一步就运算不了才导致的23行的错误,但是不知道为什么22行那里就开始运行 ...

那就重新命名一下维数的名称呗
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-12-25 20:55:44 | 显示全部楼层
stepdance 发表于 2019-12-25 10:11
那就重新命名一下维数的名称呗

老哥,还是不太懂怎么改
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2019-12-26 11:29:28 | 显示全部楼层
SST!0="time"
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2020-8-27 18:18:53 | 显示全部楼层
请问楼主解决了吗,没有看懂到底该怎样改?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-10-22 16:05:06 | 显示全部楼层
大到暴雨 发表于 2020-8-27 18:18
请问楼主解决了吗,没有看懂到底该怎样改?

重新定义sst的时间维度就可以了
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2021-4-9 22:38:38 | 显示全部楼层
a = addfile("d:/lianxi/ceshi/example/heat/isshf.nc","r")
sshf=a->ganre
sshf!0="time"
annual_mean = month_to_annual(sshf, 1)

错误提示
Assignment type mismatch, right hand side can't be coerced to type of left hand side 楼主知道问题出在哪里吗
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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