astrocook.recipes.continuum module#
- class astrocook.recipes.continuum.RecipeContinuumV2(session_v2: SessionV2)[source]#
Bases:
objectRecipes for estimating and fitting the quasar continuum.
These methods are accessed via the
session.continuumattribute and delegate heavy logic toSpectrumV2.- estimate_auto(smooth_len_lya: str = '5000.0', smooth_len_out: str = '400.0', kappa: str = '2.0', fudge: str = '1.0', smooth_std: str = '500.0', template: str = 'False', renorm_model: str = 'True') SessionV2[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 (str, optional) – Smoothing length (km/s) for initial guess in the Ly-alpha forest. Defaults to
'5000.0'.smooth_len_out (str, optional) – Smoothing length (km/s) for initial guess outside the forest. Defaults to
'400.0'.kappa (str, 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'1.0'.smooth_std (str, optional) – Standard deviation (km/s) for the final Gaussian smoothing. Defaults to
'500.0'.template (str, optional) – If
'True', use a QSO template. Defaults to'False'.renorm_model (str, optional) – If
'True', re-normalize the ‘model’ column to match the new continuum. Defaults to'True'.
- Returns:
A new
SessionV2with updated continuum and absorption mask, or 0 on failure.- Return type:
SessionV2 or int
- find_absorbed(smooth_len_lya: str = '5000.0', smooth_len_out: str = '400.0', kappa: str = '2.0', template: str = 'False') SessionV2[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.SpectrumV2.find_absorbed().- Parameters:
smooth_len_lya (str, optional) – Smoothing length (km/s) for initial guess in the Ly-alpha forest. Defaults to
'5000.0'.smooth_len_out (str, optional) – Smoothing length (km/s) for initial guess outside the forest. Defaults to
'400.0'.kappa (str, optional) – Sigma threshold for clipping. Flux below
mean - kappa * sigmais considered absorbed. Defaults to'2.0'.template (str, optional) – If
'True', use a QSO template (Not Implemented). Defaults to'False'.
- Returns:
A new
SessionV2with theabs_maskcolumn added/updated, or 0 on failure.- Return type:
SessionV2 or int
- fit_continuum(fudge: str = 'auto', smooth_std: str = '500.0', mask_col: str = 'abs_mask', renorm_model: str = 'True', template: str = 'False') SessionV2[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.SpectrumV2.fit_continuum().- Parameters:
fudge (str, optional) – Fudge factor. Can be a float (e.g.,
'1.0') or'auto'. Defaults to'auto'.smooth_std (str, optional) – Final Gaussian smoothing standard deviation (km/s). Defaults to
'500.0'.mask_col (str, optional) – Name of the mask column to use (True=Absorbed). Defaults to
'abs_mask'.renorm_model (str, optional) – If
'True', re-normalize the ‘model’ column. Defaults to'True'.template (str, optional) – If
'True', use a QSO template. Defaults to'False'.
- Returns:
A new
SessionV2with thecontcolumn added/updated, or 0 on failure.- Return type:
SessionV2 or int
- fit_powerlaw(regions: str = '128.0-129.0, 131.5-132.5, 134.5-136.0', kappa: str = '3.0') SessionV2[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.SpectrumV2.fit_powerlaw().- Parameters:
regions (str, optional) – Comma-separated rest-frame wavelength regions (nm). Example:
'128.0-129.0, 131.5-132.5'. Defaults to'128.0-129.0, 131.5-132.5, 134.5-136.0'.kappa (str, optional) – Sigma threshold for clipping outliers within regions. Defaults to
'3.0'.
- Returns:
A new
SessionV2with thecont_plcolumn added/updated, or 0 on failure.- Return type:
SessionV2 or int
- update_from_knots(knots_x: list, knots_y: list, renorm_model: bool = True) SessionV2[source]#
Update continuum from manual knots.
Interpolates a Cubic Spline through manually placed knots and updates the continuum. Delegates to
astrocook.core.spectrum.SpectrumV2.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
SessionV2with the updated continuum.- Return type: