DistortionParameters#

class esis.optics.DistortionParameters(yaw_grating, pitch_grating, roll_grating, roll_field_stop, spacing_rulings, displacement_primary, pitch, yaw, roll)[source]#

Bases: Printable

The degrees of freedom adjusted when fitting an instrument model to images.

An instance of this class serves both as a point in parameter space and as the prototype that defines the units and structure of the flat vector seen by scipy.optimize routines: named_arrays.pack() flattens it into a dimensionless vector and named_arrays.unpack() rebuilds it.

Examples

Gather the distortion parameters of the ESIS flight-1 design and flatten them into a vector suitable for scipy.optimize.

import named_arrays as na
import esis

instrument = esis.flights.f1.optics.design(num_distribution=0)
parameters = esis.optics.DistortionParameters.from_instrument(instrument)
na.pack(parameters)
ScalarArray(
    ndarray=[-268.17403457,    0.        ,    0.        ,    0.        ,    0.38660662,   -0.        ,    0.        ,
                0.        ,    0.        ],
    axes=('pack',),
)

Attributes

yaw_grating

The yaw angle of the diffraction grating.

pitch_grating

The pitch angle of the diffraction grating.

roll_grating

The roll angle of the diffraction grating.

roll_field_stop

The roll angle of the field stop.

spacing_rulings

The constant coefficient of the grating ruling spacing polynomial.

displacement_primary

The displacement of the primary mirror along the optic axis relative to its nominal focal length.

pitch

The pitch angle of the entire instrument.

yaw

The yaw angle of the entire instrument.

roll

The roll angle of the entire instrument.

Methods

__init__(yaw_grating, pitch_grating, ...)

from_file(path[, axis])

Load parameters saved by to_file().

from_instrument(instrument)

Gather the current distortion parameters of the given instrument.

to_file(path[, metadata])

Save these parameters as a plain-text ECSV table.

to_instrument(instrument)

Apply these parameters to a copy of the given instrument.

to_string([prefix])

Public-facing version of the __repr__ method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.

Inheritance Diagram

Inheritance diagram of esis.optics.DistortionParameters
Parameters:
classmethod from_file(path, axis=None)[source]#

Load parameters saved by to_file().

The logical axis of the parameters is recovered from the axis entry of the table header.

Parameters:
  • path (str | Path) – The path of the file to read.

  • axis (None | str) – The name to use for the logical axis of the parameters, overriding the name recorded in the file.

Return type:

DistortionParameters

classmethod from_instrument(instrument)[source]#

Gather the current distortion parameters of the given instrument.

The parameters are converted to a canonical set of units (arcmin for the grating angles, arcsec for the instrument pointing, etc.) so that the components of the packed vector are of order unity and bounds built from different instances are consistent.

Parameters:

instrument (AbstractInstrument) – The instrument model to gather the parameters from.

Return type:

DistortionParameters

to_file(path, metadata=None)[source]#

Save these parameters as a plain-text ECSV table.

The fields become the columns of the table (with their units), and the elements along the (single) logical axis of the parameters become its rows, so that fit results can be committed to version control and reviewed as text. Scalar fields are broadcast along the axis.

Parameters:
  • path (str | Path) – The path of the file to write.

  • metadata (None | dict[str, Any]) – Additional provenance recorded in the table header, for example the date and configuration of the fit that produced the parameters.

Raises:

ValueError – If the parameters have more than one logical axis.

Return type:

None

See also

from_file

The inverse of this method.

to_instrument(instrument)[source]#

Apply these parameters to a copy of the given instrument.

The given instrument is left unmodified, and any cached optical system on the result is discarded so that it is rebuilt with the new parameters.

The nominal focal length of the primary mirror is recovered from the invariant focal_length + translation.z, which is unchanged by applying a displacement_primary, so this method may be applied repeatedly to the results of previous applications.

Parameters:

instrument (AbstractInstrument) – The instrument model to apply the parameters to.

Return type:

AbstractInstrument

to_string(prefix=None)#

Public-facing version of the __repr__ method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.

Parameters:

prefix (None | str) – an optional string, the length of which is used to calculate how much whitespace to add to the result.

Return type:

str

displacement_primary: Quantity | AbstractScalar#

The displacement of the primary mirror along the optic axis relative to its nominal focal length.

A displacement \(d\) simultaneously sets the focal length to \(f_\mathrm{nominal} + d\) and the translation of the primary mirror to \(-d\), so that the primary moves while the focal plane stays put.

pitch: Quantity | AbstractScalar#

The pitch angle of the entire instrument.

pitch_grating: Quantity | AbstractScalar#

The pitch angle of the diffraction grating.

roll: Quantity | AbstractScalar#

The roll angle of the entire instrument.

roll_field_stop: Quantity | AbstractScalar#

The roll angle of the field stop.

roll_grating: Quantity | AbstractScalar#

The roll angle of the diffraction grating.

spacing_rulings: Quantity | AbstractScalar#

The constant coefficient of the grating ruling spacing polynomial.

yaw: Quantity | AbstractScalar#

The yaw angle of the entire instrument.

yaw_grating: Quantity | AbstractScalar#

The yaw angle of the diffraction grating.