Я пытаюсь взять среднее значение данных по суточным осадкам (для всех временных шагов; это файл .ncl), а затем взять стандартное отклонение, чтобы построить их в NCL через linux.Я новичок, так что я думаю, что могу делать что-то не так, что должно быть просто.
*************************************************
; 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
С чем он вернулся:
Variable: pr
Type: float
Total Size: 807321600 bytes
201830400 values
Number of Dimensions: 3
Dimensions and sizes:
[time | 3650] x [lat | 192] x [lon | 288]
Coordinates:
time: [729635..733284]
lat: [ -90.. 90]
lon: [ 0..358.75]
Number Of Attributes: 22
_FillValue :
1e+20
cell_measures :
area: areacella
cell_methods :
area: time: mean
comment :
at surface; includes both liquid and solid phases from all types of clouds (both large-scale and convective)
coordinates :
time lat lon
description :
at surface; includes both liquid and solid phases from all types of clouds (both large-scale and convective)
frequency :
day
id :
pr
long_name :
Precipitation
mipTable :
day
missing_value :
1e+20
out_name :
pr
prov :
day ((isd.003))
realm :
atmos
standard_name :
precipitation_flux
time :
time
time_label :
time-mean
time_title :
Temporal mean
title :
Precipitation
type :
real
units :
kg m-2 s-1
variable_id :
pr
fatal:Number of subscripts do not match number of dimensions of variable,(3) Subscripts used, (2) Subscripts expected
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 66 in file
script1.ncl