.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/indiv_funcs/hdf_test.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_indiv_funcs_hdf_test.py: Save data to HDF5 ================= Save nddata to standard HDF5 format. .. GENERATED FROM PYTHON SOURCE LINES 6-28 .. rst-class:: sphx-glr-script-out .. code-block:: none WARNING!!, attributes ['other_info'] are dictionaries! WARNING!!, attributes ['dimlabels'] are lists! You didn't set units for b before saving the data!!! Units set for the a axis are: s array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) dimlabels=['a', 'b'] axes={`a':array([0, 1, 2]) +/-None, `b':array([1, 2, 3]) +/-None} | .. code-block:: Python from pyspecdata import nddata, nddata_hdf5 from numpy import r_ import os a = nddata(r_[0:9], [3, 3], ["a", "b"]).labels( dict( a=r_[0:3], b=r_[1:4], ) ) a.name("test_data") a.set_units("a", "s").set_units("W") a.hdf5_write("test.h5") a_reload = nddata_hdf5("test.h5/test_data") print("Units set for the a axis are:", a_reload.get_units("a")) assert (a.data == a_reload.data).all() assert (a.getaxis("a") == a_reload.getaxis("a")).all() assert (a.getaxis("b") == a_reload.getaxis("b")).all() assert a.get_units("a") == "s" assert a.get_units() == "W" print(a_reload) os.remove("test.h5") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.071 seconds) .. _sphx_glr_download_auto_examples_indiv_funcs_hdf_test.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: hdf_test.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: hdf_test.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_