- 积分
- 24
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2023-3-8
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
用ncl处理nc文件,数据都可以正常输出,也不报错,就是出不了图,有没有大佬帮我看一下哪里出错了
loadscript("$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl")
loadscript("$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl")
loadscript("$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl")
begin
f = addfile ("D:/dataPRE/PRE_MON_1961-2020.nc","r")
pre = f->PRE_MON(:,:,:) ;读取1961-2020的降水数据
pre_JJA = month_to_season(pre,"JJA") ;青藏高原地区夏季平均降水
; pre_JJA = (pre,"JJA") ;青藏高原地区夏季平均降水
pre_sum = pre_JJA*3 ;青藏高原地区夏季累计降水,单位化为mm
printVarSummary(pre_sum)
copy_VarCoords(pre_JJA,pre_sum);复制参数
time = ispan(1961,2020,1);读取时间变量数据
pre_avg = new((/60/),"float");新建维度存放区域夏季降水量时间序列
pre_jp = new((/60/),"float");新建维度存放区域夏季降水距平时间序列
latS = 25
latN = 42
lonW = 73
lonE = 106
lat = f->lat
lon = f->lon
pre_avg = dim_avg_n_Wrap(pre_sum(:,:,:),(/1,2/))
jp = dim_rmvmean_Wrap(pre_avg)
; opt = True
; opt@spi_type = 3 ; calculate using Pearson III distribution
jp = dim_spi_n(pre_avg, 12, False, 0)
; dmean = avg(pre_avg(:49))
; jp = (pre_avg - dmean)/dmean*100
jp@units="mm"
print(jp)
print(pre_avg)
; print("dmean=="+dmean)
wks=gsn_open_wks("pdf","TP-pre_time");设置绘图空间
res=True
res@gsnXYBarChart=True;绘制柱状图
res@gsnMaximize = True
res@tmXBMode="Explicit";坐标轴标注
res@tmXBValues=time
res@tmXBLabels=time
res@tmXBLabelStride=5;每5个刻度添加标注
res@tmXBLabelFontHeightF=0.1;标注字号
res@tmYLLabelFontHeightF=0.1
res@tmXBLabelDirection="Down"
res@tmXBLabelFontHeightF=0.1
res@tmXBLabels=time
res@gsnScale = True ;xy轴统一尺寸
res@vpHeightF = 1.5;坐标轴高度
res@vpWidthF = 6;坐标轴宽度
;res@trYMinF = -12;y轴范围
;res@trYMaxF = 12
res@tiYAxisString = "Precipitation Anomaly/mm" ; 标题
res@tiXAxisString = "year"
res@tiMainString = "Summer Precipitation Anomaly in TP of China"
res@tiMainFontHeightF=0.19;标题字号
res@tiXAxisFontHeightF=0.1
res@tiYAxisFontHeightF=0.1
res@gsnYRefLine = 0 ; 参考线数值
res@gsnAboveYRefLineColor = "red" ; 参考线上下颜色
res@gsnBelowYRefLineColor = "blue"
;res@xyLineColors = (/"red","blue"/) ; 折线颜色
;res@pmLegendDisplayMode="Always";图例显示方式
;res@xyExplicitLegendLabels=(/"Data","Trend"/);设置图例标注文本
;res@pmLegendHeightF=0.05 ;图例高度
;res@pmLegendWidthF=0.1 ;图例宽度
;res@pmLegendOrthogonalPosF=-1.4;图例垂直移动
;res@pmLegendParallelPosF=0.1;图例水平移动
plot=gsn_csm_xy(wks,time,jp,res);绘制距平直方图
end |
|