TwiceAsNice  2019-02-18
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
laospy.metapupil_I9.MetaPupil Class Reference
Collaboration diagram for laospy.metapupil_I9.MetaPupil:
Collaboration graph

Public Member Functions

def set_image (self, image, setup='SE')
 
def find_centers (self, boxSize=40, medianSubtract=True, gauss=False)
 
def create_mask (self, mask)
 
def create_circular_pupil_mask (self, radius)
 
def create_metapupil_mask (self, snr=100, radius=16)
 
def find_mask_diameter (self)
 
def get_mask (self)
 
def delete_mask (self)
 
def calculate_tilt (self)
 
def calculate_flux (self)
 
def calculate_background (self, radius)
 
def create_zernike_reconstruction_matrix (self, maxmode, diam=None, rcond=1e-15)
 
def calculate_slopes (self, normalization='subaperture')
 
def set_zernike_conversion_factors (self, conversionFactors)
 
def find_zernike_coefficients (self)
 
def set_image (self, image, setup='SE')
 
def find_centers (self, boxSize=40, medianSubtract=True, gauss=False)
 
def create_mask (self, mask)
 
def create_circular_pupil_mask (self, radius)
 
def create_metapupil_mask (self, snr=100, radius=16)
 
def find_mask_diameter (self)
 
def get_mask (self)
 
def delete_mask (self)
 
def calculate_tilt (self)
 
def calculate_flux (self)
 
def calculate_background (self, radius)
 
def create_zernike_reconstruction_matrix (self, maxmode, diam=None, rcond=1e-15)
 
def calculate_slopes (self, normalization='subaperture')
 
def set_zernike_conversion_factors (self, conversionFactors)
 
def find_zernike_coefficients (self)
 

Public Attributes

 setup
 
 mask
 

Static Public Attributes

 img = None
 
string setup = ''
 
 quadrants = None
 
float centers = np.ones((4,2)) * 20.0
 
 meancenter = np.zeros(2)
 
int mask = 0
 
 maskcenters = np.zeros((4,2))
 
 pyramidAngle = None
 
 slopes = None
 
 recMat = None
 
 zernikeCoeffs = None
 
 zernikeConvFactors = None
 
int noise = 0.
 
 unmaskPositions = np.zeros(1600)
 
 illuminatedPositions = np.zeros(1600)
 
 metapupilMask = np.zeros((40,40))
 
 illuminatedMask = np.zeros((40,40))
 

Detailed Description

An MetaPupil object represents a measurement of the wavefront in the conjugated plane of  
a pyramid wavefront sensor. The a metapupil measurement consists of an image with slope 
information for each subaperture distributed across the 4 quadrants of the image. Each 
subaperture is associated with 4 pixels, one in each quadrant. The gradient between the 4 
associated pixels is the measurement of the slope of the wavefront in the corresponding 
subaperture. 

The association of the subaperture pixels is achieved by placing the same mask on each of the 4 
quadrants. The pixels that are masked do not contain a useable signal. The mask also defines 
the order of the subapertures. 

During alignment it is necessary to introduce a mask in the optical path and/or measure 
without a star enlarger in the optical path. Both affect the distribution of the signal on 
the CCD. The setup attribute reflects the setup, with which the image is taken.

   
Attributes
----------
img : ndarray
    the image 
setup : string
    the image type. can be 'SE', SE+mask', 'noSE+mask'
quadrants : ndarray (size: 4, imgsize/2, imgsize/2)
    masked array cube with the quadrants of the image
centers : ndarray (size: 4,2)
    the centers of the brightness distributions in the 4 quadrants
meancenter : ndarray
    the mean center for all quadrants
mask : ndarray (bool)
    the mask that is applied on quadrants
maskcenters : ndarray (size: 4, 2)
    the coordinate of the pixel in each quadrant on which the mask is centered
slopes : ndarray
    the slopes vector (sx0,sy0,sx1,sy1,...)
recMat : ndarray
    the slopes-to-modes reconstruction matrix
zernikeCoeffs : ndarray
    the reconstructed coefficients for each Zernike mode
zernikeConvFactors : ndarray
    conversion factors to scale the zernikeCoeffs

Member Function Documentation

◆ calculate_background() [1/2]

def laospy.metapupil_I9.MetaPupil.calculate_background (   self,
  radius 
)
Determines the mean per-pixel background and its standard deviation in the image. 
The background is determined outside circular avoidance regions in each quadrant.

Parameters
----------
radius : float
    avoidance radius. Circular region to exclude in the determination of the background
    
Returns
-------
mean, std : tuple of floats
    mean and standard deviation of background

◆ calculate_background() [2/2]

def laospy.metapupil_I9.MetaPupil.calculate_background (   self,
  radius 
)
Determines the mean per-pixel background and its standard deviation in the image. 
The background is determined outside circular avoidance regions in each quadrant.

Parameters
----------
radius : float
    avoidance radius. Circular region to exclude in the determination of the background
    
Returns
-------
mean, std : tuple of floats
    mean and standard deviation of background

◆ calculate_flux() [1/2]

def laospy.metapupil_I9.MetaPupil.calculate_flux (   self)

◆ calculate_flux() [2/2]

def laospy.metapupil_I9.MetaPupil.calculate_flux (   self)

◆ calculate_slopes() [1/2]

def laospy.metapupil_I9.MetaPupil.calculate_slopes (   self,
  normalization = 'subaperture' 
)
Calculates the slope vector based on the pixels that are not masked

Slopes are sorted as sx0, sy0, sx1, sy1, ...

Parameters
----------
normalization : string
    Defines the normaization method for the slopes. Possible values:
"subaperture" : normalization with the total flux of the 4 slope pixels belonging 
                to a subaperture
"metapupil"   : normalization with the total flux in all slope pixels
"none"        : no normalization

◆ calculate_slopes() [2/2]

def laospy.metapupil_I9.MetaPupil.calculate_slopes (   self,
  normalization = 'subaperture' 
)
Calculates the slope vector based on the pixels that are not masked

Slopes are sorted as sx0, sy0, sx1, sy1, ...

Parameters
----------
normalization : string
    Defines the normaization method for the slopes. Possible values:
"subaperture" : normalization with the total flux of the 4 slope pixels belonging 
                to a subaperture
"metapupil"   : normalization with the total flux in all slope pixels
"none"        : no normalization

◆ calculate_tilt() [1/2]

def laospy.metapupil_I9.MetaPupil.calculate_tilt (   self)
Evaluates tip/tilt on based on the flux in each quadrant.

If a mask is defined, only the flux in the mask is considered

Returns
-------
tilt_x, tilt_y : tuple of floats
    tilt values in arbitrary units

◆ calculate_tilt() [2/2]

def laospy.metapupil_I9.MetaPupil.calculate_tilt (   self)
Evaluates tip/tilt on based on the flux in each quadrant.

If a mask is defined, only the flux in the mask is considered

Returns
-------
tilt_x, tilt_y : tuple of floats
    tilt values in arbitrary units

◆ create_circular_pupil_mask() [1/2]

def laospy.metapupil_I9.MetaPupil.create_circular_pupil_mask (   self,
  radius 
)
Creates a circular pupil mask for each of the 4 quadrants

The mask will be centered on the full integer pixel that is nearest to the center position 
determined in each quadrant.

It is important to maintain the same geometry of the mask (distribution of pixels per row) 
in order to identify the 4 pixels that belong to each subaperture.

Parameters
----------
radius : float
    radius of the circle in pixels

◆ create_circular_pupil_mask() [2/2]

def laospy.metapupil_I9.MetaPupil.create_circular_pupil_mask (   self,
  radius 
)
Creates a circular pupil mask for each of the 4 quadrants

The mask will be centered on the full integer pixel that is nearest to the center position 
determined in each quadrant.

It is important to maintain the same geometry of the mask (distribution of pixels per row) 
in order to identify the 4 pixels that belong to each subaperture.

Parameters
----------
radius : float
    radius of the circle in pixels

◆ create_mask() [1/2]

def laospy.metapupil_I9.MetaPupil.create_mask (   self,
  mask 
)
Creates a general pupil mask for each of the 4 quadrants.

All non-zero elements will be masked

Parameters
----------
mask : ndarray
    the mask of the same dimension as a quadrant

◆ create_mask() [2/2]

def laospy.metapupil_I9.MetaPupil.create_mask (   self,
  mask 
)
Creates a general pupil mask for each of the 4 quadrants.

All non-zero elements will be masked

Parameters
----------
mask : ndarray
    the mask of the same dimension as a quadrant

◆ create_metapupil_mask() [1/2]

def laospy.metapupil_I9.MetaPupil.create_metapupil_mask (   self,
  snr = 100,
  radius = 16 
)
Creates a mask based on the illumination pattern in the image

The mask represents the region, in which the mean of all quadrants has a SNR below the 
specified value.  

Parameters
----------
snr : float
    signal-to-noise ratio
radius : float
    avoidance radius. Circular region to exclude in the determination of the noise level

◆ create_metapupil_mask() [2/2]

def laospy.metapupil_I9.MetaPupil.create_metapupil_mask (   self,
  snr = 100,
  radius = 16 
)
Creates a mask based on the illumination pattern in the image

The mask represents the region, in which the mean of all quadrants has a SNR below the 
specified value.  

Parameters
----------
snr : float
    signal-to-noise ratio
radius : float
    avoidance radius. Circular region to exclude in the determination of the noise level

◆ create_zernike_reconstruction_matrix() [1/2]

def laospy.metapupil_I9.MetaPupil.create_zernike_reconstruction_matrix (   self,
  maxmode,
  diam = None,
  rcond = 1e-15 
)
creates the Zernike reconstruction Matrix for the given number of Zernike modes

For each mode a phase screen is created. The screen has to have a diameter which 
circumvents the mask that is defined for quadrant 0. The gradient of each phase screen is 
calculated. Then the slopes are determined for each subaperture defined by the mask. The 
slopes vectors for all modes form the interaction matrix. The resulting 
reconstruction matrix is the (Moore-Penrose) pseudo-inverse of the interaction matrix.

Note: the diameter of the array has to be odd, to have the Zernike polynomial centered on
a full pixel.

If not defined, the diameter of the phase screen is chosen automatically to be slightly 
larger than the metapuil mask.

Parameters
----------
maxmode : integer
    the maximum Zernike mode that will be considered in the reconstruction matrix
    Note: J=1 (piston) will not be considered. Only modes J>1
diam : odd integer (optional)
    the diameter in pixels the zernike modes should have. Cannot be smaller than the mask.
rcond : float
    Cutoff for small singular values. Singular values smaller (in modulus) than 
    rcond * largest_singular_value (again, in modulus) are set to zero.

◆ create_zernike_reconstruction_matrix() [2/2]

def laospy.metapupil_I9.MetaPupil.create_zernike_reconstruction_matrix (   self,
  maxmode,
  diam = None,
  rcond = 1e-15 
)
creates the Zernike reconstruction Matrix for the given number of Zernike modes

For each mode a phase screen is created. The screen has to have a diameter which 
circumvents the mask that is defined for quadrant 0. The gradient of each phase screen is 
calculated. Then the slopes are determined for each subaperture defined by the mask. The 
slopes vectors for all modes form the interaction matrix. The resulting 
reconstruction matrix is the (Moore-Penrose) pseudo-inverse of the interaction matrix.

Note: the diameter of the array has to be odd, to have the Zernike polynomial centered on
a full pixel.

If not defined, the diameter of the phase screen is chosen automatically to be slightly 
larger than the metapuil mask.

Parameters
----------
maxmode : integer
    the maximum Zernike mode that will be considered in the reconstruction matrix
    Note: J=1 (piston) will not be considered. Only modes J>1
diam : odd integer (optional)
    the diameter in pixels the zernike modes should have. Cannot be smaller than the mask.
rcond : float
    Cutoff for small singular values. Singular values smaller (in modulus) than 
    rcond * largest_singular_value (again, in modulus) are set to zero.

◆ delete_mask() [1/2]

def laospy.metapupil_I9.MetaPupil.delete_mask (   self)
Deletes the metapupil mask, if it exists. 

This also deletes the Zernike reconstruction matrix and Zernike coefficients

◆ delete_mask() [2/2]

def laospy.metapupil_I9.MetaPupil.delete_mask (   self)
Deletes the metapupil mask, if it exists. 

This also deletes the Zernike reconstruction matrix and Zernike coefficients

◆ find_centers() [1/2]

def laospy.metapupil_I9.MetaPupil.find_centers (   self,
  boxSize = 40,
  medianSubtract = True,
  gauss = False 
)
Finds the centers of the brightness distributions in the image

If the image type is 'noSE+mask' the center is determined in the center of the image. 
Otherwise centers are determined in each quadrant

Parameters
----------
boxSize : positive integer
    the size of the box to compute the centroid. default value is 40
medianSubtract : bool
    to subtract the median from the image or each quadrant
gauss : bool
    if given will find the gaussian fit of the image passed and return the center 
    coordinates

◆ find_centers() [2/2]

def laospy.metapupil_I9.MetaPupil.find_centers (   self,
  boxSize = 40,
  medianSubtract = True,
  gauss = False 
)
Finds the centers of the brightness distributions in the image

If the image type is 'noSE+mask' the center is determined in the center of the image. 
Otherwise centers are determined in each quadrant

Parameters
----------
boxSize : positive integer
    the size of the box to compute the centroid. default value is 40
medianSubtract : bool
    to subtract the median from the image or each quadrant
gauss : bool
    if given will find the gaussian fit of the image passed and return the center 
    coordinates

◆ find_mask_diameter() [1/2]

def laospy.metapupil_I9.MetaPupil.find_mask_diameter (   self)
Determines the diameter of the circle that circumvents the mask defined in the quadrants

Internally it calculates the distance of every pixel to the center of the metapupil mask
and returns twice the largest distance

◆ find_mask_diameter() [2/2]

def laospy.metapupil_I9.MetaPupil.find_mask_diameter (   self)
Determines the diameter of the circle that circumvents the mask defined in the quadrants

Internally it calculates the distance of every pixel to the center of the metapupil mask
and returns twice the largest distance

◆ find_zernike_coefficients() [1/2]

def laospy.metapupil_I9.MetaPupil.find_zernike_coefficients (   self)
Reconstructs Zernike coefficients from measured slopes.

A zernike reconstruction matrix has to be created before!. Conversion factors are applied, 
if set.

◆ find_zernike_coefficients() [2/2]

def laospy.metapupil_I9.MetaPupil.find_zernike_coefficients (   self)
Reconstructs Zernike coefficients from measured slopes.

A zernike reconstruction matrix has to be created before!. Conversion factors are applied, 
if set.

◆ get_mask() [1/2]

def laospy.metapupil_I9.MetaPupil.get_mask (   self)
returns the mask for WFC

Returns
------
mask : SeqDynamicBitset

◆ get_mask() [2/2]

def laospy.metapupil_I9.MetaPupil.get_mask (   self)
returns the mask for WFC

Returns
------
mask : SeqDynamicBitset

◆ set_image() [1/2]

def laospy.metapupil_I9.MetaPupil.set_image (   self,
  image,
  setup = 'SE' 
)
Sets a new image, rearranges it into quadrants. If defined: applies mask

Parameters
----------
image : ndarray
    The image data
setup : string
    describes the condition with which the image is taken. Possible values:
"SE"        : Star Enlarger in place. a Metapupil images in each quadrant is 
              expected
"SE+mask"   : Star Enlarger in place and  a mask in the pupil or DM plane. A 
              peaked brightness distribution is expected in each quadrant
"noSE+mask" : No star enlarger is in the optical path. A mask is in the pupil or 
              DM plane. A peaked brightness distribution is expected in the center 
              of the image.

◆ set_image() [2/2]

def laospy.metapupil_I9.MetaPupil.set_image (   self,
  image,
  setup = 'SE' 
)
Sets a new image, rearranges it into quadrants. If defined: applies mask

Parameters
----------
image : ndarray
    The image data
setup : string
    describes the condition with which the image is taken. Possible values:
"SE"        : Star Enlarger in place. a Metapupil images in each quadrant is 
              expected
"SE+mask"   : Star Enlarger in place and  a mask in the pupil or DM plane. A 
              peaked brightness distribution is expected in each quadrant
"noSE+mask" : No star enlarger is in the optical path. A mask is in the pupil or 
              DM plane. A peaked brightness distribution is expected in the center 
              of the image.

◆ set_zernike_conversion_factors() [1/2]

def laospy.metapupil_I9.MetaPupil.set_zernike_conversion_factors (   self,
  conversionFactors 
)
Sets the conversion factors for each Zernike mode.

This allows to scale the fitted zernike coefficients into useful units such as steps or 
mu. The array must have the same number of elements as Zernike modes considered in the 
reconstruction matrix. Zernike mode J=1 is not considered; the first element corresponds 
to J=2

Parameters
----------
conversionFactors : ndarray
    array with conversion factors

◆ set_zernike_conversion_factors() [2/2]

def laospy.metapupil_I9.MetaPupil.set_zernike_conversion_factors (   self,
  conversionFactors 
)
Sets the conversion factors for each Zernike mode.

This allows to scale the fitted zernike coefficients into useful units such as steps or 
mu. The array must have the same number of elements as Zernike modes considered in the 
reconstruction matrix. Zernike mode J=1 is not considered; the first element corresponds 
to J=2

Parameters
----------
conversionFactors : ndarray
    array with conversion factors

Member Data Documentation

◆ centers

float laospy.metapupil_I9.MetaPupil.centers = np.ones((4,2)) * 20.0
static

◆ illuminatedMask

laospy.metapupil_I9.MetaPupil.illuminatedMask = np.zeros((40,40))
static

◆ illuminatedPositions

laospy.metapupil_I9.MetaPupil.illuminatedPositions = np.zeros(1600)
static

◆ img

laospy.metapupil_I9.MetaPupil.img = None
static

◆ mask [1/2]

int laospy.metapupil_I9.MetaPupil.mask = 0
static

◆ mask [2/2]

laospy.metapupil_I9.MetaPupil.mask

◆ maskcenters

laospy.metapupil_I9.MetaPupil.maskcenters = np.zeros((4,2))
static

◆ meancenter

laospy.metapupil_I9.MetaPupil.meancenter = np.zeros(2)
static

◆ metapupilMask

laospy.metapupil_I9.MetaPupil.metapupilMask = np.zeros((40,40))
static

◆ noise

int laospy.metapupil_I9.MetaPupil.noise = 0.
static

◆ pyramidAngle

laospy.metapupil_I9.MetaPupil.pyramidAngle = None
static

◆ quadrants

laospy.metapupil_I9.MetaPupil.quadrants = None
static

◆ recMat

laospy.metapupil_I9.MetaPupil.recMat = None
static

◆ setup [1/2]

string laospy.metapupil_I9.MetaPupil.setup = ''
static

◆ setup [2/2]

laospy.metapupil_I9.MetaPupil.setup

◆ slopes

laospy.metapupil_I9.MetaPupil.slopes = None
static

◆ unmaskPositions

laospy.metapupil_I9.MetaPupil.unmaskPositions = np.zeros(1600)
static

◆ zernikeCoeffs

laospy.metapupil_I9.MetaPupil.zernikeCoeffs = None
static

◆ zernikeConvFactors

laospy.metapupil_I9.MetaPupil.zernikeConvFactors = None
static

The documentation for this class was generated from the following file: