我正在尝试获取每日降水数据的平均值(所有时间步长;这是一个.ncl文件),然后采用其标准偏差,以便通过linux在NCL中进行绘制。我是崭新的,所以我认为我做错了一些事情,应该很简单。
Events::where('date', $my_date)
->update(['status' => $my_active_status]);
我尝试对其进行了一点编辑,看起来它几乎可以正常工作,但是失败了。稍作修改的代码:
*************************************************
; panel_3.ncl
;
; Concepts illustrated:
; - Paneling three plots vertically on a page
; - Adding a common title to paneled plots
; - Adding a common labelbar to paneled plots
; - Subsetting a color map
;************************************************
;
; These files are loaded by default in NCL V6.2.0 and newer
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
;************************************************
; read in netCDF file
;************************************************
a = addfile("pr_day_CESM2-WACCM_historical_r1i1p1f1_gn_20000101- 20091231.nc","r")
;pr = a->pr(1,:,:)
pr = a->pr(:,:,:)
printVarSummary(pr)
;Avearge over time
function dim_avg_Wrap(pr)
function dim_stddev_Wrap(pr)
; Calculate Standard deviation
pr = pr*86400.
;************************************************
; create plots
;************************************************
wks = gsn_open_wks("X11","panel") ; send graphics to PNG file
;gsn_define_colormap(wks,"BlAqGrYeOrRe")
gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")
plot = new(1,graphic) ; create a plot array
res = True
res@gsnDraw = False ; don't draw
res@gsnFrame = False ; don't advance frame
res@cnInfoLabelOn = False ; turn off cn info label
res@cnFillOn = True ; turn on color
res@cnLinesOn = False
res@gsnSpreadColors = True
;res@gsnSpreadColorStart = 1
;res@gsnSpreadColorEnd = -1
res@lbLabelBarOn = False ; turn off individual cb's
; to have a common label bar, both plots should be set to the same interval
; b/c the label bar is drawn by default from the interval of the first plot.
;res@cnLevelSelectionMode = "ManualLevels"
res@cnLevelSelectionMode = "ExplicitLevels"
; res@cnLevelSelectionMode = "AutomaticLevels"
; res@cnMinLevelValF = 0.
; res@cnMaxLevelValF = 100.
; res@cnLevelSpacingF = 5.
res@cnLevels = (/0,0.5,1,2,4,7,11,16,22,29/)
plot(0) = gsn_csm_contour_map(wks,pr(10,:,:),res)
;plot(1) = gsn_csm_contour_map(wks,v,res)
;************************************************
; create panel
;************************************************
resP = True ; modify the panel plot
resP@gsnPanelMainString = "A plot with a common label bar"
resP@gsnPanelLabelBar = True ; add common colorbar
resP@lbLabelFontHeightF = 0.007 ; make labels smaller
gsn_panel(wks,plot,(/1,1/),resP) ; now draw as one plot
end
fatal:syntax error: line 24 in file script1.ncl before or near
dim_avg_Wrap
function dim_avg_Wrap
--------------------^
fatal:Function identifier is defined
fatal:syntax error: line 25 in file script1.ncl before or near
dim_stddev_Wrap
function dim_stddev_Wrap
-----------------------^
fatal:Function identifier is defined
fatal:Syntax Error in block, block not executed
fatal:error at line 69 in file script1.ncl
返回的内容:
;*************************************************
; panel_3.ncl
;
; Concepts illustrated:
; - Paneling three plots vertically on a page
; - Adding a common title to paneled plots
; - Adding a common labelbar to paneled plots
; - Subsetting a color map
;************************************************
;
; These files are loaded by default in NCL V6.2.0 and newer
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
;************************************************
; read in netCDF file
;************************************************
a = addfile("pr_day_CESM2-WACCM_historical_r1i1p1f1_gn_20000101- 20091231.nc","r")
;pr = a->pr(1,:,:)
pr = a->pr(:,:,:)
printVarSummary(pr)
pr = pr*86400.
;************************************************
; Average and SD
;************************************************
;Avearge over time
zave = dim_avg_Wrap(pr)
zave = dim_stddev_Wrap(pr)
;pr = function dim_avg_Wrap(pr)
;pr = function dim_stddev_Wrap(pr)
; Calculate Standard deviation
;************************************************
; create plots
;************************************************
wks = gsn_open_wks("X11","panel") ; send graphics to PNG file
;gsn_define_colormap(wks,"BlAqGrYeOrRe")
gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")
plot = new(1,graphic) ; create a plot array
res = True
res@gsnDraw = False ; don't draw
res@gsnFrame = False ; don't advance frame
res@cnInfoLabelOn = False ; turn off cn info label
res@cnFillOn = True ; turn on color
res@cnLinesOn = False
res@gsnSpreadColors = True
;res@gsnSpreadColorStart = 1
;res@gsnSpreadColorEnd = -1
res@lbLabelBarOn = False ; turn off individual cb's
; to have a common label bar, both plots should be set to the same interval
; b/c the label bar is drawn by default from the interval of the first plot.
;res@cnLevelSelectionMode = "ManualLevels"
res@cnLevelSelectionMode = "ExplicitLevels"
; res@cnLevelSelectionMode = "AutomaticLevels"
; res@cnMinLevelValF = 0.
; res@cnMaxLevelValF = 100.
; res@cnLevelSpacingF = 5.
res@cnLevels = (/0,0.5,1,2,4,7,11,16,22,29/)
; plot(0) = gsn_csm_contour_map(wks,pr(10,:,:),res)
plot(0) = gsn_csm_contour_map(wks,zave(10,:,:),res)
;plot(1) = gsn_csm_contour_map(wks,v,res)
;************************************************
; create panel
;************************************************
resP = True ; modify the panel plot
resP@gsnPanelMainString = "A plot with a common label bar"
resP@gsnPanelLabelBar = True ; add common colorbar
resP@lbLabelFontHeightF = 0.007 ; make labels smaller
gsn_panel(wks,plot,(/1,1/),resP) ; now draw as one plot
end