.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/append_conc_to_h5file.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_append_conc_to_h5file.py: Edit the concentration parameter of a saved HDF5 file ===================================================== Loads in a previously saved HDF5 dataset. If the attribute 'concentration' does not exist in the acq_params, this will add the concentration defined by 'actual_conc' into acq_params under 'concentration'. If the attribute already exists it will simply replace the current concentration with the value of 'actual_conc'. .. GENERATED FROM PYTHON SOURCE LINES 12-27 .. code-block:: Python from pyspecdata import * import h5py, os data_info = dict( filename="220126_Ras_M67R1a_capProbe.h5", # file that is being edited file_location="ODNP_NMR_comp/ODNP", # location of file actual_conc=72e-6, ) # concentration of the dataset in M h5 = search_filename( data_info["filename"], exp_type=data_info["file_location"], unique=True ) with h5py.File(os.path.normpath(h5), "r+") as thisfile: acq_params = thisfile["enhancement"]["other_info"]["acq_params"] acq_params.attrs["concentration"] = data_info["actual_conc"] thisfile.close() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.011 seconds) .. _sphx_glr_download_auto_examples_append_conc_to_h5file.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: append_conc_to_h5file.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: append_conc_to_h5file.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_