[ncl-talk] Read HDF5 file

Rashed Mahmood rashidcomsis at gmail.com
Tue Jun 9 15:00:05 MDT 2015


Hi Lei,

I had spent sometime on reading the GFEDS v4 data using NCL version 6.2.1
and have written the attached NCL script that reads the data for each
month, and emission source for 18 years and a particular aerosol type. I do
not if you need those calculations as I did inside the loops to obtain
final aerosol emissions which is summed over all 6 sources. To check the
accuracy of calculation it prints "glob_mn" which can be compared with
table values provided on the data site.

I hope that may work for you, at least should provide some sense how deal
with grouped hdf5 data.
Let us how it works.

Good Luck!
Rashed


Date: Tue, 9 Jun 2015 13:35:18 -0400
From: dream916 <dream916 at gmail.com>
Subject: [ncl-talk] Read HDF5 file
To: ncl-talk forum <ncl-talk at ucar.edu>
Message-ID:
        <CABOT6NTdtm4HYqW5HV+V6whq9jzD8xyKVOYxiAQi+ZgQP++uJQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150609/c53dc913/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: convert_gfed4s_to_netcdf.ncl
Type: application/octet-stream
Size: 4381 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150609/c53dc913/attachment.obj 


More information about the ncl-talk mailing list