continuum_models
- class BaseContinuumModel[source]
Bases:
objectThe contract for BaseContinuumModel
- stack_spectra(valid_spectra_list, flux_stacker)[source]
Stacks spectra in the observed and rest-frame. Observed frame stacking is performed over f/C. Rest-frame stacking is performed over C only.
- Parameters:
valid_spectra_list (list(Spectrum)) – Valid spectra objects to iterate.
flux_stacker (FluxStacker) – Flux stacker object.
- fit_continuum(spec)[source]
Fits the continuum for a single Spectrum. Should modify
cont_paramsdictionary’svalidandcontkeys at least.x, xcov, chi2anddofkeys should be set either here or ininit_spectra().- Parameters:
spec (Spectrum) – Spectrum object to fit.
- init_spectra(spectra_list)[source]
Initializes
cont_paramsfor a list of Spectrum objects. Specifically, setmethodkey and any unused keys inx, xcov, chi2, dof.
- stacks_residual_flux()[source]
Return
Trueif the model stacks residual fluxes in the rest-frame instack_spectra()such asPiccaContinuumModel. Otherwise, returnFalse.- Return type:
- class PiccaContinuumModel(meancont_interp, meanflux_interp, varlss_interp, eta_interp, cont_order, rfwave0, denom, minimizer)[source]
Bases:
BaseContinuumModelPicca continuum model class.
- Parameters:
meancont_interp (FastCubic1DInterp) – Fast cubic spline object for the mean continuum.
meanflux_interp (FastLinear1DInterp) – Interpolator for mean flux. If fiducial is not set, this equals to 1.
varlss_interp (FastLinear1DInterp or FastCubic1DInterp) – Cubic spline for var_lss if fitting. Linear if from file.
eta_interp (FastCubic1DInterp) – Interpolator for eta. Returns one if fiducial var_lss is set.
cont_order (int) – Order of continuum polynomial from
args.cont_order.rfwave0 (float) – First rest-frame wavelength center for the mean continuum.
denom (float) – Denominator for the slope term in the continuum model.
minimizer (str) –
iminuitorl_bfgs_bto select the minimizer function.
- minimizer
Function that points to one of the minimizer options.
- Type:
function
- _continuum_costfn(x, wave, flux, ivar_sm, z_qso)[source]
Cost function to minimize for each quasar.
This is a modified chi2 where amplitude is also part of minimization. Cost of each arm is simply added to the total cost.
- Parameters:
- Returns:
cost – Cost (modified chi2) for a given
x.- Return type:
- stack_spectra(valid_spectra_list, flux_stacker)[source]
Stacks spectra in the observed and rest-frame. Observed-frame and rest-frame stacking is performed over residuals f/C.
- Parameters:
valid_spectra_list (list(Spectrum)) – Valid spectra objects to iterate.
flux_stacker (FluxStacker) – Flux stacker object.
- fit_continuum(spec)[source]
Fits the continuum for a single Spectrum.
This function uses
forestivar_smin inverse variance, which must be smoothed beforehand. It also modifiescont_paramsdictionary’svalid, cont, x, xcov, chi2, dofkeys. If the best-fitting continuum is negative at any point, the fit is invalidated. Chi2 is set separately without using thecost function.xkey is the best-fitting parameter, andxcovis their inverse Hessianhess_invgiven byscipy.optimize.minimize()using ‘L-BFGS-B’ method.- Parameters:
spec (Spectrum) – Spectrum object to fit.
- init_spectra(spectra_list)[source]
Initializes
cont_paramsfor a list of Spectrum objects.
- stacks_residual_flux()[source]
stack_spectra()stacks residual flux values f/C.- Returns:
True
- Return type:
- class InputContinuumModel(input_dir, meanflux_interp, varlss_interp, eta_interp, nside=8)[source]
Bases:
BaseContinuumModelInput continuum model class.
Input continua should be in the rest frame with equal wavelength spacing. These continua are then interpolated using a cubic spline. Uses fiducials for mean flux and varlss interpolation.
The files are assumed to be organized by healpix nside=8 with nested ordering. For example,
input-continuum-{nside}-{pixnum}.fits, wherepixnum = healpy.ang2pix(nside, ra_deg, dec_deg, lonlat=True, nest=True). Each file should have at least two extensions: FIBERMAP and CONTINUA.FIBERMAP extension should have the typical DESI fibermap columns:
TARGETID, Z, RA, DEC, PROGRAM, SURVEY. EachTARGETIDshould occur once.CONTINUA extention should be an ImageHDU and have the quasar continua in the same order of
TARGETIDs in FIBERMAP. Its header should declare the initial rest-frame wavelength byWAVE1key and the rest-frame wavelength step byDWAVEkey. The data should be in(nqso, nwave)shape.
- Parameters:
input_dir (str) – Input directory for all input-continuum FITS files.
meanflux_interp (FastLinear1DInterp) – Interpolator for mean flux. If fiducial is not set, this equals to 1.
varlss_interp (FastLinear1DInterp or FastCubic1DInterp) – Cubic spline for var_lss if fitting. Linear if from file.
eta_interp (FastCubic1DInterp) – Interpolator for eta.
nside (int, default: 8) – Healpy nside.
- _read_continua_one_file(pixnum, targetids)[source]
Reads one input continuum file.
- Parameters:
- Returns:
- Raises:
Exception – If the number of quasars in FIBERMAP and CONTINUA extension do not match.
RuntimeWarning – If the file cannot be read. In this case, all objects are assumed to have invalid continuum.
- _read_continua(spectra_list)[source]
Reads and sets input continuum for all elements in
spectra_list. If a TARGETID is not found in its expected file, its continuum will be set to invalid.If found,
qsonic.spectrum.Spectrum.cont_paramsdictionary gains the following:cont_params['valid'] = True cont_params['input_w1'] (float): First rest-frame wavelength cont_params['input_dwave'] (float): Rest-frame wavelength spacing cont_params['input_data'] (ndarray): Input continuum
- fit_continuum(spec)[source]
Input continuum reduction. Uses fiducials for mean flux and varlss interpolation. Continuum is interpolated using a cubic spline.
- Parameters:
spec (Spectrum) – Spectrum object to add true continuum.
- init_spectra(spectra_list)[source]
Reads input continuum. Initializes
cont_paramsfor a list of Spectrum objects.
- stacks_residual_flux()[source]
stack_spectra()stacks actual continuum values.- Returns:
False
- Return type:
- stack_spectra(valid_spectra_list, flux_stacker)
Stacks spectra in the observed and rest-frame. Observed frame stacking is performed over f/C. Rest-frame stacking is performed over C only.
- Parameters:
valid_spectra_list (list(Spectrum)) – Valid spectra objects to iterate.
flux_stacker (FluxStacker) – Flux stacker object.
- class TrueContinuumModel(meanflux_interp, varlss_interp)[source]
Bases:
BaseContinuumModelTrue continuum model class for mock analysis. Uses fiducials for mean flux and varlss interpolation. Continuum is interpolated using a cubic spline.
- Parameters:
meanflux_interp (FastLinear1DInterp) – Interpolator for mean flux. If fiducial is not set, this equals to 1.
varlss_interp (FastLinear1DInterp or FastCubic1DInterp) – Cubic spline for var_lss if fitting. Linear if from file.
- fit_continuum(spec)[source]
True continuum reduction. Uses fiducials for mean flux and varlss interpolation. Continuum is interpolated using a cubic spline.
- Parameters:
spec (Spectrum) – Spectrum object to add true continuum.
- init_spectra(spectra_list)[source]
Initializes
cont_paramsfor a list of Spectrum objects.
- stacks_residual_flux()[source]
stack_spectra()stacks actual continuum values.- Returns:
False
- Return type:
- stack_spectra(valid_spectra_list, flux_stacker)
Stacks spectra in the observed and rest-frame. Observed frame stacking is performed over f/C. Rest-frame stacking is performed over C only.
- Parameters:
valid_spectra_list (list(Spectrum)) – Valid spectra objects to iterate.
flux_stacker (FluxStacker) – Flux stacker object.