This tutorial enables you to get a feel for HDF5 by using the HDFView browser. It does NOT require any programming experience. You just need to download and install HDFView (and a couple of other files).
Installation
Download and install HDFView. It can be downloaded from the HDFView Home Page.
The following text file and tool are used in this tutorial. You may wish to obtain them beforehand:
- storm1.txt - A file containing data
- h5dump - An HDF5 utility to view HDF5 files textually
You can obtain h5dump from the Obtain Latest page. In the right-most column of the table at the end, you can separately download the HDF5 utilities, including h5dump.
Begin Tutorial
If you have HDFView installed, then bring it up and you are ready to begin the tutorial.
Here are some facts about HDF5 which may help in this tutorial:
- All HDF5 files contain a root group "/".
- There are two primary objects in HDF5, a group and a dataset.
-
By use of groups your data can be organized in a tree-like
(or even more complex) structure.
Following are the topics covered in the tutorial. Do the first one to create the file, and then the others can be done in any order:
- Creating a New HDF5 file with a Contiguous Dataset
- Creating a Compressed and Chunked Dataset
- Creating an Image and a Subset
- Creating a Table
Creating a New HDF5 File with a Contiguous Dataset
- Select the File pull-down menu at the top left and then select New -> HDF5.
-
Type in storm.h5 for the name of your file, and click on the
Save button.
On the left side of the HDFView screen is the "tree" view. Once you have created storm.h5, you will see a "5" icon, followed by the name of your file, storm.h5. At this point you have an empty HDF5 file that contains nothing but the root group, "/". -
Right click on storm.h5 and select New -> Group .
-
Enter Data for the name of the group and then click the OK button.
In the tree view you will see the folder (group) Data under the storm.h5 file. The path to this group is /Data. -
Right click on the group Data and select New -> Dataset.
- A window pops up on the right. Fill in the information as follows and then click OK:
Dataset Name: Storm Current Size: 57x57 Maximum Size: 57x57 Layout: Contiguous (default)
You will see Storm listed under the group Data in the tree view on the left. The path to Storm is /Data/Storm. -
Double left click on the Storm dataset in the tree view. A spreadsheet pops up on the right.
- Copy the data from the storm1.txt
file into the dataset
If you downloaded storm1.txt, then:
- Right click on the Table menu and select Import Data from File.
- Select storm1.txt and click on the Open button; answer Yes in the dialog box.If you copy/paste directly, then:
- Select and copy the data in a separate window.
- Then position your cursor at (0,0) in your table, and select paste from the Table menu. - Close the dataset and save the data.
- Right click on Storm in the tree view and select Open As.
-
Select the Image button under Display As in the
window that pops up and then click OK.
The image will be displayed. At the top of the Image window, you will see both a + and - magnifying glass button. Make the image larger and smaller with these buttons. - Optionally view the storm.h5 file with h5dump.
View your file with h5dump by typing h5dump storm.h5.
The h5dump utility displays the contents of a file in DDL
(Data Description Language). Typing h5dump --header storm.h5
will display your file without the data. It might look something like
this, depending on the platform:
HDF5 "storm.h5" { GROUP "/" { GROUP "Data" { DATASET "Storm" { DATATYPE H5T_STD_I32LE DATASPACE SIMPLE { ( 57, 57 ) / ( 57, 57 ) } } } } }
Creating a Compressed and Chunked Dataset:
- Right click on storm.h5. Select New -> Group.
-
Enter Image for the name of the group and click the OK button.
A new group (folder) entitled Image will show up in the tree view on the left, under the storm.h5 file. Its path is: "/Image" -
Right click on the Image group and select New -> Dataset.
-
Enter the following information for the dataset:
Dataset Name: Another Storm Current Size: 57x57 Maximum Size: 57x57 Storage Layout: Chunked Chunk Size: 20x20 Compression: click on gzip Compression Level: 9
The dataset gets created and will show up under the Image folder in the tree view on the left. Its path is: "/Image/Another Storm" -
Double click on the Another Storm dataset.
A spreadsheet window will pop up on the right side of the screen, containing 0s. -
Copy the data from the storm1.txt file into the dataset. (See the previous topic for copying storm1.txt into a dataset.)
- Close the table and save the data.
- Right click on Another Storm and select Open As.
-
Select the Image button and click the OK button.
You should see an image in the window that pops up on the right. -
Play with the palette (GrayWave probably is the best choice). Close.
- Optionally, use h5dump to view the Another Storm dataset in storm.h5.
Create an Image and a Subset:
- Right click on the Data group and select New -> Image.
- A window pops up on the right. Enter the following and then click OK:
Image Name: Storm Image Height: 57 Width: 57 -
Right click on Storm Image, select Open As.
A Dataset Selection window will pop up on the right. Click on the Spreadsheet button at the top left of the Dataset Selection window.
A spreadsheet will pop up in a window on the right. -
Copy the data from the storm1.txt file into the dataset, as shown previously.
- Close the dataset and save the data.
- Left double click on Storm Image. Close.
The image pops up in a window on the right. -
Right click on Storm Image and select Show Properties.
A window pops up on the right, displaying the properties of the dataset. Select the Attributes tab. Note the attribute called CLASS. This attribute is what lets HDFView know that the dataset is an image. Close.
- Right click on Storm Image and select Open As to bring up the Data Selection window.
- Select a subset by clicking the left mouse on the image in the window and dragging the mouse. Notice that the Height and Width values change. Select to display it as an image. Click OK.
A window pops up with the selected portion of the image displayed in it. -
Position the cursor in the middle of the image. Press Shift+Left Mouse button and hold, and then drag the mouse to select another subset.
- Select Image->Write Selection to Image. Enter Subset for the new image name. Click OK.
- Left double click on the image Subset to bring it up on the right. Close.
Create a Table or Compound Dataset:
- Right button click on the group Data. Select New -> Table.
- A window pops up on the right side of the screen. Only fill in
the following fields:
Dataset name Table Dataspace: Dimension Size 4 Compound Datatype Properties:
Number of Members3 Compound Datatype Properties:
Name / Datatype / Size
Description / string / 4
Temperature / float / 1
Pressure / double / 1Click okay at the bottom.
- Open the Data group (if it is not open) and double left click on the Table object to open it on the right. Edit it. Close.
- Look at the resulting dataset with the h5dump utility.
- - Last modified:September 23rd 2009
