API
fastspecfit
Tools for fast stellar continuum, emission-line, and broadband photometric modeling.
fastspecfit.cosmo
Cosmology utilities.
- class fastspecfit.cosmo.TabulatedDESI[source]
Tabulated DESI fiducial cosmology for fast redshift interpolation.
Loads tabulated \(E(z)\) and comoving radial distance as a function of redshift and performs linear interpolation. The cosmology parameters are defined by the AbacusSummit baseline (Planck 2018 ΛCDM).
Notes
Redshift interpolation range is [0, 100]. Cosmology defined at https://github.com/abacusorg/AbacusSummit; tabulated file generated with https://github.com/adematti/cosmoprimo.
Examples
>>> cosmo = TabulatedDESI() >>> distance = cosmo.comoving_radial_distance([0.1, 0.2]) >>> efunc = cosmo.efunc(0.3)
- comoving_radial_distance(z)[source]
Return comoving radial distance.
- Parameters:
z (float or array-like) – Redshift.
- Returns:
Comoving radial distance in \(\mathrm{Mpc}/h\).
- Return type:
float or
numpy.ndarray
- distance_modulus(z)[source]
Return the distance modulus.
- Parameters:
z (float or array-like) – Redshift.
- Returns:
Distance modulus in magnitudes (Hogg 1999, Eq. 24).
- Return type:
float or
numpy.ndarray
- efunc(z)[source]
Return \(E(z) = H(z) / H_0\).
- Parameters:
z (float or array-like) – Redshift.
- Returns:
Dimensionless Hubble parameter at the given redshift(s).
- Return type:
float or
numpy.ndarray
- luminosity_distance(z)[source]
Return luminosity distance.
- Parameters:
z (float or array-like) – Redshift.
- Returns:
Luminosity distance in \(\mathrm{Mpc}/h\).
- Return type:
float or
numpy.ndarray
- universe_age(z)[source]
Return the age of the universe at the given redshift.
- Parameters:
z (float or array-like) – Redshift.
- Returns:
Age of the universe in Gyr.
- Return type:
float or
numpy.ndarray
fastspecfit.igm
Tools for handling intergalactic medium (IGM) attenuation.
The Inoue14 implementation is adapted from Gabriel Brammer’s
eazy-py package and is used here under the MIT License.
Copyright (c) 2016-2022 Gabriel Brammer.
- class fastspecfit.igm.Inoue14(scale_tau=1.0)[source]
IGM absorption model from Inoue et al. (2014).
- Parameters:
scale_tau (float, optional) – Scaling factor applied to the IGM optical depth \(\tau\). The transmission is \(f_\mathrm{igm} = e^{-\mathrm{scale\_tau}\,\tau}\). Defaults to 1.
- full_IGM(z, lobs)[source]
Compute the full IGM transmission at observed wavelengths.
- Parameters:
z (float) – Source redshift.
lobs (
numpy.ndarray) – Observed-frame wavelengths in Angstroms.
- Returns:
IGM transmission \(e^{-\tau}\) at each wavelength.
- Return type:
- fastspecfit.igm._tLCDLA(zS, lobs)
Lyman continuum, DLA
- fastspecfit.igm._tLCLAF(zS, lobs)
Lyman continuum, LAF
- fastspecfit.igm._tLSDLA(zS, lobs, lam, cADLA1, cADLA2)
Lyman Series, DLA
- fastspecfit.igm._tLSLAF(zS, lobs, lam, cALAF1, cALAF2, cALAF3)
Lyman series, Lyman-alpha forest
fastspecfit.linemasker
Tools for pre-fitting and masking emission lines.
- class fastspecfit.linemasker.LineMasker(emline_table, constraints)[source]
Compute spectral line mask for continuum estimation and line parameter initialization.
- Parameters:
emline_table (
astropy.table.Table) – Emission line table.constraints (
fastspecfit.emlines.EmlineConstraints) – Parsed kinematic constraint file; passed toEMFitToolsfor the preliminary patch-fitting step.
- build_linemask(wave, flux, ivar, resolution_matrix, redshift=0.0, uniqueid=0, minsnr_balmer_broad=1.5, minsnr_linemask=3.5, initsigma_broad=None, initsigma_narrow=None, initsigma_balmer_broad=None, initvshift_broad=None, initvshift_narrow=None, initvshift_balmer_broad=None, niter=2, nsigma_mask=5.0, debug_plots=False)[source]
Generate a mask which identifies pixels impacted by emission lines.
- Parameters:
wave (
numpy.ndarray[npix]) – Observed-frame wavelength array.flux (
numpy.ndarray[npix]) – Spectrum corresponding to wave.ivar (
numpy.ndarray[npix]) – Inverse variance spectrum corresponding to flux.resolution_matrix (
list) – List offastspecfit.resolution.Resolutionobjects, one per camera.redshift (
float, optional) – Object redshift. Default is 0.uniqueid (
int, optional) – Unique identification number used in debug plot filenames.minsnr_balmer_broad (
float, optional) – Minimum S/N to accept a broad Balmer line detection. Default is 1.5.minsnr_linemask (
float, optional) – Minimum S/N to include a non-strong line in the final pixel mask. Default is 3.5.initsigma_broad (
floator None, optional) – Initial broad-line width in km/s. Default is 3000.initsigma_narrow (
floator None, optional) – Initial narrow/forbidden-line width in km/s. Default is 150.initsigma_balmer_broad (
floator None, optional) – Initial broad Balmer-line width in km/s. Default is 1000.initvshift_broad (
floator None, optional) – Initial broad-line velocity shift in km/s. Default is 0.initvshift_narrow (
floator None, optional) – Initial narrow-line velocity shift in km/s. Default is 0.initvshift_balmer_broad (
floator None, optional) – Initial broad Balmer-line velocity shift in km/s. Default is 0.niter (
int, optional) – Number of fit-in-patches iterations. Default is 2.nsigma_mask (
float, optional) – Half-width of the final line mask in units of the line sigma. Default is 5.debug_plots (
bool, optional) – IfTrue, write per-patch and per-line diagnostic PNG files. Default isFalse.
- Returns:
out – Dictionary with fitted line-width and velocity-shift scalars for broad, narrow, and broad-Balmer populations, a
balmerbroadboolean flag, andcoadd_linepixmapping each line name to its pixel indices in the coadded spectrum.- Return type:
- static linepix_and_contpix(wave, ivar, linetable, linesigmas, residuals=None, flux=None, linevshifts=None, patchMap=None, redshift=0.0, nsigma=2.5, minlinesigma=50.0, mincontpix=11, get_contpix=True, get_snr=False)[source]
Identify pixels containing emission lines and adjacent continuum.
- Parameters:
wave (
numpy.ndarray) – Observed-frame wavelength array in Angstroms.ivar (
numpy.ndarray) – Inverse variance array.linetable (
astropy.table.Table) – Emission line table withrestwaveandnamecolumns.linesigmas (
numpy.ndarray) – Line widths in km/s for each entry inlinetable.residuals (
numpy.ndarrayor None, optional) – Residual spectrum used for S/N estimation whenget_snr=True.flux (
numpy.ndarrayor None, optional) – Observed flux array used for amplitude estimation whenget_snr=True.linevshifts (
numpy.ndarrayor None, optional) – Velocity shifts in km/s for each line; defaults to zero.patchMap (
dictor None, optional) – Mapping from patch ID to(linenames, line_indices, full_indices)tuples. When provided, continuum pixels are grouped into patches.redshift (
float, optional) – Object redshift. Default is 0.nsigma (
float, optional) – Half-width of the line mask in units of the line sigma. Default is 2.5.minlinesigma (
float, optional) – Minimum line sigma in km/s used for masking. Default is 50.mincontpix (
int, optional) – Minimum number of continuum pixels per line or patch. Default is 11.get_contpix (
bool, optional) – IfTrue, also compute continuum pixel indices. Default isTrue.get_snr (
bool, optional) – IfTrue, estimate the amplitude and S/N for each line. Default isFalse.
- Returns:
pix – Dictionary with keys
linepixandcontpix(each mapping line name to pixel index arrays). Ifget_snr=True, also containsclocal,cnoise,amp, andsnrper line. IfpatchMapis provided, also containspatch_contpix,dropped,merged, andmerged_from.- Return type:
fastspecfit.linetable
Emission line table, read from a file.
- class fastspecfit.linetable.LineTable(emlines_file=None)[source]
Emission line table used for spectral fitting.
- Parameters:
emlines_file (str, optional) – Path to an ECSV emission-line parameter file. Defaults to the bundled
data/emlines.ecsv.
- table
Emission-line parameters.
- Type:
fastspecfit.logger
Unique logger object, distinct from the one used by the DESI libraries, allocated at startup and used throughout code base. We need to create our own logger to avoid the DESI libraries accidentally changing the log level out from under us.
Having just one logger allows us to initialize its level on startup and have those changes propagate everywhere.
This needs to be in its own file to prevent circular imports with other code.
- class fastspecfit.logger._DynamicStdoutHandler(stream=None)[source]
StreamHandler that always writes to the current sys.stdout.
Rebinds self.stream on every emit() so that OS-level stdout redirections (e.g. desispec.io.util.stdouterr_redirected) are followed correctly.
- emit(record)[source]
Emit a record.
If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.
- fastspecfit.logger.getFastspecLogger()[source]
Create a fastspecfit-specific logger that writes to stdout.
Returns the same logger object on every call without resetting its level, so external code (e.g. sc_data.initialize) can safely call setLevel() and have that setting persist.
- Returns:
log – Logger named
fastspec.- Return type:
fastspecfit.photometry
Tools for handling filters and photometry calculations.
- class fastspecfit.photometry.Photometry(fphotofile=None, fitstack=False, ignore_photometry=False)[source]
Load filter curves and provide photometric synthesis methods.
- Parameters:
fphotofile (
stror None, optional) – Path to the YAML file defining filter names, bands, and column mappings. Defaults to the bundled DR9 configuration.fitstack (
bool, optional) – IfTrue, load the stacked-spectra photometry configuration instead of the default DR9 one. Default isFalse.ignore_photometry (
bool, optional) – IfTrue, set all photometric bands to not be fit. Default isFalse.
- static get_ab_maggies(filters, flux, wave)[source]
Synthesize AB maggies, padding the spectrum when wavelength coverage is insufficient.
- Parameters:
filters (
speclite.filters.FilterSequence) – Filter sequence.flux (
numpy.ndarray) – Spectrum (or array of spectra) in erg/s/cm2/A.wave (
numpy.ndarray) – Wavelength array in Angstroms.
- Returns:
maggies – Synthesized flux in maggies, shape
(nfilters,)or(nspectra, nfilters).- Return type:
- static get_ab_maggies_pre(filters, wave)[source]
Precompute filter-interpolation data for
get_ab_maggies_unchecked().- Parameters:
filters (
speclite.filters.FilterSequence) – Filter sequence whose response functions lie strictly withinwave.wave (
numpy.ndarray) – Wavelength array in Angstroms.
- Returns:
pre – Tuple of
(lo, hi, resp, idenom)per filter, whereloandhiare the slice indices intowave,respis the interpolated response times wavelength, andidenomis the reciprocal of the AB-reference normalization integral.- Return type:
- static get_ab_maggies_unchecked(filters, flux, wave, pre=None)[source]
Synthesize AB maggies without speclite’s padding or interpolation.
Assumes all filter response functions lie strictly within
wave. Useget_ab_maggies()when wavelength coverage may be insufficient.- Parameters:
filters (
speclite.filters.FilterSequence) – Filter sequence.flux (
numpy.ndarray) – Spectrum in erg/s/cm2/A.wave (
numpy.ndarray) – Wavelength array in Angstroms.pre (
tupleor None, optional) – Precomputed interpolation data fromget_ab_maggies_pre(); computed on the fly ifNone.
- Returns:
maggies – Synthesized flux in maggies, one value per filter.
- Return type:
- static get_dn4000(wave, flam, flam_ivar=None, redshift=None, rest=True, uniqueid='')[source]
Compute the Dn(4000) spectral break index and its inverse variance.
- Parameters:
wave (
numpy.ndarray) – Wavelength array in Angstroms.flam (
numpy.ndarray) – Flux density in erg/s/cm2/A.flam_ivar (
numpy.ndarrayor None, optional) – Inverse variance offlam; uniform weights assumed ifNone.redshift (
floator None, optional) – Object redshift; required whenrest=False.rest (
bool, optional) – IfTrue,waveis already in the rest frame. Default isTrue.
- Returns:
Notes
Uses the narrow-band definition of Balogh et al. (1999): the ratio of mean flux density in 4000–4100 Å to that in 3850–3950 Å (rest frame), following eq. 11 of Bruzual (1983). Returns zeros when wavelength coverage is insufficient or integration fails.
- static get_photflam(maggies, lambda_eff)[source]
Convert maggies to erg/s/cm2/A at the given effective wavelength.
- kcorr_and_absmag(nanomaggies, ivar_nanomaggies, redshift, dmod, photsys, zmodelwave, zmodelflux, synth_absmag, synth_maggies_rest, snrmin=2.0, filters_obs=None, filters_out=None, bands_to_fit=None)[source]
Compute K-corrected rest-frame photometry.
- Parameters:
nanomaggies (
numpy.ndarray) – Input photometric fluxes in the observed-frame bandpasses, in nanomaggies.ivar_nanomaggies (
numpy.ndarray) – Inverse variance photometry corresponding tonanomaggies.redshift (
float) – Galaxy or QSO redshift.dmod (
float) – Distance modulus corresponding toredshift.photsys (
str) – Photometric system (e.g.'N'or'S') selecting the appropriate observed-frame filter set.zmodelwave (
numpy.ndarray) – Observed-frame (redshifted) model wavelength array in Angstroms.zmodelflux (
numpy.ndarray) – Observed-frame (redshifted) model spectrum in erg/s/cm2/A.synth_absmag (
numpy.ndarray) – Absolute magnitudes synthesized from the model SED.synth_maggies_rest (
numpy.ndarray) – Synthesized rest-frame photometry in maggies.snrmin (
float, optional) – Minimum S/N in an observed bandpass for it to contribute to the K-correction. Default is 2.filters_obs (
speclite.filters.FilterSequenceor None, optional) – Observed-frame filter set. Defaults toself.filters[photsys].filters_out (
speclite.filters.FilterSequenceor None, optional) – Rest-frame output filter set. Defaults toself.filters_out.bands_to_fit (
numpy.ndarrayor None, optional) – Boolean or integer mask selecting which photometric bands are used in the fit. Defaults toself.bands_to_fit.
- Returns:
kcorr (
numpy.ndarray) – K-corrections for each bandpass inabsmag_filters.absmag (
numpy.ndarray) – Band-shifted absolute magnitudes for each bandpass inabsmag_filters.ivarabsmag (
numpy.ndarray) – Inverse variance corresponding toabsmag; zero when derived from synthesized photometry.synth_maggies_obs (
numpy.ndarray) – Synthesized observed-frame photometry in maggies.
Notes
The K-correction uses the observed-frame bandpass whose rest-frame effective wavelength most closely matches the desired band-shifted absolute-magnitude band (and which meets the
snrminthreshold), minimizing the K-correction. When no qualifying bandpass is available,ivarabsmagis set to zero andabsmagfalls back tosynth_absmag.
- static parse_photometry(bands, maggies, lambda_eff, ivarmaggies=None, nanomaggies=True, nsigma=2.0, min_uncertainty=None, get_abmag=False)[source]
Parse (nano)maggies into a photometric table with flux-density and magnitude columns.
- Parameters:
bands (
numpy.ndarrayof str) – Photometric band names.maggies (
numpy.ndarray) – Photometric fluxes; interpreted as nanomaggies whennanomaggies=True.lambda_eff (
numpy.ndarray) – Effective wavelengths of each band in Angstroms.ivarmaggies (
numpy.ndarrayor None, optional) – Inverse variance; zeros assumed ifNone.nanomaggies (
bool, optional) – IfTrue, treatmaggiesas nanomaggies. Default isTrue.nsigma (
float, optional) – S/N threshold for computing magnitude upper limits. Default is 2.min_uncertainty (
numpy.ndarrayor None, optional) – Minimum magnitude uncertainty per band, added in quadrature toivarmaggiesbefore computingflam_ivar.get_abmag (
bool, optional) – IfTrue, also compute AB-magnitude columns needed byfastqa. Default isFalse.
- Returns:
phot – Table with columns
band,lambda_eff,nanomaggies,nanomaggies_ivar,flam, andflam_ivar. Whenget_abmag=True, also includesabmag,abmag_ivar,abmag_brighterr,abmag_fainterr, andabmag_limit.- Return type:
- synth_absmag(redshift, dmod, zmodelwave, zmodelflux, filters_out=None)[source]
Synthesize absolute magnitudes from the best-fitting SED.
- Parameters:
redshift (
float) – Galaxy or QSO redshift.dmod (
float) – Distance modulus corresponding toredshift.zmodelwave (
numpy.ndarray) – Observed-frame (redshifted) model wavelength array in Angstroms.zmodelflux (
numpy.ndarray) – Observed-frame (redshifted) model spectrum in erg/s/cm2/A.filters_out (
speclite.filters.FilterSequenceor None, optional) – Rest-frame output filter set used to synthesize absolute magnitudes. Defaults toself.filters_out.
- Returns:
synth_absmag (
numpy.ndarray) – Absolute magnitudes synthesized from the model SED.synth_maggies_rest (
numpy.ndarray) – Synthesized rest-frame photometry in maggies.
- fastspecfit.photometry._gather_tractorphot_onebrick(input_cat, legacysurveydir, radius_match, racolumn, deccolumn, datamodel, restrict_region)[source]
Retrieve Tractor photometry for targets sharing a single brick.
- fastspecfit.photometry.gather_tractorphot(input_cat, racolumn='TARGET_RA', deccolumn='TARGET_DEC', legacysurveydir=None, dr9dir=None, radius_match=1.0, restrict_region=None, columns=None)[source]
Retrieve Tractor photometry for all objects in an input catalog.
Matches using
BRICKID/BRICK_OBJIDwhen available; falls back to positional matching withinradius_matcharcseconds.- Parameters:
input_cat (
astropy.table.Table) – Input catalog with required columnsTARGETID,TARGET_RA, andTARGET_DEC. Optional columnsBRICKNAME,RELEASE,PHOTSYS,BRICKID, andBRICK_OBJIDimprove matching.racolumn (
str, optional) – Name of the RA column. Default is'TARGET_RA'.deccolumn (
str, optional) – Name of the Dec column. Default is'TARGET_DEC'.legacysurveydir (
stror None, optional) – Path to the Legacy Surveys Tractor catalog directory tree.dr9dir (
stror None, optional) – Deprecated alias forlegacysurveydir.radius_match (
float, optional) – Positional matching radius in arcseconds. Default is 1.0.restrict_region (
stror None, optional) – Restrict positional matching to'north'or'south'; both are checked by default.columns (array-like or None, optional) – If provided, return only this subset of columns.
- Returns:
out – Tractor photometry matched to
input_cat, in the same row order.- Return type:
- fastspecfit.photometry.tractorphot_datamodel(from_file=False, datarelease='dr9')[source]
Return a zero-filled table matching the Tractor catalog data model.
- Parameters:
- Returns:
datamodel – Single-row table with the Tractor catalog column names and dtypes, all values set to zero.
- Return type:
fastspecfit.util
General utilities.
- class fastspecfit.util.BoxedScalar(dtype)[source]
A zero-initialized NumPy structured scalar that can be passed by reference.
- Parameters:
dtype (dtype-like) – NumPy dtype of the scalar value.
- value
The boxed value; access via
.valueto unbox.- Type:
numpy scalar
- class fastspecfit.util.MPPool(nworkers, initializer=None, init_argdict=None)[source]
Parallel execution pool that falls back to sequential for a single worker.
Unlike
multiprocessing.Pool,starmap()accepts a list of keyword-argument dictionaries rather than positional arguments.- Parameters:
- class fastspecfit.util.ZWarningMask[source]
Redrock
ZWARNbitmask definitions (from Redrock 0.15.4).Not all flags are currently used by fastspecfit.
- fastspecfit.util._trapz_rebin(x, y, edges, ibw, out)
Numba-accelerated trapezoidal rebinning core.
- fastspecfit.util._trapz_rebin_batch(x, Y, edges, ibw, out)
Apply
_trapz_rebin()to each row ofY(ntemplates × npix).- Parameters:
x (
numpy.ndarray, shape (npix,))Y (
numpy.ndarray, shape (ntemplates, npix))edges (precomputed bin edges and inverse widths from
trapz_rebin_pre())ibw (precomputed bin edges and inverse widths from
trapz_rebin_pre())out (
numpy.ndarray, shape (ntemplates, nbins))
- fastspecfit.util._uid(data)[source]
Return a log-friendly uniqueid that includes the output basename when set.
Use in warning/error messages so SLURM logs can be linked back to a specific healpix output file without changing plot filenames.
- fastspecfit.util.air2vac(airwave)[source]
Convert an air wavelength in Angstroms to vacuum wavelength.
- fastspecfit.util.centers2edges(centers)
Convert bin centers to bin edges by linear extrapolation at the boundaries.
- Parameters:
centers (
numpy.ndarray) – Bin center coordinates.- Returns:
edges – Bin edge coordinates, length
len(centers) + 1.- Return type:
- fastspecfit.util.find_minima(x)[source]
Return indices of local minima of
x, including edges.Indices are sorted in ascending order of
xvalue. Conservative with repeated values:find_minima([1,1,1,2,2,2])returns[0,1,2,4,5].- Parameters:
x (array-like) – Input data array.
- Returns:
ii – Indices of local minima, sorted by
xvalue (smallest first).- Return type:
numpy.ndarrayof int
- fastspecfit.util.fsftime(operation, duration, context=None)[source]
Return a standardized, parseable timing message string.
Durations under 60 seconds are reported in seconds; longer durations are reported in minutes. Use
parse_fsftime()to parse these messages back out of log files.- Parameters:
operation (
str) – Short name of the pipeline stage being timed, e.g.'continuum_specfit'or'write_fastspecfit'.duration (
float) – Elapsed wall time in seconds.context (
stror None, optional) – Optional comma-separated key=value context string appended in square brackets, e.g.'targetid=39627739988231708'.
- Returns:
Formatted timing string ready to pass to a logger.
- Return type:
Examples
>>> log.info(fsftime('continuum_specfit', 3.45, context='targetid=12345')) fsftime 3.45 sec for continuum_specfit [targetid=12345] at 2026-... >>> log.info(fsftime('fit_all', 125.3, context='nobj=500')) fsftime 2.09 min for fit_all [nobj=500] at 2026-...
- fastspecfit.util.ivar2var(ivar, clip=1e-08, sigma=False, allmasked_ok=False)[source]
Safely convert an inverse variance array to variance (or sigma).
- Parameters:
ivar (
numpy.ndarray) – Inverse variance array.clip (
float, optional) – Minimumivarvalue treated as valid. Default is 1e-8.sigma (
bool, optional) – IfTrue, return the square root (i.e. standard deviation). Default isFalse.allmasked_ok (
bool, optional) – IfTrue, return zeros rather than raising when all pixels are masked. Default isFalse.
- Returns:
var (
numpy.ndarray) – Variance (or sigma) array; zero whereivar <= clip.goodmask (
numpy.ndarrayof bool) –Truewhereivar > clip.
- fastspecfit.util.median(A)
Compute the median of array
A(Numba-accelerated).
- fastspecfit.util.minfit(x, y, return_coeff=False)[source]
Fit a parabola y = y0 + ((x - x0) / xerr)^2 to find the minimum.
- Parameters:
x (array-like) – x values.
y (array-like) – y values.
return_coeff (
bool, optional) – IfTrue, also return the raw polynomial coefficients(a, b, c). Default isFalse.
- Returns:
x0 (
float) – x position of the parabola minimum (-1 on failure).xerr (
float) – Half-width of the parabola at unit height (-1 on failure).y0 (
float) – Minimum y value (-1 on failure).zwarn (
int) – Zero on success;ZWarningMask.BAD_MINFITon failure.coeff (
tuple, optional) – Raw(a, b, c)polynomial coefficients; only present whenreturn_coeff=True.
- fastspecfit.util.mwdust_transmission(ebv, filtername)[source]
Convert SFD E(B-V) to Milky Way dust transmission in a given bandpass.
- Parameters:
- Returns:
transmission – Milky Way dust transmission (0–1), same shape as
ebv.- Return type:
Notes
Uses tabulated k_X = A(X)/E(B-V) values where transmission = 10^{-0.4 * k_X * ebv}. Based on
desiutil.dust.mwdust_transmission.
- fastspecfit.util.parse_fsftime(line)[source]
Parse a line for an fsftime timing message produced by
fsftime().
- fastspecfit.util.quantile(A, q)
Compute quantile(s)
qof arrayA(Numba-accelerated).
- fastspecfit.util.radec2pix(nside, ra, dec)[source]
Convert RA/Dec to HEALPix nested pixel numbers.
- Parameters:
- Returns:
pix – HEALPix pixel numbers in the nested scheme.
- Return type:
numpy.ndarrayof int
- fastspecfit.util.sigmaclip(c, low=3.0, high=3.0)
Iterative sigma-clipping; returns the clipped array and a boolean mask.
- fastspecfit.util.trapz(y, x)
Trapezoidal integration of
yoverx(Numba-accelerated).
- fastspecfit.util.trapz_rebin(src_x, src_y, bin_centers, out=None, pre=None)[source]
Resample
src_yinto bins centered atbin_centers(area-conserving).- Parameters:
src_x (
numpy.ndarray) – x coordinates of the input signal.src_y (
numpy.ndarray) – Input signal sampled atsrc_x.bin_centers (
numpy.ndarray) – Center x coordinates of the output bins.out (
numpy.ndarrayor None, optional) – Pre-allocated output array; allocated ifNone.pre (
tupleor None, optional) – Preprocessing data fromtrapz_rebin_pre(); computed frombin_centerswhenNone.
- Returns:
out – Resampled signal at the center of each output bin.
- Return type:
- fastspecfit.util.trapz_rebin_pre(bin_centers)[source]
Precompute bin edges and inverse widths for
trapz_rebin().- Parameters:
bin_centers (
numpy.ndarray) – Center x coordinates of the output bins.- Returns:
pre –
(edges, ibw)whereedgesare the bin edges andibwis the array of inverse bin widths. Pass as thepreargument totrapz_rebin()to avoid recomputation.- Return type: