astrocook.recipes.flux module#

class astrocook.recipes.flux.RecipeFluxV2(session_v2: SessionV2)[source]#

Bases: object

Recipes for manipulating spectral flux and grid sampling.

These methods are accessed via the session.flux attribute and delegate logic to SpectrumV2.

__init__(session_v2: SessionV2)[source]#
calculate_running_std(input_col: str = 'y', output_col: str = 'running_std', window_pix: str = '21') SessionV2[source]#

Calculate running standard deviation.

Calculates a running Root-Mean-Square (RMS) on a specific column to estimate local error or variability. Delegates to astrocook.core.spectrum.SpectrumV2.calculate_running_std().

Parameters:
  • input_col (str, optional) – The column to use for StdDev calculation (e.g., 'y'). Defaults to 'y'.

  • output_col (str, optional) – Name of the new column to create (e.g., 'running_std'). Defaults to 'running_std'.

  • window_pix (str, optional) – Total window size in pixels (should be odd). Defaults to '21'.

Returns:

A new SessionV2 with the calculated column added, or 0 on failure.

Return type:

SessionV2 or int

smooth(sigma_kms: str = '100.0') SessionV2[source]#

Smooth spectrum.

Applies a Gaussian filter to the spectrum flux (y-axis), error (dy-axis), and auxiliary columns. Delegates to astrocook.core.spectrum.SpectrumV2.smooth().

Parameters:

sigma_kms (str, optional) – Standard deviation for Gaussian kernel in km/s. Defaults to '100.0'.

Returns:

A new SessionV2 with smoothed columns, or 0 on failure.

Return type:

SessionV2 or int

rebin(xstart: str = 'None', xend: str = 'None', dx: str = '10.0', xunit: str = 'km/s', kappa: str = '5.0', filling: str = 'nan', norm: str = 'False') SessionV2[source]#

Rebin spectrum.

Applies a new binning to a spectrum with a constant bin size. Delegates to astrocook.core.spectrum.SpectrumV2.rebin().

Parameters:
  • xstart (str, optional) – Start wavelength/velocity. 'None' for auto (data minimum). Defaults to 'None'.

  • xend (str, optional) – End wavelength/velocity. 'None' for auto (data maximum). Defaults to 'None'.

  • dx (str, optional) – Step size in x. Defaults to '10.0'.

  • xunit (str, optional) – Unit of wavelength or velocity for the step size (e.g., 'km/s', 'nm'). Defaults to 'km/s'.

  • kappa (str, optional) – Sigma clipping threshold for binning. 'None' for off. Defaults to '5.0'.

  • filling (str, optional) – Value to fill regions without data. Defaults to 'nan'.

  • norm (str, optional) – (Legacy flag, currently unused). Defaults to 'False'.

Returns:

A new SessionV2 with the rebinned spectrum, or 0 on failure.

Return type:

SessionV2 or int

equalize(reference_session: str = 'None', order: str = '0') SessionV2[source]#

Equalize flux to a reference session.

Scales the flux of the current session to match the flux level of a reference session using a polynomial scaling model.

Parameters:
  • reference_session (str, optional) – The name of the reference session. Defaults to 'None'.

  • order (str, optional) – The polynomial order for the scaling model ('0' = scalar, '-1' = spline). Defaults to '0'.

Returns:

A new session with the scaled flux. Returns 0 (int) on failure.

Return type:

SessionV2

resample(target_session: str = 'None') SessionV2[source]#

Resample on another grid.

Resamples this spectrum onto the exact wavelength grid of another open session. This is often a prerequisite for multi-session arithmetic. Delegates to astrocook.core.spectrum.SpectrumV2.resample_on_grid().

Parameters:

target_session (str) – Name of the session to use as the grid source.

Returns:

A new SessionV2 interpolated to the target grid, or 0 on failure.

Return type:

SessionV2 or int

calibrate_from_magnitudes(magnitudes: str = 'SDSS_r=17.0') SessionV2[source]#

Flux calibrate (multi-band).

Warps the spectrum SED to match multiple photometric points. Delegates to astrocook.core.spectrum.SpectrumV2.calibrate().

Parameters:

magnitudes (str, optional) – List of ‘Filter=Mag’ pairs separated by commas (e.g., "SDSS_g=17.5, SDSS_r=17.0"). Defaults to "SDSS_r=17.0".

Returns:

A new SessionV2 with calibrated flux, or 0 on failure.

Return type:

SessionV2 or int