anisocado.pupil_utils module

Created on Fri Jun 8 15:38:32 2018

@author: Eric Gendron

Original Title : make_ricoPupil.py

anisocado.pupil_utils.centrePourVidal(N, i0, j0, centerMark)[source]

Renvoie une image de boolens (False) de taille (N,N) avec un point ou une croix (True) centree sur (i0, j0). :param int N: taille de l’image de sortie :param float i0, j0: position du marqueur de sortie :param int centerMark: 0 (pour rien), 1 (option point) ou 2 (option croix)

anisocado.pupil_utils.createHexaPattern(pitch, supportSize)[source]

Cree une liste de coordonnees qui decrit un maillage hexagonal. Retourne un tuple (x,y).

Le maillage est centre sur 0, l’un des points est (0,0). Une des pointes de l’hexagone est dirigee selon l’axe Y, au sens ou le tuple de sortie est (x,y).

Parameters:
  • pitch (float) – distance between 2 neighbour points

  • supportSize (int) – size of the support that need to be populated

anisocado.pupil_utils.fillPolygon(x, y, i0, j0, scale, gap, N, index=0)[source]

From a list of points defined by their 2 coordinates list x and y, creates a filled polygon with sides joining the points. The polygon is created in an image of size (N, N). The origin (x,y)=(0,0) is mapped at pixel i0, j0 (both can be floating-point values). Arrays x and y are supposed to be in unit U, and scale is the pixel size in U units.

Returns:

filled polygon (N, N), boolean

Parameters:
  • y (float x,) – list of points defining the polygon

  • j0 (float i0,) – index of pixels where the pupil should be centred. Can be floating-point indexes.

  • scale (float) – size of a pixel of the image, in same unit as x and y.

  • N (float) – size of output image.

Example:

x = np.array([1,-1,-1.5,0,1.1]) y = np.array([1,1.5,-0.2,-2,0]) N = 200 i0 = N/2 j0 = N/2 gap = 0. scale = 0.03 pol = fillPolygon(x, y, i0, j0, scale, gap, N, index=2)

anisocado.pupil_utils.fillSpider(N, nspider, dspider, i0, j0, scale, rot)[source]

Creates a boolean spider mask on a map of dimensions (N,N) The spider is centred at floating-point coords (i0,j0).

Returns:

spider image (boolean)

Parameters:
  • N (int) – size of output image

  • nspider (int) – number of spiders

  • dspider (float) – width of spiders

  • i0 (float) – coord of spiders symmetry centre

  • j0 (float) – coord of spiders symmetry centre

  • scale (float) – size of a pixel in same unit as dspider

  • rot (float) – rotation angle in radians

anisocado.pupil_utils.generateCoordSegments(D, rot)[source]

Computes the coordinates of the corners of all the hexagonal segments of M1. Result is a tuple of arrays(6, 798).

Parameters:

D (float) – D is the pupil diameter in meters, it must be set to 40.0 m

for the nominal EELT. :param float rot: pupil rotation angle in radians

anisocado.pupil_utils.generateEeltPupilMask(npt, dspider, i0, j0, pixscale, gap, rotdegree, D=40.0, centerMark=0)[source]

Generates a boolean pupil mask of the binary EELT pupil on a map of size (npt, npt).

Returns:

pupil image (npt, npt), boolean

Parameters:
  • npt (int) – size of the output array

  • dspider (float) – width of spiders in meters

  • j0 (float i0,) – index of pixels where the pupil should be centred. Can be floating-point indexes.

  • pixscale (float) – size of a pixel of the image, in meters.

  • gap (float) – half-space between segments in meters

  • rotdegree (float) – rotation angle of the pupil, in degrees.

  • D (float) – diameter of the pupil. For the nominal EELT, D shall be set to 40.0

  • centerMark (int) – when centerMark!=0, a pixel is added at the centre of symmetry of the pupil in order to debug things using compass. centerMark==1 draws a point centerMark==2 draws 2 lines

Example:

npt = 752 i0 = npt/2+0.5 j0 = npt/2+0.5 rotdegree = 90.0 pixscale = 40./npt dspider = 0.53 gap = 0.02 pup = generateEeltPupilMask(npt, dspider, i0, j0, pixscale, gap, rotdegree)

anisocado.pupil_utils.generateEeltPupilPhase(phase, npt, dspider, i0, j0, pixscale, rotdegree, D=40.0)[source]

Generates a map of the segments phase errors of the EELT pupil, on an array of size (npt, npt).

Returns:

phase image (npt, npt), with the same type of input argument phase

Parameters:
  • phase (float) – scalar value or 2D-array of the piston, tip and tilt of the segments. The array shall be of dimension [3, 798] that contains [piston, tip, tilt]

  • npt (int) – size of the output array

  • dspider (float) – width of spiders in meters

  • j0 (float i0,) – index of pixels where the pupil should be centred. Can be floating-point indexes.

  • pixscale (float) – size of a pixel of the image, in meters.

  • rotdegree (float) – rotation angle of the pupil, in degrees.

  • D (float) – diameter of the pupil. For the nominal EELT, D shall be set to 40.0

Example:

phase = np.random.randn(3,798) phase = np.zeros((3,798)); phase[1,:]=1. npt = 752 i0 = npt/2+0.5 j0 = npt/2+0.5 rotdegree = 90.0 pixscale = 41./npt dspider = 0.51 pup = generateEeltPupilPhase(phase, npt, dspider, i0, j0, pixscale,

rotdegree)

anisocado.pupil_utils.generateEeltPupilReflectivity(refl, npt, dspider, i0, j0, pixscale, gap, rotdegree, D=40.0, softGap=False)[source]

Generates a map of the reflectivity of the EELT pupil, on an array of size (npt, npt).

Returns:

pupil image (npt, npt), with the same type of input argument refl

Parameters:
  • refl (float/int/bool) – scalar value or 1D-array of the reflectivity of the segments. If refl is scalar, the value will be replicated for all segments. If refl is a 1D array, then it shall contain the reflectivities of all segments. On output, the data type of the pupil map will be the same as refl.

  • npt (int) – size of the output array

  • dspider (float) – width of spiders in meters

  • j0 (float i0,) – index of pixels where the pupil should be centred. Can be floating-point indexes.

  • pixscale (float) – size of a pixel of the image, in meters.

  • gap (float) – half-space between segments in meters

  • rotdegree (float) – rotation angle of the pupil, in degrees.

  • D (float) – diameter of the pupil. For the nominal EELT, D shall be set to 40.0

  • softGap (bool) – if False, the gap between segments is binary 0/1 depending if the pixel is within the gap or not. If True, the gap is a smooth region of a fwhm of 2 pixels with a depth related to the gap width.

Example:

refl = np.ones(798)+np.random.randn(798)/20. dead = 3 refl[(np.random.rand(dead)*797).astype(int)] = 0. npt = 1200 i0 = npt/2+0.5 j0 = npt/2+0.5 rotdegree = 14.0 pixscale = 44./npt dspider = 0.53 gap = 0.02 pup = generateEeltPupilReflectivity(refl, npt, dspider, i0, j0, pixscale,

gap, rotdegree, softGap=True)

anisocado.pupil_utils.generateEeltPupil_slow(npt, dspider, i0, j0, pixscale, rotdegree)[source]

Computes the binary EELT pupil on a map of size (npt, npt). This is the original function, that builds the pupil shape according to hardcoded contours. This function is now obsolete, because it’s been replaced by the faster one generateEeltPupilMask()

Returns:

pupil image (npt, npt), boolean

Parameters:
  • dspider (float) – width of spiders in meters

  • j0 (float i0,) – index of pixels where the pupil should be centred. Can be floating-point indexes.

  • pixscale (float) – size of a pixel of the image, in meters.

  • rotdegree (float) – rotation angle of the pupil, in degrees.

Example:

>>> pup = generateEeltPupil_slow(800, 0.6, 400, 400, 0.1, 3.0)
anisocado.pupil_utils.generateSegmentProperties(attribute, hx, hy, i0, j0, scale, gap, N, D, softGap=0)[source]

Builds a 2D image of the pupil with some attributes for each of the segments. Those segments are described from arguments hx and hy, that are produced by the function generateCoordSegments(D, rot).

When attribute is a phase, then it must be a float array of dimension [3, 798] with the dimension 3 being piston, tip, and tilt. Units of phase is xxx rms, and the output of the procedure will be in units of xxx.

Returns:

pupil image (N, N), with the same type of input argument attribute

Parameters:
  • attribute (float/int/bool) –

    scalar value or 1D-array of the reflectivity of the segments or 2D array of phase

    If attribute is scalar, the value will be replicated for all segments If attribute is a 1D array, then it shall contain the reflectivities of all segments. If attribute is a 2D array then it shall contain the piston, tip and tilt of the segments. The array shall be of dimension [3, 798] that contains [piston, tip, tilt] On output, the data type of the pupil map will be the same as input

  • hy (float hx,) – arrays [6,:] describing the segment shapes. They are generated using generateCoordSegments()

  • dspider (float) – width of spiders in meters

  • j0 (float i0,) – index of pixels where the pupil should be centred. Can be floating-point indexes.

  • scale (float) – size of a pixel of the image, in meters.

  • gap (float) – half-space between segments in meters

  • N (int) – size of the output array (N,N)

  • D (float) – diameter of the pupil. For the nominal EELT, D shall be set to 40.0

  • softGap (bool) – if False, the gap between segments is binary 0/1 depending if the pixel is within the gap or not. If True, the gap is a smooth region of a fwhm of 2 pixels with a depth related to the gap width.

anisocado.pupil_utils.getEeltSegmentNumber()[source]

Just returns the number of segments of the EELT nominal pupil, in order to be able to generate either reflectivities, or phase errors, or else.

anisocado.pupil_utils.getdatatype(truc)[source]

Returns the data type of a numpy variable, either scalar value or array.

anisocado.pupil_utils.reorganizeSegmentsOrderESO(x, y)[source]

Reorganisation des segments facon ESO. Voir ESO-193058 Standard Coordinate System and Basic Conventions

Parameters:
  • x (float) – tableau des centres X des segments

  • y (float) – idem Y

Return tuple (x,y):

meme tuple que les arguments d’entree, mais tries.