xlens.catalog.redshift

Attributes

NUM_Z_GRIDS

Z_MIN

Z_MAX

Z_GRIDS

PROBS

INV1PZ

GAMMA_RISK

Classes

zEstimator

Helper class that provides a standard way to create an ABC using

flexzboostEstimator

Wraps a FlexZBoost-like predictor object with a uniform get_z API.

bpzEstimator

Wraps BPZ template/prior configuration with a uniform get_z API.

Functions

risk(→ float)

get_point_estimate(p)

get_point_estimates_from_pdfs(pdfs)

Compute point estimates from PDF samples on a redshift grid.

get_color(→ numpy.ndarray)

load_bpz_templates(data_path, bands[, filter_name, ...])

Load BPZ template fluxes on Z_GRIDS for provided filter set.

Module Contents

NUM_Z_GRIDS = 501[source]
Z_MIN = 0.0[source]
Z_MAX = 5.0[source]
Z_GRIDS[source]
PROBS[source]
INV1PZ[source]
GAMMA_RISK = 0.15[source]
risk(zx: float, p_norm: numpy.ndarray) float[source]
get_point_estimate(p)[source]
get_point_estimates_from_pdfs(pdfs: numpy.ndarray)[source]

Compute point estimates from PDF samples on a redshift grid.

Returns dict of arrays (shape (N,)):
  • zmode : z_grid[argmax p(z)]

  • z025, z160, z500, z840, z975 : CDF percentiles at [0.025, 0.16, 0.50, 0.84, 0.975]

  • zbest : argmin_zx ∫ p_norm(z) * loss(zx,z) dz (bounded to [z_grid[0], z_grid[-1]])

get_color(src: numpy.ndarray, *, bands: str = 'grizy', ref_band: str = 'i', mag_zero: float = 30.0, comp: int = 1, dg: float = 0.0, flux_name: str = 'gauss2', include_mag_err: bool = False, extinction: numpy.ndarray | None = None) numpy.ndarray[source]
Returns:

If include_mag_err=False: shape (N, 1 + (len(bands)-1))

[ref_mag, (b0-b1), (b1-b2), …]

If include_mag_err=True: shape (N, 1 + 2*(len(bands)-1))

[ref_mag, (b0-b1), err01, (b1-b2), err12, …]

Return type:

np.ndarray

class zEstimator[source]

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract get_z(src: numpy.ndarray, *, mag_zero: float = 30.0, flux_name: str = 'gauss2', bands: str = 'grizy', ref_band: str = 'i', comp: int = 1, dg: float = 0.0, flux_name2: str | None = None, flux_name3: str | None = None, extinction: numpy.ndarray | None = None, **kwargs) dict[source]

Method to get redshift point estimates

get_zsel(src: numpy.ndarray, *, mag_zero: float = 30.0, flux_name: str = 'gauss2', bands: str = 'grizy', ref_band: str = 'i', comp: int = 1, dg: float = 0.0, z_point_name: str = 'zmode', flux_name2: str | None = None, flux_name3: str | None = None, extinction: numpy.ndarray | None = None, **kwargs)[source]
class flexzboostEstimator(pz_obj)[source]

Bases: zEstimator

Wraps a FlexZBoost-like predictor object with a uniform get_z API.

pz_obj[source]
get_z(src: numpy.ndarray, *, mag_zero: float = 30.0, flux_name: str = 'gauss2', bands: str = 'grizy', ref_band: str = 'i', comp: int = 1, dg: float = 0.0, flux_name2: str | None = None, flux_name3: str | None = None, include_mag_err: bool = False, return_pdfs: bool = False, extinction: numpy.ndarray | None = None, **kwargs) dict[source]

Method to get redshift point estimates

load_bpz_templates(data_path: str, bands: str, filter_name: str = 'DC2LSST', spectra_name: str = 'cosmossedswdust136.list')[source]

Load BPZ template fluxes on Z_GRIDS for provided filter set.

class bpzEstimator(flux_templates: numpy.ndarray, prior_dict: dict, zp_errors)[source]

Bases: zEstimator

Wraps BPZ template/prior configuration with a uniform get_z API.

flux_templates[source]
prior_dict[source]
zp_errors[source]
_measure_one_source(flux: numpy.ndarray, flux_err: numpy.ndarray, mag_0: float)[source]
get_z(src: numpy.ndarray, *, mag_zero: float = 30.0, flux_name: str = 'gauss2', bands: str = 'grizy', ref_band: str = 'i', comp: int = 1, dg: float = 0.0, return_pdfs: bool = False, extinction: numpy.ndarray | None = None, **kwargs) dict[source]

Method to get redshift point estimates