Re: addfiles error?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 14 2012 - 11:10:58 MDT

Hi Erik,

In the systemfunc command, use "ls -1" so that you get one string per filename.

--Mary

On Jun 13, 2012, at 5:15 PM, Erik N wrote:

> Hi Could I please have some help understanding this error?
> The error message dos not tell me how to fix it. I can't find this error in the listserve either.
>
> fatal:incorrect size for list filevar subselection
>
> I'm using addfiles to read 3 files at once. All files are the same dimensions. I don't have any problems when I use a similar script that only uses addfile in a loop on each file.
> Thank you.
> -
> erik
>
>
> [eunoble@GS611-Noble] precip_work $ ncl hov_ncfile_and_plot_rain.ncl
> Copyright (C) 1995-2011 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.0.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
>
>
> Variable: all_files
> Type: string
> Total Size: 24 bytes
> 3 values
> Number of Dimensions: 1
> Dimensions and sizes: [3]
> Coordinates:
> (0) 0.25x0.25_grid_WA_CMORPH_0902-0914-2006_daily.nc
> (1) 0.25x0.25_grid_WA_PERSIANN_0902-0914-2006_daily.nc
> (2) 0.25x0.25_grid_WA_TRMM_0902-0914-2006_daily.nc
> fatal:incorrect size for list filevar subselection
> fatal:Execute: Error occurred at or near line 47 in file hov_ncfile_and_plot_rain.ncl
>
>
> SCRIPT
>
>
> 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
> ;***********************************************
> ; Begin Users Input
> ;***********************************************
> diri = "./"
> ;;; ;fili = "0.25x0.25_grid_Experiment_59_ACC_RAIN_daily.nc"
> fili = "0.25x0.25_grid_WA_*.nc"
> NCFILE_OUT = False
> ASCIIFILE_OUT = False
> IMAGE = True
>
> if NCFILE_OUT then
> diro = "./"
> NCTITLE = "hov_"
> end if
>
> if ASCIIFILE_OUT then
> ASCTITLE = "hov_"
> end if
>
> if IMAGE then
> diro = "./"
> IMAGETITLE = "plot_hov_"
> centertitle = ""
> ;**************************************************************
> ; Format of output file
> ;***************************************************************
> ;type = "x11"
> type = "pdf"
> ;type = "eps"
> ;type = "ps"
> end if
> ;***********************************************
> ; End Users Input
> ;***********************************************
> ;******** Get variable
> all_files = systemfunc ("ls "+fili)
> print(all_files)
> numFILES = dimsizes(all_files)
> f = addfiles (all_files+".nc", "r")
> ListSetType (f, "join")
> ;***** GET Model precipitation ********
> y = f[:]->ACC_RAIN ; SHOULD BE (numFILES,time,lat,lon)
> printVarSummary(y)
> dt = dimsizes(y(0,:,0,0))
> y!1 = "Time"
> numTime=ispan(0,dt-1,1)
> y&Time = numTime
> ;******************************
> ; Area and time of interest
> ;******************************
> printVarSummary(y)
> Y = y(:,:,{7:20},{-30:10})
> printVarSummary(Y)
> ;******************************
> ; Generate Hovmoller
> ;******************************
> Ymod = Y(:,:,:,:)
> Y_hov = dim_avg_n_Wrap(Ymod,2) ; average over all lats
> printVarSummary(Y_hov)
>
> if NCFILE_OUT then
> i = 0
> do while(i.le.numFILES-1)
> ;***************************************************************
> ; Write out to netcdf
> ;***************************************************************
> print("***************************************************************")
> NCFILE= NCTITLE+all_files(i)
> print( "Writing out netcdf file: "+NCFILE)
> system("/bin/rm -f "+diro+NCFILE) ; remove any pre-existing file
> ncdf = addfile(diro+NCFILE ,"c") ; open output netCDF file
> ; make time and UNLIMITED dimension ; recommended
> filedimdef(ncdf,"Time",-1,True)
> ncdf->rain=Y_hov(i,:,:)
> delete(ncdf)
> delete(NCFILE)
> i=i+1
> end do
> end if
>
> if ASCIIFILE_OUT then
> i = 0
> do while(i.le.numFILES-1)
> ; creat ASCII file
> N = dimsizes(Y_hov(:,0)) ; number of rows (time)
> M = dimsizes(Y_hov(0,:)) ; number of columns (lon)
> ;x = new ( numFILES, float,-9999)
> opt = True
> fmtx = M +"f8.2" ; (Lon)f10.2
> opt@fout = ASCTITLE
> write_matrix (Y_hov(i,:,:), fmtx, opt) ; Write out model ascii
> print( "Writing out ascii file: "+ASCITITLE)
> i=i+1
> end do
> end if
>
> if IMAGE then
> i = 0
> do while(i.le.numFILES-1)
> ; Make Plot
> file_title = IMAGETITLE+all_files(i)
> print(file_title)
> plot_title = "Daily Precipitation"
> type@wkColorModel = "cmyk"
> wks = gsn_open_wks(type,file_title)
> gsn_merge_colormaps(wks,"BlAqGrYeOrRe","BlWhRe")
> res = True
> res@gsnFrame = False
> res@cnFillOn = True ; turn on color fill
> res@gsnSpreadColors = True ; use full range of colors
> res@gsnSpreadColorStart = 0
> res@gsnSpreadColorEnd = 101
> res@cnLinesOn = False ; turn off contour lines
> res@cnLineLabelsOn = False ; turn off line labels
> res@lbOrientation = "vertical" ; vertical labelbar
> res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
> res@cnMinLevelValF = 0.
> res@cnMaxLevelValF = 30.
> res@cnLevelSpacingF = 3.
> res@gsnMajorLonSpacing = 5.
> res@tmXBTickSpacingF = 5.
> res@tiXAxisString = "Longitude"
> res@tmXTOn = False ; top tickmarks
> res@tmYROn = False ; right tickmarks
> res@tiYAxisString = "Elapsed Time: SEP 2 to 13, 2006"
> res@tmYLMode = "Explicit"
> res@tmYLValues = (/0,1,2,3,4,5,6,7,8,9,10,11/)
> res@tmYLLabels = (/"09/02","09/03","09/04","09/05","09/06","09/07","09/08","09/09","09/10","09/11","09/12","09/13"/)
> ;res@tmYLValues = (/2,3,4,5,6,7,8,9,10,11/)
> ;res@tmYLLabels = (/"09/04","09/05","09/06","09/07","09/08","09/09","09/10","09/11","09/12","09/13"/)
> ;res@tmXBMinorValues = ""
> res@gsnLeftString = "Lats: 7N to 20N"
> res@gsnCenterString = centertitle
> res@gsnRightString = "Units: mm/day"
> ;res@tiMainString = plot_title
> res@pmTickMarkDisplayMode = "Always"
> plot = gsn_csm_hov(wks,Y_hov(i,:,:),res)
> frame(wks)
> i=i+1
> delete(wks)
> end do
> end if
>
> end
>
> --
> - Erik -
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jun 14 11:11:14 2012

This archive was generated by hypermail 2.1.8 : Fri Jun 15 2012 - 14:51:31 MDT