edibles.utils package

edibles.utils.VoigtClass module

class edibles.utils.VoigtClass.Voigt[source]

Bases: object

An object with different vesions of the Voigt function.

type

type of voigt function

Type:str
voigtAbsorptionLine(lam, lam_0, b, d, tau_0=0.1, N=None, f=None)[source]

Function that takes in physical parameters and returns absorption line.

Choose either a tau_0 parameter, or N and f together. Default is tau_0.

Parameters:
  • lam (float64) – Wavelength grid
  • lam_0 (float64) – Central wavelength
  • b (float64) – Gaussian standard deviation
  • d (float64) – Damping parameter
  • N (float64) – Column density
  • f (float64) – Oscillator strength
  • tau_0 (float64) – Optical depth at center of line
Returns:

flux array of light transmission

Return type:

ndarray

voigtOpticalDepth(lam, lam_0, b, d, Nf=1.0)[source]

Converts parameters to make proper call to voigtMath

Parameters:
  • lam (float64) – Wavelength grid
  • lam_0 (float64) – Central wavelength
  • b (float64) – Gaussian standard deviation
  • d (float64) – Damping parameter
  • Nf (float64) – Scaling parameter, default = 1.0
Returns:

Optical depth for given input

Return type:

ndarray

edibles.utils.atomic_line_tool module

class edibles.utils.atomic_line_tool.AtomicLines[source]

Bases: object

findIndex(ion, wave)[source]
getAllLabWavelength(ion)[source]
getLabWavelength(ion, wave)[source]
get_f_known(ion, wave)[source]
get_lvl_en_cm_1(ion, wave)[source]

edibles.utils.edibles_oracle module

class edibles.utils.edibles_oracle.EdiblesOracle[source]

Bases: object

This class will process the EDIBLES obs log and target info files. Users can then query the oracle for observations matching specific criteria.

FilterEngine(object, log, value, unc_lower, unc_upper, reference_id)[source]
getFilteredObjects(object=None, Wave=None, EBV=None, EBV_min=None, EBV_max=None, EBV_reference=None, SpType=None, SpType_min=None, SpType_max=None, SpType_reference=None, WaveMin=None, WaveMax=None, LogNHI=None, LogNHI_min=None, LogNHI_max=None, LogNHI_reference=None, LogNHII=None, LogNHII_min=None, LogNHII_max=None, LogNHII_reference=None, fH2=None, fH2_min=None, fH2_max=None, fH2_reference=None, RV=None, RV_min=None, RV_max=None, RV_reference=None, AV=None, AV_min=None, AV_max=None, AV_reference=None)[source]

This method will provide a filtered list of objects that match the specified criteria on sightline/target parameters as well as on observational criteria (e.g. wavelength range). This function consists of two steps:

1. Find all targets that match specified target parameters. This is done for each parameter using the FilterEngine function.
2. Find the objects that match all target specifications.
getFilteredObsList(object=None, Wave=None, MergedOnly=False, OrdersOnly=False, EBV=None, EBV_min=None, EBV_max=None, EBV_reference=None, SpType=None, SpType_min=None, SpType_max=None, SpType_reference=None, WaveMin=None, WaveMax=None, LogNHI=None, LogNHI_min=None, LogNHI_max=None, LogNHI_reference=None, LogNHII=None, LogNHII_min=None, LogNHII_max=None, LogNHII_reference=None, fH2=None, fH2_min=None, fH2_max=None, fH2_reference=None, RV=None, RV_min=None, RV_max=None, RV_reference=None, AV=None, AV_min=None, AV_max=None, AV_reference=None)[source]

This method will provide a filtered list of observations that match the specified criteria on sightline/target parameters as well as on observational criteria (e.g. wavelength range). This function consists of three steps:

1. Find all targets that match specified target parameters. This is done for each parameter using the FilterEngine function.
2. Find the objects that match all target specifications.
3. Find the observations that match specified parameters for only these targets.
getObsListByTarget(target=None, MergedOnly=False, OrdersOnly=False)[source]

This function filters the list of Observations to return only those of the requested target. We will create a set of boolean arrays that we will then combined as the filter.

Parameters:
  • target (object) – Target name that the returned files will include
  • MergedOnly (bool) – Only include spectra from merged orders
  • OrdersOnly (bool) – Only include individual spectrum orders
getObsListByWavelength(wave=None, MergedOnly=False, OrdersOnly=False)[source]

This function filters the list of Observations to return only those that include the requested wavelength. We will create a set of boolean arrays that we will then combined as the filter.

Parameters:
  • wave (float) – Wavelength that the returned files will include
  • MergedOnly (bool) – Only include spectra from merged orders
  • OrdersOnly (bool) – Only include individual spectrum orders

edibles.utils.edibles_spectrum module

class edibles.utils.edibles_spectrum.EdiblesSpectrum(filename, fully_featured=False, noDATADIR=False)[source]

Bases: object

This class takes a spectrum file from EDIBLES, reads the header and data, and creates a DataFrame. The class will also contain a set of methods to operate on the data.

Parameters:
  • filename (str) – Name of the file, starting with the target
  • fully_featured (bool) – If true, EdiblesSpectrum generates the gky transmission and corrected spectrum
  • noDATADIR (bool) – If true, DATADIR will not be added to the front of the filename
header

The header of the FITS file from the observation

Type:astropy.io.fits.header.Header
target

The name of the target

Type:str
datetime

The date of the target observation

Type:datetime.datetime
v_bary

Barycentric velocity of the target star

Type:float
raw_wave

The wavelength data for the spectrum, geocentric reference frame, will not be updated by the functions

Type:1darray
raw_bary_wave

The wavelength data for the spectrum, barycentric reference frame, will not be updated by the functions

Type:1darray
raw_flux

The flux data for the spectrum, will not be updated by the functions

Type:1darray
raw_grid

A grid covering the entire spectral range used for interpolation

Type:1darray
raw_sky_wave

Telluric transmission data covering the entire spectral range

Type:1darray
raw_sky_flux

Telluric transmission data covering the entire spectral range

Type:1darray
wave

The wavelength data for the spectrum, geocentric reference frame, will be updated by the functions

Type:1darray
bary_wave

The wavelength data for the spectrum, barycentric reference frame, will be updated by the functions

Type:1darray
flux

The flux data for the spectrum, will be updated by the functions

Type:1darray
xmin

minimum wavelength boundary of data subset - input to getSpectrum

Type:float
xmax

maximum wavelength boundary of data subset - input to getSpectrum

Type:float
sky_wave

Telluric transmission data - created and updated by getSpectrum

Type:1darray
sky_flux

Telluric transmission data - created and updated by getSpectrum

Type:1darray
grid

Interpolation grid - created by _interpolate

Type:1darray
interp_flux

Interpolated geocentric flux - created by _interpolate

Type:1darray
interp_bary_flux

Interpolated barycentric flux - created by _interpolate

Type:1darray
corrected_wave

The wavelength data for the telluric corrected spectrum, created by corrected_spectrum

Type:1darray
flux_initial

The initial flux data for the telluric corrected spectrum, created by corrected_spectrum

Type:1darray
flux_corrO2

The O2 corrected flux data for the telluric corrected spectrum, created by corrected_spectrum

Type:1array
flux_corrO2_H2O

O2 and H2O corrected flux for the telluric corrected spectrum, created by corrected_spectrum

Type:1array
wave_units

The units of the wavelength data

Type:str
flux_units

The units of the flux data

Type:str
continuum_filename

Name of file with continuum points

Type:astropy.io.fits.header.Header
getSpectrum(xmin, xmax)[source]

Function to update the wavelength region held in an EdiblesSpectrum object.

Parameters:
  • xmin (float) – Minimum wavelength
  • xmax (float) – Maximum wavelength
get_extra_data()[source]

Get sky transmission and atmosphere corrected data about EdiblesSpectrum if fully_featured is False

shift(shift, zoom_xmin, zoom_xmax)[source]
Shift the geocentric and update the barycentric wavelength data.
Reinterpolates after shifting.
Parameters:
  • shift (float or 1darray) – Amount to shift wavelength grid by. If shift is an array, it must be the same length as the wavelength grid.
  • zoom_xmin (float) – New minimum wavelength (must be > old xmin)
  • zoom_xmax (float) – New maximum wavelength (must be < old xmax)
edibles.utils.edibles_spectrum.measure_snr(wave, flux, block_size=1.0, do_plot=False)[source]

Estimate SNR of given spectral data :param wave: wavelength grid :type wave: ndarray :param flux: flux :type flux: ndarray :param do_plot: if set, make SNR plot :type do_plot: bool

Returns:SNR, LAM, SNR and median flux of each of the 1A block
Return type:list

edibles.utils.functions module

edibles.utils.functions.barycorrectSpectrum(wave_array, v_bary)[source]

Barycentric wavelength correction tool.

Parameters:
  • wave_array (ndarray) – The wavelength array of the spectrum
  • v_bary (float64) – The barycentric velocity
Returns:

The corrected wavelength array

Return type:

ndarray

edibles.utils.functions.fitstotxt(target, filepath, writepath, xmin, xmax)[source]

Reads a FITS file, applies barycentric and cloud corrections and writes a subsection within a given range to a .txt file.

Parameters:
  • target (str) – Name of Star
  • filepath (str) – Data storage location
  • writepath (str) – Location of wanted txt file
  • xmin (float64) – Minimum wavelength
  • xmax (float64) – Maximum Wavelength
Returns:

spectrum within given range, tab separated, in a given folder.

Return type:

txt file

Example:
>>> fitstotxt('HD144470', '/data/DR3_fits/', '/home/txtfiles/, 6610, 6618)
# HD144470
# Wavelength(1/cm)      Relative Intensity
3303.1797537322504  1.0084753
3303.199755852153   1.0125096
3303.219757972055   1.012984
3303.2397600919576  1.0122045
edibles.utils.functions.make_grid(lambda_start, lambda_end, resolution=None, oversample=None)[source]
edibles.utils.functions.param_convert(params)[source]

Function to convert voigt parameteres from astronomical to mathematical version.

Parameters:params (tuple) – (cent, b_eff, Gamma, scaling)
Returns:converted parameters
Return type:tuple
edibles.utils.functions.parseTextFile(file_name, delimiter=', ', header=0)[source]

Parse a text file to a list. The file contents are delimited and have a header.

Parameters:
  • file_name (str) – The path to the file
  • delimiter (str) – The delimiter to use to parse the file
  • header (int) – The number of lines at the top of the file to ignore
Returns:

Text file parsed into a list

Return type:

list

edibles.utils.functions.peak_wavelength_all_prominent(wave, flux, prominence)[source]

Function that returns the wavelengths of the lowest n peaks of the equation

Parameters:
  • wave (ndarray) – wavelength grid
  • flux (ndarray) – flux grid
  • prominence (float, between 0 and 1) – prominence of points (see scipy.signal.find_peaks)
Returns:

wavelengths of all prominent peaks

Return type:

list

edibles.utils.functions.peak_wavelength_largest(wave, flux, n=1)[source]

Function that returns the wavelengths of the lowest n peaks of the equation

Parameters:
  • wave (ndarray) – wavelength grid
  • flux (ndarray) – flux grid
  • n (int) – number of peaks to return, default=1
Returns:

wavelengths of lowest n peaks

Return type:

list

edibles.utils.functions.printHeader(input_fits)[source]

A function to print out the header of a FITS file

Parameters:input_fits (str) – Path to FITS file starting from DATADIR
edibles.utils.functions.read_array(filename, dtype, separator=', ')[source]

Read a file with an arbitrary number of columns. The type of data in each column is arbitrary It will be cast to the given dtype at runtime

edibles.utils.functions.read_line_catalog(input_catalog)[source]
(xpos_atoms, labels_atoms) =
read_line_catalog(‘auxilarary_data/line_catalogs/edibles_linelist_atoms.csv’)
edibles.utils.functions.read_sky_transmission(transmission_dat, scale_factor=1.0)[source]
edibles.utils.functions.smooth(y, box_pts)[source]
edibles.utils.functions.vac2air_ciddor(vacw)[source]

Convert vacuum wavelengths in Angstroms to air wavelengths.

This uses the relation from Ciddor 1996, Applied Optics LP, vol. 35, Issue 9, p.1566. Only valid for wavelengths > 2000 Ang.

example:

wt,ft=np.loadtxt(“transmission.dat”, unpack=True) wtc = vac2air_ciddor(wt*10.0) #make sure wave is in Angstroms.

edibles.utils.functions.vac2air_morton(vacw)[source]

Convert vacuum wavelengths in Angstroms to air wavelengths.

This uses the relation from Morton 1991, ApJS, 77, 119. Only valid for wavelengths > 2000 Ang. Use this for compatibility with older spectra that may have been corrected using the (older) Morton relation. The Ciddor relation used in vac2air_ciddor() is claimed to be more accurate at IR wavelengths.

example: wtc = vac2air_morton(wt*10.0) #make sure wave is in Angstroms.

edibles.utils.functions.write_spectrum_ascii(output_name, x, y, yerr, header)[source]

edibles.utils.local_continuum_spline module

edibles.utils.local_continuum_spline.local_continuum(data, positions=None, windows=1.0, spline_order=1, silent=True)[source]

A function that will fit a local continuum spline to a “spectrum” using a list of anchor points. Each anchor point has a “continuum” window (or the same single value for all anchor points). A spline (order s) is fit to the “continuum” data points. The continumm is then created on the input “wavelength” grid. The input data tuple (wave, flux) is then normalised giving (wave, normalised_flux).

Parameters:
  • data (tuple) – In the form (wave, flux)
  • positions (list) – List of spline anchor points
  • windows (list) – List of window sizes around each anchor point (in Angstrom)
  • spline_order (int) – Order (s) of spline fit
  • silent (bool) – If true, no plots will generate. Default: True
Returns:

tuple containing:

tuple: Continuum flux in the form (flux) on the same spectral grid as (wave)

tuple: Normalised input spectrum In the form (normalised_flux)

Return type:

tuple

edibles.utils.voigt module

edibles.utils.voigt.voigtAbsorptionLine(x, lam_0, b, d, tau_0=0.1, N=None, f=None)[source]

Function that takes in physical parameters and returns an absorption line.

Choose either a tau_0 parameter, or N and f together. Default is tau_0.

Parameters:
  • x (float64) – Wavelength grid
  • lam_0 (float64) – Central wavelength
  • b (float64) – Gaussian standard deviation
  • d (float64) – Damping parameter
  • N (float64) – Column density
  • f (float64) – Oscillator strength
  • tau_0 (float64) – Optical depth at center of line
Returns:

flux array of light transmission

Return type:

ndarray

edibles.utils.voigt.voigtMath(x, alpha, gamma)[source]

Function to return the Voigt line shape centered at cent with Lorentzian component HWHM gamma and Gaussian component HWHM alpha.

Creates a Voigt line profile using the scipy.special.wofz, which returns the value of the Faddeeva function.

WARNING scipy.special.wofz is not compaible with np.float128 type parameters.

Parameters:
  • x (float64) – Dimensionless point/array
  • alpha (float64) – Gaussian HWHM component
  • gamma (float64) – Lorentzian HWHM component
Returns:

Flux array for given input

Return type:

ndarray

edibles.utils.voigt.voigtOpticalDepth(x, lam_0, b, d, Nf=1.0)[source]

Converts parameters to make proper call to voigtMath

Parameters:
  • x (float64) – Wavelength grid
  • lam_0 (float64) – Central wavelength
  • b (float64) – Gaussian standard deviation
  • d (float64) – Damping parameter
  • Nf (float64) – Scaling parameter, default = 1.0
Returns:

Optical depth for given input

Return type:

ndarray

edibles.utils.voigt_profile module

edibles.utils.voigt_profile.VoigtFWHM(lambda0, gamma, b)[source]

Calculate FWHM of Voigt using the formula by Olivero. See the bottom of wiki Voigt Profile page

Parameters:
  • lambda0 – center wavelength in AA
  • gamma – Lorentzian gamma (=HWHM), in frequency
  • b – Gaussian b in km/s.
Returns:

Gau_FWHM, Lor_FWHM, V_FWHM, all in km/s

edibles.utils.voigt_profile.fwhm2sigma(fwhm)[source]

Simple function to convert a Gaussian FWHM to Gaussian sigma.

edibles.utils.voigt_profile.getVGrid(lambda0, gamma, b, v_resolution, n_step)[source]

Calculate v grid to be used for Voigt profile Size of grid is determined by the greater of FWHM_Voigt and v_resolution

Returns:dv, velocity grid
edibles.utils.voigt_profile.voigt_absorption_line(wavegrid, lambda0=0.0, f=0.0, gamma=0.0, b=0.0, N=0.0, v_rad=0.0, v_resolution=0.0, n_step=25, debug=False)[source]

Function to return a complete Voigt Absorption Line Model, smoothed to the specified resolution and resampled to the desired wavelength grid. This can in fact be a set of different absorption lines – same line, different cloud components or different line for single cloud component.

Parameters:
  • wavegrid (float64) – Wavelength grid (in Angstrom) on which the final result is desired.
  • lambda0 (float64) – Central (rest) wavelength for the absorption line, in Angstrom.
  • b (float64) – The b parameter (Gaussian width), in km/s.
  • N (float64) – The column density (in cm^{-2})
  • f (float64) – The oscillator strength (dimensionless)
  • gamma (float64) – Lorentzian gamma (=HWHM) component
  • v_rad (float64) – Radial velocity of absorption line (in km/s)
  • v_resolution (float64) – Instrument resolution in velocity space (in km/s)
  • n_step (int) – no. of point per FWHM length, governing sampling rate and efficiency
  • debug (bool) – If True, info on the calculation will be displayed
Returns:

Normalized flux for specified grid & parameters.

Return type:

ndarray

edibles.utils.voigt_profile.voigt_optical_depth(wave, lambda0=0.0, b=0.0, N=0.0, f=0.0, gamma=0.0, v_rad=0.0)[source]

Function to return the value of a Voigt optical depth profile at a given wavelength, for a line centered at lambda0.

Parameters:
  • wave (float64) – Wavelength at which optical depth is to be calculatd (in Angstrom)
  • lambda0 (float64) – Central (rest) wavelength for the absorption line, in Angstrom.
  • b (float64) – The b parameter (Gaussian width), in km/s.
  • N (float64) – The column density (in cm^{-2})
  • f (float64) – The oscillator strength (dimensionless)
  • gamma (float64) – Lorentzian gamma (=HWHM) component
  • v_rad (float64) – Radial velocity of absorption line (in km/s)
Returns:

Optical Depth at wave.

Return type:

float64

edibles.utils.voigt_profile.voigt_profile(x, sigma, gamma)[source]

Function to return the value of a (normalized) Voigt profile centered at x=0 and with (Gaussian) width sigma and Lorentz damping (=HWHM) gamma.

The Voigt profile is computed using the scipy.special.wofz, which returns the value of the Faddeeva function.

WARNING scipy.special.wofz is not compaible with np.float128 type parameters.

Parameters:
  • x (float64) – Scalar or array of x-values
  • sigma (float64) – Gaussian sigma component
  • gamma (float64) – Lorentzian gamma (=HWHM) component
Returns:

Flux array for given input

Return type:

ndarray