[ncl-talk] help

Karin Meier-Fleischer meier-fleischer at dkrz.de
Tue Jul 28 04:15:20 MDT 2015


Hi George,

the error message tells you that there is something wrong with the 
subscripts used in that line. You can see that the variable season has 2 
subscripts:

print(dimsizes(season))
(0)    3
(1)    3

The line should be something like

res at gsnCenterString   = season*(ns,:)*+":"+time(0)/100 +"-"+ 
time(ntim-1)/100*
*
Bye,
Karin

Am 28.07.15 um 11:48 schrieb george luke otieno:
> Dear  All; Trying to plot 3 seasons MAM,OND,JJA together. My data has 
> 3dimension ordered like (time,lat,lon)
>
> This is the complain from this line ....*res at gsnCenterString = 
> season(ns)+":"+time(0)/100 +"-"+ time(ntim-1)/100*
>
> /fatal:Number of subscripts do not match number of dimensions of 
> variable,(1) Subscripts used, (2) Subscripts expected
> fatal:["Execute.c":8578]:Execute: Error occurred at or near line 160 
> in file trial/
> /Below is the script../
> /
> /
> /
> /
> /
> /
> /;***********************************************
> ; climo_3.ncl
> ;
> ; Concepts illustrated:
> ;   - Calculating monthly climatologies
> ;   - Calculating interannual variability
> ;   - Calculating standard deviations of monthly means
> ;   - Creating a color map using named colors
> ;   - Paneling four plots on a page
> ;   - Adding a common labelbar to paneled plots
> ;   - Explicitly setting contour levels
> ;   - Changing the center longitude for a cylindrical equidistant 
> projection
> ;   - Turning off the individual contour labelbar
> ;   - Adding a common title to paneled plots
> ;   - Turning off map fill
> ;   - Creating a center subtitle
> ;
> ;***********************************************
> 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
> ;************************************************
> ; Read the file
> ;************************************************
>   a    = addfile("GPCP.nc","r")
>   prec = a->precip(0:431,:,:)                                 ; 
> (time,lat,lon)
>   printVarSummary(prec)
>   time = a->time                                ; (time) ==> YYMM
>   ntim = dimsizes(time)
>
>   ymStrt  = 198001                           ; start yyyymm
>    ymLast  = 199912                           ; last
>    yrStrt  = ymStrt/100
>    yrLast  = ymLast/100                           ; start yyyymm
>
>
>    wksType = "x11"
>    wksName = "test"                          ; ": "+yrStrt+"_"+yrLast
>
>
> ;************************************************
> ; plots ; Compute 3-month climatologies
> ;************************************************
>                                               ; (2,6)
>   season   = (/ (/ 2, 3, 4/) \       ; March-May[MAM]
>               , (/ 5, 6, 7/)   \      ; June-August [JJA]
>        , (/ 9, 10, 11/) /)         ; Oct-Dec [OND]
>   i_season = season - 1                       ; NCL indices
>   season_label = (/ "March-May", "June-August","October-December"/)
>  plot = new ( 3, "graphic")
>   wks = gsn_open_wks(wksType, wksName)
>   gsn_define_colormap(wks,"BlueYellowRed")
>
>
> ;************************************************
> ; Compute the MAM,JJA,OND climatology using a function in contributed.ncl
> ;************************************************
> ;  precClm = month_to_season(prec)            ; monthly climatology
>   ;************************************************
> ; create colors
> ;*************************************************
>   wks = gsn_open_wks("x11","test")             ; open a workstation
>
>
>  colors = (/ (/255,255,255/),(/0,0,0/),(/255,255,255/), (/244,255,244/), \
>   (/217,255,217/), (/163,255,163/), (/106,255,106/), \
>   (/43,255,106/), (/0,224,0/), (/0,134,0/),(/255,255,0/),\
>   (/255,127,0/) /) * 1.0 ; we multiply by 1 to make colors float
>
>   colors = colors/255.               ; normalize (required by NCL)/
> /
>  ;colors = (/"white","Balck","White","RoyalBlue"\      ; back/fore ground
>   ; ,"lightSkyblue","lightseagreen","palegreen"/)         ; choose 
> colors for color map
>
>   gsn_define_colormap(wks, colors)              ; generate new color map
> ;************************************************
> ; create panel plots
> ;*************************************************
>   plot   = new ( 3, graphic)                    ; create graphical array/
>
>
>   res                      = True               ; plot options desired
>
>   res at cnFillOn             = True               ; turn on color fill
>   res at cnInfoLabelOn        = False              ; turn off contour 
> info label
>   res at cnLinesOn            = False              ; turn off contour lines
>   res at cnLineLabelsOn       = False              ; turn off line labels
>   res at cnLevelSelectionMode = "ExplicitLevels"   ; set explicit contour 
> levels
>   res at cnLevels             = (/0.0,0.5,1.0,5.0,10,15,20,25\  ; set 
> unequal contour levels
>                               ,30,35/)
>
>   res at mpFillOn             = False              ; turn off gray continents
>   res at mpCenterLonF         = 180                ; Centers the plot at 180
>
>   res at lbLabelBarOn         = False              ; No single label bar
>
>   res at gsnDraw              = False
>   res at gsnFrame             = False
>
>   resP                     = True               ; panel options
>   resP at txString            = "GPCC Observation"   ; common title
>   resP at gsnMaximize         = True               ; maximize image
>   resP at gsnPanelLabelBar    = True               ; Add common label bar
>
>   ;****************ZOOM INTO YOUR LOCATION*********************
>
>   res at mpLimitMode           = "LatLon"
>   mpOutlineOn    =True
>   mpOutlineSpecifiers     =True
>   res at mpMinLonF            = 21.               ; select a subregion
>   res at mpMaxLonF            = 54.
>   res at mpMinLatF            = -12.
>   res at mpMaxLatF            = 22.5
>
>
>   res at mpLandFillColor      = "background"       ; color of land
>   res at cnFillDrawOrder      = "Predraw"
> ;*********************Masking*********************************
>   res at mpAreaMaskingOn = True
>    res at mpMaskAreaSpecifiers = "Land"
>    res at mpOceanFillColor = 0
>    res at mpFillDrawOrder = "Postdraw"
>
>
>       resMap= True
>       resMap at mpPerimOn = False
>      resMap at mpGridAndLimbOn = False
>     resMap at gsnTickMarksOn = False
>     resMap at mpDataSetName = "Earth..3"
>    resMap at mpDataBaseVersion = "MediumRes"
>    resMap at mpOutlineOn = True
>
>    res                             = True
>   res at mpFillOn                    = False        ; turn off gray fill
>   res at mpOutlineBoundarySets       = "National"   ; turn on country 
> boundaries
>   ;res at mpGeophysicalLineColor      = "Navy"       ; color of cont. 
> outlines
>
>
>   resMap at mpFillOn = True
>
>   resMap at mpOceanFillColor = "transparent"
>   resMap at mpLandFillColor = "transparent"
>   resMap at mpInlandWaterFillColor = "transparent"
>
>    res at mpDataBaseVersion = "MediumRes"            ; choose higher 
> resolution
>
>
> ;delete(precClm at long_name)                       ; do not want
>
>        do ns =0,1
>
>
>
>   do ns=0,1                                 ; loop over the months
> *res at gsnCenterString   = season(ns)+":"+time(0)/100 +"-"+ 
> time(ntim-1)/100*
>      plot(i) = gsn_csm_contour_map_ce(wks,precClm(ns,:,:), res)  ; 
> create plot
>   end do
>
>   gsn_panel(wks,plot,(/2,2/),resP)
> ;************************************************
> ; create second panel plot
> ;*************************************************
>  delete(precStd at long_name)
>                                          ; Std Deviations
>   do ns=0,1                                 ; loop over the months
>
>      res at gsnCenterString   = season(ns)+":"+time(0)/100 +"-"+ 
> time(ntim-1)/100
>      plot(i) = gsn_csm_contour_map_ce(wks,precStd(ns,:,:), res)  ; 
> create plot
>   end do
>
>   gsn_panel(wks,plot,(/2,2/),resP)
>
> end do
>  end
>
>
>
>
>
> Best Regards
> George Otieno
>
> Intergrated Climate System Modelling Lab.
> Department of Environmental Atmospheric Sciences
> 608-737, Room 4302, Chungmu-Building
> Pukyong National University,
> 45,Yongso-ro,Nam-gu, Busan, South Korea
> Tel. +82-51-629-6643
> Fax+82-51-629-7991*
> *
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150728/25381c4d/attachment.html 


More information about the ncl-talk mailing list