Spectral1D¶
-
class
spectacle.modeling.
Spectral1D
(*args, **kwargs)[source] [edit on github]¶ Bases:
astropy.modeling.Fittable1DModel
Base representation of a compound model containing a variable number of
OpticalDepth1D
line model features.- Parameters
- linesstr,
OpticalDepth1D
, list The line information used to compose the spectral model. This can be either a string, in which case the line information is retrieve from the ion registry; an instance of
OpticalDepth1D
; or a list of either of the previous two types.- continuum
Fittable1DModel
, optional An astropy model representing the continuum of the spectrum. If not provided, a
Const1D
model is used.- zfloat, optional
The redshift applied to the spectral model. Default = 0.
- lsf
LSFModel
,Kernel1D
, str, optional The line spread function applied to the spectral model. It can be a pre-defined kernel model, or a convolution kernel, or a string referencing the built-in Hubble COS lsf, or a Gaussian lsf. Optional keyword arguments can be passed through.
- linesstr,
Attributes Summary
New spectral model that produces flux output.
New spectral model that produces flux decrement output.
New spectral model that produces optical depth output.
This property is used to indicate what units or sets of units the evaluate method expects, and returns a dictionary mapping inputs to units (or
None
if any units are accepted).Allow dimensionless input (and corresponding output).
Whether this spectrum represents a collection of single ions or a collection of multiple different ions.
The collection of profiles representing the absorption or emission lines in the spectrum model.
The data output of this spectral model.
The redshift at which the data given to.
Methods Summary
__call__
(self, x, \*args, \*\*kwargs)Override the default call function to handle fixed parameters based on the unit of the provided dispersion.
evaluate
(self, x, \*args, \*\*kwargs)Evaluate the model on some input variables.
line_stats
(self, x)Calculate statistics over individual line profiles.
region_stats
(self, x, rest_wavelength[, …])Calculate statistics over arbitrary line regions given some tolerance from the continuum.
rejection_criteria
(self, x, y[, auto_fit])Implementation of the Akaike Information Criteria with Correction (AICC) (Akaike 1974; Liddle 2007; King et al.
with_continuum
(self, continuum)New spectral model defined with a different continuum.
with_line
(self, \*args[, reset])Add a new line to the spectral model.
with_lines
(self, lines[, reset])Create a new spectral model with the added lines.
with_lsf
(self[, kernel])New spectral model with a line spread function.
with_redshift
(self, value)Generate a new spectral model with the given redshift.
Attributes Documentation
-
as_flux
¶ New spectral model that produces flux output.
-
as_flux_decrement
¶ New spectral model that produces flux decrement output.
-
as_optical_depth
¶ New spectral model that produces optical depth output.
-
continuum
¶
-
input_units
¶ This property is used to indicate what units or sets of units the evaluate method expects, and returns a dictionary mapping inputs to units (or
None
if any units are accepted).Model sub-classes can also use function annotations in evaluate to indicate valid input units, in which case this property should not be overridden since it will return the input units based on the annotations.
-
input_units_allow_dimensionless
¶ Allow dimensionless input (and corresponding output). If this is True, input values to evaluate will gain the units specified in input_units. If this is a dictionary then it should map input name to a bool to allow dimensionless numbers for that input. Only has an effect if input_units is defined.
-
input_units_equivalencies
¶
-
inputs
= ('x',)¶
-
is_single_ion
¶ Whether this spectrum represents a collection of single ions or a collection of multiple different ions.
- Returns
- : bool
Is the spectrum composed of a collection of single ions.
-
lines
¶ The collection of profiles representing the absorption or emission lines in the spectrum model.
- Returns
- : list
A list of
Voigt1D
models.
-
lsf_kernel
¶
-
output_type
¶ The data output of this spectral model. It could one of ‘flux’, ‘flux_decrement’, or ‘optical_depth’.
- Returns
- : str
The output type of the model.
-
outputs
= ('y',)¶
-
redshift
¶ The redshift at which the data given to.
- Returns
- : float
The redshift value.
-
rest_wavelength
¶
-
velocity_convention
¶
Methods Documentation
-
__call__
(self, x, *args, **kwargs)[source] [edit on github]¶ Override the default call function to handle fixed parameters based on the unit of the provided dispersion.
Notes
The initial call to this method from fitter will provide unit information on the dispersion. Subsequent calls do not. It is assumed that subsequent calls provide dispersion as km/s.
-
evaluate
(self, x, *args, **kwargs)[source] [edit on github]¶ Evaluate the model on some input variables.
-
line_stats
(self, x)[source] [edit on github]¶ Calculate statistics over individual line profiles.
- Parameters
- x
Quantity
The input dispersion in either wavelength/frequency or velocity space.
- x
- Returns
- tab
QTable
A table detailing the calculated statistics.
- tab
-
region_stats
(self, x, rest_wavelength, rel_tol=0.01, abs_tol=1e-05)[source] [edit on github]¶ Calculate statistics over arbitrary line regions given some tolerance from the continuum.
- Parameters
- x
Quantity
The input dispersion in either wavelength/frequency or velocity space.
- rest_wavelength
Quantity
The rest frame wavelength used in conversions between wavelength/ frequency and velocity space.
- rel_tolfloat
The relative tolerance parameter.
- abs_tolfloat
The absolute tolerance parameter.
- x
- Returns
- tab
QTable
A table detailing the calculated statistics.
- tab
-
rejection_criteria
(self, x, y, auto_fit=True)[source] [edit on github]¶ Implementation of the Akaike Information Criteria with Correction (AICC) (Akaike 1974; Liddle 2007; King et al. 2011). Used to determine whether lines can be safely removed from the compound model without loss of information.
- Parameters
- x
Quantity
The dispersion data.
- yarray-like
The expected flux or tau data.
- auto_fitbool
Whether the model fit should be re-evaluated for every removed line.
- x
- Returns
- final_model
Spectral1D
The new spectral model with the least complexity.
- final_model
-
with_continuum
(self, continuum)[source] [edit on github]¶ New spectral model defined with a different continuum.
-
with_line
(self, *args, reset=False, **kwargs)[source] [edit on github]¶ Add a new line to the spectral model.
- Returns
- :
Spectral1D
The new spectral model.
- :
-
with_lines
(self, lines, reset=False)[source] [edit on github]¶ Create a new spectral model with the added lines.
- Parameters
- lineslist
List of
OpticalDepth1D
line objects.
- Returns
- :
Spectral1D
The new spectral model.
- :
-
with_lsf
(self, kernel=None, **kwargs)[source] [edit on github]¶ New spectral model with a line spread function.
-
with_redshift
(self, value)[source] [edit on github]¶ Generate a new spectral model with the given redshift.