.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/ppm_example.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_ppm_example.py: ppm Example =========== Demonstrates how to convert from offset in Hz to ppm scale .. GENERATED FROM PYTHON SOURCE LINES 8-56 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/images/sphx_glr_ppm_example_001.png :alt: full spectrum, Hz :srcset: /auto_examples/images/sphx_glr_ppm_example_001.png, /auto_examples/images/sphx_glr_ppm_example_001_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_ppm_example_002.png :alt: full spectrum, ppm :srcset: /auto_examples/images/sphx_glr_ppm_example_002.png, /auto_examples/images/sphx_glr_ppm_example_002_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_ppm_example_003.png :alt: sliced spectrum, Hz :srcset: /auto_examples/images/sphx_glr_ppm_example_003.png, /auto_examples/images/sphx_glr_ppm_example_003_2_00x.png 2.00x :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_ppm_example_004.png :alt: sliced spectrum, ppm :srcset: /auto_examples/images/sphx_glr_ppm_example_004.png, /auto_examples/images/sphx_glr_ppm_example_004_2_00x.png 2.00x :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none 1: full spectrum, Hz |||Hz 2: full spectrum, ppm |||ppm 3: sliced spectrum, Hz |||Hz 4: sliced spectrum, ppm |||ppm | .. code-block:: Python from pylab import * from pyspecdata import * #pull parameters from RM1_sept30_1H_211001 expno 1 # make peaks on a frequency axis x = nddata(r_[0:6.8157439:32768j], "t2") x.set_units("t2", "s") # generate time-domain signal SW_h = 1./(x.getaxis('t2')[1] - x.getaxis('t2')[0]) signal = 0 * x # create an array of zeros that's the right shape SFO1 = 400.1307334 BF1 = 400.13 SF = 400.1301846 TMS_shift = (SF-SFO1)*1e6 for A, nu, R in [ (0.3, TMS_shift, 0.04), (1, 25, 0.08), (1, 50, 1.2), (1, 20, 0.45), (1, 750, 1.2), (1, 10, 0.08), ]: #nu = SFO1 + nu # it's really unclear why this is done! signal += A * exp(1j * 2 * pi * nu * x - x / R) signal.set_units("t2", "s") signal.ft("t2", shift=True) OFFSET = (SFO1/SF-1) * 1.0e6 + 0.5 * SW_h * SFO1/SF signal.set_prop('acq',{'SFO1':SFO1,'SW_h':SW_h}) signal.set_prop('proc',{'SF':SF, 'OFFSET':OFFSET}) # Copy of signal to demonstrate truncation signal_sliced = signal.C with figlist_var() as fl: fl.next("full spectrum, Hz") fl.plot(signal) signal.to_ppm() fl.next("full spectrum, ppm") fl.plot(signal) signal_sliced = signal_sliced["t2":(0.2e3, 1.4e3)] fl.next("sliced spectrum, Hz") fl.plot(signal_sliced) signal_sliced.to_ppm() fl.next("sliced spectrum, ppm") fl.plot(signal_sliced) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.402 seconds) .. _sphx_glr_download_auto_examples_ppm_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ppm_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ppm_example.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_