Workflows#
Different workflows that stitch the various modules in FIESpipe together to obtain the parameters of interest.
- FIESpipe.workflows.standard(filename, ins='FIES', orders=[], exclude=[], rvsys=None, gauss=False, pidx=3, rvr=41, chi2rvr=20, crmit=False, out=True, sigma=3, npoly=2, CaIIH=3968.47, CaIIK=3933.664, width=1.09, Rsection_low=3991.07, Rsection_high=4011.07, Vsection_low=3891.07, Vsection_high=3911.07, outdir=None, return_data=False, verbose=False)#
Standard workflow for FIES data extraction.
A collection of calls to the various modules in
FIESpipeto obtain the parameters of interest. This processing routine should work regardless of how the data has been acquired.Flowchart of the workflow:
![digraph G {
size ="4,4";
filename -> BJD_TDB, BVC;
filename -> spectrum;
template -> spectrum;
spectrum [shape=box]; /* this is a comment */
spectrum -> order [weight=8,label="Each order"];
order -> RV;
order -> Sidx;
order -> CCF;
BVC -> RV [style=dotted];
edge [color=red]; // so is this
CCF -> BIS [label="Summed CCF all orders"];
node [shape=box,style=filled,color=".7 .3 1.0"];
RV -> product [label="Weighted average"];
BJD_TDB -> product;
Sidx -> product;
CCF -> product;
BIS -> product;
}](_images/graphviz-01b9cf5cab23b4ca718de271b90545613bf634df.png)
S-index derived from the Ca II H and K lines following the approach in Section 3.1.2 of Boro Saikia et al. (2018).
- Parameters:
filename (str) – Name of the file to be processed.
ins (str) – Instrument used to acquire the data. Currently only FIES is supported.
orders (list) – List of orders to be processed. If empty, all orders are processed.
exclude (list) – List of orders to be excluded from the processing.
rvsys (float) – Systemic RV in km/s of the target. If not provided, an estimate is calculated.
gauss (bool) – If
True, the \(\chi^2\) RVs are fitted with a gaussian. IfFalse, a second order polynomial is fitted.pidx (int) – Number of indices on either side of peak for polynomial used to fit the \(\chi^2\) RVs. Default is 3.
rvr (float) – RV range in km/s for the CCFs.
chi2rvr (float) – RV range in km/s for the \(\chi^2\) minimization.
crmit (bool) – Cosmic ray mitigation. If
False, no mitigation is performed.out (bool) – Outlier rejection for \(\chi^2\) RVs. If
True, the \(\chi^2\) RVs are rejected if they are more thansigmaaway from the median.sigma (float) – Number of sigma for the outlier rejection.
npoly (int) – Degree of the polynomial used to normalize the spectrum.
CaIIH (float) – Wavelength of the Ca II H line in Å. Default is 3968.47 Å.
CaIIK (float) – Wavelength of the Ca II K line in Å. Default is 3933.664 Å.
width (float) – Width of the Ca II lines in Å. Default is 1.09 Å.
Rsection_low (float) – Lower limit of the wavelength range for the red continuum (Boro Saikia et al., 2018) in Å.
Rsection_high (float) – Upper limit of the wavelength range for the red continuum (Boro Saikia et al., 2018) in Å.
Vsection_low (float) – Lower limit of the wavelength range for the blue continuum (Boro Saikia et al., 2018) in Å.
Vsection_high (float) – Upper limit of the wavelength range for the blue continuum (Boro Saikia et al., 2018) in Å.
outdir (str) – Output directory. If not provided, the current directory is used.
return_data (bool) – If
True, the data structure is returned.verbose (bool) – If
True, the processing is verbose.
- Returns:
Dictionary with the results of the processing.
- Return type:
dict
Note
For poor data/low S/N, the Gaussian fits can crash.
np.nanis inserted into the output dictionary.For now, the template is hardcoded. This should be fixed in the future.
Oversampled CCFs are hardcoded to be 0.25 km/s.
BIS error seems rather large. Determined from oversampled CCFs, but Lafarga et al. (2020) uses the actual velocity resolution and gets a much smaller error.
- S-index should perhaps be estimated from the merged spectrum instead?
…merged spectrum should perhaps also be used for the first guess for the systemic velocity?
…and to estimate \(T_\mathrm{eff}\), \(\log g\), and \([\mathrm{Fe/H}]\)?
- RV \(\chi^2\) minimization can be done by fitting a gaussian.
Default is a second order polynomial fit as in Zechmeister et al. (2018).
This seems more robust, but the gaussian fit seems to have less RV drift across the orders, because the wings are taking into account.
The weighted mean and error seem to agree quite well between the two methods.
Naming scheme for the output files, revise?
- How do we provide the template?
Option to provide [temp_wl,temp_fl] as input?
Option to provide a filename for a Kurucz atmosphere?
Option to give \(T_\mathrm{eff}\), \(\log g\), and \([\mathrm{Fe/H}]\) and find best-matching Kurucz atmosphere in local dir?
- It seems for hot stars, the CCFs for some orders are not very good.
Maybe a selection of orders should be made based on the \(T_\mathrm{eff}\)?
Or we find the S/N for a CCF in a given order and reject orders with low S/N?
Fast rotators… Broadening function?
Example
>>> import FIESpipe as fp >>> filename = 'FIEf100105_step010_wave.fits' >>> data = fp.standard(filename)
Plots can be made with the
FIESpipe.evince()functions, for instance, the CCFs:>>> fp.plotCCFs(data)
- FIESpipe.workflows.servalish(filenames, run_standard=True, knot_freq=1, sigma=5, window_length=51, sk=3, ck=3, outer=1, ignore=False, norders=range(20, 70), out=True, sigma_out=5, chi2rvr=20, dv=0.1, pidx=3, **std_kwargs)#
SERVAL style template matching
Radial velocity extraction through template matching in the style of mzechmeister/serval (Zechmeister et al., 2018).
Cubic B-spline using
scipy.interpolate.splrep()andscipy.interpolate.Bspline().When creating the knots for the spline, the attempt is to get as close to the ones returned by the
SERVALsplines (mzechmeister/serval), this is achieved with inspiration from this answer: https://stackoverflow.com/questions/49191877/how-to-set-manual-knots-in-scipy-interpolate-splprep-in-case-of-periodic-boundar- Parameters:
filenames (list) – List of filenames to use for template matching. Should be larger than 3.
run_standard (bool) – Run the standard reduction in
FIESpipe.workflows.standard()before template matching. Default is True, otherwise give a list of data products already produced byFIESpipe.workflows.standard().knot_freq (float) – Frequency of knots in the spline. Default is 1, which means that the number of knots are equal to the wavelength spacing in a given order.
sigma (float) – Sigma clipping for outlier rejection when creating the master template. Default is 5.
window_length (int) – Window length for Savitzky-Golay filter. Default is 51.
sk (int) – Degree of Savitzky-Golay filter. Default is 3.
ck (int) – Degree of cubic B-spline. Default is 3.
outer (int) – Number of iterations for outlier rejection when creating the master template. Default is 1.
ignore (bool) – Ignore the check that the number of files is larger than 3. Default is False.
norders (list) – Orders to use for RV extraction. Default is range(20,70).
out (bool) – Use outlier rejection when extracting RVs. Default is True.
sigma_out (float) – Sigma clipping for outlier rejection when extracting RVs. Default is 5.
chi2rvr (float) – RV range for \(\chi^2\) fit. Default is 20 (km/s).
dv (float) – Step size for \(\chi^2\) fit. Default is 0.1 (km/s).
pidx (int) – Number of indices to include in fitting the 2nd order polynomial to the \(\chi^2\) fit. Default is 3.
std_kwargs (dict) – Keyword arguments for
FIESpipe.workflows.standard().
- Returns:
Dictionaries with the data products from the template matching, and the final data products.
- Return type:
dict, dict
Note
Using cubic B-spline from
scipyinstead of the ones from mzechmeister/serval.- The weights for creating the spline are just taken as \(1/\sigma_f\)
maybe more weighting could improve the results, like deweighting of telluric lines?
A second pair of eyes on the subtraction and adding of the barycentric correction would be good.
Find the best way to filter out low S/N orders.
Example
>>> import FIESpipe as fp >>> import glob >>> filenames = glob.glob('FI*_wave.fits') >>> sdata = fp.servalish(filenames)
Plots can be made with the
FIESpipe.evince()functions, for instance, the coadded template:>>> fp.plotCoaddTemplate(sdata)
- FIESpipe.workflows.prepareSpectra(filenames, norders, tw, tf, pidx=4, drvs_coarse=array([-200, -199, -198, -197, -196, -195, -194, -193, -192, -191, -190, -189, -188, -187, -186, -185, -184, -183, -182, -181, -180, -179, -178, -177, -176, -175, -174, -173, -172, -171, -170, -169, -168, -167, -166, -165, -164, -163, -162, -161, -160, -159, -158, -157, -156, -155, -154, -153, -152, -151, -150, -149, -148, -147, -146, -145, -144, -143, -142, -141, -140, -139, -138, -137, -136, -135, -134, -133, -132, -131, -130, -129, -128, -127, -126, -125, -124, -123, -122, -121, -120, -119, -118, -117, -116, -115, -114, -113, -112, -111, -110, -109, -108, -107, -106, -105, -104, -103, -102, -101, -100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199]), outdir=None)#
- Parameters:
outdir (str) – Output directory. If not provided, the current directory is used.
- FIESpipe.workflows.prepareThAr(tharnames, norders, outdir=None)#
Prepare ThAr spectra for template matching.
- Parameters:
tharnames (list) – List of ThAr filenames.
norders (list) – List of orders to use.
outdir (str) – Output directory. If not provided, the current directory is used.
- Returns:
Dictionary with the prepped spectra.
- Return type:
dict