.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/process_EPR.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_process_EPR.py: EPR data processing =================== An example user-defined function for processing EPR data with the DNPLab package. .. GENERATED FROM PYTHON SOURCE LINES 12-13 For the function below the call would look something like, .. GENERATED FROM PYTHON SOURCE LINES 13-28 .. code-block:: default """ lsobject = ls.start( parent_directory, skip=[".DSC", ".YGF", ".par"], # otherwise duplicates classifiers=["max_loc", "frequency"], function=process_EPR.proc_epr, function_args={}, ) lsobject.drive() """ # parent_directory contains Bruker EPR data. Add patterns, skip, date searching, etc. # according to the lsframe docs. The function_args are empty in this case. Since DTA # and spc files come with companion DSC, YGF, or par files and DNPLab uses any of these, # skip these files to avoid duplicates. .. GENERATED FROM PYTHON SOURCE LINES 31-32 Import DNPLab and any other packages that may be needed for your function, .. GENERATED FROM PYTHON SOURCE LINES 32-35 .. code-block:: default import dnplab as dnp import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 38-39 The function accepts a path to an EPR spectrum file and returns the field value where the spectrum is maximum and the frequency. The function returns zeros where errors are encountered. .. GENERATED FROM PYTHON SOURCE LINES 39-54 .. code-block:: default def proc_epr(path, args): try: data = dnp.dnpImport.load(path) if len(data.dims) == 1 and "frequency" in data.attrs.keys(): return [ np.argmax(data.values, axis=0) / len(data.values), data.attrs["frequency"], ] else: return [0, 0] except: return [0, 0] .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_process_EPR.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: process_EPR.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: process_EPR.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_