.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/generate_SC_PSD.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_generate_SC_PSD.py: Generate a PSD from SpinCore Data ================================= Here, data containing the noise signal acquired on the SpinCore is converted to a power spectral density and convolved to display a smooth spectra illustrating the noise power. .. GENERATED FROM PYTHON SOURCE LINES 8-57 .. image-sg:: /auto_examples/images/sphx_glr_generate_SC_PSD_001.png :alt: PSD acquired on SpinCore :srcset: /auto_examples/images/sphx_glr_generate_SC_PSD_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 1: PSD acquired on SpinCore |||ks | .. code-block:: Python from numpy import r_ import pyspecdata as psd from pyspecProcScripts import lookup_table from pylab import diff, sqrt lambda_G = 4e3 # Width for Gaussian convolution dg_per_V = 583e6 # Calibration coefficient to convert the # intrinsic SC units to V at the input of # the receiver. Note this value will change # with different SW filename = "230822_BNC_RX_magon_200kHz.h5" with psd.figlist_var() as fl: # Load data and apply preprocessing s = psd.find_file( filename, exp_type="ODNP_NMR_comp/Echoes", expno="signal", postproc="spincore_general", lookup=lookup_table, ) s.rename("nScans", "capture") # To be more consistent # with the oscilloscope # data, rename the nScans # dimension s /= dg_per_V # Convert the intrinsic units of the SC # to $V_{p}$ s.set_units("t", "s") # Calculate $t_{acq}$ acq_time = diff(s.getaxis("t")[r_[0, -1]])[0] s /= sqrt( 2 ) # Instantaneous Vₚ√s / √Hz to # Vᵣₘₛ√s / √Hz # {{{ equation 21 s = abs(s) ** 2 # Take mod squared to convert to # energy $\frac{V_{rms}^{2} \cdot s}{Hz}$ s.mean("capture") # Average captures s /= acq_time # Convert to Power $\frac{V_{rms}^2}{Hz} = W$ s /= 50 # Divide by impedance $\rightarrow$ W/Hz # }}} # Plot unconvolved PSD on a semilog plot s.name(r"$S(\nu)$").set_units("W/Hz") fl.next("PSD acquired on SpinCore") fl.plot(s, color="blue", alpha=0.1, plottype="semilogy") # Convolve using the $\lambda_{G}$ specified above s.convolve("t", lambda_G, enforce_causality=False) # Plot the convolved PSD on the semilog plot with the # unconvolved fl.plot(s, color="blue", alpha=0.5, plottype="semilogy") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.631 seconds) .. _sphx_glr_download_auto_examples_generate_SC_PSD.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: generate_SC_PSD.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: generate_SC_PSD.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_