Re: question about reading .nc files

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed May 19 2010 - 09:38:49 MDT

Hi Liang,

You can use the special "$...$" syntax to reference a variable that is
defined by another variable.

For example:

    var = fi->$name(i)$

You can only do this when referencing attributes, dimension names,
coordinate arrays, or variables on a file.
You can't use this syntax in free-standing method, like:

   $var$ = ...

Also, I don't know if it will help in your case, but since you are
reading in a series of files, you might want to look at "addfiles":

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

--Mary

On May 19, 2010, at 9:08 AM, Liang Guo wrote:

> Hello,
>
> I have a question about reading .nc files.
>
> I have a couple of .nc files, say, a.nc, b.nc, c.nc, ..., z.nc. And
> each file contains a variable as same name as file name, i.e. a in
> a.nc, b in b.nc, ..., z in z.nc. I try to read these files in a loop,
> some thing like:
>> begin
>>
>> name = (/"a","b","c",...,"z"/)
>> n_name = dimsizes(name)
>> do i = 0, n_name-1
>> fi = addfile(name(i)+".nc","r")
>> var = fi->name(i)
>> ...
>> ...
>> end do
>>
>> end
>
> Obviously, 'var = fi->name(i)' is not correct expression. So, my
> question is can I make it right?
>
> Thank you
> Liang
> _______________________________________________
> 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 May 19 09:39:00 2010

This archive was generated by hypermail 2.1.8 : Wed May 26 2010 - 10:39:13 MDT