Correlating Shack-Hartmann WFS¶
fft_fieldOfView_oversampling
instance-attribute
¶
npix_lenslet
instance-attribute
¶
cam
instance-attribute
¶
cam = Detector(
nPix=camera_size,
samplingTime=samplingTime,
fullWellCapacity=camera_params["fullWellCapacity"],
nBits=camera_params["nBits"],
quantumEfficiency=camera_params["quantumEfficiency"],
shotNoise=camera_params["shotNoise"],
darkCurrent=camera_params["darkCurrent"],
readoutNoise=camera_params["readoutNoise"],
gain=camera_params["gain"],
quantization_conversion=camera_params[
"quantization_conversion"
],
sensorType=camera_params["sensorType"],
darkCalibration=camera_params["darkCalibration"],
noiseFlag=noiseFlag,
logger=logger,
**camera_kwargs,
)
cube_flux
instance-attribute
¶
phasor
instance-attribute
¶
phasor_tiled
instance-attribute
¶
phasor_expanded
instance-attribute
¶
phasor_expanded_tiled
instance-attribute
¶
norm_flux_map
instance-attribute
¶
norm_flux_map = (
lightRatio
* pupil_reflectivity_resized
* samplingTime
* (D / (nSubap * npix_lenslet)) ** 2
)
photon_per_subaperture_2D
instance-attribute
¶
valid_subapertures_1D
instance-attribute
¶
valid_slopes_maps
instance-attribute
¶
__init__ ¶
__init__(
nSubap: float,
telescope,
src,
lightRatio: float,
plate_scale: float,
fieldOfView: float,
guardPx: int,
fft_fieldOfView_oversampling: float = 0,
use_brightest: int = 9,
threshold_convolution: float = 0.05,
unit_in_rad=False,
noiseFlag: bool = False,
logger=None,
**kwargs,
)
Initialize a Correlating Shack-Hartmann Wavefront Sensor (WFS).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nSubap
|
float
|
Number of subapertures across the pupil diameter. |
required |
telescope
|
Telescope
|
Telescope object to which the WFS is attached. |
required |
src
|
Source
|
Source object (SUN). |
required |
lightRatio
|
float
|
Threshold ratio to select valid subapertures based on flux. |
required |
plate_scale
|
float
|
Plate scale of the WFS in [arcsec/px]. |
required |
fieldOfView
|
float
|
Field of view of the WFS in [arcsec]. |
required |
guardPx
|
int
|
Number of pixels between subapertures. |
required |
fft_fieldOfView_oversampling
|
float
|
Extra FoV in [arcsec] that is taken for the FFT computation, in order to reduce wrapping effects. |
0
|
use_brightest
|
int
|
Picks the n brightest pixels as threshold for center-of-gravity spot detection. |
9
|
threshold_convolution
|
float
|
Cut-off threshold for Gaussian convolution. |
0.05
|
unit_in_rad
|
bool
|
Return slopes in radians if True, pixels otherwise. |
False
|
noiseFlag
|
bool
|
If True, the detector includes noise using the kwargs params/default config. By default, False. |
False
|
logger
|
Logger
|
Logger for WFS diagnostics. |
None
|
**kwargs
|
dict
|
Additional keyword arguments. fullWellCapacity : int, optional Detector parameter. Full Well Capacity of pixels [e-]. Default, 60ke- nBits : int, optional Detector parameter. Bit depth for quantization. Default is 12, shall be >= 8 quantumEfficiency : float, optional Detector parameter. Quantum efficiency (0-1). Default is 0.64. shotNoise : bool, optional Detector parameter. Shot noise flag. Default 1. darkCurrent : float, optional Detector parameter. Dark current [e-]. Default 250e-/px/s. readoutNoise : float, optional Detector parameter. Readout noise [e-]. Default 60e-. gain : float, optional Detector parameter. Gain of the detector. Default is 1. quantization_conversion : float, optional. Detector parameter. Conversion gain to discretize the measurement [e-/px]. Default 70.5e-/DN. sensorType : str, optional Detector parameter. Sensor type ('CCD', 'CMOS', 'EMCCD'). Default is 'CCD'. darkCalibration : int, optional Detector parameter. Number of frames to calibrate the dark. Default 20. randomState : int, optional Detector parameter. Seed for the random number generator. Default is None. integrationTime : float, optional Detector parameter. Integration time for the detector [s]. Default is the sampling time. |
{}
|
calib_unit ¶
Calib the unit of the sensor if the user specifies radians instead of pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
telescope
|
Telescope
|
The telescope object providing phase and pupil info. |
required |
src
|
Source
|
Source object for flux and wavelength reference. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
initialize_wfs ¶
Initialize the Shack-Hartmann WFS by measuring reference slopes and determining slope units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
telescope
|
Telescope
|
The telescope object providing phase and pupil info. |
required |
src
|
Source
|
Source object for flux and wavelength reference. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
cross_correlate ¶
Cross-correlate subaperture images with a pseudoref image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subaps
|
ndarray
|
Subaperture images. |
required |
pseudoref
|
ndarray
|
Pseudoref image. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Cross-correlation result. |
centroid ¶
Compute center of gravity for subaperture spots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
Tensor
|
Subaperture image cube. |
required |
use_brightest
|
float
|
Minimum intensity to include in centroid. |
9
|
Returns:
| Type | Description |
|---|---|
ndarray
|
X and Y centroids per subaperture. |
initialize_flux ¶
Initialize per-subaperture flux distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
Source
|
Light source object. |
required |
norm_flux_map
|
ndarray
|
Normalized flux across telescope pupil. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
get_psf ¶
Get the electromagnetic field per subaperture based on input phase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phase
|
ndarray
|
List of Wavefront phase in radians per subdirection |
required |
fwhm
|
float
|
Full width at half maximum for the PSF in [px]. |
required |
npix_sun
|
float
|
Number of pixels in the sun image [px] |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Complex field per subaperture. |
compute_images ¶
Compute correlated subaperture images using convolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
psf
|
Tensor
|
PSF of the subapertures. |
required |
subDirs_sun
|
ndarray
|
Sun subdirectories used as object. |
required |
new_px
|
int
|
New size in pixels for the sun subdirectories. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Convoluted images. |
merges_images ¶
Merge sun patches into a single frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sun_patches
|
Tensor
|
The convoluted sun patches per subaperture. |
required |
src
|
Source
|
The solar source object. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The merged full-field images. |
create_full_frame ¶
Combine subaperture images into full detector frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subaps
|
ndarray
|
Subaperture spot images. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Reconstructed full sensor image. |
get_subaps ¶
Extract individual lenslet spot images from full detector image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
noisy_frame
|
ndarray
|
2D detector frame. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Subaperture cubes [nSubaps, width, height]. |
gradient_2D ¶
Compute X and Y gradients of a phase screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
ndarray
|
2D array of phase values. |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
Gradient in X and Y. |
lenslet_propagation_geometric ¶
Compute geometric propagation through lenslets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
ndarray
|
Input phase screen. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Concatenated slope vector. |
wfs_integrate ¶
Integrate the full detector image and compute valid slopes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ideal_frame
|
ndarray
|
Full-frame ideal image. |
required |
subaps
|
ndarray
|
Spot images per subaperture. |
required |
nPhoton
|
int
|
Number of incident photons |
required |
pseudoref
|
Tensor
|
Subaperture used as pseudo-reference for the correlations, if None one subaperture is picked |
None
|
Returns:
| Type | Description |
|---|---|
tuple
|
Slopes 1D, slopes 2D, and final noisy image. |
wfs_measure ¶
Measure slopes from a wavefront phase using the SH-WFS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
phase_in
|
ndarray
|
Phase map input [radians]. |
required |
src
|
Source
|
Source object. |
required |
pseudoref
|
Tensor
|
Pseudo-reference image used for the correlations, if None the method picks one. |
None
|
reference_slopes
|
ndarray
|
Reference for the WF sensor, if None, geometric references are used. |
None
|
Returns:
| Type | Description |
|---|---|
tuple
|
Slopes 1D, slopes 2D, and detector image. |