Re: NetCDF addfile question

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Fri Nov 09 2012 - 13:59:39 MST

Hi Nick,

It is true that you cannot get the global file attributes from the list variable that contains the aggregation of all the files. That is at least in part because the global attributes for each file will not necessarily have the same values, even if they form a logical sequence of files. Also until recently 'list' type variables did not support attributes. However, you do not have to open a particular file in a separate 'addfile' call to get the global attributes for any individual file. Rather than

AttsAll=getvaratts(fAll)

just use:

AttsAll=getvaratts(fAll[0])

Hope this helps.
 -dave

On Nov 7, 2012, at 12:30 PM, Nick Guy wrote:

> Hello,
> I created NetCDF files recently and used the addfiles function to read a list. I was having trouble reading in the global attributes until I discovered that I had to only read one file at a time via addfile to be able to properly read global attributes. So just a general question: Anyone know why are the attributes not allowed to be read in the same way as variables for the different functions?
>
> I've pasted the snippet of code below that I help demonstrates what I am getting at.
> ;=========================================
> sondeList=systemfunc("ls "+fdir+"D20111122_*.nc")
>
> ; Read all NetCDF files
> fAll=addfiles(sondeList,"r")
>
> file0=addfile(sondeList(0),"r")
>
> ListSetType(fAll,"join")
>
> AttsAll=getvaratts(fAll) ;; THIS RETURNS ONLY ONE MISSING FIELD
> print(AttsAll)
>
> Atts0=getvaratts(file0) ;; THIS RETURNS THE GLOBAL ATTRIBUTES
> print(Atts0)
>
> I was having trouble reading in the global attributes
> ========================================
> All the best,
>
> Nick Guy
> nick.guy@noaa.gov
>
>
>
>
> _______________________________________________
> 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 Fri Nov 9 13:59:48 2012

This archive was generated by hypermail 2.1.8 : Tue Nov 13 2012 - 14:27:24 MST