scifysim.correctors module
- scifysim.correctors.bs2bcs(bs)[source]
Transforms a flat list of sellmeier coefficients (B1, C1, B2, C2, …) into two vectors fo coefficients B and C.
- class scifysim.correctors.corrector(config, lambs, file=None, order=3, model_comp=None, model_material2=None)[source]
Bases:
object
- __dict__ = mappingproxy({'__module__': 'scifysim.correctors', '__init__': <function corrector.__init__>, 'refresh_adjustments': <function corrector.refresh_adjustments>, 'get_phasor': <function corrector.get_phasor>, 'get_phasor_s': <function corrector.get_phasor_s>, 'get_raw_phase_correction': <function corrector.get_raw_phase_correction>, 'get_vector': <function corrector.get_vector>, 'get_dcomp': <function corrector.get_dcomp>, 'get_dcomp_from_vector': <function corrector.get_dcomp_from_vector>, 'get_phasor_from_params': <function corrector.get_phasor_from_params>, 'theoretical_phase': <function corrector.theoretical_phase>, 'theoretical_piston': <function corrector.theoretical_piston>, 'solve_air': <function corrector.solve_air>, 'solve_air_corrector': <function corrector.solve_air_corrector>, 'solve_air_model': <function corrector.solve_air_model>, 'tune_static': <function corrector.tune_static>, 'tune_static_shape': <function corrector.tune_static_shape>, 'plot_tuning': <function corrector.plot_tuning>, '__dict__': <attribute '__dict__' of 'corrector' objects>, '__weakref__': <attribute '__weakref__' of 'corrector' objects>, '__doc__': None, '__annotations__': {}})
- __init__(config, lambs, file=None, order=3, model_comp=None, model_material2=None)[source]
A module that provides beam adjustments for the input. It contains amplitude a, geometric piston b and ZnSe piston substitution c. Note that the ZnSe length replaces some air length.
Parameters:
config: A parsed config file
lambs : The wavelength channels to consider [m] (At the __init__ stage, it is only used for the computation of a mean refractive index for the dispersive material)
file A file containing the plate index
order : The order to which do the interpolation of the tabulated refractive index of the material 1
model_comp : A wet_atmo object model for the material in which compensation is made (None -> Vacuum).
model_material2 : A wet_atmo object model for the second material for compensation is made (None -> no material).
Internal parameters:
a : Vector of the amplitude term
b : Vetor of the geometric piston term [m]
c : Vetor of the dispersive piston term [m]
- __module__ = 'scifysim.correctors'
- __weakref__
list of weak references to the object (if defined)
- get_dcomp(c)[source]
Returns the theoertical value of dcomp for a given value of compensator plate, to correct for the pure piston term introduced. Arguments: * c : The value of glass plate [m]
- get_dcomp_from_vector(vector)[source]
Returns the theoertical value of dcomp for a vector value of compensator plate, to correct for the pure piston term introduced. Arguments: * vector : The vector valued corrector position [m]
(Only c at index 1 is used)
- get_phasor(lambs)[source]
Returns the complex phasor corresponding to the current a, b, c, and dcomp phasors.
Parameters:
lambs : The wavelength channels to consider [m]
Returns: alpha
- get_phasor_from_params(lambs, a=None, b=None, c=None, dcomp=None, e=None)[source]
Similar to get_phasor() but allows to provide the parameters as arguments (slower).
Returns the complex phasor corresponding to the current a, b, c, and dcomp phasors.
Parameters:
lambs : The wavelength channels to consider [m]
a : Vector of the amplitude term
b : Vetor of the geometric piston term [m]
c : Vetor of the dispersive piston term [m]
e : Vettor of the addtional corretction material term [m]
dcomp : A length of air to compensate for the plate [m] if dcomp is None: it will be computed based on self.c
- get_raw_phase_correction(lambs, b=0, c=0, e=0, dcomp=0, vector=None)[source]
Returns the raw (non-wrapped) phase produced by an optical path of b[m] in air and c[m] in plate material.
Parameters
lambs : The wavelength channels to consider [m]
a : Vector of the amplitude term
b : Vettor of the geometric piston term [m]
c : Vettor of the dispersive piston term [m]
e : Vettor of the addtional corretction material term [m]
dcomp : A length of air to compensate for the plate
vector : The vector-form of all dispersive correction shape: (n_materials, n_tel) [m]
- plot_tuning(lambs, npoints=20)[source]
Plot of the state of tuning.
Parameters: * lambs : The wavelength range to consider to consider [m] * npoints : The number number of points in the range to consider
- refresh_adjustments(a=None, chip_corr=None, atmo_corr=None, write=False)[source]
Updates the values of self.a, self.b… based on the values in self.chip_corr and atmo_corr. Except for a, arrays are of shape (n_tel, n_glasses) with n_glasses including air and air compensation.
Arguments: * a : Correction for amplitude * chip corr: Correction for the chip [m] * atmo_corr: Correction for the atmosphere [m] * write : If true, will write down the vectors received
- solve_air(lambs, model, corrector_shape=True)[source]
Computes a least squares compensation model (see Koresko et al. 2003 DOI: 10.1117/12.458032)
Parameters:
lambs : The wavelength channels to consider [m]
model : The wet atmosphere model (see n_air.wet_atmo object)
corrector_shape : (bool) if True: the matrix will be adjusted to give vectors adapted to a corrector with the correct number of materials.
Returns:
- solve_air_corrector(lambs)[source]
Computes a least squares compensation model for correction with variable thickness plates of material. (see Koresko et al. 2003 DOI: 10.1117/12.458032)
This will use
Parameters:
lambs : The wavelength channels to consider [m]
Returns:
- solve_air_model(lambs, models)[source]
Computes a least squares compensation model (see Koresko et al. 2003 DOI: 10.1117/12.458032)
Parameters:
lambs : The wavelength channels to consider [m]
model : The wet atmosphere model (see n_air.wet_atmo object)
Returns:
- theoretical_phase(lambs, proj_opds, model=None, add=0, db=False, ref=None)[source]
Computes the theoretical chromatic phase effect of the array geometry projected on axis based on the wet atmosphere model.
Parameters:
lambs : The wavelength channels to consider [m]
proj_opds : The projected piston obtained by projection (Get from simulator.obs.get_projected_geometric_pistons)
model : A model for humid air (see n_air.wet_atmo object). If None, defaults to self.model, created upon init.
add : returns n-1+add (add=0 gives the relative optical path compared to vacuum)
- refThe reference wavelength for which phase is 0.
None
the value of a reference wavelength [m]
“center” : use the central bin of lambs
“mean” : use the mean of lambs
Returns: phase [rad]
- theoretical_piston(lambs, proj_opds, model=None, add=0, db=False, ref=None)[source]
Computes the theoretical chromatic optical path effect of the array geometry projected on axis based on the wet atmosphere model.
Parameters:
lambs : The wavelength channels to consider [m]
proj_opds : The projected piston obtained by projection (Get from simulator.obs.get_projected_geometric_pistons)
model : A model for humid air (see n_air.wet_atmo object). If None, defaults to self.model, created upon init.
add : returns n-1+add (add=0 gives the relative optical path compared to vacuum)
- refThe reference wavelength for which opl is 0.
None
the value of a reference wavelength [m]
“center” : use the central bin of lambs
“mean” : use the mean of lambs
Returns: piston [m]
- tune_static(lambs, combiner, apply=True, freeze_params=['b0', 'c0', 'b2', 'c2'])[source]
Optimize the compensator to correct chromatism in the model of the combiner. Returns a lmfit solution object. If “apply” is set to True, a, b, c, and dcomp are also set to the best fit value.
Parameters:
lambs : The wavelength channels to consider [m]
combiner : A combiner object (chromatic)
apply : Boolean deciding whether to set the local parameters to best fit value (default: True)
freeze_params : The name of parameters to be freezed. Should be used to account for the larger than necessary number of degrees of freedom.
Note:
For obtaining a more practical direct results, some more complicated balancing guidelines should be followed.
- tune_static_shape(lambs, combiner, apply=True, sync_params=[('b3', 'b2', 0.0), ('c3', 'c2', 0.0)], freeze_params=['b0', 'c0', 'b1', 'c1'])[source]
Optimize the compensator to correct chromatism in the model of the combiner to obtain enantomporph combinations at the outputs. Returns a lmfit solution object. If
apply
is set to True, a, b, c, and dcomp are also set to the best fit value.Currently only works for double Bracewell 3-4 architectures.
Parameters:
lambs : The wavelength channels to consider [m]
combiner : A combiner object (chromatic)
apply : Boolean deciding whether to set the local parameters to best fit value (default: True)
Note:
For obtaining a more practical direct results, some more complicated balancing guidelines should be followed.
Example:
sol = asim.corrector.tune_static_shape(asim.lambda_science_range, asim.combiner, sync_params=[("b3", "b2", asim.corrector.b[3] - asim.corrector.b[2]), ("c3", "c2", asim.corrector.c[3] - asim.corrector.c[2])], apply=True)
- scifysim.correctors.extract_corrector_params(corrector, params)[source]
Utility function to reconstruct the b and c vectors from the lmfit Parameters object.
Parameters:
corrector : The corrector object
params : at lmfit Parameters object containing b_i and c_i terms
- scifysim.correctors.get_Is(params, combiner, corrector, lambs)[source]
Returns intensities at the combiners’ outputs taking into account the corrections provided in params.
dcomp is computed automatically be default.
Parameters:
params : either
A Parameters object from the optimization does not support e: e is taken from corrector
A tuple of vectors bvec, cvec
combiner : A combiner object.
corrector : The corrector object
lambs : The wavelengths considered.
- scifysim.correctors.get_contrast_res(params, combiner, corrector, lambs)[source]
Macro that gets the a residual from parameters for minimizing method.
- scifysim.correctors.get_depth(combiner, Is)[source]
Computes a “null depth” analogue (dark/bright) to be minimized by the tuning method. The masks in the combiner definition are used to determine the role of the different outputs.
Parameters:
combiner : A combiner object.
Is : An array of intensities
- scifysim.correctors.get_es(params, combiner, corrector, lambs)[source]
Returns the enantiomorph excursion taking into account the corrections provided in params.
Currently works only for double-bracewell 3-4 architecures
dcomp is computed automatically by default.
Parameters:
- paramseither
A Parameters object from the optimization
A tuple of vectors bvec, cvec
combiner : A combiner object.
corrector : The corrector object
lambs : The wavelengths considered.
- scifysim.correctors.get_max_differential(array)[source]
Gets the maximum differential between beams:
returns : max(array) - min(array)
- scifysim.correctors.get_shape_res(params, combiner, corrector, lambs)[source]
Macro that gets the a residual from parameters for minimizing method.
- class scifysim.correctors.material_sellmeier(bs, cs=None)[source]
Bases:
object
- __dict__ = mappingproxy({'__module__': 'scifysim.correctors', '__init__': <function material_sellmeier.__init__>, 'get_n': <function material_sellmeier.get_n>, '__dict__': <attribute '__dict__' of 'material_sellmeier' objects>, '__weakref__': <attribute '__weakref__' of 'material_sellmeier' objects>, '__doc__': None, '__annotations__': {}})
- __init__(bs, cs=None)[source]
bs : the B terms of the Sellmeier equation
cs : the C terms of the Sellmeier equation [µm^2]
if cs is not provided, then we expect coefficients given from bs as (B1, C1, B2, C2, …)
- __module__ = 'scifysim.correctors'
- __weakref__
list of weak references to the object (if defined)
- class scifysim.correctors.offband_ft(wl_ft, wl_science, wa_true, wa_model=None, corrector=None)[source]
Bases:
object
- __dict__ = mappingproxy({'__module__': 'scifysim.correctors', '__init__': <function offband_ft.__init__>, 'refresh_corrector_models': <function offband_ft.refresh_corrector_models>, 'get_ft_correction_on_science': <function offband_ft.get_ft_correction_on_science>, 'update_NCP_corrections': <function offband_ft.update_NCP_corrections>, 'update_NCP_corrections_old': <function offband_ft.update_NCP_corrections_old>, 'get_modeled_law': <function offband_ft.get_modeled_law>, 'get_S_GD_star': <function offband_ft.get_S_GD_star>, 'get_phase_GD_tracking': <function offband_ft.get_phase_GD_tracking>, 'get_phase_on_band': <function offband_ft.get_phase_on_band>, 'get_phase_science_values': <function offband_ft.get_phase_science_values>, '__dict__': <attribute '__dict__' of 'offband_ft' objects>, '__weakref__': <attribute '__weakref__' of 'offband_ft' objects>, '__doc__': None, '__annotations__': {}})
- __init__(wl_ft, wl_science, wa_true, wa_model=None, corrector=None)[source]
Builds a fringe tracker object that handles the problems of dispersion between the band in use and the band of interest. It also addresses the problems inside the band of interest.
Arguments:
wl_ft : The wavelength at which the fringe tracking is done. OPD will be set to produce 0 phase at the man FT wavelength
wl_science : The wavelength range for which the correction is optimized
wa_true : True wet air model
wa_model : Modeled wet air model (as measured at the telescopes)
corrector : An dispersion corrector object to compute corresponding glass and air thickness
Note:
Contrary to the corrector object, the corrections are stored in a single 2D array, with the b on the row 0 and c on row 1
- __module__ = 'scifysim.correctors'
- __weakref__
list of weak references to the object (if defined)
- get_S_GD_star(band=None, model=None, resample=None)[source]
S_GD_star is the transform matrix (flat in this case) that projects the phase of vacuum created phases into piston that minimize the group delay.
This is inspired by Tango 1990. In the case of only air conpensation, equation
Arguments: * band : if None: will save self.sld_sxs * pistons : * model : A specific model with which to compute the correction * resample: None (default) to keep the sampling of the band,
or int to resample band with that number of samples.
- get_ft_correction_on_science(pistons, band=None)[source]
Arguments:
pistons : The value of optical path length missing at the reference plane [m]
Output: The phases for the science wavelengths for a closed loop correction by the fringe tracker [rad]
- get_modeled_law(max_baseline=133, model=None)[source]
Evaluate a law for glass and air compensation Arguments:
max_baseline : the maximum length tho considerj
model : A humid air model for which to draw the plot
- get_phase_GD_tracking(pistons, band=None, model=None, resample=None)[source]
Arguments:
band : if None: will save self.sld_sxs
pistons :
model : A specific model with which to compute the correction
resample: None (default) to keep the sampling of the band, or int to resample band with that number of samples.
- get_phase_on_band(band, pistons, mode='ideal', ft_mode='phase')[source]
Similar to
get_phase_science_values
but for an arbitrary band for illustration purposes.Arguments: * band : * pistons : * mode : Type of correction to apply
ideal : Compensate with perfect knowledge of the atmospheric effects.
blind : Compensate using the internal atmosphere model which may deviate from ground truth.
feedforward : Assumes the dispersion is being measured at teh FT band
- update_NCP_corrections(pistons, band=None, mode='phase')[source]
Called by get_phase_on_band and get_phase_on_science_values and therefore called each time the director.point is called.
Arguments:
pistons : The value of optical path length missing at the reference plane [m]
Refreshes:
self.true_phase_on_science
self.model_phase_on_science self.correction_ft_to_science self.phase_seen_by_ft self.b_ft self.correction_feedforward self.b_science_ideal
Computing the feedforward correction based on the FT phase: - self.b_ft : The atmospheric corrector for the FT band - self.correction_feedforward : The atmospheric corrector for the FT band
Computing the ideal correction for perfect knowledge of atmosphere (If we could measure the actual phase and close a loop) - self.b_science_ideal : The atmospherci corrector for the science band - self.correction_closed_loop
Computing a biased estimation based on a full model - self.b_science_model : The atmospherci corrector for the science band - self.correction_blind
New implementation:
In the idea that the phase of phase at entrance of the NOTT chip phi_tot: ``` phi_tot = phi_v + phi_DL + phi_nott
- update_NCP_corrections_old(pistons, band=None)[source]
Called by get_phase_on_band and get_phase_on_science_values and therefore called each time the director.point is called.
Arguments:
pistons : The value of optical path length missing at the reference plane [m]
Refreshes:
self.true_phase_on_science
self.model_phase_on_science self.correction_ft_to_science self.phase_seen_by_ft self.b_ft self.correction_feedforward self.b_science_ideal
Computing the feedforward correction based on the FT phase: - self.b_ft : The atmospheric corrector for the FT band - self.correction_feedforward : The atmospheric corrector for the FT band
Computing the ideal correction for perfect knowledge of atmosphere (If we could measure the actual phase and close a loop) - self.b_science_ideal : The atmospherci corrector for the science band - self.correction_closed_loop
Computing a biased estimation based on a full model - self.b_science_model : The atmospherci corrector for the science band - self.correction_blind