shesha.util

Utilities functions Must be stand alone, ie. independent of the rest of the shesha package (except shesha_constants)

shesha.util.dm_util.createDoubleHexaPattern(pitch: float, supportSize: int, pupAngleDegree: float)

Creates a list of M actuator positions spread over an hexagonal grid. The number M is the number of points of this grid, it cannot be known before the procedure is called. Coordinates are centred around (0,0). The support of the grid is a square [-supportSize/2,vsupportSize/2].

Parameters

pitch: (float) : distance in pixels between 2 adjacent actus supportSize: (int) : size in pixels of the support over which the coordinate list

should be returned.

pupAngleDegree: (float) : Rotation angle of the DM

Returns

xy: (np.ndarray(dims=2,dtype=np.float32)) : xy[2,M] list of coodinates

shesha.util.dm_util.createHexaPattern(pitch: float, supportSize: int)

Creates a list of M actuator positions spread over an hexagonal grid. The number M is the number of points of this grid, it cannot be known before the procedure is called. Coordinates are centred around (0,0). The support that limits the grid is a square [-supportSize/2, supportSize/2].

Parameters

pitch: (float) : distance in pixels between 2 adjacent actus

supportSize: (int)size in pixels of the support over which the coordinate list

should be returned.

Returns

xy: (np.ndarray(dims=2,dtype=np.float32)) : xy[2,M] list of coordinates

shesha.util.dm_util.createSquarePattern(pitch: float, nxact: int)

Creates a list of M=nxact^2 actuator positions spread over an square grid. Coordinates are centred around (0,0).

Parameters

pitch: (float) : distance in pixels between 2 adjacent actus

nxact: (int) : number of actu across the pupil diameter

Returns

xy: (np.ndarray(dims=2,dtype=np.float32)) : xy[M,2] list of coodinates

shesha.util.dm_util.dim_dm_patch(pupdiam: int, diam: float, type: bytes, alt: float, xpos_wfs: List[float], ypos_wfs: List[float])

compute patchDiam for DM

Parameters

pupdiam: (int) : pupil diameter

diam: (float) : telescope diameter

type: (bytes) : type of dm

alt: (float) : altitude of dm

xpos_wfs: (list) : list of wfs xpos

ypos_wfs: (list) : list of wfs ypos

shesha.util.dm_util.dim_dm_support(cent: float, extent: int, ssize: int)

Compute the DM support dimensions

Parameters

cent : (float): center of the pupil

extent: (float): size of the DM support

ssize: (int): size of ipupil support

shesha.util.dm_util.filterActuWithPupil(actuPos: numpy.ndarray, pupil: numpy.ndarray, threshold: float)numpy.ndarray

Select actuators based on their distance to the nearest pupil pixel The implementation proposed here is easy but limits it precision to an integer roundoff of the threshold

actuPos: 2 x nActu np.array[float]: actuator position list - pupil pixel units pupil: nPup x nPup np.ndarray[bool]: pupil mask threshold: float: max allowed distance - pupil pixel units

shesha.util.dm_util.make_zernike(nzer: int, size: int, diameter: int, xc=- 1.0, yc=- 1.0, ext=0)

Compute the zernike modes

Parameters

nzer: (int) : number of modes

size: (int) : size of the screen

diameter: (int) : pupil diameter

xc: (float) : (optional) x-position of the center

yc: (float) : (optional) y-position of the center

ext: (int) : (optional) extension

Returns

z : (np.ndarray(ndims=3,dtype=np.float64)) : zernikes modes

shesha.util.dm_util.select_actuators(xc: numpy.ndarray, yc: numpy.ndarray, nxact: int, pitch: int, cobs: float, margin_in: float, margin_out: float, N=None)

Select the “valid” actuators according to the system geometry

Parameters

xc: actuators x positions (origine in center of mirror)

yc: actuators y positions (origine in center of mirror)

nxact:

pitch:

cobs:

margin_in:

margin_out:

N:

Returns

liste_fin: actuator indice selection for xpos/ypos

shesha.util.dm_util.zernumero(zn: int)

Returns the radial degree and the azimuthal number of zernike number zn, according to Noll numbering (Noll, JOSA, 1976)

Parameters

zn: (int) : zernike number

Returns

rd: (int) : radial degrees

an: (int) : azimuthal numbers

shesha.util.influ_util.besel_orth(m, n, phi, r)

TODO: docstring

Parameters

m:

n:

phi:

r:

Returns

B:

shesha.util.influ_util.bessel_influence(xx, yy, type_i='square')

TODO: docstring

Parameters

xx:

yy:

type_i: (optional)

Returns

influ

shesha.util.influ_util.makeBessel(pitch: float, coupling: float, x: Optional[numpy.ndarray] = None, y: Optional[numpy.ndarray] = None, patternType: bytes = 'square')

Compute Bessel influence function

Parameters

pitch: (float) : pitch of the DM expressed in pixels

coupling: (float) : coupling of the actuators

x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

Returns

influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

shesha.util.influ_util.makeBlacknutt(pitch: float, coupling: float, x=None, y=None)

Compute Blacknutt influence function Attention, ici on ne peut pas choisir la valeur de coupling. La variable a ete laissee dans le code juste pour compatibilité avec les autres fonctions, mais elle n’est pas utilisee.

Parameters

pitch: (float): pitch of the DM expressed in pixels

coupling: (float) : coupling of the actuators

x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

Returns

influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

shesha.util.influ_util.makeGaussian(pitch: float, coupling: float, x=None, y=None)

Compute Gaussian influence function. Coupling parameter is not taken into account

Parameters

pitch: (float) : pitch of the DM expressed in pixels

coupling: (float) : coupling of the actuators

x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

Returns

influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

shesha.util.influ_util.makeRadialSchwartz(pitch: float, coupling: float, x=None, y=None)

Compute radial Schwartz influence function

Parameters

pitch: (float) : pitch of the DM expressed in pixels

coupling: (float) : coupling of the actuators

x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

Returns

influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

shesha.util.influ_util.makeRigaut(pitch: float, coupling: float, x=None, y=None)

Compute ‘Rigaut-like’ influence function

Parameters

pitch: (float) : pitch of the DM expressed in pixels

coupling: (float) : coupling of the actuators

x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

Returns

influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

shesha.util.influ_util.makeSquareSchwartz(pitch: float, coupling: float, x=None, y=None)

Compute Square Schwartz influence function

Parameters

pitch: (float) : pitch of the DM expressed in pixels

coupling: (float) : coupling of the actuators

x: indices of influence function in relative position x local coordinates (float). 0 = top of the influence function

y: indices of influence function in relative position y local coordinates (float). 0 = top of the influence function

Returns

influ: (np.ndarray(dims=3,dtype=np.float64)) : cube of the IF for each actuator

shesha.util.iterkolmo.AB(n, L0, deltax, deltay, rank=0)

DOCUMENT AB, n, A, B, istencil This function initializes some matrices A, B and a list of stencil indexes istencil for iterative extrusion of a phase screen.

The method used is described by Fried & Clark in JOSA A, vol 25, no 2, p463, Feb 2008. The iteration is : x = A(z-zRef) + B.noise + zRef with z a vector containing “old” phase values from the initial screen, that are listed thanks to the indexes in istencil.

SEE ALSO: extrude createStencil Cxx Cxz Czz

shesha.util.iterkolmo.Cxx(n, Zxn, Zyn, Xx, Xy, L0)

Cxx computes the covariance matrix of the new phase vector x (new column for the phase screen).

shesha.util.iterkolmo.Cxz(n, Zx, Zy, Xx, Xy, istencil, L0)

Cxz computes the covariance matrix between the new phase vector x (new column for the phase screen), and the already known phase values z.

The known values z are the values of the phase screen that are pointed by the stencil indexes (istencil)

shesha.util.iterkolmo.Czz(n, Zx, Zy, ist, L0)

Czz computes the covariance matrix of the already known phase values z.

The known values z are the values of the phase screen that are pointed by the stencil indexes (istencil)

shesha.util.iterkolmo.asymp_macdo(x)

Computes a term involved in the computation of the phase struct function with a finite outer scale according to the Von-Karman model. The term involves the MacDonald function (modified bessel function of second kind) K_{5/6}(x), and the algorithm uses the asymptotic form for x ~ infinity.

Warnings :

  • This function makes a floating point interrupt for x=0 and should not be used in this case.

  • Works only for x>0.

shesha.util.iterkolmo.create_screen(r0, pupixsize, screen_size, L0, A, B, ist)

DOCUMENT create_screen screen = create_screen(r0,pupixsize,screen_size,&A,&B,&ist)

creates a phase screen and fill it with turbulence r0 : total r0 @ 0.5m pupixsize : pupil pixel size (in meters) screen_size : screen size (in pixels) A : A array for future extrude B : B array for future extrude ist : istencil array for future extrude

shesha.util.iterkolmo.create_screen_assist(screen_size, L0, r0)

screen_size : screen size (in pixels) L0 : L0 in pixel r0 : total r0 @ 0.5 microns

shesha.util.iterkolmo.create_stencil(n)

TODO: docstring

shesha.util.iterkolmo.extrude(p, r0, A, B, istencil)

DOCUMENT p1 = extrude(p,r0,A,B,istencil)

Extrudes a phase screen p1 from initial phase screen p. p1 prolongates p by 1 column on the right end. r0 is expressed in pixels

The method used is described by Fried & Clark in JOSA A, vol 25, no 2, p463, Feb 2008. The iteration is : x = A(z-zRef) + B.noise + zRef with z a vector containing “old” phase values from the initial screen, that are listed thanks to the indexes in istencil.

Examples n = 32; AB, n, A, B, istencil; p = array(0.0,n,n); p1 = extrude(p,r0,A,B,istencil); pli, p1

SEE ALSO: AB() createStencil() Cxx() Cxz() Czz()

shesha.util.iterkolmo.macdo_x56(x, k=10)
Computation of the function

f(x) = x^(5/6)*K_{5/6}(x) using a series for the esimation of K_{5/6}, taken from Rod Conan thesis : K_a(x)=1/2 sum_{n=0}^infty

rac{(-1)^n}{n!}

left(Gamma(-n-a) (x/2)^{2n+a} + Gamma(-n+a) (x/2)^{2n-a}

ight) ,

with a = 5/6.

Setting x22 = (x/2)^2, setting uda = (1/2)^a, and multiplying by x^a, this becomes : x^a * Ka(x) = 0.5 $ -1^n / n! [ G(-n-a).uda x22^(n+a) + G(-n+a)/uda x22^n ] Then we use the following recurrence formulae on the following quantities : G(-(n+1)-a) = G(-n-a) / -a-n-1 G(-(n+1)+a) = G(-n+a) / a-n-1 (n+1)! = n! * (n+1) x22^(n+1) = x22^n * x22 and at each iteration on n, one will use the values already computed at step (n-1). The values of G(a) and G(-a) are hardcoded instead of being computed.

The first term of the series has also been skipped, as it vanishes with another term in the expression of Dphi.

shesha.util.iterkolmo.phase_struct(r, L0=None)

TODO: docstring

shesha.util.iterkolmo.rodconan(r, L0)

The phase structure function is computed from the expression Dphi(r) = k1 * L0^(5./3) * (k2 - (2.pi.r/L0)^5/6 K_{5/6}(2.pi.r/L0))

For small r, the expression is computed from a development of K_5/6 near 0. The value of k2 is not used, as this same value appears in the series and cancels with k2. For large r, the expression is taken from an asymptotic form.

shesha.util.iterkolmo.stencil_size(n)

TODO: docstring

shesha.util.iterkolmo.stencil_size_array(size)

Compute_size2(np.ndarray[ndim=1, dtype=np.int64_t] size)

Compute the size of a stencil, given the screen size

Parameters

size: (np.ndarray[ndim=1,dtype=np.int64_t]) :screen size

shesha.util.kl_util.gkl_fcom(kers: numpy.ndarray, cobs: float, nf: int)

This routine does the work : finding the eigenvalues and corresponding eigenvectors. Sort them and select the right one. It returns the KL modes : in polar coordinates : rabas as well as the associated variance : evals. It also returns a bunch of indices used to recover the modes in cartesian coordinates (nord, npo and ordd).

Parameters

kerns : (np.ndarray[ndim= ,dtype=np.float32]) :

cobs : (float) : central obstruction

nf : (int) :

shesha.util.kl_util.make_azimuth(nord: int, npp: int)numpy.ndarray

TODO: docstring

Parameters

nord:

npp:

Returns

azbas:

shesha.util.kl_util.make_kernels(cobs: float, nr: int, radp: numpy.ndarray, kl_type: bytes, outscl: float = 3.0)numpy.ndarray

This routine generates the kernel used to find the KL modes. The kernel constructed here should be simply a discretization of the continuous kernel. It needs rescaling before it is treated as a matrix for finding the eigen-values. The outer scale should be in units of the diameter of the telescope.

TODO:

Parameters

cobs : (float): central obstruction

nr : (int) :

radp : (float) :

kl_type : (bytes) : “kolmo” or “karman”

outscl : (float) : outter scale for Von Karman spectrum

Returns

kers :

shesha.util.kl_util.make_radii(cobs: float, nr: int)float

TODO: docstring

Parameters

cobs: (float) : central obstruction

nr : (int) :

shesha.util.kl_util.pcgeom(nr, npp, cobs, ncp, ncmar)

This routine builds a geom_struct. px and py are the x and y coordinates of points in the polar arrays. cr and cp are the r and phi coordinates of points in the cartesian grids. ncmar allows the possibility that there is a margin of ncmar points in the cartesian arrays outside the region of interest

TODO:

parameters

nr:

npp:

cobs: (float) : central obstruction

ncp:

ncmar:

returns

ncp:

ncmar:

px:

py:

cr:

cp:

pincx:

pincy:

pincw:

ap:

shesha.util.kl_util.piston_orth(nr: int)numpy.ndarray

TODO: docstring

Parameters

nr:

Returns

s:

shesha.util.kl_util.polang(r: numpy.ndarray)numpy.ndarray

This routine generates an array with the same dimensions as r, but containing the azimuthal values for a polar coordinate system.

TODO:

parameters

r:

return

p:

shesha.util.kl_util.radii(nr: int, npp: int, cobs: float)numpy.ndarray

This routine generates an nr x npp array with npp copies of the radial coordinate array. Radial coordinate span the range from r=cobs to r=1 with successive annuli having equal areas (ie, the area between cobs and 1 is divided into nr equal rings, and the points are positioned at the half-area mark on each ring). There are no points on the border.

TODO:

parameters

nr:

npp:

cobs: (float) : central obstruction

return

r

shesha.util.kl_util.set_pctr(dim: int, nr, npp, nkl: int, cobs: float, nord, ncmar=None, ncp=None)

This routine calls pcgeom to build a geom_struct with the right initializations. bas is a gkl_basis_struct built with the gkl_bas routine. TODO:

Parameters

dim:

nr:

npp:

nkl:

cobs:

nord:

ncmar: (optional)

ncp: (optional)

Returns

ncp

ncmar

px

py

cr

cp

pincx

pincy

pincw

ap

shesha.util.kl_util.setpincs(ax: numpy.ndarray, ay: numpy.ndarray, px: numpy.ndarray, py: numpy.ndarray, cobs: float)Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

This routine determines a set of squares for interpolating from cartesian to polar coordinates, using only those points with cobs < r < 1 SEE ALSO : pcgeom

TODO:

parameters

ax:

ay:

px:

py:

cobs: (float) : central obstruction

return

pincx:

pincy:

pincw

shesha.util.make_apodizer.make_apodizer(dim, pupd, filename, angle)

TODO doc

Parameters

(int) : im:

(int) : pupd:

(str) : filename:

(float) : angle:

shesha.util.make_pupil.centrePourVidal(N, i0, j0, centerMark)

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)

shesha.util.make_pupil.compute1Spider(nspider, N, dspider, i0, j0, scale, rot)

Fonction de fab pour creer le slaving. La fonction cree un tableau de booleens avec une seule spider. Utilisee par la fonction compute6Segments()

shesha.util.make_pupil.compute6Segments(pupNoSpiders, N, pixscale, dspider, i0, j0, rot=0)

N = p_geom.pupdiam i0 = j0 = N / 2. - 0.5 D = p_tel.diam pixscale = D/N dspider = 0.51

Utilisee dans compass/shesha/shesha/supervisor/canapassSupervisor.py pour le slaving des actus.

shesha.util.make_pupil.createHexaPattern(pitch, supportSize)

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

shesha.util.make_pupil.fillPolygon(x, y, i0, j0, scale, gap, N, index=0)

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
  • x, y (float) – list of points defining the polygon

  • i0, j0 (float) – 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)

shesha.util.make_pupil.fillSpider(N, nspider, dspider, i0, j0, scale, rot)

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

shesha.util.make_pupil.gendron()

La fonction est appelee quand l’utilisateur a demande une pupille ELT, et renseigne un diametre de telescope different de 40 metres.

Faut vraiment que je commente ou t’as compris ??

shesha.util.make_pupil.generateCoordSegments(D, rot, pitch=1.244683637214, nseg=33, inner_rad=4.1, outer_rad=15.4, R=95.7853, nominalD=40)

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

D: (float) : pupil diameter in meters (it must be set to 40.0 m for the ELT) rot: (float) : pupil rotation angle in radians pitch: (float): Segment pitch [meters] nseg: (int) : number of segments across the diameter inner_rad : (float): Inner radius [meters] outer_rad : (float): Outer radius [meters] R : (float): Curvature radius of the M1 nominalD: (float): diameter for nominal pupil

shesha.util.make_pupil.generateEeltPupilMask(npt, dspider, i0, j0, pixscale, gap, rotdegree, D=40.0, cobs=0, centerMark=0, halfSpider=False, pitch=1.244683637214, nseg=33, inner_rad=4.1, outer_rad=15.4, R=95.7853, nominalD=40, half_seg=0.75, refl=None, rotSpiderDegree=None)

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

  • i0, j0 (float) – index of pixels where the pupil should be centred = p_geom.pupdiam / 2. - 0.5 Can be floating-point indexes.

  • pixscale (float) – size of a pixel of the image, in meters = ptel.diam/(p_geom.pupdiam / 2. - 0.5)

  • gap (float) – gap between 2 segments in metres

  • 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

  • halfSpider (bool) – half Spider computation flag

  • pitch (float) – segment pitch

  • nseg (int) – number of segments across the diameter

  • inner_rad (float) – Inner radius [meters]

  • outter_rad (float) – outter radius [meters]

  • R (float) – M1 curvature radius

  • nominalD (float) – diameter needed to get nominal aperture after projection

  • half_seg (float) – segment half size

  • refl (float) – std of the reflectivity of each segment

Example

npt = p_geom.pupdiam D = p_tel.diam i0 = npt / 2. - 0.5 j0 = npt / 2. - 0.5 rotdegree = 0. pixscale = D/(npt / 2. - 0.5) dspider = 0.51 gap = 0.0 pup = generateEeltPupilMask(npt, dspider, i0, j0, pixscale, gap, rotdegree)

shesha.util.make_pupil.generateSegmentProperties(attribute, hx, hy, i0, j0, scale, gap, N, D, softGap=0, nominalD=40, pitch=1.244683637214, half_seg=0.75)

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 attribute.

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

  • dspider (float) – width of spiders in meters

  • i0, j0 (float) – 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.

  • nominalD (float) – diameter needed to get nominal pupil aperture

  • pitch (float) – segment pitch

  • half_seg (float) – segment half size

attribute = np.ones(798)+np.random.randn(798)/20. N = 800 i0 = N/2 j0 = N/2 rotdegree = 0.0 scale = 41./N gap = 0.03

shesha.util.make_pupil.getdatatype(truc)

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

shesha.util.make_pupil.make_EELT(dim, pupd, tel, N_seg=- 1)

Initialize the EELT pupil

Parameters

dim: (long) : linear size of ???

pupd: (long) : linear size of total pupil

tel: (Param_tel) : Telescope structure

N_seg: (int)

TODO: complete TODO : add force rescal pup elt

shesha.util.make_pupil.make_VLT(dim, pupd, tel)

Initialize the VLT pupil

Parameters

dim: (long) : linear size of ???

pupd: (long) : linear size of total pupil

tel: (Param_tel) : Telescope structure

shesha.util.make_pupil.make_phase_ab(dim, pupd, tel, pup=None, xc=- 1, yc=- 1, real=0, halfSpider=False)

Compute the EELT M1 phase aberration

Parameters

dim: (long) : linear size of ???

pupd: (long) : linear size of total pupil

tel: (Param_tel) : Telescope structure

pup: (?)

TODO: complete

shesha.util.make_pupil.make_pupil(dim, pupd, tel, xc=- 1, yc=- 1, real=0, halfSpider=False)

Initialize the system pupil

Parameters

dim: (long) : = p_geom.pupdiam

pupd: (long) : linear size of total pupil = p_geom.pupdiam

tel: (Param_tel) : Telescope structure

xc: (int) = p_geom.pupdiam / 2. - 0.5

yc: (int) = p_geom.pupdiam / 2. - 0.5

real: (int)

TODO: complete

shesha.util.make_pupil.make_pupil_generic(dim, pupd, t_spiders=0.01, spiders_type='six', xc=0, yc=0, real=0, cobs=0)

Initialize the system pupil

Parameters

dim: (long) : linear size of ???

pupd: (long) : linear size of total pupil

t_spiders: (float) : secondary supports ratio.

spiders_type: (str) : secondary supports type: “four” or “six”.

xc: (int)

yc: (int)

real: (int)

cobs: (float) : central obstruction ratio.

TODO: complete

shesha.util.make_pupil.reorganizeSegmentsOrderESO(x, y)

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.

shesha.util.rtc_util.centroid_gain(E, F)

Returns the mean centroid gain

Parameters

E : (np.array(dtype=np.float32)) : measurements from WFS

F : (np.array(dtype=np.float32)) : geometric measurements

Returns

cgain : (float) : mean centroid gain between the sets of WFS measurements and geometric ones

shesha.util.rtc_util.create_interp_mat(dimx: int, dimy: int)

TODO doc

Parameters

dimx: (int) :

dimy: (int) :

shesha.util.utilities.bin2d(data_in, binfact)

Returns the input 2D array “array”, binned with the binning factor “binfact”. The input array X and/or Y dimensions needs not to be a multiple of “binfact”; The final/edge pixels are in effect replicated if needed. This routine prepares the parameters and calls the C routine _bin2d. The input array can be of type int, float or double. Last modified: Dec 15, 2003. Author: F.Rigaut SEE ALSO: _bin2d

Parmeters

data_in: (np.ndarray) : data to binned

binfact: (int) : binning factor

shesha.util.utilities.dist(dim, xc=- 1, yc=- 1)

TODO: docstring

shesha.util.utilities.fft_goodsize(s)

find best size for a fft from size s

Parameters

s: (int) size

shesha.util.utilities.first_non_zero(array: numpy.ndarray, axis: int, invalid_val: int = - 1)numpy.ndarray

Find the first non zero element of an array

Args:

array : (np.ndarray) : input array

axis : (int) : axis index

invalid_val : (int, optional) : Default is -1

Return:
non_zeros_pos(np.ndarray)Index of the first non-zero element

for each line or column following the axis

shesha.util.utilities.generate_circle(radius: float, density: float = 1.0)

Generate modulation points positions following a circular pattern s

Args:

radius : (float) : half the length of a side in lambda/D

density : (float), optional) : number of psf per lambda/D. Default is 1

Return:

cx : (np.ndarray) : X-positions of the modulation points

cy : (np.ndarray) : Y-positions of the modulation points

shesha.util.utilities.generate_square(radius: float, density: float = 1.0)

Generate modulation points positions following a square pattern

Args:

radius : (float) : half the length of a side in lambda/D

density : (float), optional) : number of psf per lambda/D. Default is 1

Return:

cx : (np.ndarray) : X-positions of the modulation points

cy : (np.ndarray) : Y-positions of the modulation points

shesha.util.utilities.load_config_from_file(filename_path: str)

Load the parameters from the parameters file

Args:

filename_path: (str): path to the parameters file

Return:

config : (config) : a config module

shesha.util.utilities.load_config_from_module(filepath: str)

Load the parameters from the parameters module

Args:

filename_path: (str): path to the parameters file

Return:

config : (config) : a config module

shesha.util.utilities.makegaussian(size, fwhm, xc=- 1, yc=- 1, norm=0)

Returns a centered gaussian of specified size and fwhm. norm returns normalized 2d gaussian

Parameters
  • size – (int) :

  • fwhm – (float) :

  • xc – (float) : (optional) center position on x axis

  • yc – (float) : (optional) center position on y axis

  • norm – (int) : (optional) normalization

shesha.util.utilities.pad_array(A, N)

TODO: docstring

shesha.util.utilities.rebin(a, shape)

TODO: docstring