.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/hello_simulation.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_hello_simulation.py: Hello, Simulation! =============================================== Simulates a wavefront shaping experiment using a SimulatedWFS object, which acts both as a spatial light modulator (SLM) and a detector. .. GENERATED FROM PYTHON SOURCE LINES 5-29 .. code-block:: Python import numpy as np from openwfs.algorithms import StepwiseSequential from openwfs.simulation import SimulatedWFS # Create a simulation of an experiment size = (25, 25) t = np.random.normal(size=size) + 1j * np.random.normal(size=size) sim = SimulatedWFS(t=t) slm = sim.slm # Use the StepwiseSequential algorithm to optimize the phase pattern, # using a correction pattern of 10x10 segments and 4 phase steps # The pattern is scaled to the size of the transmission matrix t automatically alg = StepwiseSequential(feedback=sim, slm=slm, n_x=10, n_y=10, phase_steps=4) result = alg.execute() # Measure intensity with flat and shaped wavefronts slm.set_phases(0) before = sim.read() slm.set_phases(-np.angle(result.t)) after = sim.read() print(f"Intensity in the target increased from {before} to {after}") .. _sphx_glr_download_auto_examples_hello_simulation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: hello_simulation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: hello_simulation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: hello_simulation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_