Hi Users,
I'd like to create an array to hold a new data:
nino3_cases_maps = new ((/n_nino3,dimsizes(NOAA(0,:,:))/),float)
But I got the following error message:
fatal:_NclBuildArray: each element of a literal array must have the same dimension sizes, at least one item doesn't
fatal:["Execute.c":7556]:Execute: Error occurred at or near line 50 in file trial_comp_1.ncl
Perhaps the problem is that a dimension of the an array (n_nino3) is not known before hand, and ncl is supposed to take it from a preceding calculation. Does anyone know what am doing wrong here?
Thanks in advance.
Hyacinth
Copyright (C) 1995-2012 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.1.0-beta
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
;*************************************************
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"
begin
; ==============================================================
; User defined parameters
; ==============================================================
yrStrt = 1900
yrLast = 2011
season = "DJF" ; choose Jun-Jul-Aug seasonal mean
;=============================================================
; Open the file: Read only the user specified period
; ==============================================================
f = addfile ("/home/nnamchi/work/datasets/sst/sst.mnmean.nc", "r")
TIME = f->time
YYYY = cd_calendar(TIME,-1)/100 ; entire file
iYYYY = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
noaa = short2flt(f->sst(iYYYY,:,:))
printVarSummary(noaa)
delete([/TIME,YYYY,iYYYY/]) ; Release memory
; ==============================================================
; global seasonal mean; de-trend; flip longitudes
; ==============================================================
NOAA = month_to_season (noaa,season)
nyrs = dimsizes(NOAA&time)
printVarSummary(NOAA) ; note the longitude coord
NOAA = dtrend_msg_n(NOAA&time,NOAA,True,False,0) ;de-trend data
NOAA = lonFlip(NOAA)
;===========================================
nino3 = wgt_areaave_Wrap(NOAA(time |:, {lon|-150:-90}, {lat | -5:5}),1.0, 1.0, 0) ;Nino 3 index
nino3 = dim_standardize_Wrap(nino3,0) ; normalize
;=====================================================
n_nino3 = dim_num_n(nino3.ge.1.,0)
print(n_nino3) ; 21 cases shown, integer
nino3_cases = nino3.ge.1.
print(nino3_cases) ;True indicated for the timesteps corresponding to n_nino3
nino3_cases_maps = new ((/n_nino3,dimsizes(NOAA(0,:,:))/),float) ;LINE PROBLEM
printVarSummary(nino3_cases_maps)
;============================================================
nino3_POS = dim_avg_n_Wrap(nino3_cases_maps,0)
copy_VarCoords(NOAA(0,:,:),nino3_POS)
;============================================================
; PLOTS
;============================================================
wks = gsn_open_wks("eps","nino3_POS")
gsn_define_colormap(wks,"BlueWhiteOrangeRed")
plot = new(1,graphic) ; create graphic array
; only needed if paneling
res = True
res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
res@cnMinLevelValF = -2. ; set min contour level
res@cnMaxLevelValF = 2. ; set max contour level
res@cnLevelSpacingF = .05 ; set contour spacing
res@gsnDraw = False ; don't draw yet
res@gsnFrame = False ; don't advance frame yet
res@gsnSpreadColors = True ; spread out color table
;res@mpFillDrawOrder = "PostDraw"
res@gsnPaperOrientation = "portrait"
res@mpFillOn = True ; turn off map fill
res@cnLinesOn = True ; turn off contour lines
res@mpGeophysicalLineThicknessF = 1
res@cnFillOn = True ; turn on color fill
res@cnLinesOn = False ; True is default
res@cnLineLabelsOn = True ; True is default
res@lbLabelBarOn = False ; turn off individual lb's
res@cnConstFLabelOn = False
res@cnLineLabelsOn = False ; True is default
res@cnInfoLabelOn = False
;===============
;******************************************
; Create plots
;==========================================
plot(0) = gsn_csm_contour_map(wks,nino3_POS,res)
;====================================================================
; panel plot only resources
resP = True ; modify the panel plot
resP@gsnPanelLabelBar = True ; add common colorbar
resP@lbLabelAutoStride = True ; auto stride on labels
resP@gsnPanelYWhiteSpacePercent = 0.0 ; default is 1.0
resP@gsnMaximize = True ; large format
resP@gsnPaperOrientation = "portrait"
resP@gsnPanelFigureStrings= (/"a","b","c","d","e","f"/) ; add strings to panel
resP@amJust = "TopRight"
resP@gsnPanelFigureStringsFontHeightF = .01
resP@gsnPanelFigureStringsPerimOn = False
resP@gsnMaximize = True ; large format
gsn_panel(wks,plot,(/1,1/),resP)
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Sep 6 09:20:01 2012
This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:42 MDT