EchelleSpectrum#

class aesop.EchelleSpectrum(spectrum_list, header=None, name=None, fits_path=None, time=None)[source]#

Bases: object

Echelle spectrum of one or more spectral orders.

The spectral orders will be indexed in order of increasing wavelength.

Parameters:
spectrum_listlist of Spectrum1D objects

List of Spectrum1D objects for the spectra in each echelle order.

headerastropy.io.fits.header.Header (optional)

FITS header object associated with the echelle spectrum.

namestr (optional)

Name of the target or a name for the spectrum

fits_pathstr (optional)

Path where FITS file was opened from.

timeTime (optional)

Time at which the spectrum was taken

Methods Summary

barycentric_correction([time, skycoord, ...])

Barycentric velocity correction, code from StuartLittlefair (https://gist.github.com/StuartLittlefair/5aaf476c5d7b52d20aa9544cfaa936a1)

continuum_normalize_from_standard(...[, ...])

Normalize the spectrum by a polynomial fit to the standard's spectrum.

continuum_normalize_lstsq(polynomial_order)

Normalize the spectrum with a robust least-squares polynomial fit to the spectrum of each order.

fit_order(spectral_order, polynomial_order)

Fit a spectral order with a polynomial.

from_fits(path[, format])

Load an echelle spectrum from a FITS file.

get_order(order)

Get the spectrum from a specific spectral order

offset_wavelength_solution(wavelength_offset)

Offset the wavelengths by a constant amount in each order.

predict_continuum(spectral_order, fit_params)

Predict continuum spectrum given results from a polynomial fit from EchelleSpectrum.fit_order.

rv_wavelength_shift(spectral_order[, T_eff, ...])

Solve for the radial velocity wavelength shift.

rv_wavelength_shift_ransac([min_order, ...])

Solve for the radial velocity wavelength shift of every order in the echelle spectrum, then do a RANSAC (outlier rejecting) linear fit to the wavelength correction between orders min_order and max_order.

to_Spectrum1D()

Convert this echelle spectrum into a simple 1D spectrum.

Methods Documentation

barycentric_correction(time=None, skycoord=None, location=None)[source]#

Barycentric velocity correction, code from StuartLittlefair (https://gist.github.com/StuartLittlefair/5aaf476c5d7b52d20aa9544cfaa936a1)

Uses the ephemeris set with astropy.coordinates.solar_system_ephemeris.set for corrections.

For more information see solar_system_ephemeris.

Will attempt to get the necessary info from the header if possible, otherwise requires time, skycoord, and location parameters to be set.

Parameters:
timeTime

The time of observation, optional

skycoord: `~astropy.coordinates.SkyCoord`

The sky location to calculate the correction for, optional.

location: `~astropy.coordinates.EarthLocation`, optional

The location of the observatory to calculate the correction for.

Returns:
barycentric_velocityQuantity

The velocity correction that was added to the wavelength arrays of each order.

continuum_normalize_from_standard(standard_spectrum, polynomial_order, only_orders=None, plot_masking=False, plot_fit=False)[source]#

Normalize the spectrum by a polynomial fit to the standard’s spectrum.

Parameters:
standard_spectrumEchelleSpectrum

Spectrum of the standard object

polynomial_orderint

Fit the standard’s spectrum with a polynomial of this order

only_ordersndarray

Only do the continuum normalization for these echelle orders.

plot_maskingbool

Plot the masked-out low S/N regions

plot_fitbool

Plot the polynomial fit to the standard star spectrum

continuum_normalize_lstsq(polynomial_order, only_orders=None, plot=False, fscale_mad_factor=0.2)[source]#

Normalize the spectrum with a robust least-squares polynomial fit to the spectrum of each order.

Parameters:
polynomial_orderint

Fit the standard’s spectrum with a polynomial of this order

only_ordersndarray (optional)

Only do the continuum normalization for these echelle orders.

plot_maskingbool (optional)

Plot the masked-out low S/N regions

plot_fitbool (optional)

Plot the polynomial fit to the standard star spectrum

fscale_mad_factorfloat (optional)

The robust least-squares fitter will reject outliers by keeping the standard deviation of inliers close to fscale_mad_factor times the median absolute deviation (MAD) of the fluxes.

fit_order(spectral_order, polynomial_order, plots=False)[source]#

Fit a spectral order with a polynomial.

Ignore fluxes near the CaII H & K wavelengths.

Parameters:
spectral_orderint

Spectral order index

polynomial_orderint

Polynomial order

Returns:
fit_paramsndarray

Best-fit polynomial coefficients

classmethod from_fits(path, format=None)[source]#

Load an echelle spectrum from a FITS file.

Parameters:
pathstr

Path to the FITS file

get_order(order)[source]#

Get the spectrum from a specific spectral order

Parameters:
orderint

Echelle order to return

Returns:
spectrumSpectrum1D

One order from the echelle spectrum

offset_wavelength_solution(wavelength_offset)[source]#

Offset the wavelengths by a constant amount in each order.

Parameters:
wavelength_offsetQuantity or list

Offset the wavelengths by this amount. If wavelength_offset is a list, each value will be treated as an offset for on echelle order, otherwise a single wavelength_offset will be applied to every order.

predict_continuum(spectral_order, fit_params)[source]#

Predict continuum spectrum given results from a polynomial fit from EchelleSpectrum.fit_order.

Parameters:
spectral_orderint

Spectral order index

fit_paramsndarray

Best-fit polynomial coefficients

Returns:
flux_fitndarray

Predicted flux in the continuum for this order

rv_wavelength_shift(spectral_order, T_eff=None, plot=False)[source]#

Solve for the radial velocity wavelength shift.

Parameters:
spectral_orderint

Echelle spectrum order to shift

rv_wavelength_shift_ransac(min_order=10, max_order=45, T_eff=4700)[source]#

Solve for the radial velocity wavelength shift of every order in the echelle spectrum, then do a RANSAC (outlier rejecting) linear fit to the wavelength correction between orders min_order and max_order.

Parameters:
min_orderint

Index of the bluest order to fit in the wavelength correction

max_orderint

Index of the reddest order to fit in the wavelength correction

T_effint

Effective temperature of the PHOENIX model atmosphere to use in the cross-correlation.

Returns:
wlQuantity

Wavelength corrections for each order.

to_Spectrum1D()[source]#

Convert this echelle spectrum into a simple 1D spectrum.

In wavelength regions where two spectral orders overlap, take the mean of the overlapping region.

Parameters:
mad_outlier_factorfloat

Mask positive outliers max_outlier_factor times the median absolute deviation plus the median of the fluxes.

Returns:
spectrumSpectrum1D

Simple 1D spectrum.