calpit.qp_io

Conversion between calpit CDEs and qp ensembles.

qp (https://github.com/LSSTDESC/qp) is the format LSST DESC uses to store photometric redshift PDFs. calpit only reads and writes it at the edges: a qp ensemble becomes a GridCDE or a QuantileCDE, and the recalibrated CDEs go back into a qp ensemble.

Functions

_pdf_name(→ str)

from_qp(...)

Converts a qp ensemble into calpit CDEs.

to_qp(→ Any)

Converts calpit CDEs into a qp ensemble.

Module Contents

_pdf_name(ensemble: Any) → str[source]
from_qp(ensemble: Any, y_grid: numpy.typing.ArrayLike | None = None, quantile_levels: numpy.typing.ArrayLike | None = None) → calpit.representations.GridCDE | calpit.representations.QuantileCDE[source]

Converts a qp ensemble into calpit CDEs.

An interp ensemble becomes a GridCDE on its own grid and a quant ensemble a QuantileCDE at its own levels. Any other ensemble, or one of those two resampled, needs y_grid or quantile_levels.

Parameters:
  • ensemble – The qp.Ensemble.

  • y_grid – The grid to evaluate the densities on, shape (n_grid,).

  • quantile_levels – The levels to evaluate the quantiles at, shape (n_levels,). Ignored when y_grid is given.

Returns:

A GridCDE when y_grid is given or the ensemble is an interp ensemble, otherwise a QuantileCDE.

to_qp(cde: calpit.representations.GridCDE | calpit.representations.QuantileCDE | calpit.representations.SampleCDE) → Any[source]

Converts calpit CDEs into a qp ensemble.

Parameters:

cde – The CDEs. Samples are stored as quantiles at the levels i / (m + 1), as SampleCDE.to_quantiles gives them.

Returns:

an interp ensemble for a GridCDE, otherwise a quant ensemble.

Return type:

A qp.Ensemble