scifysim.injection module

This module revolves around the injector class At __init__(), injector builds

  • one atmo object for each telescope (stored in a list)

  • one focuser object (badly named) for each wavelength AND each telescope

  • one fiber_head object that builds the map of LP01 mode.

It then creates a generator called self.it that will return a series of complex numbers corresponding to injection complex phasors.

Testing:

  • test_fiber for the fiber_head

  • test_injector for the injector

scifysim.injection.Hn(A)[source]
scifysim.injection.J0

alias of J_0

scifysim.injection.J1

alias of J_1

scifysim.injection.K0

alias of K_0

class scifysim.injection.atmo(name='GRAVITY+', csz=512, psz=200, lsz=8.0, r0=0.2, ro_wl=3.5e-06, L0=10.0, fc=24.5, correc=1.0, seed=None, wind_speed=1.0, wind_angle=0.1, step_time=0.01, lo_excess=0.0, pdiam=8.0, config=None)[source]

Bases: object

Atmospheric Kolmogorov-type phase screen.

Class Attributes:

  • csz : size (csz x csz) of the phase screen (in pixels)

  • pdiam : diameter of the aperture within this array (in pixels)

  • rndarr : uniformly distributed random array (csz x csz)

  • kolm : the original phase screen (csz x csz)

  • kolm2 : the oversized phase screen ((csz + pdiam) x (csz + pdiam))

  • qstatic : an optional quasi static aberration (pdiam x pdiam)

  • rms : total phase screen rms value (in nanometers)

  • rms_i : instant rms inside the pupil (in nanometers)

Comment:

While the attributes are documented here for reference, the prefered way of interacting with them is via the functions defined within the class.

__dict__ = mappingproxy({'__module__': 'scifysim.injection', '__doc__': 'Atmospheric Kolmogorov-type phase screen.\n    \n    **Class Attributes:**\n    \n    \n    - csz     : size (csz x csz) of the phase screen       (in pixels)\n    - pdiam   : diameter of the aperture within this array (in pixels)\n    - rndarr  : uniformly distributed random array         (csz x csz)\n    - kolm    : the original phase screen                  (csz x csz)\n    - kolm2   : the oversized phase screen    ((csz + pdiam) x (csz + pdiam))\n    - qstatic : an optional quasi static aberration    (pdiam x pdiam)\n    - rms     : total phase screen rms value           (in nanometers)\n    - rms_i   : instant rms inside the pupil           (in nanometers)\n\n    **Comment:**\n    \n    While the attributes are documented here for reference, the prefered\n    way of interacting with them is via the functions defined within the\n    class.\n\n    ', '__init__': <function atmo.__init__>, 'update_step_vector': <function atmo.update_step_vector>, 'set_qstatic': <function atmo.set_qstatic>, 'update_screen': <function atmo.update_screen>, 'reset': <function atmo.reset>, 'give': <function atmo.give>, '__dict__': <attribute '__dict__' of 'atmo' objects>, '__weakref__': <attribute '__weakref__' of 'atmo' objects>, '__annotations__': {}})
__init__(name='GRAVITY+', csz=512, psz=200, lsz=8.0, r0=0.2, ro_wl=3.5e-06, L0=10.0, fc=24.5, correc=1.0, seed=None, wind_speed=1.0, wind_angle=0.1, step_time=0.01, lo_excess=0.0, pdiam=8.0, config=None)[source]

Kolmogorov type atmosphere + qstatic error

Parameters:

  • name : a string describing the instrument

  • csz : the size of the Fourier array

  • psz : the size of the pupil in pixels

  • lsz : the screen linear size (in meters)

  • r0 : the Fried parameter (in meters)

  • L0 : the outer scale parameter (in meters)

  • fc : the cutoff frequency [lambda/D] defined by the number of actuators

  • correc : the correction factor to apply to controlled spatial frequencies.

  • wind_speed : the speed of the phas screen in [m/s]

  • step_time : the time resolution of the simulation [s]

  • config : a parsed config file

__module__ = 'scifysim.injection'
__weakref__

list of weak references to the object (if defined)

give()[source]

Main loop: frozen screen slid over the aperture

This returns a iterator that yelds the phase screen for one aperture.

use:

a = atmo.give()
phscreen = next(a)
phscreen = next(a)

Options:

reset()[source]
set_qstatic(qstatic=None)[source]

Defines some quasistatic errors in the wavefront

Parameters:

  • qstatic : A static phase screen

update_screen(correc=None, fc=None, r0=None, L0=None, seed=None)[source]

Generic update of the properties of the phase-screen

Parameters:

  • correc : float The correction factor for the control region

  • fc : float The cutoff fequency

  • r0 : flaot r0 of the initial phase screen

update_step_vector(wind_angle=0.1, wind_speed=None, step_time=None)[source]

Refresh the step vector that will be applied

Parameters:

  • wind_angle : the angle of incience of the wind (values around 0.1 rad are favoured since they provide long series before repeating)

  • wind_speed : The speed of the moving phase screen.

  • step_time : The time step of the simulation [s]

scifysim.injection.atmo_screen(screen_dimension, screen_extent, r0, L0, fc=25, correc=1.0, lo_excess=0.0, pdiam=None, seed=None)[source]

The Kolmogorov - Von Karman phase screen generation algorithm.

Adapted from the work of Carbillet & Riccardi (2010). http://cdsads.u-strasbg.fr/abs/2010ApOpt..49G..47C

Kolmogorov screen can be altered by an attenuation of the power by a correction factor correc up to a cut-off frequency fc expressed in number of cycles across the phase screen

Parameters:

  • screen_dimension : the size of the array to be computed (in pixels)

  • screen_extent : the physical extent of the phase screen (in meters)

  • r0 : the Fried parameter, measured at a given wavelength (in meters)

  • L0 : the outer scale parameter (in meters)

  • fc : DM cutoff frequency (in lambda/D)

  • correc : correction of wavefront amplitude (factor 10, 100, …)

  • lo_excess: A factor introducing excess low-order averations (mosly tip-tilt) Must be striclty 0 =< lo_excess < 1.

  • pdiam : pupil diameter (in meters)

  • seed : random seed for the screen (default: None produces a new seed)

Returns: two independent phase screens, available in the real and imaginary part of the returned array.

Remarks:

If pdiam is not specified, the code assumes that the diameter of the pupil is equal to the extent of the phase screen “screen_extent”.

class scifysim.injection.fiber_head[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'scifysim.injection', '__init__': <function fiber_head.__init__>, 'define_substitutions': <function fiber_head.define_substitutions>, 'build_equation': <function fiber_head.build_equation>, 'consolidate_equation': <function fiber_head.consolidate_equation>, 'full_consolidation': <function fiber_head.full_consolidation>, 'numerical_evaluation': <function fiber_head.numerical_evaluation>, '__dict__': <attribute '__dict__' of 'fiber_head' objects>, '__weakref__': <attribute '__weakref__' of 'fiber_head' objects>, '__doc__': None, '__annotations__': {}})
__init__()[source]

A class that constructs helps compute the LP01 mode of a fiber.

ufuncs are stored in:

  • Hy_r

  • Hy_xy

__module__ = 'scifysim.injection'
__weakref__

list of weak references to the object (if defined)

build_equation()[source]
consolidate_equation(thesubs)[source]
define_substitutions()[source]
full_consolidation(NA, a, ncore)[source]

Completes the consolidation of the lambda function with the application parameters:

  • NA : The numerical aperture

  • a : The core radius in meters

  • ncore : the refractive index of the core

numerical_evaluation(half_range, nsamples, lambs)[source]
class scifysim.injection.focuser(name='SCExAO_chuck', csz=200, ysz=256, xsz=256, pupil=None, screen=None, rm_inj_piston=False, pdiam=7.92, pscale=10.0, wl=1.6e-06)[source]

Bases: object

Generic monochoromatic camera class

This class simulates focusing optics. It can simulate injection either:

  • by computing the product of the image plane complex amplitude with the fiber mode field, or

  • by computing the product of the pupil plane complex amplitude with the conjugation of the fiber mode field.

__dict__ = mappingproxy({'__module__': 'scifysim.injection', '__doc__': ' Generic monochoromatic camera class\n    \n    This class simulates focusing optics. It can simulate injection \n    either:\n    \n    - by computing the product of the image plane complex amplitude with\n      the fiber mode field, or\n    - by computing the product of the pupil plane complex amplitude with\n      the conjugation of the fiber mode field.\n    ', '__init__': <function focuser.__init__>, 'define_TT': <function focuser.define_TT>, 'update_pupil': <function focuser.update_pupil>, 'update_cam': <function focuser.update_cam>, 'update_signal': <function focuser.update_signal>, 'sft': <function focuser.sft>, 'getimage': <function focuser.getimage>, 'get_inv_image': <function focuser.get_inv_image>, 'get_injection': <function focuser.get_injection>, 'get_tilt': <function focuser.get_tilt>, '__dict__': <attribute '__dict__' of 'focuser' objects>, '__weakref__': <attribute '__weakref__' of 'focuser' objects>, '__annotations__': {}})
__init__(name='SCExAO_chuck', csz=200, ysz=256, xsz=256, pupil=None, screen=None, rm_inj_piston=False, pdiam=7.92, pscale=10.0, wl=1.6e-06)[source]

Default instantiation of a cam object:

Parameters are:

  • name : a string describing the camera (“instrument + camera name”)

  • csz : array size for Fourier computations

  • (ys,xs) : the dimensions of the actually produced image

  • pupil : a csz x csz array containing the pupil

  • pscale : the plate scale of the image, in mas/pixel

  • wl : the central wavelength of observation, in meters

__module__ = 'scifysim.injection'
__weakref__

list of weak references to the object (if defined)

define_TT()[source]

Defines tip and tilt phase screens based on the pupil

get_injection(phscreen)[source]

Computes the complex injection phasor based on fiber mode in the pupil plane.

Parameters:

  • phscreen: The piston map in µm

get_inv_image(image)[source]
get_tilt(phscreen=None)[source]

Measures the tip-tilt measurement corresponding to the wavefront provided. The tip-tilt is in a 2-array and the unit is lambda/D where D is the extent of the pupil mask.

Parameters:

  • phscreen: The piston map in µm

getimage(phscreen=None)[source]

Produces an image, given a certain number of phase screens, and updates the shared memory data structure that the camera instance is linked to with that image

If you need something that returns the image, you have to use the class member method get_image(), after having called this method.

Parameters:

  • phscreen: The piston map in µm

sft(A2)[source]

Class specific implementation of the explicit Fourier Transform

The algorithm is identical to the function in the sft module, except that intermediate FT arrays are stored for faster computation.

For a more generic implementation, refer to the sft module of this package.

Assumes the original array is square. No need to “center” the data on the origin.

update_cam(wl=None, pscale=None, between_pixel=None)[source]

Change the filter, the plate scale or the centering of the camera

Parameters:

  • pscale : the plate scale of the image, in mas/pixel

  • wl : the central wavelength of observation, in meters

  • between_pixel : whether FT are centered between four pixels or not

update_pupil(pupil, reference_pupil)[source]
update_signal(nph=1000000.0)[source]

Update the strength of the signal

Automatically sets the phot_noise flag to True IF the value provided is negative, it sets the phot_noise flag back to False and sets the signal back to 1e6 photons

Parameters:

  • nph: the total number of photons inside the frame

class scifysim.injection.fringe_tracker(theconfig, seed=None, precompute=False)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'scifysim.injection', '__init__': <function fringe_tracker.__init__>, 'prepare_time_series': <function fringe_tracker.prepare_time_series>, 'iterator': <function fringe_tracker.iterator>, 'prepare_interpolation': <function fringe_tracker.prepare_interpolation>, 'interpolate_batch': <function fringe_tracker.interpolate_batch>, 'get_phasor_precomputed_dry': <function fringe_tracker.get_phasor_precomputed_dry>, 'get_phasor_dry': <function fringe_tracker.get_phasor_dry>, '__dict__': <attribute '__dict__' of 'fringe_tracker' objects>, '__weakref__': <attribute '__weakref__' of 'fringe_tracker' objects>, '__doc__': None, '__annotations__': {}})
__init__(theconfig, seed=None, precompute=False)[source]

Creates the module that simulates the OPD residual from fring tracker performance theconfig : A parsed config file seed : Seed for the generation of random OPDs

__module__ = 'scifysim.injection'
__weakref__

list of weak references to the object (if defined)

get_phasor_dry(i, lamb)[source]
get_phasor_precomputed_dry(i, lamb)[source]

Precomputed computation are recommended for longer time series when trying to factor-in long timescale effects. One can prepare the “low” resolution series, and dump the original dataset.

interpolate_batch(duration)[source]

optional: Prepares lookup tables for direct lookup of piston values

iterator(lamb)[source]

Iterator that yields the phasors of fringe tracker residuals The iterator sets for precomputed or direct interpolation depending on the configuration. It also sets for wet or dry computation depending on the configuration.

prepare_interpolation()[source]

Mandatory Computes the interpolation functions to be used later

save:

self.piston_interpolation() self.dispersion_interpolation

prepare_time_series(lamb, duration=10, replace=True)[source]

Call to refresh the time series to use duration : The duration of the time series to prepare replace : Replace the time series (otherwise append)

class scifysim.injection.gaussian_fiber_head(NA=None, mfd=None, wl_mfd=None, apply=True)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'scifysim.injection', '__init__': <function gaussian_fiber_head.__init__>, 'define_substitutions': <function gaussian_fiber_head.define_substitutions>, 'build_equation': <function gaussian_fiber_head.build_equation>, 'consolidate_equation': <function gaussian_fiber_head.consolidate_equation>, 'full_consolidation': <function gaussian_fiber_head.full_consolidation>, 'numerical_evaluation': <function gaussian_fiber_head.numerical_evaluation>, '__dict__': <attribute '__dict__' of 'gaussian_fiber_head' objects>, '__weakref__': <attribute '__weakref__' of 'gaussian_fiber_head' objects>, '__doc__': None, '__annotations__': {}})
__init__(NA=None, mfd=None, wl_mfd=None, apply=True)[source]

A class that constructs a gaussian approximation for a fiber mode. Numerical evaluations are based on NA or mfd and wl_mfd, depending on which is provided. ufuncs are stored in: Hy_r Hy_xy

Parameters:

  • NA : The numerical aperture

  • mfd : The mode field diameter [m]

  • wl_mfd : The wavelength at which the mfd is measured [m]

__module__ = 'scifysim.injection'
__weakref__

list of weak references to the object (if defined)

build_equation()[source]
consolidate_equation(thesubs)[source]
define_substitutions()[source]
full_consolidation(NA=None, mfd=None, wl_mfd=None)[source]

Completes the consolidation of the lambda function with the application parameters:

Parameters:

NA : The numerical aperture mfd : The mode field diameter in [m] wl_mfd : The wavelength at which mfd is measured in [m]

numerical_evaluation(half_range, nsamples, lambs)[source]
class scifysim.injection.injection_cloud(injector, res, crop=1.0)[source]

Bases: object

A shortcut to injection simulation in the case of diffuse sources injector : an injector object to emulate res :

__dict__ = mappingproxy({'__module__': 'scifysim.injection', '__doc__': '\n    A shortcut to injection simulation in the case of diffuse sources\n    injector     : an injector object to emulate\n    res          : \n    ', '__init__': <function injection_cloud.__init__>, 'vigneted_spectrum': <function injection_cloud.vigneted_spectrum>, '__dict__': <attribute '__dict__' of 'injection_cloud' objects>, '__weakref__': <attribute '__weakref__' of 'injection_cloud' objects>, '__annotations__': {}})
__init__(injector, res, crop=1.0)[source]

A shortcut to injection simulation in the case of diffuse sources

Parameters:

  • injector : an injector object to emulate

  • res : The resolution of the map

  • crop : A factor that scales the FoV of the map

__module__ = 'scifysim.injection'
__weakref__

list of weak references to the object (if defined)

vigneted_spectrum(spectrum, lambda_range, exptime, transmission=None)[source]

transmission: The first object of the transmission-emission chain to be used to compute the instrument transmission. This allows to account for throughtput, including airmass.

spectrum : Flux density in ph/s/sr/m^2

class scifysim.injection.injection_vigneting(injector, res, crop=0.8)[source]

Bases: object

A shortcut to injection simulation in the case of diffuse sources injector : an injector object to emulate res :

__dict__ = mappingproxy({'__module__': 'scifysim.injection', '__doc__': '\n    A shortcut to injection simulation in the case of diffuse sources\n    injector     : an injector object to emulate\n    res          : \n    ', '__init__': <function injection_vigneting.__init__>, 'vigneted_spectrum': <function injection_vigneting.vigneted_spectrum>, '__dict__': <attribute '__dict__' of 'injection_vigneting' objects>, '__weakref__': <attribute '__weakref__' of 'injection_vigneting' objects>, '__annotations__': {}})
__init__(injector, res, crop=0.8)[source]

A shortcut to injection simulation in the case of diffuse sources

Parameters:

  • injector : an injector object to emulate

  • res : The resolution of the map

  • crop : A factor that scales the FoV of the map

__module__ = 'scifysim.injection'
__weakref__

list of weak references to the object (if defined)

vigneted_spectrum(spectrum, lambda_range, exptime, transmission=None)[source]

Includes collecting area, throughput (in transmission is not None) and pixel solid angle

transmission: The first object of the transmission-emission chain to be used to compute the instrument transmission. This allows to account for throughtput, including airmass.

spectrum : Flux density in ph/s/sr/m^2

class scifysim.injection.injector(pupil='VLT', pdiam=8.0, odiam=1.0, ntelescopes=4, tt_correction=None, no_piston=False, lambda_range=None, fiber_mode='diameter', NA=0.23, a=4.25e-06, ncore=2.7, wl_mfd=None, focal_hrange=2e-05, focal_res=50, pscale=4.5, interpolation=None, rm_inj_piston=False, seed=None, atmo_config=None)[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'scifysim.injection', '__init__': <function injector.__init__>, 'from_config_file': <classmethod object>, '_setup': <function injector._setup>, 'reset_screen': <function injector.reset_screen>, 'give_fiber': <function injector.give_fiber>, 'give_comparison': <function injector.give_comparison>, 'all_inj_phasors': <function injector.all_inj_phasors>, 'best_injection': <function injector.best_injection>, 'give_interpolated_injection_image_plane': <function injector.give_interpolated_injection_image_plane>, 'give_interpolated': <function injector.give_interpolated>, 'compute_best_injection': <function injector.compute_best_injection>, 'compute_injection_function': <function injector.compute_injection_function>, 'update_screens': <function injector.update_screens>, '__dict__': <attribute '__dict__' of 'injector' objects>, '__weakref__': <attribute '__weakref__' of 'injector' objects>, '__doc__': None, '__annotations__': {}})
__init__(pupil='VLT', pdiam=8.0, odiam=1.0, ntelescopes=4, tt_correction=None, no_piston=False, lambda_range=None, fiber_mode='diameter', NA=0.23, a=4.25e-06, ncore=2.7, wl_mfd=None, focal_hrange=2e-05, focal_res=50, pscale=4.5, interpolation=None, rm_inj_piston=False, seed=None, atmo_config=None)[source]

Generates fiber injection object.

Parameters:

  • pupil : The telescope pupil to consider

  • pdiam : The pupil diameter

  • ntelescopes : The number of telescopes to inject

  • pupil : Apupil name or definition

  • tt_correction : Amount of TT to correct (Not implemented yet)

  • no_piston : Remove the effect of piston at the injection (So that it is handled only by the FT.)

  • NA : Then numerical aperture of the fiber

  • a : The radius of the core (m)

  • ncore : The refractive index of the core

  • focal_hrange : The half-range of the focal region to simulate (m)

  • focal_res : The total resolution of the focal plane to simulate

  • pscale : The pixel scale for imager setup (mas/pix)

  • seed : Value to pass for random phase screen initialization

  • atmo_config: A parsed config file

Use: call next(self.it) that returns injection phasors For more information, look into the attributes.

To get the ideal injection: self.best_injection(lambdas)

__module__ = 'scifysim.injection'
__weakref__

list of weak references to the object (if defined)

_setup(seed=None)[source]

Common part of the setup Nota: the seed for creation of the screen is incremented by 1 between pupils

all_inj_phasors(lambdas)[source]

Convenience function that applies interpolation for all the inputs

best_injection(lambdas)[source]

Convenience function that applies interpolation for all the inputs

compute_best_injection(interpolation)[source]

This one will yield the method that interpolates ideal injection

Arguments:

  • interpolation: type of interpolation to use based on the computed n (typically n=3) wavefronts.

compute_injection_function(interpolation='linear', tilt_res=50, tilt_range=2.0)[source]

Computes an interpolation of the injection as a function of a tip-tilt

injector.injection_abs(wl [m], offset [lambda/D])

classmethod from_config_file(file=None, fpath=None, focal_res=50, pupil=None, seed=None)[source]

Construct the injector object from a config file

Parameters:

file : A pre-parsed config file fpath : The path to a config file nwl : The number of wl channels focal_res : The total resolution of the focal plane to simulate

Gathers the variables from the config file then calls for a class instance (__init__())

give_comparison()[source]

A test comparison between image and pupil plane injection

give_fiber()[source]
give_interpolated(interpolation)[source]

This one will yield the method that interpolates all the injection phasors

Arguments:

  • interpolation: type of interpolation to use based on the computed n (typically n=3) wavefronts.

give_interpolated_injection_image_plane(interpolation)[source]

This one will yield the method that interpolates all the injection phasors

reset_screen()[source]
update_screens()[source]

Reset all the screens for the injection

scifysim.injection.optimize_a()[source]
scifysim.injection.seeing_to_r0(seeing, wl)[source]

seeing : seeing in arcseconds wl : wl in m

scifysim.injection.tel_pupil(n, m, radius, file=None, pdiam=None, odiam=None, spiders=True, between_pix=True, tel_index=0)[source]

returns an array that draws the pupil of the VLT at the center of an array of size (n,m) with radius “radius”.

This is an approximation to reduce number of parameters: offset an angle are approximated. See xaosim.pupil.VLT for original

Parameters describing the pupil were deduced from a pupil mask description of the APLC coronograph of SPHERE, by Guerri et al, 2011.

http://cdsads.u-strasbg.fr/abs/2011ExA….30…59G

scifysim.injection.test_fiber()[source]
scifysim.injection.test_injection(phscreensz=200, r0=8.0, interpolation=None, seed=20127)[source]

Remember to pass seed=None if you want a random initialization

scifysim.injection.test_injection_fromfile(phscreensz=200, fpath='/home/rlaugier/Documents/hi5/SCIFYsim/scifysim/config/default_new_4T.ini', seed=20127)[source]

Remember to pass seed=None if you want a random initialization

scifysim.injection.test_injection_function(asim)[source]