Inits¶
Classes derived from the Init
class initialize the parameters of components. After
creating an Init, it is applied to a component by calling it with the component and a filename as parameters.
Therefore a derived class must implement both the constructor __init__()
and
__call__()
.
spexxy comes with a few pre-defined init classes:
InitFromCsv
reads initial values from a CSV file.InitFromPath
looks for a file of the same name in a given path and reads the initial values from its FITS header.InitFromValues
takes initial values directly from its constructor.InitFromVhelio
takes coordinates and time from the FITS header, and calculates the heliocentric or baryiocentric correction, which then can be set as initial value for a component.
Init¶
-
class
spexxy.init.
Init
(*args, **kwargs)¶ Init is the base class for all objects that can initialize values of a component.
-
__call__
(cmp: spexxy.component.component.Component, filename: str)¶ Initializes values for the given component.
Parameters: - cmp (Component) – Component to initialize.
- filename (str) – Name of file containing spectrum to create mask for.
-
__init__
(*args, **kwargs)¶ Initialize an Init object.
-
InitFromCsv¶
-
class
spexxy.init.
InitFromCsv
(filename: str = 'initials.csv', filename_col: str = 'Filename', parameters: list = None, cmp_sep: str = ' ', *args, **kwargs)¶ Initializes a component from a line in a CSV file.
This class, when called, initializes the given parameters (or all if None) of a given component to the values in the given CSV file.
-
__call__
(cmp: spexxy.component.component.Component, filename: str)¶ Initializes parameters of the given component with values from the CSV given in the configuration.
Parameters: cmp – Component to initialize. filename: Filename of spectrum.
-
__init__
(filename: str = 'initials.csv', filename_col: str = 'Filename', parameters: list = None, cmp_sep: str = ' ', *args, **kwargs)¶ Initializes a new Init object.
Parameters: - filename – Name of CSV file.
- filename_col – Name of column containing filename.
- parameters – List of parameter names to set from CSV.
- cmp_sep – String separating component and parameter name in CSV.
-
InitFromPath¶
-
class
spexxy.init.
InitFromPath
(path: str, *args, **kwargs)¶ Initializes a component from another file in a given directory.
This class, when called, initializes the parameters of a given component to the values in the header of a file with the same name (usually written in a previous fit) in the given directory.
-
__call__
(cmp: spexxy.component.component.Component, filename: str)¶ Initializes parameters of the given component with values from another file.
Parameters: - cmp – Component to initialize.
- filename – Name of file (in given path) to read initial values from.
-
__init__
(path: str, *args, **kwargs)¶ Initializes a new Init object.
Parameters: path – Path in which to look for the file to read the initial values from.
-
InitFromValues¶
-
class
spexxy.init.
InitFromValues
(values: dict, *args, **kwargs)¶ Initializes a component from given values.
This class, when called, initializes the parameters of a given component to the provided values from a dict.
-
__call__
(cmp: spexxy.component.component.Component, filename: str)¶ Initializes parameters of the given component with values from the configuration
Parameters: - cmp – Component to initialize.
- filename – Unused.
-
__init__
(values: dict, *args, **kwargs)¶ Initializes a new Init object.
Parameters: values – Dictionary of key/value pairs defining initial values for the component’s parameters.
-
InitFromVhelio¶
-
class
spexxy.init.
InitFromVhelio
(negative: bool = False, parameter: str = 'v', scale: str = 'utc', obs: str = 'paranal', kind: str = 'barycentric', *args, **kwargs)¶ Initializes a component from the heliocentric correction calculated for RA/Dec given in the FITS headers.
This class, when called, initializes a single parameter (the radial velocity, default to “v”) of the given component with the heliocentric correction calculated from RA/DEC/DATE-OBS in the given file.
-
__call__
(cmp: spexxy.component.component.Component, filename: str)¶ Initializes the radial velocity parameter of a given component to the (negative) heliocentric correction.
Parameters: - cmp – Component to initialize.
- filename – Name of file containing RA/DEC/DATE-OBS in FITS header to calculate correction from.
-
__init__
(negative: bool = False, parameter: str = 'v', scale: str = 'utc', obs: str = 'paranal', kind: str = 'barycentric', *args, **kwargs)¶ Initializes a new Init object.
Parameters: - negative – If True, uses the negative of the calculated correction.
- parameter – Name of the parameter in the component to set.
- scale – Time scale to use for DATE-OBS.
- obs – Observatory to use for calculating correction.
- kind – Either barycentric or heliocentric.
-