Cannot draw the third panel

The NCL graphics package.

Cannot draw the third panel

Postby ukjohnug » Sun Sep 25, 2016 6:23 pm

Hi all,
I need to compare spectral plots of four datasets in one panel. I already merged them in one nc data file. It's fine if I plot any two of these four variable, so the input is ok. I fail to plot all four plots in one panel. Any suggestions? Thank you in advance.
;*************************************************
; fig1.ncl
;************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
;************************************************
begin
;************************************************
; variable and file handling
;************************************************
latS = 12
latN = 12
lonL = 55
lonR = 55
fn = "djf.nc" ; define filename
f = addfile(fn,"r") ; open netcdf file
; print(f)
; list_filevars(f)

X = f->aahfl(:,{latS:latN},{lonL:lonR}) ; (time,lat,lon)
x = X(:,0,0)
Y = f->bahfl(:,{latS:latN},{lonL:lonR}) ; (time,lat,lon)
y = Y(:,0,0)
M = f->cahfl(:,{latS:latN},{lonL:lonR}) ; (time,lat,lon)
m = M(:,0,0)
N = f->dahfl(:,{latS:latN},{lonL:lonR}) ; (time,lat,lon)
n = N(:,0,0)

;************************************************
; set function arguments
;************************************************
d = 0 ; detrending opt: 0=>remove mean 1=>remove mean + detrend
sm = 21 ; smooth: should be at least 3 and odd
pct = 0.10 ; percent taper: (0.0 <= pct <= 1.0) 0.10 common.
;************************************************
; calculate spectrum
;************************************************
xdof = specx_anal(x,d,sm,pct)
ydof = specx_anal(y,d,sm,pct)
mdof = specx_anal(m,d,sm,pct)
ndof = specx_anal(n,d,sm,pct)
;************************************************
; plotting parameters
;************************************************
wks = gsn_open_wks("ps","spec") ; Opens a ps file
plot = new(2,graphic) ; create graphic array

r = True ; plot mods desired
r@gsnDraw = False ; do not draw
r@gsnFrame = False ; do not advance frame
r@tiMainString = "LATENT" ; title
r@tiXAxisString = "Frequency (cycles/months)" ; xaxis
r@tiYAxisString = "Variance" ; yaxis
;************************************************
xplt = specx_ci(xdof, 0.05, 0.95)/1000 ; calc confidence interval
yplt = specx_ci(ydof, 0.05, 0.95)/1000
mplt = specx_ci(mdof, 0.05, 0.95)/1000 ; calc confidence interval
nplt = specx_ci(ndof, 0.05, 0.95)/1000
;***********************************************
r@xyLineThicknesses = (/2.,1.,1.,1./) ; Define line thicknesses
r@xyDashPatterns = (/0,0,1,1/) ; Dash patterns

;***********************************************

;***********************************************
r@xyLineColors = (/"foreground","grey","red","blue"/)
plot(0) = gsn_csm_xy(wks,xdof@frq, xplt,r)
plot(1) = gsn_csm_xy(wks,ydof@frq, yplt,r)
plot(2) = gsn_csm_xy(wks,mdof@frq, mplt,r)
plot(3) = gsn_csm_xy(wks,ndof@frq, nplt,r)
;***********************************************
res_P = True ; panel mods desired
res_P@gsnMaximize = True ; blow up plot
gsn_panel(wks,plot,(/2,2/),res_P) ; create panel plots
end


ERROR: fatal:Subscript out of range, error in subscript #0
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 102 in file 1.ncl
ukjohnug
 
Posts: 1
Joined: Sun Sep 25, 2016 6:12 pm

Return to NCL

Who is online

Users browsing this forum: No registered users and 1 guest