Cuda Engined Optics

Cuda Engined Optics or CEO is a CUDA library for the modeling of Adaptive Optics (AO) systems in Astronomy.

CEO consists of a C++ API that hides most of the CUDA API. The CEO API can then be used to build AO simulations.

A CEO python interface has also been developed and is usually the preferred way to interact with CEO functionalities. This high level interface has been written with Cython to preserve speed.

All the code has been written following the literate programming methodology. This means that the code and the associated documentation are tangled together in a few source files. CEO relies on noweb to extract the code from the source files and to build the corresponding Latex documentation.

CEO can be downloaded from <https://github.com/rconan/CEO>. The C++ API is compiled with make all, the Python interface with make cython and the code documentation with make doc.

atmosphere

AtmosphereAbstract

class ceo.AtmosphereAbstract(float r0, float L0, N_LAYER=1, altitude=0.0, xi0=1.0, wind_speed=0.0, wind_direction=0.0)

Atmosphere base class

Attributes

r0 (number) The Fried parameter [m].
L0 (number) The outer scale of turbulence [m].
N_LAYER (int, optionnal) The number of atmospheric layers, default: 1.
altitude (ndarray of floats, optionnal) The atmosphere layer altitudes [m], default: 0.0.
xi0 (ndarray of floats, optionnal) The atmosphere layer weights 0<=xi0<=1, the sum must equal 1, default: 1.0.
wind_speed (ndarray of floats, optionnal) The atmosphere layer wind speeds [m/s], default: 0.0.
wind_direction (ndarray of floats, optionnal) The atmosphere layer wind directions [rd], default: 0.0.

Methods

get_phase_screen(self, Source src, …) Computes the N_x$ imes$N_y phase screen of the source wavefront
get_phase_screen_circ_centroids(self, …)
get_phase_screen_circ_uplink_centroids(self, …)
get_phase_screen_gradient(self, …) Computes the phase screen gradient of the source wavefront
get_phase_screen_gradientSH(self, …) Computes the phase screen gradient of the source wavefront
get_phase_values(self, cuFloatArray x, …) Computes the phase screen of the source wavefront
phase_screen(self, Source src, float time)
propagate(self, Source src)
ray_tracing(self, Source src, float delta_x, …) Computes the N_x$ imes$N_y phase screen of the source wavefront
ray_tracing_values(self, …) Computes the phase screen of the source wavefront
reset(self)
save_layer_phasescreens(self, …)
get_phase_screen(self, Source src, float delta_x, int N_x, float delta_y, int N_y, float time, float exponent=0.0)

Computes the N_x$ imes$N_y phase screen of the source wavefront

Parameters:

src: Source object

The light source

delta_x: float

X-axis spacing

N_x: int

X-axis sampling

delta_y: float

Y-axis spacing

N_y: int

Y-axis sampling

time: float

The time of the atmosphere snapshot since the beginning of the simulation

get_phase_screen_circ_centroids(self, Centroiding cog, float R, Source src, int N_SRC, float time)
get_phase_screen_gradient(self, Centroiding cog, int NL, float d, Source src, float time, float delay=0.0)

Computes the phase screen gradient of the source wavefront

Parameters:

cog: Centroiding object

The centroids container object.

NL: int

The size of the square lenslet array.

d: float

The lenslet array pitch.

src: Source object

The light source.

time: float

The time of the atmosphere snapshot since the beginning of the simulation

get_phase_screen_gradientSH(self, ShackHartmann wfs, int NL, float d, Source src, float time)

Computes the phase screen gradient of the source wavefront

Parameters:

cog: Centroiding object

The centroids container object.

NL: int

The size of the square lenslet array.

d: float

The lenslet array pitch.

src: Source object

The light source.

time: float

The time of the atmosphere snapshot since the beginning of the simulation

get_phase_values(self, cuFloatArray x, cuFloatArray y, Source src, float time)

Computes the phase screen of the source wavefront

Parameters:

x: cuFloatArray

X coordinates of the phase screen samples.

y: cuFloatArray

Y coordinates of the phase screen samples.

src: Source object

The light source.

time: float

The time of the atmosphere snapshot since the beginning of the simulation.

phase_screen(self, Source src, float time)
propagate(self, Source src)
ray_tracing(self, Source src, float delta_x, int N_X, float delta_y, int N_Y, float tau)

Computes the N_x$ imes$N_y phase screen of the source wavefront

Parameters:

src: Source object

The light source

delta_x: float

X-axis spacing

N_x: int

X-axis sampling

delta_y: float

Y-axis spacing

N_y: int

Y-axis sampling

time: float

The time of the atmosphere snapshot since the beginning of the simulation

ray_tracing_values(self, cuFloatArray x_PUPIL, cuFloatArray y_PUPIL, int NXY_PUPIL, Source src, float tau)

Computes the phase screen of the source wavefront

Parameters:

x: cuFloatArray

X coordinates of the phase screen samples.

y: cuFloatArray

Y coordinates of the phase screen samples.

src: Source object

The light source.

time: float

The time of the atmosphere snapshot since the beginning of the simulation.

reset(self)
save_layer_phasescreens(self, bytes filename, int N_DURATION)

Atmosphere

class ceo.Atmosphere(float r0, float L0, N_LAYER=1, altitude=0.0, xi0=1.0, wind_speed=0.0, wind_direction=0.0, float L=0.0, int NXY_PUPIL=0, float fov=0.0, float duration=1.0, bytes filename=None, int N_DURATION=1)

Create an atmosphere

Parameters:

r0 : number

The Fried parameter [m].

L0 : number

The outer scale of turbulence [m].

N_LAYER : int, optionnal

The number of atmospheric layers, default: 1.

altitude : ndarray of floats, optionnal

The atmosphere layer altitudes [m], default: 0.0.

xi0 : ndarray of floats, optionnal

The atmosphere layer weights 0<=xi0<=1, the sum must equal 1, default: 1.0.

wind_speed : ndarray of floats, optionnal

The atmosphere layer wind speeds [m/s], default: 0.0.

wind_direction : ndarray of floats, optionnal

The atmosphere layer wind directions [rd], default: 0.0.

L : float, optionnal

The size of the square phase screen at an altitude of 0km [m], default: 0.0.

NXY_PUPIL : int, optionnal

The sampling of the square phase screen at an altitude of 0km [px], default: 0.

fov : float, optionnal

The field of view [rd], default: 0.0.

duration : float, optionnal

The time length of the phase screens [s], default: 1.0.

filename : bytes, optionnal

The name of the file to save the phase screens of the layers to, default: None.

N_DURATION : int, optionnal

The number of phase screens of time length duration, default: 1.

See also

AtmosphereAbstract
the Atmosphere base class

Examples

>>> import numpy as np
>>> import ceo
>>> h   = np.array([0,1,2.5,5,8,10,12],dtype=np.float32)*1e3
>>> xi0 = np.array([0.3,0.15,0.25,0.1,0.1,0.05,0.05], dtype=np.float32)
>>> vs  = np.array([10,10,10,10,10,10,10],dtype=np.float32)
>>> vo  = np.array([0,0,0,0,0,0,0], dtype=np.float32)

An atmosphere with r0=15cm and L0=30m is created with

>>> atm = Atmosphere(15e-2,30,h,xi0,vs,vo)

A 25m square phase screen sampled with 401 pixels across is computed a t=0s with

>>> L = 25.0
>>> N = 401
>>> delta = L/(N-1)
>>> src =ceo.Source('R',resolution=(N,N))
>>> atm.get_phase_screen(src,delta,N,delta,N,0.0)

The phase screen can be computed faster by precomputing the phase screen in the layers of the atmosphere:

>>> atm = Atmosphere(15e-2,30,h,xi0,vs,vo,L=L,NXY_PUPIL=N,fov=1.0*ceo.constants.ARCMIN2RAD,duration=1.0)

The phase screens are computed for a 1 arc minute field-of-view and for 1s, meaning that a source can be propagated anywhere within this field-of-view and for anytime between 0 and 1s; the fast ray tracing through the precomputed layers is called with

>>> atm.ray_tracing(src,delta,N,delta,N,0.0)

The precomputed phase screens can be saved to a file by passing the filename to the atmosphere constructor

>>> atm = Atmosphere(15e-2,30,h,xi0,vs,vo,L=L,NXY_PUPIL=N,fov=1.0*ceo.constants.ARCMIN2RAD,duration=1.0,
                     filename="myWondrousAtmosphere.bin")

If the file already exists the constructor will attempt to load it.

The phase screens are loaded into the device memory, so duration must be chosen with care to not overflow the device memory. For longer time sequence of N_DURATIONxduration time length, the full sequence of phase screens is loaded into the device memory. ray_tracing will copy the appropriate time sequence of duration time length from the host to the device based of the time parameters.

>>> atm = Atmosphere(15e-2,30,h,xi0,vs,vo,L=L,NXY_PUPIL=N,fov=1.0*ceo.constants.ARCMIN2RAD,duration=10.0,
                     filename="myWondrousAtmosphere.bin",N_DURATION=10)
>>> atm.ray_tracing(src,delta,N,delta,N,8.88)

Attributes

L0
N_LAYER
altitude
layers
r0
wind_direction
wind_speed
xi0

Methods

get_phase_screen(self, Source src, …) Computes the N_x$ imes$N_y phase screen of the source wavefront
get_phase_screen_circ_centroids(self, …)
get_phase_screen_circ_uplink_centroids(self, …)
get_phase_screen_gradient(self, …) Computes the phase screen gradient of the source wavefront
get_phase_screen_gradientSH(self, …) Computes the phase screen gradient of the source wavefront
get_phase_values(self, cuFloatArray x, …) Computes the phase screen of the source wavefront
phase_screen(self, Source src, float time)
propagate(self, Source src)
ray_tracing(self, Source src, float delta_x, …) Computes the N_x$ imes$N_y phase screen of the source wavefront
ray_tracing_values(self, …) Computes the phase screen of the source wavefront
reset(self)
save_layer_phasescreens(self, …)

GmtAtmosphere

class ceo.GmtAtmosphere(float r0, float L0, float L=0.0, int NXY_PUPIL=0, float fov=0.0, float duration=1.0, bytes filename=None, int N_DURATION=1, int SEED=2016, int ID=1)

Creates an atmosphere with the GMT default Cn2 and wind vector profiles

Parameters:

r0 : number

The Fried parameter [m].

L0 : number

The outer scale of turbulence [m].

L : float, optionnal

The size of the square phase screen at an altitude of 0km [m], default: 0.0.

NXY_PUPIL : int, optionnal

The sampling of the square phase screen at an altitude of 0km [px], default: 0.

fov : float, optionnal

The field of view [rd], default: 0.0.

duration : float, optionnal

The time length of the phase screens [s], default: 1.0.

filename : bytes, optionnal

The name of the file to save the phase screens of the layers to, default: None.

N_DURATION : int, optionnal

The number of phase screens of time length duration, default: 1.

SEED : int, optional

The seed of the random generator, default: 2016.

ID : int, optional

The ID number of the GMT atmosphere model, default: 1.

See also

AtmosphereAbstract
the Atmosphere base class
Atmosphere
the generic atmosphere class

Attributes

L0
N_LAYER
altitude
layers
r0
wind_direction
wind_speed
xi0

Methods

get_phase_screen(self, Source src, …) Computes the N_x$ imes$N_y phase screen of the source wavefront
get_phase_screen_circ_centroids(self, …)
get_phase_screen_circ_uplink_centroids(self, …)
get_phase_screen_gradient(self, …) Computes the phase screen gradient of the source wavefront
get_phase_screen_gradientSH(self, …) Computes the phase screen gradient of the source wavefront
get_phase_values(self, cuFloatArray x, …) Computes the phase screen of the source wavefront
phase_screen(self, Source src, float time)
propagate(self, Source src)
ray_tracing(self, Source src, float delta_x, …) Computes the N_x$ imes$N_y phase screen of the source wavefront
ray_tracing_values(self, …) Computes the phase screen of the source wavefront
reset(self)
save_layer_phasescreens(self, …)

Layer

class ceo.Layer

Attributes

LENGTH
N_LENGTH
N_WIDTH
WIDTH
phase_screen

source

Bundle

SourceBundle

FreeBundle

class ceo.FreeBundle(ndarray x, ndarray y, list origin)

A class to represent a bundle of rays

Parameters:

x : ndarray

the x coordinates of the rays in the entrance pupil

y : ndarray

the y coordinates of the rays in the entrance pupil

origin : list

the point of origin of the chief ray

See also

Bundle
the parent class for all ray bundle classes

Attributes

L
N_BUNDLE
N_L
chief_coordinates
chief_directions
chief_optical_path_length
coordinates
directions
n_iteration
optical_path_difference
optical_path_length
origin
piston_mask
refractive_index
rot_angle
sphere_distance sphere_distance: ceo.utilities.cuDoubleArray
sphere_origins
sphere_radius sphere_radius: ceo.utilities.cuDoubleArray
vignetting

Methods

ee80(self[, spaxel]) Computes the size of the geometric EE80 square
get_optical_path_difference(self, …)
gmt_truss_onaxis(self)
to_focal_plane(self, …) Propagates the rays to the focal plane
to_sphere(self[, sphere_origin]) Computes the optical path difference with respect to the reference sphere
to_z_plane(self, rtd z_plane) Propagates the rays to a given plane

Complex_amplitude

class ceo.Complex_amplitude

A class to represent a wavefront complex amplitude

Parameters:

Source : Source

a CEO Source object

See also

Source
a class for astronomical sources

Attributes

phase (float) The complex amplitude angle
amplitude (float, read only) the complex amplitude magnitude

Methods

addPhase(self, cuFloatArray phase)
axpy(self, float alpha, cuFloatArray phase)
finiteDifference(self, int NL, float d, …) Computes the average finite difference of the wavefront
gradientAverage(self, int NL=1, float d=1.0) Computes the average finite difference of the wavefront
gradientAverageFast(self, float d) Computes the average finite difference of the wavefront
reset(self, cuFloatArray phase=None, …) Reset the wavefront amplitude to 1 and phase to 0 or to the given phase
rms(self, int units_exponent=0) Computes the rms of the wavefront phase
addPhase(self, cuFloatArray phase)
axpy(self, float alpha, cuFloatArray phase)
finiteDifference(self, int NL, float d, MaskAbstract M=None)

Computes the average finite difference of the wavefront

Parameters:

NL : int

The linear size of the lenslet array

d : float

The lenslet pitch

M : MaskAbstract, optional

The valid lenslet mask

Returns:

cuFloatArray

The wavefront finite differences in an array of size [N_SRCxNLx2,NL]

gradientAverage(self, int NL=1, float d=1.0)

Computes the average finite difference of the wavefront

Parameters:

NL : int

The linear size of the lenslet array

d : float

The lenslet pitch

Returns:

cuFloatArray

The wavefront gradient average in an array of size [N_SRCxNLx2,NL]

gradientAverageFast(self, float d)

Computes the average finite difference of the wavefront

Parameters:

d : float

The lenslet pitch

Returns:

cuFloatArray

The wavefront gradient average in an array of size [N_SRCx2,1]

reset(self, cuFloatArray phase=None, Complex_amplitude wavefront=None)

Reset the wavefront amplitude to 1 and phase to 0 or to the given phase

Parameters:

phase : cuFloatArray, optional

The GPU array the wavefront phase is reset to; default to None

See also

cuFloatArray
a class for GPU host and device float data
rms(self, int units_exponent=0)

Computes the rms of the wavefront phase

Parameters:

units_exponent: int, optional

3 for km, 0 for meter, -2 for cm, -3 for mm, -6 for micron, -9 for nm, etc; default: 0

Returns:

float

the wavefront phase rms

Source

class ceo.Source(photometric_band, zenith=0, azimuth=0, magnitude=None, height=float('inf'), resolution=(0, 0), fwhm=None, rays_box_size=None, rays_box_sampling=None, rays_origin=[0.0, 0.0, 25.0], chief_ray_origin=None, samplingTime=1.0, int N_RAY=0, __Pyx_memviewslice rays_x=None, __Pyx_memviewslice rays_y=None)

A class to represent an astronomical source

Parameters:

photometric_band : char

The sources photometric band

zenith : list, tuple or numpy array, optional

The sources zenith angles [rd], defaults to 0.

azimuth : list, tuple or numpy array, optional

The sources azimuth angles [rd], defaults to 0.

height : float, optional

The sources altitude [m], defaults to infinity.

resolution : tuple

A 2 element tuple with the sampling [n,m] in pixel of the source wavefront complex amplitude.

fwhm : float, optional

The fwhm of the source intensity distribution in detector pixel unit (before binning), defaults to None.

rays_box_size : float, optional

The size of the ray bundle [m], defaults to 25.5.

rays_box_sampling : int, optional

The linear sampling of the ray bundle

rays_origin : list, optional

A 3 element list, with the first 2 being the (x,y) origin of the ray bundle and the 3rd the ray bundle starting z coordinates, defaults to [0,0,25]

samplingTime : double

the source propagation sampling time; default: 1s

Examples

>>> import math
>>> import numpy as np
>>> import ceo

An on-axis source in K band is simply defined with:

>>> src = Source("K")

The resolution of the source wavefront is specifed with

>>> n = 256
>>> src = Source("K",resolution=(n,n))

For a 20” off-axis and 10th magnitude source, zenith and azimuth are set with

>>> src = Source("K",zenith=20*math.pi/180/3600,azimuth=math.pi/4,resolution=(n,n),magnitude=10)

A Laser guide star constellation of 6 sources is defined with

>>> zen = np.ones(6)*30*math.pi/180/3600,
>>> azi = np.linspace(0,5,6)*2*math.pi/6
>>> lgs = ceo.Source("R",zenith=zen,azimuth=azi,height=90e3,resolution=(n,n))

If the source is to be used for ray tracing through an optical model like the GMT, then

>>> lgs = ceo.Source("R",zenith=zen,azimuth=azi,height=90e3,
                    rays_box_size=25.5, rays_box_sampling=n, rays_origin=[0,0,25])

Attributes

samplingTime samplingTime: ‘double’
timeStamp timeStamp: ‘double’
parameters parameters: dict
n (int) wavefront resolution
m (int) wavefront resolution
size (int) number of sources
zenith (ndarray) zenith angle
azimuth (ndarray) azimuth angle
thetax (ndarray) tan(zenith)cos(azimuth)
thetay (ndarray) tan(zenith)sin(azimuth)
height (float) source height
ray (Bundle) geometric ray bundle
phase (cuFloatArray) wavefront phase
wavelength (float, read only) the wavelength of the source
spectral_bandwidth (float, read only) the spectral bandwidth associated to the source
nPhoton (float, read only) number of photon [m^-2.s^-1]
magnitude (float, write only) star magnitude
wavefront (Complex_amplitude) the wavefront complex amplitude
sphere_distance (float) the distance to the reference sphere used to compute the OPD
OPTICALPATH (tuple (readonly)) the source optical path

Methods

masked(self, MaskAbstract tel) Apply the binary mask of the telescope pupil to the source wavefront
nBackgroundPhoton(self, …)
opd2phase(self, int FLAG=1) Transfer the OPD from ray tracing to the wavefront phase
phaseRms(self[, where]) Get the phase rms corresponding to either the pupil or the segments
piston(self[, where]) Get the piston corresponding to either the pupil or the segments
reset(self) Reset the wavefront amplitude to 1 and phase to 0 and re–initialize the ray bundle
resetRays(self, int FLAG=1) Re–initialize the ray bundle
segmentsWavefrontGradient(self) Computes the average angle of arrival (tip and tilt) of each segment
segmentsWavefrontGradientSlow(self) Computes the average angle of arrival (tip and tilt) of each segment
updateDirections(self, zenith, azimuth) Update the zenith and azimuth direction angles
band

band: bytes

masked(self, MaskAbstract tel)

Apply the binary mask of the telescope pupil to the source wavefront

Parameters:

mask : Mask

The binary mask structure

nBackgroundPhoton(self, float backgroundMagnitude)
opd2phase(self, int FLAG=1)

Transfer the OPD from ray tracing to the wavefront phase

Parameters:

FLAG : int (optional)

If FLAG is 0, the rays vignetting mask is not reset, this is used for sequential ray tracing (default: 1)

parameters

parameters: dict

phaseRms(self, where='pupil', int units_exponent=0)

Get the phase rms corresponding to either the pupil or the segments

Parameters:

where : string, optional

Either “pupil” for a piston on the full pupil or “segments” for pistons of each segment; default: pupil

units_exponent : int, optional

Multiply the rms phase values by 10^-units_exponent; default: 0

Returns:

ndarray of float

The vector of phase rms values in meters as either an N_SRC vector for “pupil” or a N_SRCx7 array for “segments”

piston(self, where='pupil', int units_exponent=0)

Get the piston corresponding to either the pupil or the segments

Parameters:

where : string, optional

Either “pupil” for a piston on the full pupil or “segments” for pistons of each segment; default: pupil

units_exponent : int, optional

Multiply the piston values by 10^-units_exponent; default: 0

Returns:

ndarray of float

The vector of piston values in meters as either an N_SRC vector for “pupil” or a N_SRCx7 array for “segments”

See also

GMT_MX
a class embedding GMT M1 and M2 classes
GMT_M1
a class for GMT M1 model

Examples

>>> import ceo
>>> gs = ceo.Source("V",rays_box_size=25.5, rays_box_sampling=256, rays_origin=[0,0,25])
>>> gmt = ceo.GMT_MX(25.5,256)
>>> gmt.propagate(gs)

The piston over the entire pupil is obtained with:

>>> gs.piston(where="pupil")

The 7 segment pistons are retrieved with

>>> gs.piston(where="segments")
reset(self)

Reset the wavefront amplitude to 1 and phase to 0 and re–initialize the ray bundle

resetRays(self, int FLAG=1)

Re–initialize the ray bundle

Parameters:

FLAG : int (optional)

If FLAG is 0, the rays vignetting mask is not reset, this is used for sequential ray tracing (default: 1)

samplingTime

samplingTime: ‘double’

segmentsWavefrontGradient(self)

Computes the average angle of arrival (tip and tilt) of each segment

Returns:

cuFloatArray

The average angle of arrival of each segment in an array of size [N_SRCx7x2,1] as [cx,cy]

segmentsWavefrontGradientSlow(self)

Computes the average angle of arrival (tip and tilt) of each segment

Returns:

cuFloatArray

The average angle of arrival of each segment in an array of size [N_SRCx7x2,1] as [cx,cy]

timeStamp

timeStamp: ‘double’

updateDirections(self, zenith, azimuth)

Update the zenith and azimuth direction angles

Parameters:

zenith : float, tuple, list or numpy array

The zenith angle array in radian

azimuth : float, tuple, list or numpy array

The azimuth angle array in radian

GMTLIB

GMT_MX

class ceo.GMT_MX(D=None, D_px=None, M1_radial_order=0, M2_radial_order=0, M1_mirror_modes='zernike', M2_mirror_modes='zernike', M1_N_MODE=0, M2_N_MODE=0, M1_mirror_modes_data=None, M2_mirror_modes_data=None)[source]

A class container from GMT_M1 and GMT_M2 classes

Parameters:

D : float

The size of the pupil plane in meter

D_px : int

The size of the pupil plane in pixel

M1_radial_order : int, optionnal

The largest radial order of the Zernike polynomials on M1 segments, default to 0

M2_radial_order : int, optionnal

The largest radial order of the Zernike polynomials on M2 segments, default to 0

See also

GMT_M1
the class for GMT M1 model
GMT_M2
the class for GMT M2 model
Source
a class for astronomical sources
cuFloatArray
an interface class between GPU host and device data for floats

Examples

>>> import ceo

The mandatory parameters are the size of the pupil plane in meter or in pixel

>>> gmt = ceo.GMT_MX(25.5,256)

If more that one source (lets say 3) is going to be propagated through the telescope:

>>> gmt = ceo.GMT_MX(25.5,256, N_SRC=3)

A combination of Zernike polynomials can be applied to M1 and M2 segments by specifying the largest radial order on each mirror

>>> gmt = ceo.GMT_MX(25.5,256, M1_radial_order=8, M2_radial_order=14)

A source is propagated (geometrically) through the telescope with the following procedure:

>>> src = ceo.Source("R",rays_box_size=25.5,rays_box_sampling=256,rays_origin=[0.0,0.0,25])
>>> gmt.propagate(src)

and the wavefront phase is retrieved either as a 2D map cuFloatArray object with

>>> gpu_ps2d = src.phase()

or as a 1D vector with

>>> gpu_ps1d = src.wavefront.phase()

Attributes

M1 M1: ceo.gmtMirrors.GMT_M1
M2 M2: ceo.gmtMirrors.GMT_M2
D (float) The size of the pupil plane in meter
D_px (int) The size of the pupil plane in pixel
sphere_radius (float) The curvature radius of the ray tracing reference sphere

Methods

AGWS_calibrate(wfs, gs[, stroke, coupled, …])
PSSn(src[, r0, L0, zenith_distance, C, AW0, …]) Computes the PSSn corresponding to the current state of the telescope
calibrate(wfs, gs[, mirror, mode, stroke, …]) Calibrate the different degrees of freedom of the mirrors
cloop_calib_init(D, nPx[, …])
dump_log(self, bytes filename) Writes the M1 and M2 segment commands log to a file
propagate(self, Source src, str where_to=, …) Propagate the Source object to the pupil plane conjugated to M1
reset(self, dict state=None) Reset M1 and M2 mirror segments to their original locations and shapes
segmentsWavefrontGradient(self, Source src) Computes the gradient of the phase of the wavefront on each segment
update(self, dict state) Update M1 and M2 rigid body motions using dictionary input: {‘M1’:{‘Rxyz’:val1,…},’M2’,{‘Txyz’:val2,…}}
PSSn(src, r0=0.16, L0=25.0, zenith_distance=30, C=None, AW0=None, ref_src=None, save=False, amplitude_filter=None)[source]

Computes the PSSn corresponding to the current state of the telescope

Parameters:

src : Source

The source object that is propagated through the telescope, the PSSn is given at the wavelenght of the source

r0 : float, optional

The Fried parameter at zenith and at 500nm in meter; default: 0.15m

L0 : float, optional

The outer scale in meter; default: 25m

zenith_distance : float, optional

The angular distance of the source from zenith in degree; default: 30 degree

C : ndarray, optional

The atmosphere OTF; default: None

AW0 : ndarray, optional

The collimated telescope OTF; default: None

ref_src : Source

The source from which AW0 is computed

save : boolean, optional

If True, return in addition to the PSSn, a dictionnary with C and AW0; default: False

calibrate(wfs, gs, mirror=None, mode=None, stroke=None, first_mode=3, closed_loop_calib=False, minus_M2_TT=False, calibrationVaultKwargs=None)[source]

Calibrate the different degrees of freedom of the mirrors

Parameters:

wfs : ShackHartmann, DispersedFringeSensor, etc.

The wavefront sensor

gs : Source

The guide star

mirror : string

The mirror label: eiher “M1” or “M2” (“MOUNT” is also accepted and will emulate a telescope pointing error)

mode : string

The degrees of freedom label for M1: “global tip-tilt”, “zernike”, “bending modes”, “Txyz”, “Rxyz”, “Rz”, “segment tip-tilt” for M2: “global tip-tilt”, “pointing neutral”, “coma neutral”, “zernike”, “Karhunen-Loeve”, “Txyz”, “Rxyz”, “Rz”, “segment tip-tilt”, “TT7 segment tip-tilt” for MOUNT: “pointing”

stroke : float

The amplitude of the motion

IdealSegmentPistonSensor

class ceo.IdealSegmentPistonSensor(src, D, D_px, W=1.5, L=1.5, segment=None)[source]

A class for the GMT segment piston sensor

Parameters:

src : Source

The Source object used for piston sensing

D : float

Telescope diameter (m)

nPx : integer

Pupil linear sampling (pixels)

W : float, optional

The width of the lenslet; default: 1.5m

L : float, optional

The length of the lenslet; default: 1.5m

segment : string

“full” for piston on the entire segments or “edge” for the differential piston between segment.

See also

GMT_MX
a class for GMT M1 and M2 mirrors
Source
a class for astronomical sources

Examples

>>> import ceo
>>> nPx = 256
>>> D = 25.5
>>> src = ceo.Source("R",rays_box_size=D,rays_box_sampling=nPx,rays_origin=[0.0,0.0,25])
>>> gmt = ceo.GMT_MX(D,nPx)
>>> src.reset()
>>> gmt.propagate(src)

The piston per M1 segment is obtained with >>> SPS = ceo.IdealSegmentPistonSensor(src,D,nPx,segment=’full’) >>> SPS.piston(src)

The 12 differential pistons are given by >>> SPS = ceo.IdealSegmentPistonSensor(src,D,nPx,segment=’edge’) >>> SPS.piston(src)

Attributes

P (numpy ndarray) M1 segment mask as a 7 columns array
rc (float) The radius of the circle where are centered the first 6 lenslets
rp (float) The radius of the circle where are centered the last 6 lenslets
W (float) The width of the lenslet
L (float) The length of the lenslet
M (numpy ndarray) The mask corresponding to the 12 lenslet array as a 12 columns array
segment (string) “full” for piston on the entire segments or “edge” for the differential piston between segment.

Methods

analyze(src) Computes either M1 segment piston or M1 differential piston (calling the “piston” method), and stores the result in the “measurement” property.
get_measurement() Returns the measurement vector
get_measurement_size() Returns the size of the measurement vector
piston(src) Return either M1 segment piston or M1 differential piston
reset()
analyze(src)[source]

Computes either M1 segment piston or M1 differential piston (calling the “piston” method), and stores the result in the “measurement” property.

get_measurement()[source]

Returns the measurement vector

get_measurement_size()[source]

Returns the size of the measurement vector

piston(src)[source]

Return either M1 segment piston or M1 differential piston

Parameters:

src : Source

The piston sensing guide star object

DispersedFringeSensor

class ceo.DispersedFringeSensor(M1, src, dispersion=5.0, field_of_view=3.0, nyquist_factor=1.0)[source]

A class for the GMT Dispersed Fringe Sensor. This class inherits from the SegmentPistonSensor class.

Parameters:Same parameters as in SegmentPistonSensor class.

See also

SegmentPistonSensor
the super class
IdealSegmentPistonSensor
the class for an idealized segment piston sensor
GMT_M1
the class for GMT M1 model
Source
a class for astronomical sources
cuFloatArray
an interface class between GPU host and device data for floats

Attributes

INIT_ALL_ATTRIBUTES (bool ; Default: False) If True, additional attributes (mainly for display and debugging) will be created. See list of Additional Attributes below.
fftlet_rotation (float ; vector with 12xN_SRC elements) The angle of the line joining the center of the three lobes of the fftlet image. Init by calibrate() method.
lobe_detection (string ; default: ‘gaussfit’) Algorithm for lobe detection, either ‘gaussfit’ for 2D gaussian fit, or ‘peak_value’ for peak detection.
spsmask (bool) Data cube containing the masks (one for each fftlet) required to isolate the “detection blob”, i.e. the upper-most lobe from which the measurement will be computed. Init by calibrate() method.
measurement (float) Dispersed Fringe Sensor output measurement vector; y-coordinate of the detection blob in the rotated reference frame (i.e. the reference frame having the x-axis passing through the three lobe peaks on a fftlet image, and the y-axis perpendicular to it. Units: pixels in the fftlet image plane.

Methods

analyze(src) Propagates the guide star to the SPS detector (noiseless) and processes the frame
calibrate(src, gmt) Calibrates the lobe detection masks (spsmask).
fft(self) Fourier transforms the detector framelets
fitgaussian(data) Fits a 2D Gaussian to the input data, and returns the Gaussian fit parameters: (amplidute, x, y, width_x, width_y, rotation)
gaussian_func(height, center_x, center_y, …) Returns a gaussian function G(x,y) to produce a 2D Gaussian with the given parameters
get_data_cube([data_type]) Returns the DFS data (either fringe or fftlet images) in cube format
get_measurement() Returns the measurement vector
get_measurement_size() Returns the size of the measurement vector
init_detector_mask(mask_size) Defines the circular mask to be applied over each fringe image.
piston(src) Return M1 differential piston.
process() Processes the Dispersed Fringe Sensor detector frame
propagate(self, Source gs) Propagates the guide star wavefront from the segment piston sensor pupil plane to the detector in the focal plane
readOut(self, float exposureTime, …) Reads-out the detector applying photon noise, read-out noise and background noise
reset() Resets both the SPS detector frame and the fftlet buffer to zero.
analyze(src)[source]

Propagates the guide star to the SPS detector (noiseless) and processes the frame

Parameters:

src : Source

The piston sensing guide star object

calibrate(src, gmt)[source]

Calibrates the lobe detection masks (spsmask).

Parameters:

src : Source

The Source object used for piston sensing

gmt : GMT_MX

The GMT object

fitgaussian(data)[source]

Fits a 2D Gaussian to the input data, and returns the Gaussian fit parameters: (amplidute, x, y, width_x, width_y, rotation)

Parameters:

data : numpy 2D ndarray

The array containing the image (i.e. the detection blob) to be fitted with a 2D Gaussian

gaussian_func(height, center_x, center_y, width_x, width_y, rotation)[source]

Returns a gaussian function G(x,y) to produce a 2D Gaussian with the given parameters

Parameters:

height : float

Amplitude of the Gaussian

center_x : float

x-coordinates of the Gaussian’s center in pixels.

center_y : float

y-coordinates of the Gaussian’s center in pixels.

width_x : float

standard deviation in the x-direction in pixels.

width_y : float

standard deviation in the y-direction in pixels.

rotation : float

angle of rotation of the Gaussian (x,y) axes in degrees.

get_data_cube(data_type='fftlet')[source]

Returns the DFS data (either fringe or fftlet images) in cube format

Parameters:

data_type : string

Set to “camera” to return fringes; set to “fftlet” to return fftlet images; default: fftlet

get_measurement()[source]

Returns the measurement vector

get_measurement_size()[source]

Returns the size of the measurement vector

init_detector_mask(mask_size)[source]

Defines the circular mask to be applied over each fringe image.

Parameters:

mask_size: float

Diameter of mask in arcseconds.

piston(src)[source]

Return M1 differential piston. This method was created to provide compatibility with the IdealSegmentPistonSensor Piston method.

Parameters:

src : Source

The piston sensing guide star object

process()[source]

Processes the Dispersed Fringe Sensor detector frame

reset()[source]

Resets both the SPS detector frame and the fftlet buffer to zero.

Imaging

class ceo.Imaging(int N_SIDE_LENSLET=1, int N_PX_PUPIL=128, int DFT_osf=2, int N_PX_IMAGE=0, int BIN_IMAGE=1, int N_SOURCE=1, float exposureTime=1.0, float readOutNoiseRms=0.0, float nBackgroundPhoton=0.0, float noiseFactor=1.0, float photoElectronGain=1.0, char isPtr=0, **kwargs)

Creates an imaging object.

Parameters:

N_PX_PUPIL : int

The sampling in pixel of one lenslet.

N_SIDE_LENSLET : int

The linear size of the lenslet array (>=1).

DFT_osf : int

The oversampling factor for the Discrete Fourier Transform (>=1).

N_PX_IMAGE : int

The sampling in pixel of the imagelet (>=1).

BIN_IMAGE : int

The binning factor of the imagelet (>=1).

N_SOURCE : int

The number of guide stars (>=1).

photoelectron_gain : float

The photon to electron conversion gain of the camera; default: 1

exposureTime : float

The detector exposure time in second; default: 1s

readOutNoiseRms : float

The detector read-out noise rms; default: 0

nBackgroundPhoton : float

The number of background photon; default: 0

noiseFactor : float

The excess noise factor; default: 1

See also

cuFloatArray
class acting as the interface between GPU host and device

Attributes

exposureTime exposureTime: ‘float’
readOutNoiseRms readOutNoiseRms: ‘float’
nBackgroundPhoton nBackgroundPhoton: ‘float’
noiseFactor noiseFactor: ‘float’
N_SIDE_LENSLET (int) The linear size of the lenslet array (>=1).
N_PX_PUPIL (int) The sampling in pixel of one lenslet.
DFT_osf (int) The oversampling factor for the Discrete Fourier Transform
N_PX_IMAGE (int) The sampling in pixel of the imagelet
BIN_IMAGE (int) The binning factor of the imagelet
N_GS (int) The number of guide stars
N_PX_FRAME (int) The detector resolution
frame (cuFloatArray) The detector frame of size [N_SOURCE`x`N_PX_CAMERA,`N_PX_CAMERA`]
photoelectron_gain (float) The photon to electron conversion gain of the camera; default: 1

Methods

analyze(self, *args, **kwargs)
calibrate(self, Source src[, args])
ee50(self, double units=1.0, bool from_ghost=0) Computes the 50% ensquared energy patch size
ee80(self, double units=1.0, bool from_ghost=0) Computes the 80% ensquared energy patch size
get_measurement(self, **kwargs)
noiselessReadOut(self, float exposureTime) Reads-out the detector
pixelScale(self, Source src) Returns the pixel scale in radian
pixelScaleArcsec(self, Source src) Returns the pixel scale in arcsecond
process(self)
propagate(self, Source src) Propgates a source through the lenset to detector in the focal plane
propagateThroughFieldStop(self, Source src, …) Propgates a source through the lenset then through a field stop in
propagateThroughPyramid(self, Source src, …) Propgates a source through a pyramid wavefront sensor to a detector in a pupil plane
propagate_cpx(self, Source src)
readOut(self, float exposureTime, …) Reads-out the detector
reset(self) Resets the frame of the camera to 0
reset_rng(self, int SEED) Resets the random number generator
calibrate(self, Source src, args=None)
ee50(self, double units=1.0, bool from_ghost=0)

Computes the 50% ensquared energy patch size

Parameters:

units : double

The units to convert the 80% ensquared energy to

Returns:

delta : double

The 80% ensquared energy patch size in pixel (default) or units if given

ee80(self, double units=1.0, bool from_ghost=0)

Computes the 80% ensquared energy patch size

Parameters:

units : double

The units to convert the 80% ensquared energy to

Returns:

delta : double

The 80% ensquared energy patch size in pixel (default) or units if given

exposureTime

exposureTime: ‘float’

ghost_frame

ghost_frame: ‘__Pyx_memviewslice’

nBackgroundPhoton

nBackgroundPhoton: ‘float’

noiseFactor

noiseFactor: ‘float’

noiselessReadOut(self, float exposureTime)

Reads-out the detector

Parameters:

exposureTime : float

The exposure time of the camera

pixelScale(self, Source src)

Returns the pixel scale in radian

pixelScaleArcsec(self, Source src)

Returns the pixel scale in arcsecond

process(self)
propagate(self, Source src)

Propgates a source through the lenset to detector in the focal plane

Parameters:

src : Source

A source object

See also

Source
class modeling star objects
propagateThroughFieldStop(self, Source src, float field_stop_diam)

Propgates a source through the lenset then through a field stop in the focal plane and to a pupil plane

Parameters:

src : Source

A source object

field_stop_diam : float

The diameter of the field stop in units of \(\lambda/D\)

See also

Source
class modeling star objects
propagateThroughPyramid(self, Source src, float modulation=0.0, int modulation_sampling=0, float alpha=0.5)

Propgates a source through a pyramid wavefront sensor to a detector in a pupil plane

Parameters:

src : Source

A source object

modulation : float

The pyramid modulation amplitude in units of \(\lambda/D\); default: 0.0

See also

Source
class modeling star objects
propagate_cpx(self, Source src)
readOut(self, float exposureTime, float readOutNoiseRms, float nBackgroundPhoton=0.0, float noiseFactor=1.0)

Reads-out the detector

Parameters:

exposureTime : float

The exposure time of the camera

readOutNoiseRms : float

The read-out moise rms of the camera

nBackgroundPhoton : float (optional)

The number of background photon per second; default: 0

noiseFactor : float (optional)

The excess noise factor for EMCCD ($sqrt{2}$); default: 1

readOutNoiseRms

readOutNoiseRms: ‘float’

reset(self)

Resets the frame of the camera to 0

reset_rng(self, int SEED)

Resets the random number generator

Centroiding

class ceo.Centroiding
Create a centroiding container
Parameters:

N_SIDE_LENSLET : int

1 The linear size of the lenslet array (>=1)

N_SOURCE : int, optional

The number of guide stars (>=1); default: 1

See also

cuFloatArray
class acting as the interface between GPU host and device

Attributes

N_SIDE_LENSLET (int) The linear size of the lenslet array (>=1) N_SOURCE : int The number of guide stars (>=1) flux : cuFloatArray The map of flux per lenset c: cuFloatArray The centroid vector of length `N_SOURCE`x`N_SIDE_LENSLET`**2

Methods

filter(self, cuFloatArray F)
fried_geometry(self, MaskAbstract dm, …)
get_data(self, cuFloatArray frame, int N)
noisify(self, float stddev)
reset(self)
filter(self, cuFloatArray F)
fried_geometry(self, MaskAbstract dm, MaskAbstract pupil, int n, float threshold)
get_data(self, cuFloatArray frame, int N)
noisify(self, float stddev)
reset(self)

ShackHartmann

class ceo.ShackHartmann(int N_SIDE_LENSLET=0, int N_PX_LENSLET=0, float d=0.0, int DFT_osf=2, int N_PX_IMAGE=0, int BIN_IMAGE=1, int N_GS=1, float exposureTime=1.0, float readOutNoiseRms=0.0, float nBackgroundPhoton=0.0, float noiseFactor=1.0, float photoElectronGain=1.0, **kwargs)

Creates a shackHartmann object.

Parameters:

N_SIDE_LENSLET : int

The linear size of the lenslet array (>=1).

N_PX_LENSLET : int

The sampling in pixel of one lenslet.

d : float

The lenslet pitch [m].

DFT_osf : int, optional

The oversampling factor for the Discrete Fourier Transform, defaults to 2

N_PX_IMAGE : int, optional

The sampling in pixel of the imagelet, defaults to N_PX_LENSLET

BIN_IMAGE : int, optional

The binning factor of the imagelet, default to 1

N_GS : int, optional

The number of guide stars, defaults to 1

photoelectron_gain : float

The photon to electron conversion gain of the camera; default: 1

exposureTime : float

The detector exposure time in second; default: 1s

readOutNoiseRms : float

The detector read-out noise rms; default: 0

nBackgroundPhoton : float

The number of background photon; default: 0

noiseFactor : float

The excess noise factor; default: 1

See also

MaskAbstract
a class to hold masks properties
cuFloatArray
an interface class for GPU host and device float data
Imaging
a class for a Fourier propagation moel and for a detector model
Centroiding
a class for the data processing of wavefront sensor frames

Examples

A 30x30, 1m lenslet pitch, Nyquist sampled Shack-Hartmann WFS with 8x8 pixel per lenslet is created with

>>> wfs = ShackHartmann(30,8,1.0)

The detector resolution is 240 pixels with a lenslet field of view of \(8\lambda / 2d\).

Twice the Nyquist sampling is realized with

>>> wfs = ShackHartmann(30,8,1.0,DFT_osf=4)

The detector resolution is still 240 pixels but with a lenslet field of view of \(8\lambda / 4d\).

Half the Nyquist sampling is obtained with

>>> wfs = ShackHartmann(30,8,1.0, BIN_IMAGE=2)

The detector resolution is now 120 pixels with a lenslet field of view of \(4\lambda / d\). A 240 pixels detector resolution is restored with

>>> wfs = ShackHartmann(30,8,1.0, N_PX_IMAGE=16, BIN_IMAGE=2)

increasing the field of view by a factor 2 i.e. \(8\lambda / d\).

The number of guide star needs to be passed if larger than 1:

>>> wfs = ShackHartmann(..., N_GS=6)

Attributes

N_SIDE_LENSLET (int) The linear size of the lenslet array (>=1).
N_PX_LENSLET (int) The sampling in pixel of one lenslet.
DFT_osf (int) The oversampling factor for the Discrete Fourier Transform
N_PX_IMAGE (int) The sampling in pixel of the imagelet
BIN_IMAGE (int) The binning factor of the imagelet
N_GS (int) The number of guide stars
N_PX_FRAME (int) The detector resolution
valid_lenslet (MaskAbstract) The mask object representing the valid lenslet location
valid_actuator (MaskAbstract) The mask object representing the valid actuator location in a Fried geometry
n_valid_lenslet (int) The number of valid lenslet
n_valid_slopes (int) The number of valid slopes
pixel_scale (float) The size of the detector pixel in radian
pixel_scale_arcsec (float) The size of the detector pixel in arcsec
frame (cuFloatArray) The detector frame
c0 (cuFloatArray) The reference slopes vector as [N_GSx2 N_SIDE_LENSLET**2]
c (cuFloatArray) The slopes vector as [N_GSx2 N_SIDE_LENSLET**2]
flux (cuFloatArray) The map of flux per lenset
valid_slopes (cuFloatArray) The vector of valid slopes
camera (Imaging, readonly) The detector object
data_proc (Centroiding, readonly) The measurements container

Methods

analyze(self, Source gs, **kwargs) Propagates the guide star to the WFS detector (noiseless) and processes the frame
calibrate(self, Source gs, float threshold=0.0) Selects the WFS valid lenslet and calibrated the reference slopes
get_measurement(self) Returns the measurement vector
get_measurement_size(self) Returns the size of the measurement vector
guide_star(self, char *photometric_band=, …)
identifyValidLenslet(self, Source gs, …) Selects the WFS valid lenslet
pointing(self, __Pyx_memviewslice zen, …) Sets the pointing of the WFS relative to the guide star
process(self) Processes the WFS detector frame
propagate(self, Source gs) Propagates the guide star to the WFS detector (noiseless)
readOut(self, float exposureTime, …) Reads-out the WFS detector frame adding photon and read-out noises
reset(self) Resets the WFS detector frame to 0
setReferenceSlopes(self, Source gs) Sets the reference slopes
slopesNorm(self)
update_lenslet(self, filt)
analyze(self, Source gs, **kwargs)

Propagates the guide star to the WFS detector (noiseless) and processes the frame

Parameters:

gs : Source

The WFS guide star

See also

Source
a class for astronomical sources
calibrate(self, Source gs, float threshold=0.0)

Selects the WFS valid lenslet and calibrated the reference slopes

Parameters:

gs : Source

The WFS guide star

threshold : float

The intensity threshold, a lenslet is discared if the flux of the lenslet divided by the fully illuminated flux of the lenslet is less than the threshold

See also

Source
a class for astronomical sources
get_measurement(self)

Returns the measurement vector

get_measurement_size(self)

Returns the size of the measurement vector

guide_star(self, char *photometric_band='V', tuple zenith=(0), tuple azimuth=(0), tuple magnitude=(0), float height=float('inf'), float fhwm=0)
identifyValidLenslet(self, Source gs, float threshold)

Selects the WFS valid lenslet

Parameters:

gs : Source

The WFS guide star

threshold : float

The intensity threshold, a lenslet is discared if the flux of the lenslet divided by the fully illuminated flux of the lenslet is less than the threshold

See also

Source
a class for astronomical sources
pointing(self, __Pyx_memviewslice zen, __Pyx_memviewslice azim)

Sets the pointing of the WFS relative to the guide star

Parameters:

zen : float

The zenith angle [rd]

azim : float

The azimuth angle [rd]

process(self)

Processes the WFS detector frame

propagate(self, Source gs)

Propagates the guide star to the WFS detector (noiseless)

Parameters:

gs : Source

The WFS guide star

See also

Source
a class for astronomical sources
readOut(self, float exposureTime, float readOutNoiseRms, float nBackgroundPhoton=0.0, float noiseFactor=1.0)

Reads-out the WFS detector frame adding photon and read-out noises

Parameters:

exposureTime : float

The detector integration time [s]

readoutNoiseRms : float

The rms of the detector read-out noise

reset(self)

Resets the WFS detector frame to 0

setReferenceSlopes(self, Source gs)

Sets the reference slopes

Parameters:

gs : Source

The WFS guide star

See also

Source
a class for astronomical sources
slopesNorm(self)
update_lenslet(self, filt)

Pyramid

class ceo.Pyramid

Creates a pyramid wavefront sensor object

Parameters:

N_SIDE_LENSLET : int

The linear size of the equivalent lenslet array (>1).

N_PX_LENSLET : int

The sampling in pixel of the pupil plane.

modulation : float, optional

The modulation at the vertex of the pyramid in lambda/D units, defaults to 0

modulation_sampling : int, optional

The number of points sampling the modulation at the vertex of the pyramid in lambda/D units, defaults to 0

separation : float, optional

The distance between left/right and up/down pupil images on the detector in telescope diameter D units, defaults to 2

N_GS : int, optional

The number of guide stars, defaults to 1

See also

Imaging
a class for a Fourier propagation model and for a detector model

Examples

A 30x30 lenslet equivalent pyramid with a 240x240 pupil resolution is created with

>>> import ceo
>>> wfs = ceo.Pyramid(30,240)

The same pyramid as above but with a 5lambda/D modulation

>>> wfs = ceo.Pyramid(30,240,modulation=5)

For an asterism of 3 guide stars:

>>> wfs = ceo.Pyramid(30,240,modulation=5,N_GS=3)

Attributes

camera (Imaging, readonly) The detector object
N_SIDE_LENSLET (int, readonly) The linear size of the equivalent lenslet array (>1).
modulation (float) The modulation at the vertex of the pyramid in lambda/D units, defaults to 0
modulation_sampling (int) The number of points sampling the modulation at the vertex of the pyramid in lambda/D units, defaults to 0
separation (float) The distance between left/right and up/down pupil images on the detector in telescope diameter D units, defaults to 2

Methods

propagate(self, Source gs) Propagates the guide star to the WFS detector (noiseless)
propagate(self, Source gs)

Propagates the guide star to the WFS detector (noiseless)

Parameters:

gs : Source

The WFS guide star

See also

Source
a class for astronomical sources

rayTracing

Coordinates

class ceo.Coordinates

An interface between an array of device vectors and an array of host coordinates

Examples

>>> import ceo
>>> gmt = ceo.GMT_MX(25.5,256, M1_radial_order=8, M2_radial_order=14)

The origin of M1 segment in the motion coordinate system is a Coordinates object

>>> print gmt.M1.motion_CS.origin

to retrieve the origin values:

>>> print gmt.M1.motion_CS.origin[:]

Segment 1 is moved along the y-axis of 1mm:

>>> gmt.M1.motion_CS.origin[0,1] = 1e-3

All the segments are resetted to their nominal position with

gmt.M1.motion_CS.origin[:] = 0

Attributes

shape
size

Coordinate_system

class ceo.Coordinate_system

A class for the coordinate system origins and euler angles

Attributes

origin origin: ceo.rayTracing.Coordinates
euler_angles euler_angles: ceo.rayTracing.Coordinates
N (int) The number of coordinate systems
R (ndarray) The rotation natrix of the coordinate systems as a [N,3,3] array

Methods

reset(self) Resets the coordinate systems to its nominal position
update(self, __Pyx_memviewslice Txyz=None, …) Updates the coordinate systems on the device
euler_angles

euler_angles: ceo.rayTracing.Coordinates

origin

origin: ceo.rayTracing.Coordinates

reset(self)

Resets the coordinate systems to its nominal position

tag

tag: bytes

update(self, __Pyx_memviewslice Txyz=None, __Pyx_memviewslice Rxyz=None, **kwargs)

Updates the coordinate systems on the device

Parameters:

Txyz : ndarray

The coordinates translation updates in the $7 imes3$ matrix form

Rxyz : ndarray

The coordinates rotation updates in the $7 imes3$ matrix form

Aperture

class ceo.Aperture

A class defining a circular aperture for ray tracing

Parameters:

D : rtd

The aperture diameter [m]

ri : rtd

The central obscuration ratio

D_px : int

The sampling of the diameter [pixel]

origin : list, optional

The location of the aperture [m]; default: [0.0,0.0,0.0]

euler_angles : list, optional

The rotation along the x,y and z axis [rd]; default: [0.0,0.0,0.0]

Attributes

ref_frame ref_frame: ceo.rayTracing.Coordinate_system

Methods

vignetting(self, Bundle rays) Vignets the rays of the source according to the aperture geometry
ref_frame

ref_frame: ceo.rayTracing.Coordinate_system

vignetting(self, Bundle rays)

Vignets the rays of the source according to the aperture geometry

Parameters:

src : Source

A Source object

See also

Source
the celestial source class

Conic

class ceo.Conic

A class defining a conic surface

Parameters:

c : rtd

The vertex curvature

k : rtd

The conic constant

origin : list, optional

The location of the conic surface [m]; default: [0.0,0.0,0.0]

euler_angles : list, optional

The rotation along the x,y and z axis [rd]; default: [0.0,0.0,0.0]

conic_origin : list, optional

The coordinates of the center of the conic surface; default: [0.0,0.0,0.0]

material : str, optional

The material type of the surface e.g. “mirror”, “BK7”, etc.. ; default: ‘’

refractive_index : rtd, optional

The refractive index of the surface, either 0 for a dummy surface,

-1 for a reflective surface, >0 for a refractive surface; default: 0.0

coord_break : bint, optional

The coordinate break surface type flag, True of False; default: False

asphere_a : rtd[:], optional

The coefficient of an even asphere surface; default: numpy.empty(0)

Attributes

coord_break coord_break: ‘bool’
material material: dict
ref_frame (Coordinate_system, read only) The coordinate system of the surface
origin (Coordinates, read only) The location of the origin of the conic surface within the surface coordinate system

Methods

refractive_index(self, float wavelength=-1.0)
trace(self, Bundle rays) Traces the rays of the source to the conic optical surface
coord_break

coord_break: ‘bool’

material

material: dict

refractive_index(self, float wavelength=-1.0)
trace(self, Bundle rays)

Traces the rays of the source to the conic optical surface

Parameters:

src : Source

A Source object

See also

Source
the celestial source class

ZernikeS

class ceo.ZernikeS

A class to represent a surface as the weighted sum of Zernike polynomials

Parameters:

max_n : int

The largest of the radial orders

a : ndarray, optional

The Zernike polynomial coefficients as a N_SURFxn_modes array; default to all 0

N_SURF : int, optional

The number of Zernike surfaces; default: 1

origin : list, optional

Origin of the coordinate system of the Zernike polynomials; default: [0,0,0]

euler_angles : list, optional

Euler angles of the coordinate system of the Zernike polynomials; default: [0,0,0]

Examples

>>> import ceo
>>> import numpy as np
>>> import matplotlib as plt

Lets define a Zernike surface made of the first 15 Zernike polynomials (4th radial order)

>>> Z = ceo.ZernikeS(4)

and setting it to be a pure focus mode:

>>> Z.a[3] = 1.0
>>> Z.update()

The surface is computed with

>>> npx = 512
>>> u = np.linspace(-1,1,npx)
>>> x,y = np.meshgrid(u,u, indexing='xy')
>>> r = np.hypot(x,y)
>>> o = np.arctan2(y,x)
>>> cuo = ceo.cuDoubleArray(host_data=o)
>>> cur = ceo.cuDoubleArray(host_data=r)
>>> S = Z.surface(cur,cuo)

and its derivative with

>>> (dSdx,dSdy) = Z.surface_derivatives(cur,cuo)
>>> fig, (ax1,ax2,ax3) = plt.subplots(ncols=3,sharey=True)
>>> fig.set_size_inches(20,4.5)
>>> h1 = ax1.imshow(S.host(),interpolation=None,origin='lower')
>>> plt.colorbar(h1,ax=ax1)
>>> h2 = ax2.imshow(dSdx.host(),interpolation=None,origin='lower')
>>> plt.colorbar(h2,ax=ax2)
>>> h3 = ax3.imshow(dSdy.host(),interpolation=None,origin='lower')
>>> plt.colorbar(h3,ax=ax3)

Attributes

max_n max_n: ‘int’
n_mode n_mode: ‘int’
N_SURF N_SURF: ‘int’
a a: numpy.ndarray

Methods

fitting(self, phase)
fitting_init(self, Source gs, int alphaId=0)
projection(self, cuFloatArray phase, …) Projects the phase onto a set on Zernike polynomials
projectionS(self, phase)
reset(self) Resets the Zernike coefficients to zero and update the Zernike surface
surface(self, cuDoubleArray r, …) Computes the Zernike surface in polar coordinates
surface_and_derivatives(self, …) Computes the Zernike surface x and y derivatives in polar coordinates
surface_derivatives(self, cuDoubleArray r, …) Computes the Zernike surface x and y derivatives in polar coordinates
update(self, __Pyx_memviewslice modes=None, …) Updates the Zernike surface based on the Zernike coefficients
N_SURF

N_SURF: ‘int’

Zmat

Zmat: numpy.ndarray

a

a: numpy.ndarray

fitting(self, phase)
fitting_init(self, Source gs, int alphaId=0)
invZmat

invZmat: numpy.ndarray

max_n

max_n: ‘int’

n_mode

n_mode: ‘int’

projZmat

projZmat: numpy.ndarray

projection(self, cuFloatArray phase, cuDoubleArray r, cuDoubleArray o)

Projects the phase onto a set on Zernike polynomials

Parameters:

phase : cuFloatArray

The wavefront phase

r : cuDoubleArray

The radius of the coordinates

o : cuDoubleArray

The azimuth of the coordinates

projectionS(self, phase)
reset(self)

Resets the Zernike coefficients to zero and update the Zernike surface

surface(self, cuDoubleArray r, cuDoubleArray o, int surf_id=0, __Pyx_memviewslice surf_ids=None, cuDoubleArray out=None)

Computes the Zernike surface in polar coordinates

Parameters:

r : cuDoubleArray

The normalized radius

o : cuDoubleArray

The azimuth

surf_id : int, optional

The surface index; default: 0

surf_ids : int[:], optional

The surface index vector; default: None

out : cuDoubleArray, optional

The Zernike surface boutput array; default: None

Returns:

S : cuDoubleArray

The Zernike surface

surface_and_derivatives(self, cuDoubleArray r, cuDoubleArray o)

Computes the Zernike surface x and y derivatives in polar coordinates

Parameters:

r : cuDoubleArray

The normalized radius

o : cuDoubleArray

The azimuth

Returns:

S : cuDoubleArray

The Zernike surface

dSdx : cuDoubleArray

The Zernike surface x derivative

dSdy : cuDoubleArray

The Zernike surface y derivative

surface_derivatives(self, cuDoubleArray r, cuDoubleArray o)

Computes the Zernike surface x and y derivatives in polar coordinates

Parameters:

r : cuDoubleArray

The normalized radius

o : cuDoubleArray

The azimuth

Returns:

dSdx : cuDoubleArray

The Zernike surface x derivative

dSdy : cuDoubleArray

The Zernike surface y derivative

update(self, __Pyx_memviewslice modes=None, **kwargs)

Updates the Zernike surface based on the Zernike coefficients

Transform_to_S

ceo.Transform_to_S(Bundle rays, Conic F)

Transforms the rays of the source into the coordinate system of the conic object

Parameters:

src : Source

A Source object

F : Conic

A Conic object

See also

Source
the celestial source class
Conic
the optics conic surface class

Transform_to_R

ceo.Transform_to_R(Bundle rays, Conic F)

Transforms the rays of the source into the coordinate system of the rays This is the inverse of Transform_to_S

Parameters:

src : Source

A Source object

F : Conic

A Conic object

See also

Source
the celestial source class
Conic
the optics conic surface class

Intersect

ceo.Intersect(Bundle rays, Conic F)

Intersection of the rays of the source with the surface represented by the conic object

Parameters:

src : Source

A Source object

F : Conic

A Conic object

See also

Source
the celestial source class
Conic
the optics conic surface class

Reflect

ceo.Reflect(Bundle rays)

Reflection of the rays of the source from the surface represented by the conic object

Parameters:

src : Source

A Source object

See also

Source
the celestial source class

Refract

ceo.Refract(Bundle rays, rtd mu)

Refraction of the rays of the source through the surface represented by the conic object

Parameters:

src : Source

A Source object

mu : rtd

The ratio of the index of refraction associated to the incident and refracted rays

See also

Source
the celestial source class

gmtMirrors

GmtMirrors

class ceo.GmtMirrors(int M1_radial_order=0, int M2_radial_order=0, unicode M1_mirror_modes=None, unicode M2_mirror_modes=None, int M1_N_MODE=0, int M2_N_MODE=0, dict M1_mirror_modes_data=None, dict M2_mirror_modes_data=None)

A class container from GMT_M1 and GMT_M2 classes

Parameters:

M1_radial_order : int, optionnal

The largest radial order of the Zernike polynomials on M1 segments, default to 0

M2_radial_order : int, optionnal

The largest radial order of the Zernike polynomials on M2 segments, default to 0

M1_mirror_modes : unicode, optional

The modal basis on the M1 segments either “”zernike”” or “”bending modes”“, default: “”zernike”“

M1_N_MODE : int, optional

The number of modes, default: 0

M2_mirror_modes : unicode, optional

The modal basis on the M2 segments either “”zernike”” or “Karhunen-Loeve” (https://s3-us-west-1.amazonaws.com/gmto.rconan/KarhunenLoeveModes.bin), default: “”zernike”“

M2_N_MODE : int, optional

The number of modes, default: 0

See also

GMT_M1
the class for GMT M1 model
GMT_M2
the class for GMT M2 model
Source
a class for astronomical sources
cuFloatArray
an interface class between GPU host and device data for floats

Examples

>>> import ceo

The mandatory parameters are the size of the pupil plane in meter or in pixel

>>> gmt = ceo.GMT_MX(25.5,256)

If more that one source (lets say 3) is going to be propagated through the telescope:

>>> gmt = ceo.GMT_MX(25.5,256, N_SRC=3)

A combination of Zernike polynomials can be applied to M1 and M2 segments by specifying the largest radial order on each mirror

>>> gmt = ceo.GMT_MX(25.5,256, M1_radial_order=8, M2_radial_order=14)

A source is propagated (geometrically) through the telescope with the following procedure:

>>> src = ceo.Source("R",rays_box_size=25.5,rays_box_sampling=256,rays_origin=[0.0,0.0,25])
>>> gmt.propagate(src)

and the wavefront phase is retrieved either as a 2D map cuFloatArray object with

>>> gpu_ps2d = src.phase()

or as a 1D vector with

>>> gpu_ps1d = src.wavefront.phase()

Attributes

M1 M1: ceo.gmtMirrors.GMT_M1
M2 M2: ceo.gmtMirrors.GMT_M2
sphere_radius (float) The curvature radius of the ray tracing reference sphere

Methods

dump_log(self, bytes filename) Writes the M1 and M2 segment commands log to a file
propagate(self, Source src, str where_to=, …) Propagate the Source object to the pupil plane conjugated to M1
reset(self, dict state=None) Reset M1 and M2 mirror segments to their original locations and shapes
segmentsWavefrontGradient(self, Source src) Computes the gradient of the phase of the wavefront on each segment
update(self, dict state) Update M1 and M2 rigid body motions using dictionary input: {‘M1’:{‘Rxyz’:val1,…},’M2’,{‘Txyz’:val2,…}}
M1

M1: ceo.gmtMirrors.GMT_M1

M2

M2: ceo.gmtMirrors.GMT_M2

dump_log(self, bytes filename)

Writes the M1 and M2 segment commands log to a file

Parameters:

filename : bytes

The name of the file

pointing_error_azimuth

pointing_error_azimuth: ‘float’

pointing_error_zenith

pointing_error_zenith: ‘float’

propagate(self, Source src, str where_to='exit pupil', bool M2_is_a_stop=True, bool project_truss_onaxis=False)

Propagate the Source object to the pupil plane conjugated to M1

Parameters:

src : Source

The Source object

where_to: char, optional

Either “exit pupil” or “focal plane”; default: “exit pupil”

M2_is_a_stop: boolean, optional

Set if M2 acts also a stop; default: True

reset(self, dict state=None)

Reset M1 and M2 mirror segments to their original locations and shapes

segmentsWavefrontGradient(self, Source src)

Computes the gradient of the phase of the wavefront on each segment

Parameters:

src : Source

The Source object

Returns:

cuFloatArray

The wavefront gradient average in an array of size [N_SRCx14,1]

update(self, dict state)

Update M1 and M2 rigid body motions using dictionary input: {‘M1’:{‘Rxyz’:val1,…},’M2’,{‘Txyz’:val2,…}}

GMT M1

class ceo.GMT_M1

A class to represent GMT M1 or M2 segmented mirror

Parameters:

radial_order : int, optional

The radial order of the last Zernike polynomials, default to 0

mirror_modes : unicode, optional

The modal basis on the segment either “”zernike”” or “”bending modes”” for M1 or “Karhunen-Loeve” (https://s3-us-west-1.amazonaws.com/gmto.rconan/KarhunenLoeveModes.bin) for M2, default: “”zernike”“

N_MODE : int, optional

The number of modes, default: 0

Examples

>>> import ceo
>>> M1 = ceo.GMT_M1()

With multiple sources:

>>> M2 = ceo.GMT_M2()

With Zernike modes

>>> M1 = ceo.GMT_M1(25.5,101,radial_order=4)

An M1 segment (#2) is displaced in x of 2 micron and tilted in y of 50mas with

>>> import math
>>> theta = 50e-3*math.pi/180/3600
>>> M1.update(origin=[2e-6,0,0],euler_angles=[0,theta,0],idx=2)

A global tip-tilt of M1 is achieved with

>>> M1.global_tiptilt(theta,-theta)

M2 pointing neutral and coma neutral tip-tilt are realized with

>>> M2.pointing_neutral(theta,-theta)
>>> M2.coma_neutral(theta,-theta)

Attributes

zernike zernike: ceo.rayTracing.ZernikeS
aperture_CS aperture_CS: ceo.rayTracing.Coordinate_system
conic_CS conic_CS: ceo.rayTracing.Coordinate_system
motion_CS motion_CS: ceo.rayTracing.Coordinate_system
rigid_body_CS rigid_body_CS: ceo.rayTracing.Coordinate_system
TT_CS TT_CS: ceo.rayTracing.Coordinate_system
D_assembly (rtd) The mirror assembly diameter
D_full (rtd) The segment full aperture diameter
D_clear (rtd) The segment clear aperture diameter
L (rtd) The distance from the optical axis to the center of the tilted peripheral segments
conic_c (rtd) The inverse of the mirror radius of curvature
conic_k (rtd) The conic parametert
M_ID (int) The mirror ID #

Methods

blocking(self, Bundle rays) Makes the mirror acting as a stop
clocking(self, seg_id, theta) Decomposes mirror clocking into segment Txyx and Rxyz
global_tiptilt(self, float tip, float tilt) Applies a global tip–tilt to M1
keep(self, list seg_ID) Keep some segments and remove the others
locate(self, ndarray x, ndarray y, …) Coordinate transformation from global CS to motion CS
preset(self, Bundle rays, float margin)
remove(self, list seg_ID) Remove some segments and keep the others
test(self)
trace(self, Bundle rays, bool vignetting=True) Ray tracing to the mirror
track(self, ndarray x, ndarray y, ndarray z, …) Coordinate transformation from motion CS to global CS
transform(self, list xyz, list abc, …) Decomposes mirror Txyz and Rxyz (origin is conic vertex) into segment Txyx and Rxyz
update(self, list origin=[0.0, 0.0, 0.0], …) Updates the position of the mirror segments
B

B: ceo.gmtMirrors.Modes

BM

BM: ceo.gmtMirrors.BendingModes

D

D: dict

KL

KL: ceo.gmtMirrors.KarhunenLoeve

PM

PM: ceo.gmtMirrors.PolishMap

TT_CS

TT_CS: ceo.rayTracing.Coordinate_system

aperture_CS

aperture_CS: ceo.rayTracing.Coordinate_system

blocking(self, Bundle rays)

Makes the mirror acting as a stop

Parameters:

rays : Bundle

A ray bundle used to propagate the light

See also

Bundle
a class representing a bundle of light rays used for geometric propagation
clocking(self, seg_id, theta)

Decomposes mirror clocking into segment Txyx and Rxyz

Parameters:

seg_id : any

The segment number ID (1 base)

theta : any

The mirror clocking angle in radian

Returns:

(ndarray,ndarray)

(Txyz,Rxyz)

conic_CS

conic_CS: ceo.rayTracing.Coordinate_system

conic_const

conic_const: ceo.utilities.cuDoubleArray

conic_curv

conic_curv: ceo.utilities.cuDoubleArray

global_tiptilt(self, float tip, float tilt)

Applies a global tip–tilt to M1

Parameters:

tip : float

The x axis angle

tilt : float

The y axis angle

keep(self, list seg_ID)

Keep some segments and remove the others

Parameters:

seg_ID : int

The ID numbers of the segment to keep

locate(self, ndarray x, ndarray y, ndarray z, int segId)

Coordinate transformation from global CS to motion CS

Parameters:

x : ndarray

The X axis coordinate

y : ndarray

The Y axis coordinate

z : ndarray

The Z axis coordinate

segId : int

The ID number of the segment

mirror_modes_type

mirror_modes_type: bytes

motion_CS

motion_CS: ceo.rayTracing.Coordinate_system

preset(self, Bundle rays, float margin)
remove(self, list seg_ID)

Remove some segments and keep the others

Parameters:

seg_ID : int

The ID numbers of the segment to remove

rigid_body_CS

rigid_body_CS: ceo.rayTracing.Coordinate_system

test(self)
trace(self, Bundle rays, bool vignetting=True)

Ray tracing to the mirror

Parameters:

rays : Bundle

A ray bundle used to propagate the light

See also

Bundle
a class representing a bundle of light rays used for geometric propagation
track(self, ndarray x, ndarray y, ndarray z, int segId)

Coordinate transformation from motion CS to global CS

Parameters:

x : ndarray

The X axis coordinate

y : ndarray

The Y axis coordinate

z : ndarray

The Z axis coordinate

segId : int

The ID number of the segment

transform(self, list xyz, list abc, list segId=None)

Decomposes mirror Txyz and Rxyz (origin is conic vertex) into segment Txyx and Rxyz

Parameters:

seg_id : list

The segment number ID (1 base)

xyz : list

The GCS translations

abc : list

The GCS rotations

Returns:

(ndarray,ndarray)

(Txyz,Rxyz)

update(self, list origin=[0.0, 0.0, 0.0], list euler_angles=[0.0, 0.0, 0.0], int idx=0)

Updates the position of the mirror segments

Parameters:

origin : list of float, optional

The location of a segment center; default: [0,0,0]

euler_angles : list of float, optional

The tip, tilt and clock angles of a segment; default: [0,0,0]

idx : int

The segment index from 1 to 7

zernike

zernike: ceo.rayTracing.ZernikeS

GMT M2

class ceo.GMT_M2

A class to represent GMT M1 or M2 segmented mirror

Parameters:

radial_order : int, optional

The radial order of the last Zernike polynomials, default to 0

mirror_modes : unicode, optional

The modal basis on the segment either “”zernike”” or “”bending modes”” for M1 or “Karhunen-Loeve” (https://s3-us-west-1.amazonaws.com/gmto.rconan/KarhunenLoeveModes.bin) for M2, default: “”zernike”“

N_MODE : int, optional

The number of modes, default: 0

Examples

>>> import ceo
>>> M1 = ceo.GMT_M1()

With multiple sources:

>>> M2 = ceo.GMT_M2()

With Zernike modes

>>> M1 = ceo.GMT_M1(25.5,101,radial_order=4)

An M1 segment (#2) is displaced in x of 2 micron and tilted in y of 50mas with

>>> import math
>>> theta = 50e-3*math.pi/180/3600
>>> M1.update(origin=[2e-6,0,0],euler_angles=[0,theta,0],idx=2)

A global tip-tilt of M1 is achieved with

>>> M1.global_tiptilt(theta,-theta)

M2 pointing neutral and coma neutral tip-tilt are realized with

>>> M2.pointing_neutral(theta,-theta)
>>> M2.coma_neutral(theta,-theta)

Attributes

zernike zernike: ceo.rayTracing.ZernikeS
aperture_CS aperture_CS: ceo.rayTracing.Coordinate_system
conic_CS conic_CS: ceo.rayTracing.Coordinate_system
motion_CS motion_CS: ceo.rayTracing.Coordinate_system
rigid_body_CS rigid_body_CS: ceo.rayTracing.Coordinate_system
TT_CS TT_CS: ceo.rayTracing.Coordinate_system
D_assembly (rtd) The mirror assembly diameter
D_full (rtd) The segment full aperture diameter
D_clear (rtd) The segment clear aperture diameter
L (rtd) The distance from the optical axis to the center of the tilted peripheral segments
conic_c (rtd) The inverse of the mirror radius of curvature
conic_k (rtd) The conic parametert
M_ID (int) The mirror ID #

Methods

blocking(self, Bundle rays) Makes the mirror acting as a stop
clocking(self, seg_id, theta) Decomposes mirror clocking into segment Txyx and Rxyz
coma_neutral(self, float tip, float tilt) Applies a coma neutral global tip–tilt to M2
global_tiptilt(self, float tip, float tilt) Applies a global tip–tilt to M1
keep(self, list seg_ID) Keep some segments and remove the others
locate(self, ndarray x, ndarray y, …) Coordinate transformation from global CS to motion CS
pointing_neutral(self, float tip, float tilt) Applies a pointing neutral global tip–tilt to M2
remove(self, list seg_ID) Remove some segments and keep the others
trace(self, Bundle rays, bool vignetting=True) Ray tracing to the mirror
track(self, ndarray x, ndarray y, ndarray z, …) Coordinate transformation from motion CS to global CS
transform(self, list xyz, list abc, …) Decomposes mirror Txyz and Rxyz (origin is conic vertex) into segment Txyx and Rxyz
update(self, list origin=[0.0, 0.0, 0.0], …) Updates the position of the mirror segments
B

B: ceo.gmtMirrors.Modes

BM

BM: ceo.gmtMirrors.BendingModes

D

D: dict

KL

KL: ceo.gmtMirrors.KarhunenLoeve

PM

PM: ceo.gmtMirrors.PolishMap

TT_CS

TT_CS: ceo.rayTracing.Coordinate_system

aperture_CS

aperture_CS: ceo.rayTracing.Coordinate_system

blocking(self, Bundle rays)

Makes the mirror acting as a stop

Parameters:

rays : Bundle

A ray bundle used to propagate the light

See also

Bundle
a class representing a bundle of light rays used for geometric propagation
clocking(self, seg_id, theta)

Decomposes mirror clocking into segment Txyx and Rxyz

Parameters:

seg_id : any

The segment number ID (1 base)

theta : any

The mirror clocking angle in radian

Returns:

(ndarray,ndarray)

(Txyz,Rxyz)

coma_neutral(self, float tip, float tilt)

Applies a coma neutral global tip–tilt to M2

Parameters:

tip : float

The x axis angle

tilt : float

The y axis angle

conic_CS

conic_CS: ceo.rayTracing.Coordinate_system

conic_const

conic_const: ceo.utilities.cuDoubleArray

conic_curv

conic_curv: ceo.utilities.cuDoubleArray

global_tiptilt(self, float tip, float tilt)

Applies a global tip–tilt to M1

Parameters:

tip : float

The x axis angle

tilt : float

The y axis angle

keep(self, list seg_ID)

Keep some segments and remove the others

Parameters:

seg_ID : int

The ID numbers of the segment to keep

locate(self, ndarray x, ndarray y, ndarray z, int segId)

Coordinate transformation from global CS to motion CS

Parameters:

x : ndarray

The X axis coordinate

y : ndarray

The Y axis coordinate

z : ndarray

The Z axis coordinate

segId : int

The ID number of the segment

mirror_modes_type

mirror_modes_type: bytes

motion_CS

motion_CS: ceo.rayTracing.Coordinate_system

pointing_neutral(self, float tip, float tilt)

Applies a pointing neutral global tip–tilt to M2

Parameters:

tip : float

The x axis angle

tilt : float

The y axis angle

remove(self, list seg_ID)

Remove some segments and keep the others

Parameters:

seg_ID : int

The ID numbers of the segment to remove

rigid_body_CS

rigid_body_CS: ceo.rayTracing.Coordinate_system

trace(self, Bundle rays, bool vignetting=True)

Ray tracing to the mirror

Parameters:

rays : Bundle

A ray bundle used to propagate the light

See also

Bundle
a class representing a bundle of light rays used for geometric propagation
track(self, ndarray x, ndarray y, ndarray z, int segId)

Coordinate transformation from motion CS to global CS

Parameters:

x : ndarray

The X axis coordinate

y : ndarray

The Y axis coordinate

z : ndarray

The Z axis coordinate

segId : int

The ID number of the segment

transform(self, list xyz, list abc, list segId=None)

Decomposes mirror Txyz and Rxyz (origin is conic vertex) into segment Txyx and Rxyz

Parameters:

seg_id : list

The segment number ID (1 base)

xyz : list

The GCS translations

abc : list

The GCS rotations

Returns:

(ndarray,ndarray)

(Txyz,Rxyz)

update(self, list origin=[0.0, 0.0, 0.0], list euler_angles=[0.0, 0.0, 0.0], int idx=0)

Updates the position of the mirror segments

Parameters:

origin : list of float, optional

The location of a segment center; default: [0,0,0]

euler_angles : list of float, optional

The tip, tilt and clock angles of a segment; default: [0,0,0]

idx : int

The segment index from 1 to 7

zernike

zernike: ceo.rayTracing.ZernikeS

StereoscopicEdgeSensors

class ceo.StereoscopicEdgeSensors

A class for the GMT stereoscopic edge sensors. The stereoscopic model measures the coordinates of the 3-dimension vector joining a pair of edge sensors.

Parameters:

mirror : GMT_M1

The GMT M1 mirror

See also

Coordinates
an interface between an array of device vectors and an array of host coordinates

Attributes

v0 v0: ceo.rayTracing.Coordinates
v v: ceo.rayTracing.Coordinates
dv0 dv0: ceo.rayTracing.Coordinates
dv dv: ceo.rayTracing.Coordinates

Methods

data(self) Computes the edge sensor measurements
data(self)

Computes the edge sensor measurements

dv

dv: ceo.rayTracing.Coordinates

dv0

dv0: ceo.rayTracing.Coordinates

v

v: ceo.rayTracing.Coordinates

v0

v0: ceo.rayTracing.Coordinates

LateralEdgeSensors

class ceo.LateralEdgeSensors(GMT_M1 mirror, *args, **kwargs)

A class for the GMT lateral displacement edge sensors. It applies to the case of a laser aiming at a camera. The measurements are the laser spot location within the frame of the camera.

Parameters:

mirror : GMT_M1

The GMT M1 mirror

See also

Coordinates
an interface between an array of device vectors and an array of host coordinates
cuDoubleArray
an interface class between GPU host and device data for doubles

Attributes

A A: ceo.rayTracing.Coordinates
B B: ceo.rayTracing.Coordinates
B0 B0: ceo.rayTracing.Coordinates
k_cam k_cam: ceo.rayTracing.Coordinates
k_laser k_laser: ceo.rayTracing.Coordinates
x x: ceo.utilities.cuDoubleArray
y y: ceo.utilities.cuDoubleArray

Methods

data(self) Computes the edge sensor measurements
A

A: ceo.rayTracing.Coordinates

A0

A0: ceo.rayTracing.Coordinates

B

B: ceo.rayTracing.Coordinates

B0

B0: ceo.rayTracing.Coordinates

data(self)

Computes the edge sensor measurements

k_cam

k_cam: ceo.rayTracing.Coordinates

k_laser

k_laser: ceo.rayTracing.Coordinates

x

x: ceo.utilities.cuDoubleArray

y

y: ceo.utilities.cuDoubleArray

segmentPistonSensor

class ceo.SegmentPistonSensor

The segment piston sensor model

Parameters:

M1 : GMT_M1

The GMT M1 model class

gs : Source

The guide star(s) of the segment piston sensor

dispersion : float, optional

The grism dispersion; default: 5arcsec/micron

field_of_view : float, optional

The segment piston sensor field-of-view; default: 3 arcsec

nyquist_factor : float, optional

The Nyquist sampling factor; default: 1, meaning Nyquist sampling

See also

Imaging
the lenslet and detector class

Attributes

W (Complex_amplitude, read-only) The piecewise wavefront on the 12 lenslets
camera (Imaging, read-only) The detector of the segment piston sensor
fftlet (cuFloatArray) The Fourier trasform of the detector framelet
N_LAMBDA (int) The number of spectral element
pixel_Scale (float) The detector pixel scale

Methods

fft(self) Fourier transforms the detector framelets
propagate(self, Source gs) Propagates the guide star wavefront from the segment piston sensor pupil plane to the detector in the focal plane
readOut(self, float exposureTime, …) Reads-out the detector applying photon noise, read-out noise and background noise
fft(self)

Fourier transforms the detector framelets

propagate(self, Source gs)

Propagates the guide star wavefront from the segment piston sensor pupil plane to the detector in the focal plane

Parameters:

gs : Source

The segment piston sensor guide star(s)

readOut(self, float exposureTime, float readOutNoiseRms, float backgroundMagnitude)

Reads-out the detector applying photon noise, read-out noise and background noise

Parameters:

exposureTime : float

The detector exposure time

readOutNoiseRms : float

The number of photon-electron rms per pixel

backgroundMagnitude : float

The background magnitude per arcsec square

utilities

mask

MaskAbstract

class ceo.MaskAbstract(int n)

The abstract class for all other mask classes

See also

cuFloatArray
an interface for GPU host and device float data

Attributes

f (cuFloatArray) the mask as a float array
nnz (int, readonly) the number of non zeros values in the mask
nel (int, readonly) the total number of elements in the mask
area (float, readonly) the area covered by the mask

Methods

alter(self, cuFloatArray filter) Modifies the mask pattern
alter(self, cuFloatArray filter)

Modifies the mask pattern

Parameters:

filter : cuFloatArray

The filter to apply to the mask

Mask

class ceo.Mask(int n, float L=0.0, float i_0=0.0, float j_0=0.0, float n_s=0.0, float theta=0.0, float i_s=0.0, float j_s=0.0)

Creates a square mask object.

Parameters:

n : an int

the linear sampling in pixel of the pupil

L : float

the linear size of the mask in meter

i_s : float, optional

the row pixel coordinate of the mask center, default: 0

j_s : float, optional

the column pixel coordinate of the mask center, default: 0

n_s : float, optional

the mask size in pixel, default: 0 means n_s=n

theta : float

the rotation angle [rd] of the mask with respect to i_s and j_s, default: 0

See also

MaskAbstract

Attributes

area
f
n
nel
nnz

Methods

alter(self, cuFloatArray filter) Modifies the mask pattern

Telescope

class ceo.Telescope(int n, float D, float scale=1.0)

Creates a circular mask object.

Parameters:

n : int

the sampling in pixel of the pupil.

D : float

the diamter in meter of the pupil

See also

MaskAbstract

Attributes

area
f
n
nel
nnz

Methods

alter(self, cuFloatArray filter) Modifies the mask pattern

GMT

class ceo.GMT(int n, float S=25.5)

Creates a mask object for the Giant Magellan Telescope pupil.

Parameters:

n : int

The sampling in pixel of the pupil.

S : float

The size of the pupil in meter.

See also

MaskAbstract

Attributes

piston_mask (list) A list of piston mask, one per segment

Methods

alter(self, cuFloatArray filter) Modifies the mask pattern
get_gmt_piston(self, cuFloatArray phase) Retrieves the segment piston from the phase
set_gmt_piston(self, cuFloatArray phase, …) Adds segment piston to the phase
get_gmt_piston(self, cuFloatArray phase)

Retrieves the segment piston from the phase

Parameters:

phase : cuFloatArray

The source wavefront phase.

Returns:

numpy array : The 1D array of segment piston in meter

set_gmt_piston(self, cuFloatArray phase, __Pyx_memviewslice value)

Adds segment piston to the phase

Parameters:

phase : cuFloatArray

The source wavefront phase.

value : float[::1]

The 1D array of segment piston in meter

StopWatch

class ceo.StopWatch

Creates a stopwatch object to time cuda based routines

Attributes

elapsedTime elapsedTime: ‘float’

Methods

ping(self) Stops the stopwatch and display the elapsed time in ms
tic(self) Starts the stopwatch
toc(self) Stops the stopwatch
elapsedTime

elapsedTime: ‘float’

ping(self)

Stops the stopwatch and display the elapsed time in ms

tic(self)

Starts the stopwatch

toc(self)

Stops the stopwatch

CUDA array

cuFloatArray

class ceo.cuFloatArray

A class to interact with a cuda float array

Parameters:

shape : tuple of int, optional

Number of rows and colums; default: None

order : string, optional

Set the memory layout, “C” or “F”; default: “C”

host_data : list or tuple or numpy array, optional

Host data to copy to the device; default: None

dev_malloc : bool, optional

Flag to allocate memory on device; default: False

Attributes

shape shape: object
order order: object
size size: ‘int’
host_data host_data: numpy.ndarray
dev_malloc (bool) True is memory has been allocated on the device

Methods

assign_ptr(self)
host(self[, units, zm, mask, shape, order]) Transfers data on the GPU device to the memory of the host
reset(self)
assign_ptr(self)
host(self, units=None, zm=False, mask=None, shape=None, order=None)

Transfers data on the GPU device to the memory of the host

Parameters:

shape : tuple, optional

The shape of the data array, default to None

order : string, optional

Set the memory layout, “C” or “F”; default: None

units : string, optional

The data converstion units: “”micron”“, “”nm”“, “”arcsec” and “”mas”“, default to None

zm : boolean, optional

If True, the data mean is removed; default to False

mask : boolean

If zm is True, the mean is computed for data values where the mask is True

Returns:

numpy array : a copy of the device data on the host

host_data

host_data: numpy.ndarray

order

order: object

reset(self)
shape

shape: object

size

size: ‘int’

type

type: numpy.dtype

cuDoubleArray

class ceo.cuDoubleArray

A class to interact with a cuda double array

Parameters:

shape : tuple of int, optional

Number of rows and colums; default: None

order : string, optional

Set the memory layout, “C” or “F”; default: “C”

host_data : list or tuple or numpy array, optional

Host data to copy to the device; default: None

dev_malloc : bool, optional

Flag to allocate memory on device; default: False

Attributes

shape shape: object
order order: object
size size: ‘int’
host_data host_data: numpy.ndarray
dev_malloc (bool) True is memory has been allocated on the device

Methods

assign_ptr(self)
host(self[, units, zm, mask, shape, order]) Transfers data on the GPU device to the memory of the host
reset(self)
assign_ptr(self)
host(self, units=None, zm=False, mask=None, shape=None, order=None)

Transfers data on the GPU device to the memory of the host

Parameters:

shape : tuple, optional

The shape of the data array, default to None

order : string, optional

Set the memory layout, “C” or “F”; default: None

units : string, optional

The data converstion units: “”micron”“, “”nm”“, “”arcsec” and “”mas”“, default to None

zm : boolean, optional

If True, the data mean is removed; default to False

mask : boolean

If zm is True, the mean is computed for data values where the mask is True

Returns:

numpy array : a copy of the device data on the host

host_data

host_data: numpy.ndarray

order

order: object

reset(self)
shape

shape: object

size

size: ‘int’

type

type: numpy.dtype

cuIntArray

class ceo.cuIntArray

A class to interact with a cuda integer array

Parameters:

shape : tuple of int, optional

Number of rows and colums; default: None

order : string, optional

Set the memory layout, “C” or “F”; default: “C”

host_data : list or tuple or numpy array, optional

Host data to copy to the device; default: None

dev_malloc : bool, optional

Flag to allocate memory on device; default: False

Attributes

shape shape: object
order order: object
size size: ‘int’
host_data host_data: numpy.ndarray
dev_malloc (bool) True is memory has been allocated on the device

Methods

assign_ptr(self)
host(self[, units, zm, mask, shape, order]) Transfers data on the GPU device to the memory of the host
reset(self)
assign_ptr(self)
host(self, units=None, zm=False, mask=None, shape=None, order=None)

Transfers data on the GPU device to the memory of the host

Parameters:

shape : tuple, optional

The shape of the data array, default to None

order : string, optional

Set the memory layout, “C” or “F”; default: None

units : string, optional

The data converstion units: “”micron”“, “”nm”“, “”arcsec” and “”mas”“, default to None

zm : boolean, optional

If True, the data mean is removed; default to False

mask : boolean

If zm is True, the mean is computed for data values where the mask is True

Returns:

numpy array : a copy of the device data on the host

host_data

host_data: numpy.ndarray

order

order: object

reset(self)
shape

shape: object

size

size: ‘int’

type

type: numpy.dtype

Indices and tables