ATK.Models.Spectrum#

class ATK.Models.Spectrum[source]#

Bases: Container, DataFrameIOMixin, TableIOMixin, FITSIOMixin

Container for storing spectral data. This object stores both data and relevant metadata.

Valid Configurations

A Spectrum must be initialised with one of the following mutually exclusive parameters:

  • wavelength or velocity

Providing both or neither raises a ValueError.

Units

The following attributes are automatically converted to Quantity with a default unit unless one is explictly provided:

  • exposure - s

  • wav_ref - Å

  • wavelength - Å

  • velocity - km s⁻¹

  • flux - 1×10⁻¹⁷ erg Å⁻¹ s⁻¹ cm⁻²


Data Methods

The following Data Methods are supported by Spectrum - either individually or through DataSet.apply():


Plotting Arguments

The following keyword arguments are accepted when plotting via plot() or open().

overlaySED, optional

Overlays a spectral energy distribution.

By default, no SED is overlayed.




Attributes

correction

Achieved degree of proper motion correction.

exposure

Exposure of spectrum.

flux

Flux values.

search_pos

Position of search at time of execution (i.e. post-correction).

separation

Separation between position of the search and the returned data.

survey

Survey from which the stored data originates.

velocity

Velocity values.

wav_ref

Reference wavelength.

wavelength

Wavelength values.

Methods

bin([bins, size, inplace])

Bins all array-like attributes into a number of bins or a bin size in x (i.e. wavelength or velocity).

crop([cmin, cmax, inplace])

Bins all array-like attributes into a number of bins or a bin size in x (i.e. wavelength or velocity).

from_dataframe(target, data, **kwargs)

Construct a Spectrum from a DataFrame.

from_table(target, data, **kwargs)

Construct a Spectrum from a Table.

show([show_types, show_all])

Prints structure to stdout in a human-readable format.

to_dataframe()

Combines all array-like attributes of a structure into a DataFrame.

to_hdu()

Converts structure into a FITS BinTableHDU.

to_table()

Combines all array-like attributes of a structure into a Table, preserving units.

vspec(wav_ref[, inplace])

Convert wavelength values to velocity relative to a reference wavelength.



Attribute Descriptions

correction: str | None = None#

Achieved degree of proper motion correction.

  • 'full' = complete 3-dimensional projection on the sky.

  • 'partial' = 2-dimensional plane projection.

  • 'none' = no correction.

exposure: Quantity | None = None#

Exposure of spectrum.

flux: Quantity | None = None#

Flux values.

search_pos: SkyCoord | None = None#

Position of search at time of execution (i.e. post-correction).

separation: Quantity | None = None#

Separation between position of the search and the returned data.

survey: str | None = None#

Survey from which the stored data originates.

velocity: Quantity | None = None#

Velocity values. Mutually exclusive with wavelength.

wav_ref: Quantity | None = None#

Reference wavelength.

None unless spectrum has been converted to a velocity spectrum via vspec().

wavelength: Quantity | None = None#

Wavelength values. Mutually exclusive with velocity.


Method Descriptions

bin(bins: int | None = None, size: Quantity | float | None = None, inplace=True)[source]#

Bins all array-like attributes into a number of bins or a bin size in x (i.e. wavelength or velocity).

Exactly one of bin or size must be provided.

Parameters:
binsint, optional

Number of bins in which to bin data.

sizefloat or Quantity, optional

Size of each bin in which to bin data. If a Unit is not provided, size is assumed to be in the same unit as x.

inplacebool, optional

If True, modify the current Spectrum inplace. If False, operate on and return a copy - leaving the original unchanged.

Returns:
Self

The binned Spectrum. Returns self if inplace=True, otherwise returns a new instance.

crop(cmin: float | None = None, cmax: float | None = None, inplace=True)[source]#

Bins all array-like attributes into a number of bins or a bin size in x (i.e. wavelength or velocity).

Exactly one of bin or size must be provided.

Parameters:
binsint, optional

Number of bins in which to bin data.

sizefloat or Quantity, optional

Size of each bin in which to bin data. If a Unit is not provided, size is assumed to be in the same unit as x.

inplacebool, optional

If True, modify the current Spectrum inplace. If False, operate on and return a copy - leaving the original unchanged.

Returns:
Self

The binned Spectrum. Returns self if inplace=True, otherwise returns a new instance.

classmethod from_dataframe(target, data, **kwargs)#

Construct a Spectrum from a DataFrame.

Parameters:
targetTarget, int, or SkyCoord

Astronomical target with which to associate input data.

Can be a Target, a Gaia Source ID (int), or a SkyCoord.

dataDataFrame

Tabular data containing the relevant fields (i.e. array-like attributes) required to construct a Spectrum. Units are assumed to be as listed above.

**kwargs

Additional keyword arguments to be forwarded to the internal parser.

The following keyword arguments are required: survey

Returns:
Spectrum
classmethod from_table(target, data, **kwargs)#

Construct a Spectrum from a Table.

Parameters:
targetTarget, int, or SkyCoord

Astronomical target with which to associate input data.

Can be a Target, a Gaia Source ID (int), or a SkyCoord.

dataTable

Tabular data containing the relevant fields (i.e. array-like attributes) required to construct a Spectrum. Units are taken from the table where available, with missing units assumed to be those listed above.

**kwargs

Additional keyword arguments to be forwarded to the internal parser.

The following keyword arguments are required: survey

Returns:
Spectrum
show(show_types=False, show_all=False)#

Prints structure to stdout in a human-readable format.

Parameters:
show_typesbool, optional

If True, print data types of structure attributes.

Default is False

show_allbool, optional

If True, do not truncate printing of large iterables.

Default is False.

Returns:
self
to_dataframe()#

Combines all array-like attributes of a structure into a DataFrame.

Units are not preserved.

Returns:
DataFrame
to_hdu() BinTableHDU#

Converts structure into a FITS BinTableHDU.

Returns:
BinTableHDU
to_table()#

Combines all array-like attributes of a structure into a Table, preserving units.

Returns:
Table
vspec(wav_ref: float | Quantity, inplace: bool = True)[source]#

Convert wavelength values to velocity relative to a reference wavelength. This replaces the stored wavelength axis with velocity.

Parameters:
wav_reffloat | Quantity

Reference (rest) wavelength used to compute velocities.

If a Unit is not provided, wav_ref is assumed to be in the same unit as wavelength.

inplacebool, optional

If True, modify the current Spectrum in place - leaving the original unchanged. If False, operate on and return a copy.