astrocook.recipes.continuum module#
- class astrocook.recipes.continuum.RecipeContinuum(session_v2: Session)[source]#
Bases:
objectRecipes for estimating and fitting the quasar continuum.
These methods are accessed via the
session.continuumattribute and delegate heavy logic toSpectrum.- estimate_auto(smooth_len_lya: float = 5000.0, smooth_len_out: float = 400.0, kappa: float = 2.0, fudge: str = 'auto', smooth_fwhm: float = 800.0, template: bool = False, renorm_model: bool = True, smooth_std: str | None = None) Session[source]#
Auto-estimate continuum (single-click).
A single-click recipe that runs
find_absorbedand thenfit_continuumin sequence, based on the V1 ‘clip_flux’ algorithm.- Parameters:
smooth_len_lya (float, optional) – Smoothing length (km/s) for initial guess in the Ly-alpha forest. Defaults to
5000.0.smooth_len_out (float, optional) – Smoothing length (km/s) for initial guess outside the forest. Defaults to
400.0.kappa (float, optional) – Sigma threshold for finding absorption. Defaults to
2.0.fudge (str, optional) – A multiplicative factor. Can be a float (e.g.,
'1.0') or'auto'. If'auto', the factor is calculated to center the continuum residuals. Defaults to'auto', as the GUI (the same result as'1.0', seefit_continuum()).smooth_fwhm (float, optional) – FWHM (km/s) of the final Gaussian smoothing. Defaults to
800.0.smooth_std (str, optional) – Deprecated: the standard deviation (km/s) used before; overrides
smooth_fwhmwhen given. Defaults toNone.template (bool, optional) – If
True, use a QSO template. Defaults toFalse.renorm_model (bool, optional) – If
True, re-normalize the ‘model’ column to match the new continuum. Defaults toTrue.('5000.0' (The parameters can also be given as strings)
:param : :param
'True'): :type'True'): they are :param as the dialogs and the session log give them: :type as the dialogs and the session log give them: they are :param converted to their types before the recipe runs.:- Returns:
A new
Sessionwith updated continuum and absorption mask.- Return type:
- Raises:
RecipeError – If a parameter cannot be used, or the continuum cannot be estimated (
astrocook.recipes.errors).
- find_absorbed(smooth_len_lya: float = 5000.0, smooth_len_out: float = 400.0, kappa: float = 2.0, template: bool = False) Session[source]#
Find absorbed regions (V1 logic).
Runs the V1 ‘clip_flux’ kappa-sigma algorithm (with Ly-alpha forest split) to create a boolean mask (
abs_mask) where True indicates absorption. Delegates toastrocook.core.spectrum.Spectrum.find_absorbed().- Parameters:
smooth_len_lya (float, optional) – Smoothing length (km/s) for initial guess in the Ly-alpha forest. Defaults to
5000.0.smooth_len_out (float, optional) – Smoothing length (km/s) for initial guess outside the forest. Defaults to
400.0.kappa (float, optional) – Sigma threshold for clipping. Flux below
mean - kappa * sigmais considered absorbed. Defaults to2.0.template (bool, optional) – If
True, use a QSO template (Not Implemented). Defaults toFalse.
- Returns:
A new
Sessionwith theabs_maskcolumn added/updated.- Return type:
- Raises:
RecipeError – If the recipe cannot run (
astrocook.recipes.errors).
- fit_continuum(fudge: str = 'auto', smooth_fwhm: float = 800.0, mask_col: str = 'abs_mask', renorm_model: bool = True, template: str = 'False', smooth_std: str | None = None) Session[source]#
Fit continuum to mask (V1 logic).
Interpolates unabsorbed regions from a mask, optionally applies an auto-fudge factor to center residuals, and smooths the result. Delegates to
astrocook.core.spectrum.Spectrum.fit_continuum().- Parameters:
fudge (str, optional) – Fudge factor. Can be a float (e.g.,
'1.0') or'auto'. Defaults to'auto'.smooth_fwhm (float, optional) – FWHM (km/s) of the final Gaussian smoothing. Defaults to
800.0.smooth_std (str, optional) – Deprecated: the standard deviation (km/s) used before; overrides
smooth_fwhmwhen given. Defaults toNone.mask_col (str, optional) – Name of the mask column to use (True=Absorbed). Defaults to
'abs_mask'.renorm_model (bool, optional) – If
True, re-normalize the ‘model’ column. Defaults toTrue.template (str, optional) – If
'True', use a QSO template. Defaults to'False'.
- Returns:
A new
Sessionwith thecontcolumn added/updated.- Return type:
- Raises:
RecipeError – If the recipe cannot run (
astrocook.recipes.errors).
- fit_powerlaw(regions: str = '128.0-129.0, 131.5-132.5, 134.5-136.0', kappa: float = 3.0) Session[source]#
Fit power-law continuum.
Fits a power-law (linear in log-log space) to user-defined, unabsorbed rest-frame regions. Creates the
cont_plcolumn. Delegates toastrocook.core.spectrum.Spectrum.fit_powerlaw().- Parameters:
- Returns:
A new
Sessionwith thecont_plcolumn added/updated.- Return type:
- Raises:
RecipeError – If the recipe cannot run (
astrocook.recipes.errors).
- update_from_knots(knots_x: list, knots_y: list, renorm_model: bool = True) Session[source]#
Update continuum from manual knots.
Interpolates a Cubic Spline through manually placed knots and updates the continuum. Delegates to
astrocook.core.spectrum.Spectrum.update_continuum_from_knots().- Parameters:
knots_x (list) – List of x coordinates (wavelength/velocity) for the knots.
knots_y (list) – List of y coordinates (flux) for the knots.
renorm_model (bool, optional) – If
True, re-normalize the ‘model’ column to match the new continuum. Defaults toTrue.
- Returns:
A new
Sessionwith the updated continuum.- Return type: