Re: syntax of reading netCDF4 files with groups

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Fri Jan 04 2013 - 16:38:21 MST

Wenshan,

I'll check and get back to you.

Thanks,

Wei

huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

On Jan 4, 2013, at 4:32 PM, Wenshan Wang wrote:

> The version of NCL I am using is: 6.1.0-08Oct2012_1119
>
> I've put my sample file on the ftp:
> incoming/snd_LImon_all-model_historical_all-ens_GN_monthly-anomaly.nc
>
> Thank you!
>
> Best,
> Wenshan
>
>
> On Fri, Jan 4, 2013 at 3:15 PM, Wenshan Wang <wenshanw@uci.edu> wrote:
> Dear all,
>
> I am trying to read netCDF4 files with groups, following the example given on the page of 'getfilegrpnames'.
> Here it is:
> f = addfile ("X.nc" , "r") ; could also have ccm, grb or hdf suffux
> gNames = getfilegrpnames (f) ; get names of all groups on file
>
> nNames = dimsizes (gNames) ; number of groups on the file
>
> print (nNames) ; print all group names on file
>
> do n=0,nNames-1 ; loop thru each group
> v = f->$gNames(n)$ ; read the group to memory
>
> dimv = dimsizes(v) ; dimension size of the group
> rank = dimsizes(dimv) ; rank [ie: number of dimensions]
>
> [SNIP]
>
> delete (v)
> delete (rank)
> end do
>
> However, if I followed the example and use:
> v = f->$gNames(n)$
> It will result in:
> fatal:["Execute.c":5709]:variable (snc_LImon_bcc-csm1-1_historical_all-ens_clm) is not in file (fin)
>
> Instead, if I use:
> gg = fin=>$gn(j)$
> dd = gg->$var(i)$
> It can read what I want, but there is an error message:
> fatal:NclNetCDF4: Could not reopen the file (~/data/cmip5/output/4plot/snd_LImon_all-model_historical_all-ens_clm.nc) for reading
>
> So, what syntax should I use to read variables in groups?
>
> Thank you very much!
> Happy New Year!
>
> Best,
> Wenshan
>
> _______________________________________________
> 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 Jan 4 16:38:39 2013

This archive was generated by hypermail 2.1.8 : Mon Jan 07 2013 - 08:57:08 MST