slmsuite.hardware.slms.santec.Santec#
- class Santec(slm_number=1, display_number=2, bitdepth=10, wav_um=1, pitch_um=(8, 8), **kwargs)[source]#
Bases:
SLMInterfaces with Santec SLMs.
Methods
See
SLM.close().Fits the SLM's
apertureto the measured source amplitude distribution insource["amplitude"].Deprecated.
Read the drive board and option board errors.
Return this object's log records (only), as a list of plain-text strings.
Fourier transforms the wavefront calibration's measured amplitude to directly compute the expected diffraction-limited performance of the system in
"knm"space.The phase the SLM shows for
phase: quantized to itsbitresolutionlevels exactly asset_phase()quantizes it (throughlutwhen a gamma is set), in radians wrapped to \([0, 2\pi)\).Approximates the \(1/e\) amplitude (\(1/e^2\) power) radius of farfield spots in the
"kxy"basis: \(1 / (\pi w)\) for a Gaussian source of \(1/e\) amplitude radius \(w =\)source_radius.Gets
SLM_STATUSreturn from a Santec SLM and parses the result.Read the drive board and option board temperatures.
Discovers the names of all the displays.
Creates and displays a live viewer.
Write the phase image contained in a .csv file to the SLM.
Loads
displayfrom a file and writes to the SLM.Load phase correction provided by Santec from file, setting
"phase"insource.Log the current values of all tracked attributes.
Returns a dictionary containing selected attributes of this class.
Plots the provided phase.
Plots
gamma, the measured phase response as a function of grayscale level.Plots measured or simulated amplitude and phase distribution of the SLM illumination.
Saves the dictionary returned from
pickle()to a file like"path/name_id.h5".Splits the area of the SLM into a number of segments.
Sets the SLM's
aperturewhich defines the working coordinate frame (gridcentering), the Zernike lateral scaling (zernike_scaling), the in-use mask (aperture_mask), and the effective (masked) source amplitude and phase.Sets
lut, the lookup table mapping a desired phase onto the grayscale level which best realizes it, from a measured phase responsegamma.(Not supported by this SLM.) Configures the input trigger of the SLM, where an external electronic signal can synchronize the time at which the SLM updates its display.
(Not supported by this SLM.) Configures the output trigger of the SLM, where the SLM can send an electronic signal upon updating its display.
Checks, cleans, and adds to data, then sends the data to the SLM and potentially waits for
settle_time_sseconds.In the absence of a proper wavefront calibration, sets
sourceamplitude and phase using afit_functionfromfitfunctions.Test that the hardware behind this
SLMresponds to every core method.Backwards-compatibility alias for
set_phase().Attributes
Number of levels,
2**bitdepth.\((x, y)\) coordinate meshgrids of the SLM's pixels in normalized units (wavelengths), measured from the aperture center.
Height in pixels,
shape[0].Wavelength normalized to the phase range of the SLM,
wav_um / wav_design_um.Pixel pitch
(x, y)normalized to wavelengths,pitch_um / wav_um.(width, height)in pixels, the reverse ofshape.The \(1/e\) field-amplitude source radius in normalized units, for structured beams such as
laguerre_gaussian().Width in pixels,
shape[1].The
(x_scale, y_scale)lateral scaling mappinggridonto the Zernike unit disk, fromaperture.- __init__(slm_number=1, display_number=2, bitdepth=10, wav_um=1, pitch_um=(8, 8), **kwargs)[source]#
Initializes an instance of a Santec SLM.
- Parameters:
slm_number – See
slm_number.display_number – See
display_number.bitdepth (int) – Depth of SLM pixel well in bits. Defaults to 10.
wav_um (float) – Wavelength of operation in microns. Defaults to 1 μm.
pitch_um ((float, float)) – Pixel pitch in microns. Defaults to 8 micron square pixels.
**kwargs – See
SLM.__init__()for permissible options.
Note
Santec SLMs can reconfigure their phase table: the correspondence between grayscale values and applied voltages. This is configured based upon the wavelength supplied to
SLM.wav_design_um. This allowsSLM.phase_scalingto be one if desired, and make use of optimized routines (seeset_phase()). However, sometimes setting the phase table runs into issues, where the maximum value doesn’t correspond to exactly \(2\pi\) at the target wavelength. This is noted in the initialization, and the user should updateSLM.wav_design_umor otherwise to avoid undesired behavior.wav_design_umdefaults towav_umif it is not given.Caution
Santecdefaults to 8 micron square pixel sizeSLM.pitch_umand 10-bitSLM.bitdepth. This is valid for SLM-200, SLM-210, and SLM-300, but may not be valid for future Santec models.
- static info(verbose=True)[source]#
Discovers the names of all the displays. Checks all 8 possible supported by Santec’s SDK.
- load_vendor_phase_correction(file_path, smooth=False, overwrite=True)[source]#
Load phase correction provided by Santec from file, setting
"phase"insource.- Parameters:
Note
This correction is only fully valid at the wavelength at which it was collected.
- Returns:
source["phase"], the Santec-provided phase correction.- Return type:
- close()[source]#
See
SLM.close().
- get_error(raise_error=True, return_codes=False)[source]#
Read the drive board and option board errors.
- Parameters:
- Returns:
List of errors.
- Return type:
- get_status(raise_error=True)[source]#
Gets
SLM_STATUSreturn from a Santec SLM and parses the result.
- load_csv(filename)[source]#
Write the phase image contained in a .csv file to the SLM. This image should have the size of the SLM.
- Parameters:
filename (str) – Path to the .csv file.
- fit_aperture(method='moments', edge_level=0.1)[source]#
Fits the SLM’s
apertureto the measured source amplitude distribution insource["amplitude"]. Two radii are fit independently:The circular aperture (pupil), which sets
aperture_maskandzernike_scaling, is fit to the rolloff of the measured source power withimage_aperture_fit(): its center is that of the circle which best fits the edge where the power falls off, and its radius is where the power has fallen toedge_level. Unlike the power centroid, this is not pulled toward bright regions inside the aperture, and edges which do not belong to the circle (such as a straight clip) are rejected.The
source_radius: the \(1/e\) field-amplitude radius (\(1/e^2\) in intensity) of the measured amplitude, analyzed via"moments"or least-squares"fit".
If no rolloff is found (for instance, for an unclipped Gaussian beam), the aperture is instead centered by
method, and the pupil is placed where a Gaussian’s power falls toedge_levelof its peak (\(\sqrt{\ln(1 / \text{edge\_level}) / 2}\) source radii, \(\approx 1.07\) for the default). A clip where the power has already fallen below about a tenth of its peak (for a Gaussian, beyond about 1.1 source radii) is not found as a rolloff; set such an aperture withset_aperture()instead.If no source amplitude has been measured, the aperture is set to a circular aperture of source radius equal to a quarter of the smallest SLM extent.
- Parameters:
method (str {"fit", "moments"}) – Whether to use moment calculations (
"moments", faster) or a least-squares"fit"(more accurate) to determine the source radius, and the center when no rolloff is found.edge_level (float) – Where on the rolloff to place the pupil edge, as a fraction in \((0, 1)\) of the way from the background to the power inside the aperture. Smaller values give a larger pupil which includes more of the rolloff; values near \(0.5\) place it near the steepest descent. The center does not depend on
edge_level.
- Returns:
The fitted
aperture.- Return type:
- fit_source_amplitude(method='moments', extent_threshold=0.1, force=True)[source]#
Deprecated. Forwards to
fit_aperture();extent_thresholdandforceare ignored.
- get_log(verbose=False)[source]#
Return this object’s log records (only), as a list of plain-text strings.
- Parameters:
verbose (bool, optional) – If
True, also print the records to the console.
- get_point_spread_function_knm(padded_shape=None)[source]#
Fourier transforms the wavefront calibration’s measured amplitude to directly compute the expected diffraction-limited performance of the system in
"knm"space.- Parameters:
padded_shape ((int, int) OR None) – The point spread function changes in resolution depending on the padding. Use this variable to provide this padding. If
None, do not pad.- Returns:
The point spread function of shape
padded_shape, on the SLM’s backend.- Return type:
numpy.ndarray OR cupy.ndarray
- get_realized_phase(phase=None)[source]#
The phase the SLM shows for
phase: quantized to itsbitresolutionlevels exactly asset_phase()quantizes it (throughlutwhen a gamma is set), in radians wrapped to \([0, 2\pi)\).A 4-bit SLM realizes only 16 phases; this is what it displays, where
phaseis what was asked of it.- Parameters:
phase (array_like OR None) – Phase in radians, of any shape. Defaults to
phase, the last phase written (including any wavefront correction).- Returns:
Float32 phase in radians, on the SLM’s backend.
- Return type:
numpy.ndarray OR cupy.ndarray
- get_spot_radius_kxy()[source]#
Approximates the \(1/e\) amplitude (\(1/e^2\) power) radius of farfield spots in the
"kxy"basis: \(1 / (\pi w)\) for a Gaussian source of \(1/e\) amplitude radius \(w =\)source_radius.- Returns:
Radius of the farfield spot.
- Return type:
- property grid[source]#
\((x, y)\) coordinate meshgrids of the SLM’s pixels in normalized units (wavelengths), measured from the aperture center. This is the working coordinate frame that analytic phase functions (lenses, gratings, Zernike, …) are generated in. Of size
shape. Read-only: it is derived from the immutable geometric grid and theaperturecenter.Held on
xp, so this is acupymeshgrid for acupy-backed SLM; pass it throughslmsuite.misc.xp.as_numpy()where host memory is required. See the note onxp.
- live(activate=None, widgets=True, backend='ipython', **kwargs)[source]#
Creates and displays a live viewer.
When used with a camera, the viewer displays the last image: the result of
get_image()or the last image ofget_images()whenever these methods are called. Averaging and HDR are displayed with the same color scaling as without.When used with an SLM, the viewer displays the phase pattern currently on the SLM: the phase pattern passed to
set_phase()whenever it is called.
The view itself is drawn either inside the notebook (
backend="ipython") or in a resizable window of its own (backend="pyglet"), which also works from a plain script, where no notebook is available to draw into.If
Trueis passed to thewidgetsargument, this viewer is accompanied by a series of IPython widgets in the form of sliders and buttons for controlling the color scale, colormap, viewer scale, and live viewing, along with buttons to copy the current view to the clipboard or save it to a file, either as a.pngof the view or an.h5of the raw data. By toggling theLivewidget button, a loop is created that continuously polls the camera for new images. This viewer can be used as a realtime camera monitor within the jupyter notebook. However, note that any user-execution will block the monitoring loop. Regardless, any image polling during the blocked period will still update the viewer, which provides useful active feedback for what is happening during the execution.Livemode is ignored for SLMs.The viewer also supports zooming into a region of interest. With the
Zoomwidget enabled, scroll the mouse wheel to zoom in/out toward the cursor, click-drag to pan, and double-click to restore the full image; disablingZoomalso restores the full image. Clicking prints the source-image pixel coordinate under the cursor. These mouse interactions require the optionalipyeventspackage (pip install ipyevents); without it the viewer still functions normally. Apygletwindow needs no such package, and zooms by default since it has no page to scroll over. It restores the full image on a right-click and carries keyboard shortcuts (escclose,rreset,ccolormap,xcrosshairs,llogarithmic,aautorange) so that it is usable without any widgets. The shortcuts that change color scaling take effect on the next frame. TheScalewidget sizes the window itself, which keeps the image’s aspect ratio. Closing the window closes the viewer, as togglinglive()would.A viewer leaves its settings on the hardware when it closes, so calling
live()again reopens with the same colormap, scaling, and crosshairs, and with the window where and how big it last was. Pass an argument to override any of them.This limitation is imposed by the Python Global Interpreter Lock (GIL) which restricts operation to a single thread, especially operation connecting to a diverse set of camera and SLM hardware. We use
asyncioto allow the realtime monitoring loop to be interrupted by user-execution (e.g. running a cell in jupyter), blocking until the execution is finished.- Parameters:
activate (bool OR None) – If
True, creates a live viewer in the current cell, destroying any other attached viewer. IfFalse, destroys any other attached viewer. IfNone, toggles the live viewer, destroying any attached viewer or creating one in the current cell if none is attached. Defaults toNone.widgets (bool OR str OR None) – The backend hosting the sliders and controls used to hone the display properties; one of
"ipython".Trueselects the default andFalsedisplays no controls. Widgets need a notebook, so a"pyglet"view opened from a script goes without.backend (str) – The backend drawing the view itself:
"ipython"or"pyglet". The default is"ipython".**kwargs – Options passed to the
_ViewerObjectto customize the default settings. These features will be made less hidden in the future. Most things are customizable via these keywords. For instance, the user can pass a custom list of colormaps to appear in the widget dropdown ascmap_options=.
- load_phase(file_path=None, settle=False)[source]#
Loads
displayfrom a file and writes to the SLM. Logs a warning if the storedphasedoes not reproduce the stored display.- Parameters:
file_path (str OR None) – Full path to the phase file. If
None, will search the current directory for a file with a name likename+'_phase'.settle (bool OR float) – Whether to sleep for
settle_time_s, or any number (integers included) of seconds to sleep instead.
- Returns:
The file path that the phase was loaded from.
- Return type:
- Raises:
FileNotFoundError – If a file is not found.
- log_state(level=10)[source]#
Log the current values of all tracked attributes.
- Parameters:
level (int, optional) – Logging level. Defaults to
logging.DEBUG.
- property phase_scaling[source]#
Wavelength normalized to the phase range of the SLM,
wav_um / wav_design_um. Seewav_design_um.
- pickle(attributes=True, metadata=True)[source]#
Returns a dictionary containing selected attributes of this class.
- Parameters:
attributes (bool OR list of str) – If
False, pickles only baseline attributes, usually single floats. IfTrue, also pickles ‘heavy’ attributes such as large images and calibrations. Iflist of str, pickles the keys in the given list. By default, the chosen attributes should be things that can be written to .h5 files: scalars and lists of scalars.metadata (bool) – If
True, package the dictionary as the"__meta__"value of a superdictionary which also contains:"__version__", the current slmsuite version,"__time__", the time formatted as a date string, and"__timestamp__", the time formatted as a floating point timestamp. This information is used as standard metadata for calibrations and saving.
- property pitch[source]#
Pixel pitch
(x, y)normalized to wavelengths,pitch_um / wav_um. This value is more useful thanpitch_umwhen considering conversions to \(k\)-space.
- plot(phase=None, limits=None, title='Phase', ax=None, cbar=True, aperture=True)[source]#
Plots the provided phase.
- Parameters:
phase (ndarray OR None) – Phase to be plotted. If
None, grabs the last writtenphasefrom the SLM.limits (None OR float OR [[float, float], [float, float]]) – Scales the limits by a given factor or uses the passed limits directly.
title (str) – Title the axis.
ax (matplotlib.pyplot.axis OR None) – Axis to plot upon.
cbar (bool) – Also plot a colorbar. Does not work if
axis passed.aperture (bool) – If
True(default), overlay the currentaperture(when it crops the SLM): an outline, with the masked-off region faded.
- Returns:
Axis of the plotted phase.
- Return type:
matplotlib.pyplot.axis
- plot_gamma(gamma=None, ax=None, **kwargs)[source]#
Plots
gamma, the measured phase response as a function of grayscale level.- Parameters:
gamma (array_like OR None) – Phase response to plot, in units of \(2\pi\). If
None, usesgamma.ax (matplotlib.axes.Axes OR None) – Axis to plot onto, if desired.
- Returns:
Axis handle for the generated plot.
- Return type:
- plot_source(source=None, sim=False, power=False, aperture=True)[source]#
Plots measured or simulated amplitude and phase distribution of the SLM illumination. Also plots the rsquared goodness of fit value if available.
- Parameters:
source (dict OR None) – The data to plot. If
None, usessource.sim (bool) – Plots the simulated source distribution if
Trueor the measured source distribution ifFalse.power (bool) – If
True, plot the power (amplitude squared) instead of the amplitude.aperture (bool) – If
True(default), overlay the currentaperture(when it crops the SLM) on the phase and amplitude panels: an outline, with the masked-off region faded. The data plotted is always the raw source, so that illumination the aperture discards stays visible.
- Returns:
Axis handles for the generated plot.
- Return type:
- save(path='.', name=None, **kwargs)[source]#
Saves the dictionary returned from
pickle()to a file like"path/name_id.h5".- Parameters:
- Returns:
The file path that the pickled data was saved to.
- Return type:
- set_aperture(spec=None, *, radius=None, center=None, units='norm')[source]#
Sets the SLM’s
aperturewhich defines the working coordinate frame (gridcentering), the Zernike lateral scaling (zernike_scaling), the in-use mask (aperture_mask), and the effective (masked) source amplitude and phase.Setting an aperture always applies it to the source amplitude and phase: the region outside the aperture is masked off everywhere the source is used (e.g. holography,
set_phase()’s wavefront correction). The default aperture ("cropped") circumscribes the whole grid and so masks nothing.- Parameters:
spec (
ApertureOR spec OR None) – The aperture shape/scaling, as accepted byAperture("circular"/"elliptical"/"cropped"/float/(float, float)/ anAperture). Mutually exclusive withradius. If bothspecandradiusareNone, the current aperture’s spec is kept.radius (float OR None) – Shorthand for a circular aperture of the given source (\(1/e\)) radius, interpreted in
unitsand stored assource_radius. The aperture/pupil itself extends to twice this radius (the lateral scaling is \(1 / (2\,r)\)). Passing a newspecinstead drops any stored source radius, sosource_radiusis again derived from the aperture.center ((float, float) OR None) – The
(x, y)pixel the aperture is centered on.None(the default) centers the aperture on the geometric center of the SLM.units (str) – Units for
radius:"norm"(normalized to wavelengths, the default),"frac"(fraction of the smaller half-extent of the SLM),"pix"(number of pixels), or a physical length ("um","mm", …). As the pupil extends to twiceradius, a"frac"radiusputs the pupil at that fraction of the full extent of the shorter axis, as inset_source_analytic().
- Returns:
The new
aperture.- Return type:
- set_gamma(gamma=None, levels=None, lut_size=65536)[source]#
Sets
lut, the lookup table mapping a desired phase onto the grayscale level which best realizes it, from a measured phase responsegamma. Measuregammawithpixel_calibration_process(). Its sweep projects grayscale levels directly, so a previously-setlutdoes not disturb the measurement.Note
The lookup table supersedes
phase_scaling, as a measuredgammaalready contains the phase range which the SLM achieves atwav_um. Phases outside this range are mapped to the nearest phase which the SLM can realize.- Parameters:
gamma (array_like OR None) – Magnitude of the phase realized by each of the
bitresolutiongrayscale levels, in units of \(2\pi\), increasing with level for the usual SLM. Its sense is set per class, as most SLMs decrease phase delay with increasing level whereas aPLMincreases it. Must be unwrapped, as an SLM with more than \(2\pi\) of range spans more than one unit.Noneclearslut, restoring the ideal linear response.levels (array_like OR None) – The grayscale levels at which
gammawas sampled, in any order.gammais then interpolated onto every level, with levels outside the sampled range closed circularly at the curve’s average slope. IfNone,gammamust sample every level.lut_size (int) – Number of entries in
lut. Must be a power of two.
- Returns:
lut.- Return type:
numpy.ndarray OR cupy.ndarray OR None
- set_input_trigger(on=False)[source]#
(Not supported by this SLM.) Configures the input trigger of the SLM, where an external electronic signal can synchronize the time at which the SLM updates its display.
- Parameters:
on (
bool) – Subclasses must support a boolean configuration argument, but can also accept other datatypes or parameters as needed.
- set_output_trigger(on=False)[source]#
(Not supported by this SLM.) Configures the output trigger of the SLM, where the SLM can send an electronic signal upon updating its display.
- Parameters:
on (
bool) – Subclasses must support a boolean configuration argument, but can also accept other datatypes or parameters as needed.
- set_phase(phase, phase_correct=None, settle=None, execute=None, block=None, **kwargs)[source]#
Checks, cleans, and adds to data, then sends the data to the SLM and potentially waits for
settle_time_sseconds. This method calls the SLM-specific private method_format_phase_hw()(if implemented) to format the phase data before calling_set_phase_hw()which transfers the data to the SLM.Warning
Subclasses implementing vendor-specific software should not overwrite this method. Subclasses should overwrite
_set_phase_hw()(and_format_phase_hw()if required) instead.Caution
The sign on
phaseis flipped before converting to integer data. This is to convert between the ‘increasing value ==> increasing voltage (= decreasing phase delay)’ convention in most SLMs andslmsuite’s ‘increasing value ==> increasing phase delay’ convention. As a result, zero phase will appear entirely white (255 for an 8-bit SLM), and increasing phase will darken the displayed pattern. If integer data is passed, this data is displayed directly and the sign is not flipped.Important
The user does not need to wrap (e.g.
numpy.mod(data, 2*numpy.pi)) the passed phase data, unless they are pre-caching data for speed (see below).set_phase()uses optimized routines to wrap the phase (see the private method_phase2gray()). When a measured phase response is loaded withset_gamma(), phase is instead wrapped and converted by lookup intolut. Otherwise, which routine is used depends onphase_scaling:phase_scalingis one.Fast bitwise integer modulo is used. Much faster than the other routines which depend on
numpy.mod().
phase_scalingis less than one.In this case, the SLM has more phase tuning range than necessary. If the data is within the SLM range
[0, 2*pi/phase_scaling], then the data is passed directly. Otherwise, the data is wrapped by \(2\pi\) using the very slownumpy.mod(). Try to avoid this in applications where speed is important.
phase_scalingis more than one.In this case, the SLM has less phase tuning range than necessary. Processed the same way as the
phase_scalingis less than one case, with the important exception that phases (after wrapping) between2*pi/phase_scalingand2*piare set to zero. For instance, a sawtooth blaze would be truncated at the tips.
Caution
With
phase_scalingequal to one, phase is rounded to the nearest level. Otherwise, the scaled data is truncated to integers bynp.copyto, and with alut, phase is floored onto one of its entries. Where this matters, pass integer data toset_phase()directly.- Parameters:
phase (numpy.ndarray OR cupy.ndarray OR) –
slmsuite.holography.algorithms.Hologram OR None Phase data to display, in radians, unless the passed data is of integer type and the data is applied directly.
If
Noneis passed toset_phase(), data is zeroed.If a
Hologramis passed, the phase is grabbed fromget_phase().If the array has a larger shape than the SLM shape, then the data is cropped to size in a centered manner (
unpad()).If integer data is passed with the same type as
display(np.uint8for <=8-bit SLMs,np.uint16otherwise), then this data is directly passed to the SLM, without going through the “phase delay to grayscale” conversion defined in the private method_phase2gray(). In this situation,phase_correctis ignored. This is error-checked such that bits with greater significance than the bitdepth of the SLM are zero (e.g. the final 6 bits of 16 bit data for a 10-bit SLM). Integer data with type different fromdisplayleads to a TypeError.
Usually, an exact stored copy of the data passed by the user under
phaseis stored in the attributephase. Whenphase_scalingis one and nolutis set, this copy is rounded to a whole number of levels. If the data was cropped, then the cropped data is stored, etc. If integer data was passed, the equivalent floating point phase is computed and stored in the attributephase.phase_correct (
bool) – Whether to add wavefront correction to the pattern. This correction is stored insource["phase"]. IfNone, defaults tophase_correct(which defaults toTrue).settle (
bool|float) – Whether to sleep forsettle_time_s, or any number (integers included) of seconds to sleep instead. IfNone, defaults tosettle(which defaults toFalse). Ifblock=False, this parameter is ignored.execute (
bool) –Whether to actually send the image to the SLM. Most SLMs do not support this feature, and will error if
executeis notNone. Otherwise,Nonemust default toTrue. Use case: ifexecute=Falseandblock=True, only the block is enforced and no new data is written.Important
New phase/display data is always calculated regardless of the value of
execute.block (
bool) – Some SLM subclasses support non-blocking writes that are triggered externally. This parameter will determine whether to block the thread until the image is fully written. Most SLMs do not support this feature, and will error ifblockis notNone. Otherwise,Nonemust default toTrue. Use case: ifexecute=Trueandblock=False, the write is non-blocking.**kwargs – Passed to the SLM in case the subclass needs to do something special. For instance, some SLMs support a
timeoutparameter that determines how long to wait for the SLM commands to execute before raising an error.
- Returns:
display, the integer data sent to the SLM.- Return type:
numpy.ndarray OR cupy.ndarray
- Raises:
TypeError – If integer data is incompatible with the bitdepth or if the passed phase is otherwise incompatible (not a 2D array or smaller than the SLM shape, etc).
- set_source_analytic(fit_function='gaussian2d', units='norm', phase_offset=0, sim=False, **kwargs)[source]#
In the absence of a proper wavefront calibration, sets
sourceamplitude and phase using afit_functionfromfitfunctions.Note
FourierSLMincludes capabilities for wavefront calibration viawavefront_calibrate(). This process also measures the amplitude of the source on the SLM and stores this insource.sourcekeywords are also used for better refinement of holograms during numerical optimization. If unable to runwavefront_calibrate(), this method allows the user to set an approximation of the complex source.- Parameters:
fit_function (str OR lambda) – Function name from
fitfunctionsused to set the source profile. The function can also be passed directly. Defaults to"gaussian2d".units (str in {"norm", "frac", "nm", "um", "mm", "m"}) – Units for the \((x,y)\) grid passed to
fit_function:"norm"(normalized to wavelengths),"frac"(each axis divided by the full extent of the SLM along it, so the grid spans \([-1/2, 1/2]\)), or a physical length. A"frac"radius here is thus a fraction of the full extent, which is whereset_aperture()places the pupil for the same"frac"radius.phase_offset (float OR numpy.ndarray OR cupy.ndarray) – Additional phase (of shape
shape) added tosource.sim (bool) – Sets the simulated source distribution if
Trueor the approximate experimental source distribution (in absence of wavefront calibration) ifFalse.**kwargs – Arguments passed to
fit_functionin addition to the SLM grid in the requestedunits. If thefit_functionis"gaussian2d"and no keyword arguments have been passed, the radius defaults to a quarter of the smaller of the two SLM dimensions.
- Returns:
- Return type:
- property source_radius[source]#
The \(1/e\) field-amplitude source radius in normalized units, for structured beams such as
laguerre_gaussian(). Set independently of the pupil byfit_aperture()or byset_aperture()(radius=...). Otherwise, it is derived from theaperturescaling as \(1 / (2\,s)\), where \(s\) is the (isotropic) lateral scale, which raisesValueErrorfor an anisotropic (elliptical) aperture that a single radius cannot describe.
- test()[source]#
Test that the hardware behind this
SLMresponds to every core method.Each step is named, so a failure reports which feature is broken. Correctness of the phase mapping is the business of the test suite, not of a hardware check.
- write(phase, phase_correct=True, settle=False, **kwargs)[source]#
Backwards-compatibility alias for
set_phase().