Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
hdf5 [2018/02/01 19:49] – [Using H5 tools] adminhdf5 [2018/02/01 19:57] (Version actuelle) – [Links] admin
Ligne 66: Ligne 66:
 </code> </code>
  
 +===Python example===
 +We need to load python first <code bash>$ module load lang/python</code>
 +**Wrire HDF5**
 +<code python>
 +#!/usr/bin/env python
 +import h5py
  
 +# Create random data
 +import numpy as np
 +data_matrix = np.random.uniform(-1, 1, size=(10, 3))
 +
 +# Write data to HDF5
 +data_file = h5py.File('file.hdf5', 'w')
 +data_file.create_dataset('group_name', data=data_matrix)
 +data_file.close()
 +</code>
 +
 +**Read HDF5**
 +<code python>
 +
 +import h5py
 +filename = 'file.hdf5'
 +f = h5py.File(filename, 'r')
 +
 +# List all groups
 +print("Keys: %s" % f.keys())
 +a_group_key = list(f.keys())[0]
 +
 +# Get the data
 +data = list(f[a_group_key])
 +
 +</code>
 ===== Using H5 tools ===== ===== Using H5 tools =====
  
Ligne 84: Ligne 115:
 {{ :hdfview.png? |}} {{ :hdfview.png? |}}
 */ */
-====== Liens ======+====== Links ======
  
-http://www.hdfgroup.org/HDF5/+  * http://www.hdfgroup.org/HDF5/ 
 +  * https://support.hdfgroup.org/HDF5/doc/H5.intro.html
  • hdf5.1517514599.txt.gz
  • Dernière modification : 2018/02/01 19:49
  • de admin