API

class actin2.actin2.ACTIN

The ACTIN class. Reads fits files and calculates activity indices.

Any index is calculated as

\[I = \frac{\sum C_i F_i}{\sum K_j R_j}\]

where \(F_i\) and \(R_j\) are the flux inside the activity sensitive lines and reference bands, respectively. \(C_i\) and \(K_j\) are constants to be multiplyed to the \(F_i\) and \(R_j\) fluxes.

Class attributes:

ReadSpec

Object that reads spectrum and headers. See actin2.readspec.ReadSpec

Type:

actin2.ReadSpec

IndTable

Object containing the indices parameters table. See actin2.indtable.IndTable

Type:

actin2.IndTable

CalcIndices

Object that calculates the indices. See actin2.calcindices.CalcIndices

Type:

actin2.CalcIndices

plot_index_line(file, line_id, table_df=None, wkey='wave', fkey='flux', show=True, ntol=4, show_bandpass=True, spec_kw={}, **plt_kw)

Plot spectral line ‘line_id’.

plot_index_lines(file, index, table_df=None, wkey='wave', fkey='flux', ntol=2, show=True, spec_kw={}, **plt_kw)

Plot spectral lines and bandpasses used to calculate index ‘index’.

run(files, indices, obj_in=None, save_data=None, progress=True, verb=False, table_df=None, spec_kw={}, calcind_kw={})

Run ACTIN for a list of fits files and indices.

Parameters:
  • files (list, str) – List of fits files paths, or string with one fits file path to be read.

  • indices (list, str) – List of indices identification (as in the indices table) to be calculated. If empty returns the fits headers only.

  • rv_in (float, None) – If float, use this RV value to shift spectrum to stellar rest frame, if None use RV value from fits file.

  • spec_class_in (None, str) – Name of the spectrograph to be read. Usefull if new spectrographs are added to the ACTIN spectrograph directory.

  • obj_in (str, None) – If not None, the target name from the fits file is overriden by this input.

  • save_data (str, None) – path with file_name to save output in csv format.

  • progress (bool) – If True show progress bar.

  • table_df (None, pd.DataFrame) – Table DataFrame with the indices parameters. If None use the default table.

  • verb (bool) – Activate verbose option.

Returns:

Output pandas table.

Return type:

pandas.DataFrame

class actin2.readspec.ReadSpec(file, verb=False, spec_class_in=None, spec_file_in=None, **spec_kw)

Extracts data from spectrograph fits files.

Parameters:
  • file (str) – Fits file path containing the spectral data.

  • spec_class_in (str, None) – Spectrograph class identification. Useful if new spectrographs are added.

  • verb (bool) – Turn verbose on/off.

  • **spec_kw (dict) – Additional keyword arguments to be passed to the spectrograph class.

Class attributes:

spectrum

Dictionary containing wavelength and flux

Type:

dict

header

Dictionary containing selected headers from the fits file

Type:

dict

spec

The spectrograph class.

Type:

object

plot_spec(key_wave='wave', key_flux='flux', order=None, ax=None, show=False, **plt_kw)

Plot spectrum.

Parameters:
  • key_wave (str, option) – Keyword for the wavelength array stored in spectrum dictionary.

  • key_flux (str, option) – Keyword for the flux array stored in spectrum dictionary.

  • order (int, None) – Spectral order to plot if using 2D spectrum.

  • ax (matplotlib.axes, None) – Axes for the plot. If None creates plt axes.

  • show (bool) – If True show the plot.

  • **plt_kw – Additional keyword arguments to be passed to plt.plot().

class actin2.indtable.IndTable(table_csv=None, verb=False)

Class to manipulate the indices table.

Parameters:

table_csv (str, None) – Path to the csv table with indices data. If None use built-in table (default).

Class attributes:

table

Table with indices.

Type:

pd.DataFrame

indices

List of available indices.

Type:

list

params

List of required index line parameters.

Type:

list

add_line(ind_id, ind_var, ln_id, ln_c, ln_ctr, ln_win, bandtype)

Add a line to the indices table.

Parameters:
  • ind_id (str) – Index identification for the line.

  • ind_var (str) – A string identifying the line as activity line (if L1, L2, …) or reference band (if R1, R2, …).

  • ln_id (str) – Line identification

  • ln_c (float) – Constant value to be multiplied to the line.

  • ln_ctr (float) – Line centre [angstrom]

  • ln_win (float) – Line bandwidth [angstrom]

  • bandtype (str) – Bandpass type. If sq is square filter, if tri is triangular filter where ln_win will be the triangle FWHM.

class actin2.calcindices.CalcIndices(spectrum, headers, indices, step=0.001, table_df=None, plot_lines=False, full_output=False, interp=True, verb=False)

Calculates activity indices.

Parameters:
  • spectrum (dict) – Dictionary containing wavelength wave and flux flux data.

  • headers (dict) – Dictionary containing useful fits headers information.

  • indices (list, str) – List of indices ìnd_id to be extracted.

  • step (float) – Step used in interpolation. Must have interp=True

  • table_df (pd.DataFrame, None) – Indices table to be used as input. If None the default actin_table.csv will be used.

  • plot_lines (bool) – Diagnostic plot.

  • full_output (bool) – if True the output includes the fluxes and errors in of each line.

  • interp (bool) – Use interpolation to reeduce the effect of finite resolution of thhe spectrographs. The interpolation step is step value.

  • verb (bool) – Turn verbose on/off.

indices

Dictionary with indices data.

Type:

dict

_calc_Rneg_ln(flux)

Negative flux ratio.

\[R_\mathrm{neg} = \frac{\sum(F_\mathrm{neg})} {\sum(F_\mathrm{tot})}\]
Parameters:

flux (array) – Flux inside a bandpass.

Returns:

Negative flux ratio for a given spectral line [0, 1]

Return type:

float