Some sample snippet to read kalpana-1 hdf5 dataset using NCSA hdf5 library:
public Test(String filename) throws HDF5Exception, Exception {
H5File h5File = new H5File(filename, FileFormat.READ);
int id = h5File.open();
H5Group rootGroup = (H5Group) ((DefaultMutableTreeNode)
h5File.getRootNode()).getUserObject();
List<HObject> member_list = rootGroup.getMemberList();
H5Group vhrr_group = null;
for (int i = 0; i < member_list.size(); i++) {
HObject member = member_list.get(i);
if (member.getName().equals("VHRR")) {
vhrr_group = (H5Group) member;
break;
}
}
List<HObject> vhrr_members = vhrr_group.getMemberList();
H5Group image_data_group = null;
for (int i = 0; i < vhrr_members.size(); i++) {
HObject vhrr_member = vhrr_members.get(i);
if (vhrr_member.getName().equals("Image Data")) {
image_data_group = (H5Group) vhrr_member;
break;
}
}
List<HObject> image_data_members =
image_data_group.getMemberList();
H5ScalarDS tir_ds = null;
for (int i = 0; i < image_data_members.size(); i++) {
HObject image_data_member = image_data_members.get(i);
if (image_data_member.getName().equals("VHRR_TIR")) {
tir_ds = (H5ScalarDS) image_data_member;
break;
}
}
short[] tir_data =(short[]) tir_ds.read();
long dims[] = tir_ds.getDims();
int scans = (int) dims[0];
int pixels = (int) dims[1];
h5File.close();
}
Now you have got the samples and dimensions of dataset, now you can
create a visad data object using
that. You can check any of the examples bundled with visad library.
I think you can start from here...
As far as library settings are concerned.
You should have all java-hdf jars in your project.
and dll(for windows) and .so (for linux) in LD_LIBRARY_PATH.
I hope it helps
One more point, being a JNI library this should be relatively
performance wise faster as compared to netcdf-java which is pure java
library.
Ghansham
On 03/25/2014 11:30 PM, visad-request@xxxxxxxxxxxxxxxx wrote:
Send visad mailing list submissions to
visad@xxxxxxxxxxxxxxxx
To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.unidata.ucar.edu/mailman/listinfo/visad
or, via email, send a message with subject or body 'help' to
visad-request@xxxxxxxxxxxxxxxx
You can reach the person managing the list at
visad-owner@xxxxxxxxxxxxxxxx
When replying, please edit your Subject line so it is more specific
than "Re: Contents of visad digest..."
Today's Topics:
1. Re: help (Tom Whittaker)
2. Re: help (Curtis Rueden)
3. Re: help (Tom Whittaker)
----------------------------------------------------------------------
Message: 1
Date: Tue, 25 Mar 2014 09:12:12 -0500
From: Tom Whittaker<whittaker@xxxxxxxx>
To: Devanshi Prajapati<prajapati.devanshi@xxxxxxxxx>
Cc: "visad@xxxxxxxxxxxxxxxx"<visad@xxxxxxxxxxxxxxxx>
Subject: Re: [visad] help
Message-ID:
<CAA6nkJBHXNWD=YWJ2+TWbG865GQwVXQmC4+xTEZuj2X2YSDJrg@xxxxxxxxxxxxxx>
Content-Type: text/plain; CHARSET=US-ASCII
I believe the main issue here is that the code in the VisAD library
for HDF files has not been maintained by the original authors. This
also is true of the netCDF adapter ("Plain"). Unfortunately, this
means that for files that use newer features in these formats, the
code no longer works.
I do not have any solutions, other than as Ghansham suggests, using
the "official" releases of the respective libraries and then building
your own VisAD Data objects...
tom
On Fri, Mar 21, 2014 at 3:14 AM, Devanshi Prajapati
<prajapati.devanshi@xxxxxxxxx> wrote:
Hi.......This is my program,
package myapp;
import java.rmi.RemoteException;
import visad.DataImpl;
import visad.VisADException;
import visad.data.hdf5.HDF5Form;
import ncsa.hdf.hdf5lib.*;
public final class hfAdapter2
{ String filePath;
public hfAdapter2() throws VisADException, RemoteException
{
filePath="F:\\Devanshi\\Input\\xyz.h5";
System.load("F:\\Devanshi\\Projects\\MyApp\\Lib\\jhdf.dll");
System.load("F:\\Devanshi\\Projects\\MyApp\\Lib\\jhdf5.dll");
HDF5Form h=new HDF5Form();
DataImpl ncData=h.open(filePath);
}
public static void main(String[] args)
throws RemoteException, VisADException, IOException
{ new hfAdapter2();
}
}
And the Error I got is,
run:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
ncsa.hdf.hdf5lib.H5.H5Fopen(Ljava/lang/String;II)I
at ncsa.hdf.hdf5lib.H5.H5Fopen(Native Method)
at visad.data.hdf5.hdf5objects.HDF5File.<init>(HDF5File.java:85)
at visad.data.hdf5.HDF5FileAdapted.<init>(HDF5FileAdapted.java:70)
at visad.data.hdf5.HDF5Form.open(HDF5Form.java:102)
at myapp.hfAdapter2.<init>(hfAdapter2.java:46)
at myapp.hfAdapter2.main(hfAdapter2.java:96)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
--
Devanshi U. Prajapati
_______________________________________________
visad mailing list
visad@xxxxxxxxxxxxxxxx
For list information, to unsubscribe, visit:
http://www.unidata.ucar.edu/mailing_lists/