.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/noise_sources/dark_current.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_gallery_noise_sources_dark_current.py: Dark Current ============ This example illustrates the impact of varying dark current levels on a flow cytometer detector signal. The detector is initialized, dark current noise is applied, and the resulting signals are visualized along with their distributions. .. GENERATED FROM PYTHON SOURCE LINES 10-62 .. image-sg:: /gallery/noise_sources/images/sphx_glr_dark_current_001.png :alt: Raw Signals with Different Dark Current Levels, Histogram of Raw Signals :srcset: /gallery/noise_sources/images/sphx_glr_dark_current_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/FlowCyPy/FlowCyPy/docs/examples/noise_sources/dark_current.py:52: UserWarning: No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument. ax_signal.legend() | .. code-block:: Python import matplotlib.pyplot as plt from FlowCyPy.detector import Detector from FlowCyPy import units from FlowCyPy import TransimpedanceAmplifier import numpy from FlowCyPy import NoiseSetting NoiseSetting.include_noises = True NoiseSetting.include_shot_noise = False NoiseSetting.include_dark_current_noise = True NoiseSetting.include_source_noise = False # Define dark current levels dark_currents = [1e-9 * units.ampere, 5e-9 * units.ampere, 1e-8 * units.ampere] # Dark current levels in amperes # Create a figure for signal visualization fig, (ax_signal, ax_hist) = plt.subplots(2, 1, figsize=(10, 6), sharex=False) # Loop over the dark current levels for dark_current in dark_currents: # Initialize the detector detector = Detector( name=f"{dark_current.magnitude:.1e} A", responsivity=1 * units.ampere / units.watt, # Responsitivity (current per power) numerical_aperture=0.2 * units.AU, # Numerical aperture phi_angle=0 * units.degree, # Detector orientation angle dark_current=dark_current # Dark current level ) # Add dark current noise to the raw signal noise_current = detector.get_dark_current_noise(sequence_length=200, bandwidth=10 * units.megahertz).to(units.ampere) # Plot the raw signal on the first axis ax_signal.step(x=numpy.arange(200), y=noise_current) # Plot the histogram of the raw signal ax_hist.hist(noise_current, bins=50, alpha=0.6, label=detector.name) # Customize the axes ax_signal.set_title("Raw Signals with Different Dark Current Levels") ax_signal.set_ylabel("Signal Voltage (A)") ax_signal.legend() ax_hist.set_title("Histogram of Raw Signals") ax_hist.set_xlabel("Signal Voltage (A)") ax_hist.set_ylabel("Frequency") ax_hist.legend() # Show the plots plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.581 seconds) .. _sphx_glr_download_gallery_noise_sources_dark_current.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: dark_current.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: dark_current.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: dark_current.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_