爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3126|回复: 0

假相当位温剖面图,脚本出错,希望大佬能帮忙看看

[复制链接]

新浪微博达人勋

发表于 2022-5-11 21:32:06 | 显示全部楼层 |阅读模式

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

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

x
begin

ft = addfile("air.2021.nc", "r")
fr = addfile("rhum.2021.nc", "r")
tem = short2flt(ft->air(:,:,:,:))
q = short2flt(fr->rhum(:,:,:,:))
lev=ft->level

ose = new((/365,16,180,360/),float)
;ose = new(dimsizes(tem), float)
;do i = 0, dimsizes(lev) - 1
   ; ose(i,:,:) = lev(i)
;end do
;;;;;;;;;;;;;;;;;;;计算各个高度层的假相当位温
do i = 0,16

e = lev(i)*q(:,i,:,:)/(0.622+q(:,i,:,:)) ;常数
copy_VarMeta(q(:,0,:,:), e)
tlcl=55.0+2840.0/(3.5*log(tem(:,i,:,:))-log(e)-4.805) ;1*4逆矩阵
copy_VarMeta(e, tlcl)
theta = tem(:,i,:,:)*((1000/lev(i))^(0.2854*(1.0-0.28*q(:,i,:,:)))) ;1行4列
copy_VarMeta(e, theta)
ose(:,i,:,:) = theta*exp(((3376./tlcl)-2.54)*q(:,i,:,:)*(1.0+0.81*q(:,i,:,:)))
copy_VarMeta(q, ose)

;e=0
end do
printVarSummary(ose)
printMinMax(ose, 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
delete(tem)
delete(q)
delete(tlcl)
delete(theta)

wks = gsn_open_wks("pdf", "osepou")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;剖面图
gsn_define_colormap(wks,"rainbow+gray")

res = True
res@gsnDraw = False
res@gsnFrame = False
res@gsnLeftString = ""
res@gsnRightString = ""

res@tmXBMode = "Explicit"
res@tmXBValues = (/-90,-60,-30,0,30,60,90/)
res@tmXBLabels = (/"90~S~o~N~S","60~S~o~N~S","30~S~o~N~S","0","30~S~o~N~N","60~S~o~N~N","90~S~o~N~N"/)
res@tmXBLabelFontHeightF = 0.02
res@tmYLLabelFontHeightF = 0.02

res@tiYAxisString = "Level (hPa)"

res@cnFillOn = True  ; res@cnFillOn = False
res@cnFillPalette="rainbow+gray"

;res@cnLinesOn = True
;res@cnLineLabelsOn = False
;res@cnLevelSpacingF = 0.05
;res@gsnContourZeroLineThicknessF = 4. ;0 值用 2 倍粗细线
;res@cnInfoLabelOn = False
;res@lbLabelBarOn = False

;res@lbOrientation         ="Vertical"
;res@cnFillPalette         = "BlAqGrYeOrRe"
;res@lbOrientation         = "Vertical"
;res@gsnAddCyclic          = False    ; data already has cyclic poin

  res  = True                                      ; plot mods desired
  res@tiMainString     = ""
  res@vcRefMagnitudeF  = 50.0                       ; add a reference vector
  res@vcRefLengthF     = 0.2                      ; what the ref length is
  ;res@vcGlyphStyle     = "CurlyVector"             ; turn on curly vectors

  res                       = True     ; plot mods desired
  res@gsnMaximize           = True     ; Make plot fit the frame
  res@cnFillOn              = True     ; turn on color fill
  res@cnLinesOn             = False    ; turn of contour lines
  res@cnLevelSpacingF       = 0.05    ; contour spacing
  res@cnFillPalette         = "BlAqGrYeOrRe"
  res@lbOrientation         = "Vertical"
  res@gsnAddCyclic          = False    ; data already has cyclic poin




; res@cnLevelSelectionMode = "ManualLevels" ; manually set the contour levels with the following 3 resources
;res@cnMinLevelValF  = -10.0         ; set the minimum contour level
;res@cnMaxLevelValF  = 10.           ; set the maximum contour level
;res@cnLevelSpacingF = 0.00025          ; set the interval between contours

;base=gsn_csm_pres_hgt(wks,var_zm,res) ;1 月的纬向平均 u
;base=gsn_csm_contour(wks,var_zm,res)
base = gsn_csm_contour(wks,var_eth(200,:,{-90:90},{112}), vores) ;
;base = ColorNegDashZeroPosContour(base,"blue","black","red")
;小于 0 用蓝色虚线,大于 0 用红色实线,0 值用黑线

draw(base)

frame(wks)
end


fatal:Dimension size mismatch on subscript #2, left-hand and right-hand side dimensions do not match
出错语句:ose(:,i,:,:) = theta*exp(((3376./tlcl)-2.54)*q(:,i,:,:)*(1.0+0.81*q(:,i,:,:)))

密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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