爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5024|回复: 2

[作图] 利用ncl的例子绘制pv,报错

[复制链接]
发表于 2022-11-17 20:40:08 | 显示全部楼层 |阅读模式

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

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

x
利用ncl官网的例子绘制pv,报错了本人依据   PV  = pot_vort_isobaric(lev,u,v,t,t&latitude, gridType, optPV ) 各变量要求下载了ERA5数据,也进行了数据的重新排列,还是出错了
求各位帮帮孩子吧!!!
错误如下:
fatal:divide: Division by 0, Can't continue
fatal:Div: operator failed, can't continue

代码如下:
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
;=================================================================================
;                       MAIN
;=================================================================================
     TEST     = True
     gridType = 0       ; gaussian grid
     optPV    = 1       ; return variable of type list
     plev     = (/ 300 /)

     fu       = addfile ("E:/data/pv/U201606.nc", "r")
     fv       = addfile ("E:/data/pv/V201606.nc", "r")
     ft       = addfile ("E:/data/pv/T201606.nc", "r")

     u = fu->u    ; (time,lev,lat,lon)
     v = fv->v
     t = ft->t

     u   = u(:,:,::-1,:)    ; 对数据重新排序(换为从南到北)。reorder to South -> North
     v   = v(:,:,::-1,:)
     t   = t(:,:,::-1,:)

     if (TEST) then
         ntStrt = 0
         ntLast = 0
         u   = u(ntStrt:ntLast,:,:,:)    ; (time,lev,lat,lon)
         v   = v(ntStrt:ntLast,:,:,:)
         t   = t(ntStrt:ntLast,:,:,:)    ; K
     else
         u   = fu->u                         ; (time,lev,lat,lon)
         v   = fv->v                    
         t   = ft->t                       ; K
     end if

    printVarSummary(u)
    printVarSummary(v)
    printVarSummary(t)

     lev = ft->level  ; hPa
     lev = lev*100  ; convert units
     lev@units = "Pa"

     printVarSummary(lev)

     PV  = pot_vort_isobaric(lev,u,v,t,t&latitude, gridType, optPV )
     printVarSummary(PV)

     pv    = PV[0]          ; extract PV
     s     = PV[1]          ; extract static stability
     theta = PV[2]          ; extract potential temperature

     printVarSummary(pv)
     printMinMax(pv,0)
     printVarSummary(s)
     printMinMax(s,0)
     printVarSummary(theta)
     printMinMax(theta,0)

;************************************************
; create plots
;************************************************
     dims = dimsizes(t)
     ntim = dims(0)
     klev = dims(1)
     nlat = dims(2)
     mlon = dims(3)

     if (.not.TEST) then
         ntStrt = 0
         ntLast = ntim-1
     end if

     wks = gsn_open_wks("png","pv_isobaric")    ; send graphics to PNG file
   ;;gsn_define_colormap(wks,"gui_default")
     plot = new(3,graphic)                      ; create a plot array

     res                      = True
     res@gsnDraw              = False
     res@gsnFrame             = False
     res@cnFillOn             = True            ; turn on color
     res@cnLinesOn            = False
     res@cnLineLabelsOn       = False
     res@cnLevelSelectionMode = "ManualLevels"   
     res@lbOrientation        = "Vertical"   

     resP                     = True                ; modify the panel plot
     resP@gsnMaximize         = True  

     do nt=ntStrt,ntLast
       do pl=0,dimsizes(plev)-1
          res@gsnCenterString     = plev(pl)+"hPa"

          symMinMaxPlt( pv(nt,{plev(pl)},:,:), 16, True, res)
          res@cnLevelSpacingF = 0.5*res@cnLevelSpacingF

          res@gsnLeftString = "PV: NCL derived"
          plot(0) = gsn_csm_contour_map(wks,   pv(nt,{plev(pl)},:,:),res)
          delete( [/res@gsnLeftString, res@cnLevelSelectionMode \
                   ,res@cnMinLevelValF, res@cnMaxLevelValF, res@cnLevelSpacingF/] )

          plot(1) = gsn_csm_contour_map(wks,    s(nt,{plev(pl)},:,:),res)
          plot(2) = gsn_csm_contour_map(wks,theta(nt,{plev(pl)},:,:),res)

          gsn_panel(wks,plot   ,(/3,1/),resP)            ; now draw as one plot
       end do
     end do

end





密码修改失败请联系微信:mofangbao
发表于 2022-11-18 10:02:13 | 显示全部楼层
数据是float吗,或许可以转为double试试
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

发表于 2023-2-16 20:05:43 | 显示全部楼层
您好,请问问题解决了吗?我也是计算位涡时出现了这个问题
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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