firecrown.generators

Classes used to generate metadata for likelihoods and cosmological models.

This package provides generators for creating various types of metadata used in Firecrown analyses. It includes:

  • Two-point statistics generators for creating ell and theta values

  • Inferred galaxy redshift distribution generators for LSST surveys

Public API

Two-Point Generators

These classes and functions generate ell and theta values for two-point statistics:

  • LogLinearElls: Generator for log-linear integral ell values

  • EllOrThetaConfig: Configuration dictionary for ell or theta generation

  • generate_bin_centers: Generate bin centers for ell or theta values

  • generate_ells_cells: Generate ells and Cells from configuration

  • generate_reals: Generate theta and xi values from configuration

Inferred Galaxy Redshift Distributions

These classes generate inferred galaxy redshift distributions for LSST:

  • ZDistLSSTSRD: LSST inferred galaxy redshift distributions

  • ZDistLSSTSRDBin: Single bin configuration for LSST redshift distributions

  • ZDistLSSTSRDBinCollection: Collection of bins for LSST redshift distributions

  • LinearGrid1D: 1D linear grid generator

  • RawGrid1D: 1D grid from explicit values

  • Grid1D: Type alias for LinearGrid1D or RawGrid1D

Constants

Constants for LSST Year 1 and Year 10 surveys:

  • Y1_LENS_ALPHA, Y1_LENS_BETA, Y1_LENS_Z0: Year 1 lens distribution parameters

  • Y1_SOURCE_ALPHA, Y1_SOURCE_BETA, Y1_SOURCE_Z0: Year 1 source parameters

  • Y10_LENS_ALPHA, Y10_LENS_BETA, Y10_LENS_Z0: Year 10 lens parameters

  • Y10_SOURCE_ALPHA, Y10_SOURCE_BETA, Y10_SOURCE_Z0: Year 10 source parameters

  • Y1_LENS_BINS: Year 1 lens bins

  • Y1_SOURCE_BINS: Year 1 source bins

  • Y10_LENS_BINS: Year 10 lens bins

  • Y10_SOURCE_BINS: Year 10 source bins

  • LSST_Y1_LENS_HARMONIC_BIN_COLLECTION: Year 1 lens harmonic bin collection

  • LSST_Y1_SOURCE_HARMONIC_BIN_COLLECTION: Year 1 source harmonic bin collection

  • LSST_Y10_LENS_HARMONIC_BIN_COLLECTION: Year 10 lens harmonic bin collection

  • LSST_Y10_SOURCE_HARMONIC_BIN_COLLECTION: Year 10 source harmonic bin collection

Type Definitions

  • BinsType: Type defining redshift bin configuration

  • ZDistLSSTSRDOpt: Optional parameters for LSST redshift distributions

Attributes

Grid1D

Y1_LENS_ALPHA

Y1_LENS_BETA

Y1_LENS_Z0

Y1_SOURCE_ALPHA

Y1_SOURCE_BETA

Y1_SOURCE_Z0

Y10_LENS_ALPHA

Y10_LENS_BETA

Y10_LENS_Z0

Y10_SOURCE_ALPHA

Y10_SOURCE_BETA

Y10_SOURCE_Z0

Y1_LENS_BINS

Y1_SOURCE_BINS

Y10_LENS_BINS

Y10_SOURCE_BINS

LSST_Y1_LENS_HARMONIC_BIN_COLLECTION

LSST_Y1_SOURCE_HARMONIC_BIN_COLLECTION

LSST_Y10_LENS_HARMONIC_BIN_COLLECTION

LSST_Y10_SOURCE_HARMONIC_BIN_COLLECTION

Classes

LogLinearElls

Generator for log-linear integral ell values.

EllOrThetaConfig

A dictionary of options for generating the ell or theta.

ZDistLSSTSRD

LSST Inferred galaxy redshift distributions.

ZDistLSSTSRDBin

LSST Inferred galaxy redshift distributions in bins.

ZDistLSSTSRDBinCollection

LSST Inferred galaxy redshift distributions in bins.

LinearGrid1D

A 1D linear grid.

RawGrid1D

A 1D grid.

BinsType

Type defining redshift bin configuration.

ZDistLSSTSRDOpt

Optional parameters for the LSST Inferred galaxy redshift distribution.

Functions

generate_bin_centers(*, minimum, maximum, n[, binning])

Return the centers of bins that span the range from minimum to maximum.

generate_ells_cells(ell_config)

Generate ells or theta values from the configuration dictionary.

generate_reals(theta_config)

Generate theta and xi values from the configuration dictionary.

Package Contents

class firecrown.generators.LogLinearElls(/, **data)

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.generators.LogLinearElls

Generator for log-linear integral ell values.

The initializer for LogLinearElls accepts only named parameters. A default value is provided for each parameter, which default is used if the parameter is not provided to the initializer.

Not all ell values will be generated. The result will contain each integral value from min to mid. Starting from mid, and going up to max, there will be n_log logarithmically spaced values.

Note that midpoint must be strictly greater than minimum, and strictly less than maximum. n_log must be positive. All must be integers. All these conditions are verified in the initializer.

LogLinearElls objects are immutable, so they are safe to share and to use as default values for parameters.

Parameters:

data (Any)

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

minimum: Annotated[int, Field(ge=0)] = 2
midpoint: Annotated[int, Field(ge=0)] = 50
maximum: Annotated[int, Field(ge=0)] = 60000
n_log: Annotated[int, Field(ge=1)] = 200
require_increasing()

Validate the ell values.

Return type:

LogLinearElls

generate(min_ell=None, max_ell=None)

Generate the log-linear ell values.

This will use the object’s minimum, midpoint, maximum, and n_log, unless min_ell and max_ell are provided, in which case those will be used.

Parameters:
  • min_ell (int | None) – The low edge of the first bin.

  • max_ell (int | None) – The high edge of the last bin.

Returns:

The ell values.

Return type:

numpy.typing.NDArray[numpy.int64]

generate_all()

Generate all ell values from minimum to maximum, inclusive.

Return type:

numpy.typing.NDArray[numpy.int64]

class firecrown.generators.EllOrThetaConfig

Bases: TypedDict

Inheritance diagram of firecrown.generators.EllOrThetaConfig

A dictionary of options for generating the ell or theta.

This dictionary contains the minimum, maximum and number of bins to generate the ell or theta values at which to compute the statistics.

Parameters:
  • minimum – The start of the binning.

  • maximum – The end of the binning.

  • n – The number of bins.

  • binning – Pass ‘log’ to get logarithmic spaced bins and ‘lin’ to get linearly spaced bins. Default is ‘log’.

minimum: float
maximum: float
n: int
binning: str
firecrown.generators.generate_bin_centers(*, minimum, maximum, n, binning='log')

Return the centers of bins that span the range from minimum to maximum.

If binning is ‘log’, this will generate logarithmically spaced bins; if binning is ‘lin’, this will generate linearly spaced bins.

Parameters:
  • minimum (float) – The low edge of the first bin.

  • maximum (float) – The high edge of the last bin.

  • n (int) – The number of bins.

  • binning (str) – Either ‘log’ or ‘lin’.

Returns:

The centers of the bins.

Return type:

numpy.typing.NDArray[numpy.float64]

firecrown.generators.generate_ells_cells(ell_config)

Generate ells or theta values from the configuration dictionary.

Parameters:

ell_config (EllOrThetaConfig) – the configuration parameters.

Returns:

ells and Cells

firecrown.generators.generate_reals(theta_config)

Generate theta and xi values from the configuration dictionary.

Parameters:
Returns:

ells and Cells

class firecrown.generators.ZDistLSSTSRD(alpha, beta, z0, max_z=5.0, use_autoknot=False, autoknots_reltol=0.0001, autoknots_abstol=1e-15)

LSST Inferred galaxy redshift distributions.

Inferred galaxy redshift distribution is based on the LSST Science Requirements Document (SRD), equation 5. Note that the SRD fixes \(\beta = 2\).

The values of \(\alpha\) and \(z_0\) are different for Year 1 and Year 10. ZDistLSSTSRD provides these values as defaults and allows for greater flexibility when desired.

Parameters:
  • alpha (float)

  • beta (float)

  • z0 (float)

  • max_z (float)

  • use_autoknot (bool)

  • autoknots_reltol (float)

  • autoknots_abstol (float)

alpha
beta
z0
max_z = 5.0
use_autoknot = False
autoknots_reltol = 0.0001
autoknots_abstol = 1e-15
classmethod year_1_lens(alpha=Y1_LENS_ALPHA, beta=Y1_LENS_BETA, z0=Y1_LENS_Z0, **kwargs)

Create a ZDistLSSTSRD object for the first year of LSST.

It uses the default values of the alpha, beta and z0 parameters from the LSST SRD Year 1 for the lens distribution.

Parameters:
  • alpha (float) – The alpha parameter of the distribution

  • beta (float) – The beta parameter of the distribution

  • z0 (float) – The z0 parameter of the distribution

  • kwargs (Unpack[ZDistLSSTSRDOpt])

Returns:

A ZDistLSSTSRD object.

Return type:

ZDistLSSTSRD

classmethod year_1_source(alpha=Y1_SOURCE_ALPHA, beta=Y1_SOURCE_BETA, z0=Y1_SOURCE_Z0, **kwargs)

Create a ZDistLSSTSRD object for the first year of LSST.

It uses the default values of the alpha, beta and z0 parameters from the LSST SRD Year 1 for the source distribution.

Parameters:
  • alpha (float) – The alpha parameter of the distribution

  • beta (float) – The beta parameter of the distribution

  • z0 (float) – The z0 parameter of the distribution

  • kwargs (Unpack[ZDistLSSTSRDOpt])

Returns:

A ZDistLSSTSRD object.

Return type:

ZDistLSSTSRD

classmethod year_10_lens(alpha=Y10_LENS_ALPHA, beta=Y10_LENS_BETA, z0=Y10_LENS_Z0, **kwargs)

Create a ZDistLSSTSRD object for the tenth year of LSST.

It uses the default values of the alpha, beta and z0 parameters from the LSST SRD Year 10 for the lens distribution.

Parameters:
  • alpha (float) – The alpha parameter of the distribution

  • beta (float) – The beta parameter of the distribution

  • z0 (float) – The z0 parameter of the distribution

  • kwargs (Unpack[ZDistLSSTSRDOpt])

Returns:

A ZDistLSSTSRD object.

Return type:

ZDistLSSTSRD

classmethod year_10_source(alpha=Y10_SOURCE_ALPHA, beta=Y10_SOURCE_BETA, z0=Y10_SOURCE_Z0, **kwargs)

Create a ZDistLSSTSRD object for the tenth year of LSST.

It uses the default values of the alpha, beta and z0 parameters from the LSST SRD Year 10 for the source distribution.

Parameters:
  • alpha (float) – The alpha parameter of the distribution

  • beta (float) – The beta parameter of the distribution

  • z0 (float) – The z0 parameter of the distribution

  • kwargs (Unpack[ZDistLSSTSRDOpt])

Returns:

A ZDistLSSTSRD object.

Return type:

ZDistLSSTSRD

distribution(z)

Generate the inferred galaxy redshift distribution.

Parameters:

z (numpy.typing.NDArray) – The redshifts at which to evaluate the distribution

Returns:

The inferred galaxy redshift distribution

Return type:

numpy.typing.NDArray

distribution_zp(zp, sigma_z)

Generate the Gaussian convolution of the distribution.

Parameters:
  • sigma_z (float) – The resolution parameter

  • zp (float) – The photometric redshift

Returns:

The Gaussian distribution

Return type:

float

compute_distribution(sigma_z)

Generate the inferred galaxy redshift distribution.

Computes the distribution by convolving the true distribution with a Gaussian. The convolution is computed using the AutoKnots algorithm of NumCosmo.

Parameters:

sigma_z (float) – The resolution parameter

Returns:

The inferred galaxy redshift distribution

Return type:

numcosmo_py.Ncm.StatsDist1d

compute_true_distribution()

Generate the inferred galaxy redshift distribution.

Computes the distribution without the convolution with the Gaussian. That is, the true redshift distribution.

Returns:

The inferred galaxy redshift distribution

Return type:

numcosmo_py.Ncm.StatsDist1d

equal_area_bins(n_bins, sigma_z, last_z, use_true_distribution=False)

Generate equal area bins for the distribution.

In order to compute the bin edges, the convolution of the distribution with a Gaussian is computed. The bin edges are then computed by inverting the cumulative distribution function of the convolution.

If the true distribution is used, the convolution is not computed. This provides a faster way to compute the bin edges.

Parameters:
  • n_bins (int) – The number of bins

  • sigma_z (float) – The resolution parameter

  • last_z (float) – The last redshift to consider

  • use_true_distribution (bool) – Whether to use the true distribution

Returns:

The bin edges

Return type:

numpy.typing.NDArray

binned_distribution(*, zpl, zpu, sigma_z, z, name, measurements)

Generate the inferred galaxy redshift distribution in bins.

Parameters:
  • zpl (float) – The lower bound of the integration

  • zpu (float) – The upper bound of the integration

  • sigma_z (float) – The resolution parameter

  • z (numpy.typing.NDArray) – The redshifts at which to evaluate the distribution

  • name (str) – The name of the distribution

  • measurements (set[firecrown.metadata_types.Measurement]) – The set of measurements of the distribution

Returns:

The inferred galaxy redshift distribution

Return type:

firecrown.metadata_types.InferredGalaxyZDist

class firecrown.generators.ZDistLSSTSRDBin(/, **data)

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.generators.ZDistLSSTSRDBin

LSST Inferred galaxy redshift distributions in bins.

Parameters:

data (Any)

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

zpl: float
zpu: float
sigma_z: float
z: Annotated[Grid1D, Field(union_mode='left_to_right')]
bin_name: str
measurements: Annotated[set[firecrown.metadata_types.Measurement], BeforeValidator(make_measurements)]
classmethod serialize_measurements(value)

Serialize the Measurement.

Parameters:

value (set[firecrown.metadata_types.Measurement])

Return type:

list[dict]

generate(zdist)

Generate the inferred galaxy redshift distribution in bins.

Parameters:

zdist (ZDistLSSTSRD)

Return type:

firecrown.metadata_types.InferredGalaxyZDist

class firecrown.generators.ZDistLSSTSRDBinCollection(/, **data)

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.generators.ZDistLSSTSRDBinCollection

LSST Inferred galaxy redshift distributions in bins.

Parameters:

data (Any)

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

alpha: float
beta: float
z0: float
bins: list[ZDistLSSTSRDBin]
max_z: float = 5.0
use_autoknot: bool = True
autoknots_reltol: float = 0.0001
autoknots_abstol: float = 1e-15
generate()

Generate the inferred galaxy redshift distributions in bins.

Return type:

list[firecrown.metadata_types.InferredGalaxyZDist]

class firecrown.generators.LinearGrid1D(/, **data)

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.generators.LinearGrid1D

A 1D linear grid.

Parameters:

data (Any)

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

start: float
end: float
num: int
generate()

Generate the 1D linear grid.

Return type:

numpy.typing.NDArray

class firecrown.generators.RawGrid1D(/, **data)

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.generators.RawGrid1D

A 1D grid.

Parameters:

data (Any)

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

values: list[float]
generate()

Generate the 1D grid.

Return type:

numpy.typing.NDArray

firecrown.generators.Grid1D
class firecrown.generators.BinsType

Bases: TypedDict

Inheritance diagram of firecrown.generators.BinsType

Type defining redshift bin configuration.

Contains bin edges array and photometric redshift scatter parameter.

edges: numpy.typing.NDArray
sigma_z: float
class firecrown.generators.ZDistLSSTSRDOpt

Bases: TypedDict

Inheritance diagram of firecrown.generators.ZDistLSSTSRDOpt

Optional parameters for the LSST Inferred galaxy redshift distribution.

max_z: float
use_autoknot: bool
autoknots_reltol: float
autoknots_abstol: float
firecrown.generators.Y1_LENS_ALPHA = 0.94
firecrown.generators.Y1_LENS_BETA = 2.0
firecrown.generators.Y1_LENS_Z0 = 0.26
firecrown.generators.Y1_SOURCE_ALPHA = 0.78
firecrown.generators.Y1_SOURCE_BETA = 2.0
firecrown.generators.Y1_SOURCE_Z0 = 0.13
firecrown.generators.Y10_LENS_ALPHA = 0.9
firecrown.generators.Y10_LENS_BETA = 2.0
firecrown.generators.Y10_LENS_Z0 = 0.28
firecrown.generators.Y10_SOURCE_ALPHA = 0.68
firecrown.generators.Y10_SOURCE_BETA = 2.0
firecrown.generators.Y10_SOURCE_Z0 = 0.11
firecrown.generators.Y1_LENS_BINS: BinsType
firecrown.generators.Y1_SOURCE_BINS: BinsType
firecrown.generators.Y10_LENS_BINS: BinsType
firecrown.generators.Y10_SOURCE_BINS: BinsType
firecrown.generators.LSST_Y1_LENS_HARMONIC_BIN_COLLECTION: ZDistLSSTSRDBinCollection
firecrown.generators.LSST_Y1_SOURCE_HARMONIC_BIN_COLLECTION: ZDistLSSTSRDBinCollection
firecrown.generators.LSST_Y10_LENS_HARMONIC_BIN_COLLECTION: ZDistLSSTSRDBinCollection
firecrown.generators.LSST_Y10_SOURCE_HARMONIC_BIN_COLLECTION: ZDistLSSTSRDBinCollection