[ncl-talk] Read HDF5 file

dream916 dream916 at gmail.com
Tue Jun 9 13:13:42 MDT 2015


Sorry about the typo. I meant HDF5, not HDF4. I am able to access the top
group using statement emissions = f=>emissions. However, I am unable to
access the subgroup in the group emissions. For instance, group emissions
has two subgroups : monthly value dry matter (DM) and corresponding
partitioning. How can I read DM from group 01 and C_AGRI from group
partitioning?
Thanks!

Lei


On Tue, Jun 9, 2015 at 2:49 PM, David Brown <dbrown at ucar.edu> wrote:

> This is a bit confusing, because you say HDF5 in the subject, but then
> you say that the data is in hdf4 format. The current version of NCL
> handles HDF4 groups differently from HDF5 groups. The HDF4 module uses
> group tag numbers appended to the variable names to differentiate
> groups. Eventually we would like to make both modules work the same
> way but that is not the case now.
> You have not said whether you tried your code on a sample file. If it
> worked, then you actually have HDF5 data.
> Basically you should be able to treat a group just like a file, so you
> should be able to get subgroups of a group the same way you get the
> top level groups from the file.
>  -dave
>
>
>
> On Tue, Jun 9, 2015 at 11:35 AM, dream916 <dream916 at gmail.com> wrote:
> > Hi,
> >
> > I was trying to read global fire emission dataset v4 in hdf4 format. I
> > searched online and couldn't find any examples how to read groups within
> > group. My code is as follows:
> >
> > ; read hdf5 fire dataset
> > begin
> > setfileoption("h5", "FileStructure", "Advanced")
> > f = addfile("GFED4.0s_1997.hdf5","r")
> > grps = getfilegroups(f,"/",0)
> > print(grps)
> > grps2 = getfilegroups(f,"/emissions/",0)
> > print(grps2)
> > lat = f->lat
> > lon = f->lon
> > printVarSummary(lat)
> > printVarSummary(lon)
> > g = f=>ancill
> > gridarea = g->grid_cell_area
> > printVarSummary(gridarea)
> > emissions = f=>emissions
> >
> > in the dataset, emissions is a group which contains two subgroups (month
> and
> > partitioning) (see below).
> >
> > group: emissions {
> >
> >
> >   group: \01 {
> >
> >     dimensions:
> >
> >     phony_dim_52 = 720 ;
> >
> >     phony_dim_53 = 1440 ;
> >
> >     variables:
> >
> >     float C(phony_dim_52, phony_dim_53) ;
> >
> >     string C:long_name = "GFED4s biomass burning carbon emissions" ;
> >
> >     string C:units = "g C / m^2 / month" ;
> >
> >     float DM(phony_dim_52, phony_dim_53) ;
> >
> >     string DM:long_name = "GFED4s biomass burning dry matter emissions" ;
> >
> >     string DM:units = "kg DM / m^2 / month" ;
> >
> >     float small_fire_fraction(phony_dim_52, phony_dim_53) ;
> >
> >     string small_fire_fraction:long_name = "Fraction of total GFED4s
> biomass
> > burning emissions originating from \"small fire burned area\"" ;
> >
> >     string small_fire_fraction:units = "Unitless (fraction)" ;
> >
> >
> >     group: partitioning {
> >
> >       dimensions:
> >
> >       phony_dim_50 = 720 ;
> >
> >       phony_dim_51 = 1440 ;
> >
> >       variables:
> >
> >       float C_AGRI(phony_dim_50, phony_dim_51) ;
> >
> >       string C_AGRI:long_name = "Contribution of agricultural waste
> burning
> > to total monthly biomass burning carbon emissions" ;
> >
> >       string C_AGRI:units = "Unitless" ;
> >
> >       float C_BORF(phony_dim_50, phony_dim_51) ;
> >
> >       string C_BORF:long_name = "Contribution of boreal forest fires to
> > total monthly biomass burning carbon emissions" ;
> >
> >       string C_BORF:units = "Unitless" ;
> >
> >
> > So my question is how to read the monthly emissions and partitioning
> > associated with each month into an array.
> > Thanks,
> > Lei Meng
> >
> >
> > _______________________________________________
> > ncl-talk mailing list
> > ncl-talk at ucar.edu
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150609/1863812b/attachment.html 


More information about the ncl-talk mailing list