LineDetect.feature_finder

Created on Wed Apr 2 03:28:53 2023

@author: daniel

Module Contents

Functions

featureFinder(→ numpy.ndarray)

Find the limits of absorption or emission features in a spectrum.

apertureFeatureLimits(→ Tuple[int, int])

Returns the indices of the leftmost and rightmost pixels of a feature centered at the given index.

optimizedFeatureLimits(→ Tuple[int, int])

Finds the left and right limits of a feature based on the recovery of the flux.

optimizedResEleEW(→ Tuple[int, int])

Calculates the equivalent width per resolution element using the optimized method.

getP(→ numpy.ndarray)

Calculates the instrumental spread function around a pixel i using a discrete or continuous Gaussian model.

fluxDec(→ Tuple[float, float])

Calculate the flux decrement at a pixel i.

aperturePixelEW(→ Tuple[float, float])

Calculate the equivalent width per resolution element for a given pixel i.

apertureEW(→ Tuple[float, float])

Calculate the equivalent width (EW) of a feature between two limits (j and k) and associated uncertainty.

LineDetect.feature_finder.featureFinder(Lambda: numpy.ndarray, flux: numpy.ndarray, yC: numpy.ndarray, sigFlux: numpy.ndarray, sig_yC: numpy.ndarray, N_sig_limits: float = 0.5, N_sig_line2: float = 3) numpy.ndarray[source]

Find the limits of absorption or emission features in a spectrum.

Parameters:
  • Lambda (np.ndarray) – Array of wavelengths.

  • flux (np.ndarray) – Array of flux values.

  • yC (np.ndarray) – Array of continuum values.

  • sigFlux (np.ndarray) – Array of uncertainties in the flux values.

  • sig_yC (np.ndarray) – Array of uncertainties in the continuum values.

  • N_sig_limits (int) – Threshold of flux recovery for determining feature limits. Defaults to 3. Can be set to 5 for a higher significant level.

Returns:

2D array of feature limits, where each row contains the left and right limit of a feature.

LineDetect.feature_finder.apertureFeatureLimits(i: int, Lambda: numpy.ndarray, flux: numpy.ndarray, yC: numpy.ndarray, sigFlux: numpy.ndarray, sig_yC: numpy.ndarray, N_sig_limits: int = 0.5) Tuple[int, int][source]

Returns the indices of the leftmost and rightmost pixels of a feature centered at the given index.

Parameters:
  • i (int) – Index of the central pixel of the feature.

  • Lambda (np.ndarray) – Array of wavelength values.

  • flux (np.ndarray) – Array of flux values.

  • yC (np.ndarray) – Array of continuum values.

  • sigFlux (np.ndarray) – Array of uncertainties in the flux values.

  • sig_yC (np.ndarray) – Array of uncertainties in the continuum values.

  • N_sig (int) – Threshold of flux recovery for determining feature limits. Defaults to 0.5.

Returns:

Two valeues, index of the leftmost pixel of the feature followed by the index of the rightmost pixel of the feature.

LineDetect.feature_finder.optimizedFeatureLimits(i: int, Lambda: numpy.array, flux: numpy.array, yC: numpy.array, sigFlux: numpy.array, sig_yC: numpy.array, R: numpy.ndarray, N_sig_limits: float = 0.5, resolution_element: int = 3) Tuple[int, int][source]

Finds the left and right limits of a feature based on the recovery of the flux.

Parameters:
  • i (int) – Index of the pixel.

  • Lambda (np.array) – Array of wavelength values.

  • flux (np.array) – Array of flux values.

  • yC (np.array) – Array of continuum values.

  • sigFlux (np.array) – Array of flux uncertainties.

  • sig_yC (np.array) – Array of continuum uncertainties.

  • R (np.ndarray) – Array of resolving powers.

  • N_sig (float) – Threshold of flux recovery for determining feature limits. Defaults to 0.5.

  • resolution_element (int) – The size of the resolution element in pixels. Defaults to 3.

Returns:

Index of the left limit of the feature. right_index (int): Index of the right limit of the feature.

Return type:

left_index (int)

LineDetect.feature_finder.optimizedResEleEW(i: int, Lambda: numpy.ndarray, flux: numpy.ndarray, yC: numpy.ndarray, sigFlux: numpy.ndarray, sig_yC: numpy.ndarray, R: numpy.ndarray, resolution_element: int = 3) Tuple[int, int][source]

Calculates the equivalent width per resolution element using the optimized method.

Parameters:
  • i (int) – Index of the pixel.

  • Lambda (np.ndarray) – Array of wavelength values.

  • flux (np.ndarray) – Array of flux values.

  • yC (np.ndarray) – Array of continuum values.

  • sigFlux (np.ndarray) – Array of flux uncertainties.

  • sig_yC (np.ndarray) – Array of continuum uncertainties.

  • R (np.ndarray) – Array of resolving powers.

  • resolution_element (int) – The size of the resolution element in pixels. Defaults to 3.

Returns:

Two values, the equivalent width per resolution element and its uncertainty.

LineDetect.feature_finder.getP(i: int, Lambda: numpy.ndarray, R: numpy.ndarray, resolution_element: int = 3) numpy.ndarray[source]

Calculates the instrumental spread function around a pixel i using a discrete or continuous Gaussian model.

Note

The continuous method is more accurate than the discrete method, since it models the ISF as a continuous function rather than a discrete sum. However, it is also more computationally expensive, since it requires the evaluation of a Gaussian function at every pixel within a certain range. The discrete method is less accurate, but much faster to compute.

Parameters:
  • i (int) – Index of the pixel.

  • Lambda (np.ndarray) – Array of wavelength values.

  • R (np.ndarray) – Array of resolving powers.

  • resolution_element (int) – The size of the resolution element in pixels. Defaults to 3.

Returns:

Array of normalized instrumental spread function values.

LineDetect.feature_finder.fluxDec(i: int, flux: numpy.ndarray, yC: numpy.ndarray, sigFlux: numpy.ndarray, sig_yC: numpy.ndarray) Tuple[float, float][source]

Calculate the flux decrement at a pixel i.

If the flux decrement satisfies some detection threshold at a pixel, go left and right from the pixel to find the points where the continuum recovers sufficiently.

Parameters:
  • i (int) – the index of the pixel to calculate the flux decrement for.

  • flux (np.ndarray) – Array of flux values.

  • yC (np.ndarray) – Array of continuum values.

  • sigFlux (np.ndarray) – Array of uncertainties in the flux values.

  • sig_yC (np.ndarray) – Array of uncertainties in the continuum values.

Returns:

Two values, the flux decrement at the given pixel and the corresponding uncertainty.

LineDetect.feature_finder.aperturePixelEW(i: int, Lambda: numpy.ndarray, flux: numpy.ndarray, yC: numpy.ndarray, sigFlux: numpy.ndarray, sig_yC: numpy.ndarray) Tuple[float, float][source]

Calculate the equivalent width per resolution element for a given pixel i.

Parameters:
  • i (int) – the index of the pixel to calculate the equivalent width for

  • Lambda (np.ndarray) – Array of wavelengths.

  • flux (np.ndarray) – Array of flux values.

  • yC (np.ndarray) – Array of continuum values.

  • sigFlux (np.ndarray) – Array of uncertainties in the flux values.

  • sig_yC (np.ndarray) – Array of uncertainties in the continuum values.

Returns:

Two values, the equivalent width per resolution element for the given pixel and its uncertainty.

LineDetect.feature_finder.apertureEW(j: int, k: int, Lambda: numpy.ndarray, flux: numpy.ndarray, yC: numpy.ndarray, sigFlux: numpy.ndarray, sig_yC: numpy.ndarray) Tuple[float, float][source]

Calculate the equivalent width (EW) of a feature between two limits (j and k) and associated uncertainty.

Unlike the apertureResEleEW function, this routine calculates the equivalent width of a feature between two limits (j and k) by summing up the equivalent width per pixel over the range defined by those limits.

Parameters:
  • j (int) – Index of the starting point of the feature in the Lambda array.

  • k (int) – Index of the ending point of the feature in the Lambda array.

  • Lambda (np.ndarray) – Array of wavelengths.

  • flux (np.ndarray) – Array of flux values.

  • yC (np.ndarray) – Array of continuum values.

  • sigFlux (np.ndarray) – Array of uncertainties in the flux values.

  • sig_yC (np.ndarray) – Array of uncertainties in the continuum values.

Returns:

Two values, the equivalent width per resolution element for the given pixel and its uncertainty.