Re: Help with reading in multiple files to continue through errors

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Wed Aug 01 2012 - 12:26:00 MDT

Use the function isfilevar(). See the first example on this page:

http://www.ncl.ucar.edu/Document/Functions/Built-in/isfilevar.shtml

--Dave

On Wed, Aug 1, 2012 at 11:53 AM, Erika Roesler <eroesler@gmail.com> wrote:
>
>> Hi,
>>
>> I am reading variables into an array from in a large set of *.nc files.
>> These files were generated from a set of simulations where some worked, and
>> some didn't. In the simulations that didn't, I want ncl to keep the missing
>> values (-9999) for that spot in the array and continue to the next file.
>> How do I tell ncl to keep going after a file variable input failure:
>>
>> fatal:["Execute.c":5609]:
>> variable (XYZ) is not in file (ncdf_file0)
>>
>>
>> and the example script:
>>
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>
>> begin
>>
>> nfiles = 5000
>>
>> ;**********************************************
>> ; Create variable arrays
>> ;**********************************************
>> zztop = 96 ; max height to plot
>> zz = ispan(20,3820,40)
>> day = (118.5-117.5)/144
>> t0 = ispan(0,143,1)*day + 117.5
>>
>> dfe = ispan(1,nfiles,1)
>>
>> XYZ0 = new((/zztop,dimsizes(t0),dimsizes(dfe)/), float, -9999)
>>
>> ;**********************************************
>> ; Loop over files to create plots
>> ;**********************************************
>>
>> do h=0,dimsizes(dfe)-1
>>
>> filename(h) = "myfile" + h + ".nc"
>> ncdf_file0 = addfile(filename(h),"r")
>>
>> do i=0,dimsizes(t0)-1
>> do j=0,zztop-1
>> XYZ0(j,i,h) = ncdf_file0->XYZ(i,j) ; XYZ var
>> end do
>> end do
>>
>> end do
>>
>> end
>
>
>
> _______________________________________________
> 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 Wed Aug 1 12:26:14 2012

This archive was generated by hypermail 2.1.8 : Fri Aug 03 2012 - 14:39:58 MDT