爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5374|回复: 4

[作图] 求助,画图错误,麻烦帮我看看,刚学ncl

[复制链接]

新浪微博达人勋

发表于 2022-4-24 08:50:22 | 显示全部楼层 |阅读模式

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

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

x
f1 = addfile("/Users/xueyuxiaodan/Desktop/data/fnl/fnl_20150102_06_00.grib2", "r")
f2 = addfile("/Users/xueyuxiaodan/Desktop/data/fnl/fnl_20160119_12_00.grib2", "r")
f3 = addfile("/Users/xueyuxiaodan/Desktop/data/fnl/fnl_20190125_18_00.grib2", "r")

; ncl_filedump
lats1=15
lats2=40
lons1=65
lons2=105
hgt=50000

rh1= f1->RH_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})
tk1 = f1->TMP_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})
u1 = f1->UGRD_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})
v1 = f1->VGRD_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})

rh2= f2->RH_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})
tk2 = f2->TMP_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})
u2 = f2->UGRD_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})
v2 = f2->VGRD_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})

rh3= f3->RH_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})
tk3 = f3->TMP_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})
u3 = f3->UGRD_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})
v3 = f3->VGRD_P0_L100_GLL0({hgt},{lats1:lats2},{lons1:lons2})

e1=6.112*exp(17.67*(tk1-273.15)/(tk1-29.65))
; copy_VarCoords(tk1,e1)
qs1=0.622*e1/(1000-0.378*e1)
; copy_VarCoords(tk1,qs1)
q1=qs1*rh1/100
; copy_VarCoords(tk1,q1)
U1=q1*u1
; copy_VarCoords(tk1,U1)
V1=q1*v1
; copy_VarCoords(tk1,V1)

qdiv1 =uv2dvG_Wrap(U1,V1)*100000000
; qdiv1=1/9.8*uv2dv_cfd(U1,V1,lat,lon,2)*100000000
; copy_VarCoords(tk1,qdiv1)

e2=6.112*exp(17.67*(tk2-273.15)/(tk2-29.65))
; copy_VarCoords(tk2,e2)
qs2=0.622*e2/(1000-0.378*e2)
; copy_VarCoords(tk2,qs2)
q2=qs2*rh2/100
; copy_VarCoords(tk2,q2)
U2=q2*u2
; copy_VarCoords(tk2,U2)
V2=q2*v2
; copy_VarCoords(tk2,V2)

qdiv2 = uv2dvG_Wrap(U2,V2)*100000000
; qdiv2=1/9.8*uv2dv_cfd(U2,V2,lat,lon,2)*100000000
; copy_VarCoords(tk2,qdiv2)

e3=6.112*exp(17.67*(tk3-273.15)/(tk3-29.65))
; copy_VarCoords(tk3,e3)
qs3=0.622*e3/(1000-0.378*e3)
; copy_VarCoords(tk3,qs3)
q3=qs3*rh3/100
; copy_VarCoords(tk3,q3)
U3=q3*u3
; copy_VarCoords(tk3,U3)
V3=q3*v3
; copy_VarCoords(tk3,V3)

qdiv3 = uv2dvG_Wrap(U3,V3)*100000000;不能有缺失
; qdiv3=1/9.8*uv2dv_cfd(U3,V3,lat,lon,2)*100000000
copy_VarCoords(tk3,qdiv3)

speed1=sqrt(U1^2+V1^2)*1000
; copy_VarCoords(tk3,speed1)
speed2=sqrt(U2^2+V2^2)*1000
; copy_VarCoords(tk3,speed2)
speed3=sqrt(U3^2+V3^2)*1000
; copy_VarCoords(tk3,speed3)

wks = gsn_open_wks("eps","tu4-2121")
; gsn_define_colormap(wks, "temp_diff_18lev")
gsn_define_colormap(wks, "MPL_ocean")
; gsn_reverse_colormap(wks,"CBR_wet")

res=True
res@gsnFrame = False ;画在一张图上,图像输出关
res@gsnDraw  = False ;不画中间图,图像输出关

; res@gsnMaximize = True

res@gsnLeftString = ""
res@gsnRightString = ""

; ; ;平滑
res@cnSmoothingOn                 = True               
res@cnSmoothingDistanceF        = 0.002
res@cnSmoothingTensionF = True

cnres=res
cnres@cnFillOn               = False  ;不画彩色图
cnres@cnLinesOn            = True ;画等直线
cnres@cnLineLabelsOn       = True ;不画等值线的标签
cnres@cnInfoLabelOn=False            ;等值线框
cnres@cnLineLabelFontHeightF=0.014;标签字体大小
cnres@cnLevelSelectionMode = "ManualLevels" ;颜色与数据对应
cnres@cnMinLevelValF       = 0      ; 等值线最小值
cnres@cnMaxLevelValF       =  20      ; 等值线最大值
cnres@cnLevelSpacingF     = 4        ; 控制等值线间隔
; resc@cnLevelSelectionMode  = "AutomaticLevels"
; resc@cnLevelSpacingF = 15.

res@mpOutlineOn             =True;显示海陆分布线
res@mpFillOn=False ;陆地不填充
res@pmTickMarkDisplayMode  = "Always"  ;画度数
res@gsnAddCyclic= False
res@mpMinLatF               =20
res@mpMaxLatF               = 36
res@mpMinLonF               = 70
res@mpMaxLonF               = 100

res@cnFillOn               = True  ;画彩色图
res@cnLinesOn              = False ;不画等直线
res@cnLineLabelsOn         = False ;不画等值线的标签

res@cnLevelSelectionMode = "ManualLevels" ;颜色与数据对应
res@cnMinLevelValF       = -3      ; 等值线最小值
res@cnMaxLevelValF       =  0      ; 等值线最大值
res@cnLevelSpacingF     = 4         ; 控制等值线间隔

plot = new(3,graphic)
cnplot = new(3,graphic)

plot(0)= gsn_csm_contour_map(wks,qdiv1,res)
plot(1)= gsn_csm_contour_map(wks,qdiv2,res)
plot(2)= gsn_csm_contour_map(wks,qdiv3,res)

cnplot(0) = gsn_csm_contour(wks,speed1,cnres)
cnplot(1) = gsn_csm_contour(wks,speed2,cnres)
cnplot(2) = gsn_csm_contour(wks,speed3,cnres)

overlay(plot(0),cnplot(0))
overlay(plot(1),cnplot(1))
overlay(plot(2),cnplot(2))

pres = True
pres@gsnPanelFigureStrings = (/"a","b","c"/)
pres@amJust = "TopLeft" ;; 调整标签的位置

res@gsnPanelRowSpec = True

gsn_panel(wks,(/plot/),(/2,2/),pres)
gsn_panel(wks,(/cnplot/),(/2,2/),pres)
draw(plot)
; draw(map)
frame(wks)

错误报如下:
(0)        check_for_y_lat_coord: Warning: Data either does not contain
(0)        a valid latitude coordinate array or doesn't contain one at all.
(0)        A valid latitude coordinate array should have a 'units'
(0)        attribute equal to one of the following values:
(0)            'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
(0)        check_for_lon_coord: Warning: Data either does not contain
(0)        a valid longitude coordinate array or doesn't contain one at all.
(0)        A valid longitude coordinate array should have a 'units'
(0)        attribute equal to one of the following values:
(0)            'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
(0)        check_for_y_lat_coord: Warning: Data either does not contain
(0)        a valid latitude coordinate array or doesn't contain one at all.
(0)        A valid latitude coordinate array should have a 'units'
(0)        attribute equal to one of the following values:
(0)            'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
(0)        check_for_lon_coord: Warning: Data either does not contain
(0)        a valid longitude coordinate array or doesn't contain one at all.
(0)        A valid longitude coordinate array should have a 'units'
(0)        attribute equal to one of the following values:
(0)            'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
warning:ContourPlotSetValues: attempt to set overlay member plot view ignored
warning:ContourPlotSetValues: attempt to set overlay member plot view ignored
warning:ContourPlotSetValues: attempt to set overlay member plot view ignored
warning:NhlDraw: cannot draw Plot Member, ID 176, independently
warning:NhlDraw: cannot draw Plot Member, ID 204, independently
warning:NhlDraw: cannot draw Plot Member, ID 232, independently
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2022-4-24 10:02:14 | 显示全部楼层
上面报错是变量坐标不对把, copy_VarCoord用上试试?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2022-4-24 10:23:16 | 显示全部楼层
一大碗年糕 发表于 2022-4-24 10:02
上面报错是变量坐标不对把, copy_VarCoord用上试试?

老师,用了后报这样错误:
warning:ContourPlotSetValues: attempt to set overlay member plot view ignored
warning:ContourPlotSetValues: attempt to set overlay member plot view ignored
warning:ContourPlotSetValues: attempt to set overlay member plot view ignored
warning:NhlDraw: cannot draw Plot Member, ID 176, independently
warning:NhlDraw: cannot draw Plot Member, ID 204, independently
warning:NhlDraw: cannot draw Plot Member, ID 232, independently
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2022-4-24 10:40:40 来自手机 | 显示全部楼层
雪域小丹 发表于 2022-04-24 10:23
老师,用了后报这样错误:
warning:ContourPlotSetValues: attempt to set overlay member plot view ignored
warning:ContourPlotSetValues: attempt to set overlay member plot view ignored
warning:ContourPlotSetValues: attempt to set overlay member plot view ignored
warning:NhlDraw: cannot draw Plot Member, ID 176, independently
warning:NhlDraw: cannot draw Plot Member, ID 204, independently
warning:NhlDraw: cannot draw Plot Member, ID 232, independently

我也没遇到过这个warning抱歉,如果只是warning的话,有可能图还是可以出的
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2022-4-24 10:44:17 | 显示全部楼层
一大碗年糕 发表于 2022-4-24 10:40
我也没遇到过这个warning抱歉,如果只是warning的话,有可能图还是可以出的

但我这个出不来图!
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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