.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/slm_demo.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_slm_demo.py: SLM Demo ======== Example on how different geometries and patches work for an SLM. Currently, uses SLM number 0, which is the left upper corner of the primary monitor. EPILEPSY WARNING: YOUR PRIMARY SCREEN MAY QUICKLY FLASH DURING RUNNING THIS FILE .. GENERATED FROM PYTHON SOURCE LINES 9-58 .. code-block:: Python import time import astropy.units as u import numpy as np from skimage import data from openwfs.devices.slm import SLM, Patch, geometry from openwfs.utilities import patterns # construct a new SLM object and add a patch to it numerical_aperture = 0.8 s1 = SLM(0, shape=(300, 200)) s2 = SLM(0, pos=(0, 300)) s3 = s1.clone(0, pos=(300, 0), shape=(400, 500)) g = geometry.rectangle(numerical_aperture) # p1 = Patch(s1, g) s1.primary_patch.geometry = g pf = Patch(s1) p2 = Patch(s2) p3 = Patch(s2, geometry.rectangle(0.2)) p4 = Patch(s2, geometry.rectangle(0.1)) p3.phases = 0.25 p4.phases = 1 p4.additive_blend = False pf.phases = patterns.lens(100, 1 * u.m, 0.8 * u.um, numerical_aperture) rng = np.random.default_rng() for n in range(200): random_data = rng.random([10, 10], np.float32) * 2.0 * np.pi s1.set_phases(random_data) s2.set_phases(n / 4.0) if n == 100: del s3 p1 = None # test deletion. After deleting the two windowed SLMs, we can create a new full screen one s1.patches.clear() s1 = 0 s2 = 0 s3 = SLM(1) # full-screen window s3.update() s3.monitor_id = 0 # test switching monitor id time.sleep(0.5) s = SLM(0) s.set_phases(data.camera() / 255 * 2 * np.pi) s.update() .. _sphx_glr_download_auto_examples_slm_demo.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: slm_demo.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: slm_demo.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: slm_demo.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_