Scripts

Scripts provided with eniric.

phoenix_precision.py

Script to generate RV precision of synthetic spectra, see Calculating Precisions.

scripts.phoenix_precision.check_model(model: str) → str[source]

Check model is ‘aces’ or ‘btsettl’.

Parameters:model (str) – Model name. Should be either ‘aces’ or ‘btsettl’.
Returns:model – Valid model output; either ‘aces’ or ‘btsettl’.
Return type:str
scripts.phoenix_precision.convolve_and_resample(wav: numpy.ndarray, flux: numpy.ndarray, vsini: float, R: float, band: str, sampling: float, **conv_kwargs) → Tuple[numpy.ndarray, numpy.ndarray][source]

Convolve and resample functions together.

Returns:
  • wav_grid (ndarray) – Resampled wavelength array
  • sampled_flux (ndarray) – Convolved and resampled flux array
scripts.phoenix_precision.do_analysis(star_params, vsini: float, R: float, band: str, sampling: float = 3.0, conv_kwargs=None, snr: float = 100.0, ref_band: str = 'J', rv: float = 0.0, air: bool = False, model: str = 'aces', verbose: bool = False) → Tuple[astropy.units.quantity.Quantity, ...][source]

Calculate RV precision and Quality for specific parameter set.

Parameters:
  • star_param – Stellar parameters [temp, logg, feh, alpha] for phoenix model libraries.
  • vsini (float) – Stellar equatorial rotation.
  • R (float) – Instrumental resolution.
  • band (str) – Spectral band.
  • sampling (float (default=False)) – Per pixel sampling (after convolutions)
  • conv_kwargs (Dict (default=None)) – Arguments specific for the convolutions, ‘epsilon’, ‘fwhm_lim’, ‘num_procs’, ‘normalize’, ‘verbose’.
  • snr (float (default=100)) – SNR normalization level. SNR per pixel and the center of the ref_band.
  • ref_band (str (default="J")) – Reference band for SNR normalization.
  • rv (float) – Radial velocity in km/s (default = 0.0).
  • air (bool) – Get model in air wavelengths (default=False).
  • model (str) – Name of synthetic library (aces, btsettl) to use. Default = ‘aces’.
  • verbose – Enable verbose (default=False).
Returns:

  • q (astropy.Quality) – Spectral quality.
  • result_1 (astropy.Quality) – RV precision under condition 1.
  • result_2 (astropy.Quality) – RV precision under condition 2.
  • result_3 (astropy.Quality) – RV precision under condition 3.

Notes

We apply the radial velocity doppler shift after
  • convolution (rotation and resolution)
  • resampling
  • SNR normalization.

in this way the RV only effects the precision due to the telluric mask interaction. Physically the RV should be applied between the rotational and instrumental convolution but we assume this effect is negligible.

scripts.phoenix_precision.get_already_computed(filename: str, add_rv: bool = False) → List[str][source]

Get the string of already computed model/parameters from the result file.

scripts.phoenix_precision.header_row(add_rv=False) → str[source]

Header row for output file.

scripts.phoenix_precision.is_already_computed(computed_values: List[str], model, pars, add_rv: bool = False, correct: bool = False, verbose=False) → bool[source]

Check if any combinations have already been preformed. Correct is boolean for applied Artigau correction.

scripts.phoenix_precision.model_format_args(model, pars)[source]

Format the model and parameter args to save in output file. Change to int, str and float.

model in [temp, logg, fe/h, alpha] pars in order (R, band, vsini, sample).

Can now also optionally handle a 5th parameter RV.

scripts.phoenix_precision.select_csv_columns(line: str, ncols: int = 8) → str[source]

Select first ncols in a line from a csv.

Parameters:ncols (int) – Number of column to select.
Returns:selected_cols – Selected ncols of csv.
Return type:str

barycenter_broaden_atmmodel

Doppler shift the Tapas atmosphere model and save to files. This makes the RV precision calculations faster.

scripts.barycenter_broaden_atmmodel.main(bands: Optional[List[str]] = None, verbose: bool = False) → None[source]

Preform the barycentric shifting of atmosphere masks and saves result.

This saves time in the precision determination code.

Parameters:bands (list of str) – Wavelength bands to perform barycenter shifts on. Default is all bands.

split_atmmodel

Script to split the large atmospheric model transmission spectra into the separate bands. This create smaller files to load for each band for individual bands only.

scripts.split_atmmodel.check_positive(value: str) → float[source]

Check if input is positive.

http://stackoverflow.com/questions/14117415.

Parameters:value (str) – A input string from argparse to check if it is a positive number.
Returns:float_value – The value if it is positive as a float.
Return type:float
Raises:ArgumentTypeError: – If value is not a positive number.
scripts.split_atmmodel.main(model: str = 'Average_TAPAS_2014.dat', bands: Optional[List[str]] = None, new_name: Optional[str] = None, data_dir: Optional[str] = None, rv_extend: float = 100.0, cutoff_depth: float = 2.0, verbose: bool = False)[source]

Split the large atmospheric model transmission spectra into the separate bands.

Keeps wavelength of atmosphere model as nanometers.

Parameters:
  • model (str) – Telluric model file to load. It has columns wavelength, flux, std_flux, mask.
  • bands (list[str]) – List bands to split model into separate files.
  • new_name (str) – New file name base.
  • data_dir (Optional[str]) – Directory for results. Can also be given in config.yaml “paths:atmmodel:”…
  • rv_extend (float) – Absolute RV to extend wavelength range of telluric band. To later apply barycenter shifting. Default is 100.
  • cutoff_depth (float) – Telluric line depth cutoff percent. Default = 2.0.
Returns:

exit_status – Unix-like exit. Non-zero indicates a failure occurred.

Return type:

int

precision_four_panel.py

Plot a Figueira et al. (2016) Figure 1 like plot.

scripts.precision_four_panel.cumulative_df(df, full_cum=False)[source]

Calculated cumulative RV precision across bands. The precision of “Z”, “ZY”, “ZYJ”, “ZYJH”, “ZYJHK” bands.

Parameters:
  • df (pandas.DataFrame) – DataFrame.
  • full_cum (bool) – Include “YJHK”, “JHK”, “HK”, “K” grouping also. Default is False.
scripts.precision_four_panel.cumulative_plot(precision_file, teffs=None, logg=4.5, fe_h=0.0, vsini=1.0, sampling=3, full_cum=False)[source]

RV precision with cumulative bands.

full_cum: bool Cumlative over entire range [ “Z”,”ZY”, “ZYJ”, “ZYJH”, “ZYJHK”,”YJHK”, “JHK”,”HK”,”K”]

Saves figure to plots/.

Parameters:
  • precision_file (str) – Name of phoenix_precision.py output.
  • teffs (List of int or None) – Stellar temperatures. Default is [3900, 3500, 2800, 2600].
  • logg (int) – Stellar Logg. Default is 4.5.
  • fe_h (int) – Stellar metallicity. Default is 0.0.
  • vsini (float) – Rotational velocity. Default is 1.0.
  • sampling – Spectral sampling. Default is 3.
  • full_cum (bool) – Cumulative over entire range. Default is False.
scripts.precision_four_panel.filter_df(df, filter_dict, drop_list=None)[source]

Filter DataFrame by dictionary of key and values.

scripts.precision_four_panel.load_dataframe(filename)[source]

Load in precision file, clean up spaces in csv.

Parameters:filename (str) – Name of phoenix_precision.py output.
Returns:df – DataFrame of data.
Return type:pandas.DataFrame
scripts.precision_four_panel.plot_precision(precision_file, teffs=None, logg=4.5, fe_h=0.0, vsini=1.0, sampling=3)[source]

Plot precision 4 panel with RV precision.

Saves figure to plots/.

Parameters:
  • precision_file (str) – Name of phoenix_precision.py output.
  • teffs (List of int or None) – Stellar temperatures. Default is [3900, 3500, 2800, 2600].
  • logg (int) – Stellar Logg. Default is 4.5.
  • fe_h (int) – Stellar metallicity. Default is 0.0.
  • vsini (float) – Rotational velocity. Default is 1.0.
  • sampling – Spectral sampling. Default is 3.
Example relative precisions from ``precision_four_panel.py``

csv2tsv.py

Simple script using pandas to transform from *.csv to *.tsv.

untar_here.py

Bundled script to un-tar the eniric data downloaded.

Uses the tarfile module to extract the data.

Download Scripts

Scripts to download the eniric data and phoenix data. They can be run from the command line.

scripts/download/download_eniric_data.sh

This is also available as a powershell script.

scripts/download/ps_download_eniric_data.ps1

The test data from the PHOENIX-ACES library is specifically downloaded using Starfish utilities in

scripts/download/download_test_aces.py.