Mathieu, yes you can. Here's a simple example that reads the dataset at
'/hs' and prints

its dimensions and values. (You'll need IronPython http://ironpython.net/)

I'm not sure what you mean by "projection and matrix information". Where do

they live? In attributes? You can look at the file in HDFView

(http://www.hdfgroup.org/hdf-java-html/hdfview/)...

 

Cheers, G.

 

From: hdf-forum-boun...@hdfgroup.org [mailto:hdf-forum-boun...@hdfgroup.org]
On Behalf Of Mathieu
Sent: Sunday, August 12, 2012 7:39 AM
To: hdf-forum@hdfgroup.org
Subject: [Hdf-forum] Can Hdf5DotNet replace GDAL# in my case?

 

Dear all,

 

I am a windows C# developer, I develop a weather forecast web site for
french surfers.

I am working with a oceanographic data provider since 3 years, and until now
I was using Gdal# to read their HDF (.nc) data.

Recently, this data provider released a new product, and used a new version
of HDF : V5.

GDAL# cannot read these data. After some researchs on the web and
discussions with the data provider, Gfdal#'s HDF library is too old. Gdal
does not plan to update it in a near future.

As a consequence I am looking for an alternative library to read HDF data.

 

Then I found HDF5DotNet.

 

I have started to study the library, but I fell I will have to invest a lot
to adapt my tools to this library.

That's why before to start working on HDF5DotNet, I would like to ensure
that this library is able to read these data I want to be compatible with.

 

So my request is :

Could anybody who is confortable with HDF5DotNet try to open this file with
this library?

I know it is not a common request, but it would save me so much time!

The sample file is here :

www.yadusurf.com/PREVIMER_WW3-AQUITAINE-200M_20120101T00Z.nc

(It is quiet big, 54Mo, but the server has a quiet good bandwidth)

 

Basically my need is to :

- Read projection and matrix information (projection is just position of the
grid and cell size/size of the grid)

- Read the band "hs" (there are other intersecting datasets but validating
this one is enough)

 

 

In advance, thanks

Mathieu

import clr
clr.AddReferenceToFile('HDF5DotNet.dll')
import HDF5DotNet
from HDF5DotNet import *

import System
from System import Array, Int16

print 'Initializing HDF5 library'
status = H5.Open()

h5file = H5F.open('PREVIMER_WW3-AQUITAINE-200M_20120101T00Z.nc', 
H5F.OpenMode.ACC_RDONLY)

dset = H5D.open(h5file, 'hs')

dspace = H5D.getSpace(dset)
rank = H5S.getSimpleExtentNDims(dspace)
dims = H5S.getSimpleExtentDims(dspace)

print 'rank %d, dimensions %ld x %ld x %ld' % (rank, dims[0], dims[1], dims[2])

data = Array.CreateInstance(Int16, dims)

dtype = H5T.copy(H5T.H5Type.NATIVE_SHORT)

P_DEFAULT = H5PropertyListId(H5P.Template.DEFAULT)

H5D.read(dset, dtype, H5Array[Int16](data))

for row in range(dims[1]):
    for col in range(dims[2]):
        print '%d ' % data[0,row,col],
    print ''

H5T.close(dtype)
H5S.close(dspace)
H5D.close(dset)

H5F.close(h5file)

print 'Shutting down HDF5 library'
status = H5.Close()
_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to