extract#
This is the API for the extract module.
Collection of modules used to extract data from fits files from, e.g., model atmospheres from Kurucz to stellar spectra from FIES.
- FIESpipe.extract.extractESPRESSO(filename, to_air=True)#
Extract ESPRESSO data.
Extract header and flux from ESPRESSO S2D file.
Note
The wavelength is in vacuum, so it is converted to air following Husser et al. (2013).
- Parameters:
filename (str) – Path to ESPRESSO fits file.
to_air (bool, optional) – Convert wavelength to air. Default is True.
- Returns:
wavelength, flux, error, header
- Return type:
array, array, array, fits-header
- FIESpipe.extract.extractFIES(filename)#
Extract FIES data (FIEStool).
Extract the flux and wavelength from a FIES fits file.
Adapted and extended from functions written by R. Cardenes, J. Jessen-Hansen, and J. Sinkbaek.
- Parameters:
filename (str) – Path to FIES fits file.
- Returns:
wavelength, flux, error, header
- Return type:
array, array, array, fits-header
- FIESpipe.extract.extractFIESold(filename, return_hdr=False, check_ThAr=True)#
Extract FIES data (FIEStool).
Reads a wavelength calibrated spectrum in IRAF (FIEStool) format. Returns a record array with wavelength and flux order by order as a two column array in data[‘order_i’].
Adapted and extended from functions written by R. Cardenes and J. Jessen-Hansen.
- Parameters:
filename (str) – Name of .fits file.
- Returns:
observed spectrum, wavelength and flux order by order, number of orders for spectrum, name of object, date of observations in UTC, exposure time in seconds
- Return type:
array, int, str, str, float
- FIESpipe.extract.getBarycorrs(filename, rvmeas)#
Barycentric correction.
Function to correct for the barycentric velocity, and convert the time of the observation to BJD TDB.
- Parameters:
filename (str) – FIES fits file.
rvsys (float) – The measured radial velocity. See
barycorrpy@ shbhuk/barycorrpy.
- Returns:
BJD TDB, barycentric velocity correction
- Return type:
float, float
Note
Could be altered to also be able to deal with other instruments.
Exception omits star name, defaults to RA/DEC.
Split into two functions, one for barycentric correction, one for BJD TDB?
- FIESpipe.extract.getKurucz(teff, logg=4.5, feh=0.0, alpha=0.0, url='http://130.79.128.5/ftp/more/splib120/', cache=True)#
Download ATLAS9/Kurucz template
Download ATLAS9/Kurucz template using the effective temperature, surface gravity, metallicity and alpha enhancement values closest to the values provided.
Effective temperature range: 3500-7250 K in steps of 250 K. Surface gravity range: 0.0-5.0 in steps of 0.5 dex. Metallicity values: -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.2, 0.5 dex. Alpha enhancement values: 0.0, 0.4 dex.
- Parameters:
teff (int) – Effective temperature.
logg (float) – Surface gravity. Default is 4.5.
feh (float) – [Fe/H]. Default is ‘0.0’.
alpha (float) – [alpha/Fe]. Default is ‘0.0’.
url – Path to the template files. Default is ‘http://130.79.128.5/ftp/more/splib120/’.
cache (bool) – Cache the downloaded file. Default is True.
- Returns:
File name of the downloaded template.
- Return type:
str
- FIESpipe.extract.getOrder(wl, wave, rv=0.0)#
Order at a given wavelength.
Get the orders containing a given wavelength.
- Parameters:
wl (float) – Wavelength at which to find the order.
wave (array) – Wavelength array.
rv (float) – Radial velocity of the star. Optional, default is 0.0 km/s.
- Returns:
List of orders that contain the wavelength.
- Return type:
list
- FIESpipe.extract.getPhoenix(teff, logg=4.5, feh=0.0, alpha=0.0, url='ftp://phoenix.astro.physik.uni-goettingen.de/v2.0/HiResFITS/', cache=True)#
Download PHOENIX template
Download PHOENIX template using the effective temperature, surface gravity, metallicity and alpha enhancement values closest to the values provided.
Effective temperature range: 2300-7100 K in steps of 100 K, 7200-13200 K in steps of 200 K. Surface gravity range: 0.0-6.0 in steps of 0.5 dex. Metallicity values: -4.0, -3.0, -2.0, -1.0, 0.0, 0.2, 0.5 dex. Alpha enhancement values: -0.2 to 1.2 in steps of 0.2 dex.
Similar to Hoeijmakers/StarRotator.
- Parameters:
teff (int) – Effective temperature in K.
logg (float) – Surface gravity. Default is 4.5.
feh (float) – [Fe/H]. Default is ‘0.0’.
alpha (float) – [alpha/Fe]. Default is ‘0.0’.
url – Path to the template files. Default is ‘ftp://phoenix.astro.physik.uni-goettingen.de/v2.0/HiResFITS/’.
cache (bool) – Cache the downloaded file. Default is True.
- Returns:
File names of the downloaded templates.
- Return type:
str
- FIESpipe.extract.grids(rvr=401, R=67000, s=2.1, fib=None)#
Grids for CCFs.
Create the CCF grids for the given radial velocity range and resolution. As the velocity grid will be scaled, the radial velocity range is altered slightly. Therefore, there is a difference between the desired radial velocity range and the actual one.
A (typically) finer grid is also created for the CCFs, with a resolution of 250 m/s.
- Parameters:
rvr (int) – (Desired) radial velocity range for the CCF in km/s. Default is 401.
R (float) – Spectral resolution. Default is 67000 (FIES fibre 4, see
velRes()).s (float) – Spectral sampling in pixels per spectral element. Default is 2.1 (FIES, see
velRes()).fib (int) – Fibre number. Default is
None. IfNone, the default values are used (fibre 4).
- Returns:
CCF grid, CCF error grid, actual radial velocity range, finer CCF grid, finer CCF error grid, finer radial velocity range
- Return type:
array, array, int, array, array, int
- FIESpipe.extract.groupByEpochs(path, thresh=0.041666666666666664)#
Group spectra by epochs.
Function to group spectra by epochs, in the sense that spectra obtained in quick succession are grouped together. Intended for observing strategies of the type:
![digraph acq {
rankdir="LR";
th1 -> sci1 -> sci2 -> sci3 -> th2;
th1 [shape=box, label="ThAr"];
th2 [shape=box, label="ThAr"];
sci1 [label="Science"];
sci2 [label="Science"];
sci3 [label="Science"];
}](../_images/graphviz-b550518f3e816a6cf2e135a7f838400919c398a1.png)
- Parameters:
path (str) – Path to files.
thresh (float) – Threshold for grouping epochs, in days. Default
1/24(1 hour).
- Returns:
Dictionary with epochs (labeled as 1,2,3,…) as keys, and lists of filenames and timestamps (\(\mathrm{BJD}_\mathrm{TDB}\)) as values.
- Return type:
dict
- FIESpipe.extract.readKurucz(filename)#
Read Kurucz/ATLAS9 stellar template.
Extract template wavelength and flux from Castelli and Kurucz (2003).
Available here.
- Parameters:
filename (str) – Path to template.
- Returns:
template wavelength, template flux
- Return type:
array, array
- FIESpipe.extract.readPhoenix(specname, wavename='', wl_min=3600, wl_max=8000, to_air=True)#
Read PHOENIX stellar template.
Extract template wavelength and flux from Husser et al. (2013).
Avaliable here.
To go from vacuum to air wavelength, the function uses Eq. (9-10) from Husser et al. (2013).
- Parameters:
specname (str) – Path to template.
wavename (str) – Path to wavelength file. Default is
'', no wavelength.wl_min (float, optional) – Minimum wavelength to keep. Default is 3600 Å.
wl_max (float, optional) – Maximum wavelength to keep. Default is 8000 Å.
to_air (bool, optional) – Convert wavelength to air. Default is True.
- Returns:
template wavelength, template flux
- Return type:
array, array
- FIESpipe.extract.sortFIES(path)#
Sort files in Science/ThAr.
Function that returns list of science and/or ThAr spectra from FIES.
- Parameters:
path (str) – Path to files.
- Returns:
list of science spectra, list of ThAr spectra
- Return type:
list, list
- FIESpipe.extract.velRes(R=67000, s=2.1, fib=None)#
Velocity resolution.
The resolution of the spectrograph in velocity space.
\[\Delta v = \frac{c}{R \cdot s}\]where \(c\) is the speed of light, \(R\) is the spectral resolution, and \(s\) is the spectral sampling in pixels per spectral element.
The default values are for the FIES spectrograph, collected from: http://www.not.iac.es/instruments/fies/fies-commD.html#wavelengths
- Parameters:
R (float) – Spectral resolution. Default is 67000.
s (float) – Spectral sampling in pixels per spectral element. Default is 2.1.
fib (int) – Fibre number. Default is
None. IfNone, the default values are used (fibre 4).
- Returns:
Velocity resolution in km/s.
- Return type:
float