firecrown.generators ==================== .. py:module:: firecrown.generators .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: firecrown.generators.Grid1D firecrown.generators.Y1_LENS_ALPHA firecrown.generators.Y1_LENS_BETA firecrown.generators.Y1_LENS_Z0 firecrown.generators.Y1_SOURCE_ALPHA firecrown.generators.Y1_SOURCE_BETA firecrown.generators.Y1_SOURCE_Z0 firecrown.generators.Y10_LENS_ALPHA firecrown.generators.Y10_LENS_BETA firecrown.generators.Y10_LENS_Z0 firecrown.generators.Y10_SOURCE_ALPHA firecrown.generators.Y10_SOURCE_BETA firecrown.generators.Y10_SOURCE_Z0 firecrown.generators.Y1_LENS_BINS firecrown.generators.Y1_SOURCE_BINS firecrown.generators.Y10_LENS_BINS firecrown.generators.Y10_SOURCE_BINS firecrown.generators.LSST_Y1_LENS_HARMONIC_BIN_COLLECTION firecrown.generators.LSST_Y1_SOURCE_HARMONIC_BIN_COLLECTION firecrown.generators.LSST_Y10_LENS_HARMONIC_BIN_COLLECTION firecrown.generators.LSST_Y10_SOURCE_HARMONIC_BIN_COLLECTION Classes ------- .. autoapisummary:: firecrown.generators.LogLinearElls firecrown.generators.EllOrThetaConfig firecrown.generators.ZDistLSSTSRD firecrown.generators.ZDistLSSTSRDBin firecrown.generators.ZDistLSSTSRDBinCollection firecrown.generators.LinearGrid1D firecrown.generators.RawGrid1D firecrown.generators.BinsType firecrown.generators.ZDistLSSTSRDOpt Functions --------- .. autoapisummary:: firecrown.generators.generate_bin_centers firecrown.generators.generate_ells_cells firecrown.generators.generate_reals Package Contents ---------------- .. py:class:: LogLinearElls(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.generators.LogLinearElls :parts: 1 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. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: minimum :type: Annotated[int, Field(ge=0)] :value: 2 .. py:attribute:: midpoint :type: Annotated[int, Field(ge=0)] :value: 50 .. py:attribute:: maximum :type: Annotated[int, Field(ge=0)] :value: 60000 .. py:attribute:: n_log :type: Annotated[int, Field(ge=1)] :value: 200 .. py:method:: require_increasing() Validate the ell values. .. py:method:: 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. :param min_ell: The low edge of the first bin. :param max_ell: The high edge of the last bin. :return: The ell values. .. py:method:: generate_all() Generate all ell values from minimum to maximum, inclusive. .. py:class:: EllOrThetaConfig Bases: :py:obj:`TypedDict` .. autoapi-inheritance-diagram:: firecrown.generators.EllOrThetaConfig :parts: 1 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. :param minimum: The start of the binning. :param maximum: The end of the binning. :param n: The number of bins. :param binning: Pass 'log' to get logarithmic spaced bins and 'lin' to get linearly spaced bins. Default is 'log'. .. py:attribute:: minimum :type: float .. py:attribute:: maximum :type: float .. py:attribute:: n :type: int .. py:attribute:: binning :type: str .. py:function:: 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. :param minimum: The low edge of the first bin. :param maximum: The high edge of the last bin. :param n: The number of bins. :param binning: Either 'log' or 'lin'. :return: The centers of the bins. .. py:function:: generate_ells_cells(ell_config) Generate ells or theta values from the configuration dictionary. :param ell_config: the configuration parameters. :return: ells and Cells .. py:function:: generate_reals(theta_config) Generate theta and xi values from the configuration dictionary. :param ell_config: the configuration parameters. :return: ells and Cells .. py:class:: 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 :math:`\beta = 2`. The values of :math:`\alpha` and :math:`z_0` are different for Year 1 and Year 10. `ZDistLSSTSRD` provides these values as defaults and allows for greater flexibility when desired. .. py:attribute:: alpha .. py:attribute:: beta .. py:attribute:: z0 .. py:attribute:: max_z :value: 5.0 .. py:attribute:: use_autoknot :value: False .. py:attribute:: autoknots_reltol :value: 0.0001 .. py:attribute:: autoknots_abstol :value: 1e-15 .. py:method:: year_1_lens(alpha = Y1_LENS_ALPHA, beta = Y1_LENS_BETA, z0 = Y1_LENS_Z0, **kwargs) :classmethod: 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. :param alpha: The alpha parameter of the distribution :param beta: The beta parameter of the distribution :param z0: The z0 parameter of the distribution :return: A ZDistLSSTSRD object. .. py:method:: year_1_source(alpha = Y1_SOURCE_ALPHA, beta = Y1_SOURCE_BETA, z0 = Y1_SOURCE_Z0, **kwargs) :classmethod: 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. :param alpha: The alpha parameter of the distribution :param beta: The beta parameter of the distribution :param z0: The z0 parameter of the distribution :return: A ZDistLSSTSRD object. .. py:method:: year_10_lens(alpha = Y10_LENS_ALPHA, beta = Y10_LENS_BETA, z0 = Y10_LENS_Z0, **kwargs) :classmethod: 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. :param alpha: The alpha parameter of the distribution :param beta: The beta parameter of the distribution :param z0: The z0 parameter of the distribution :return: A ZDistLSSTSRD object. .. py:method:: year_10_source(alpha = Y10_SOURCE_ALPHA, beta = Y10_SOURCE_BETA, z0 = Y10_SOURCE_Z0, **kwargs) :classmethod: 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. :param alpha: The alpha parameter of the distribution :param beta: The beta parameter of the distribution :param z0: The z0 parameter of the distribution :return: A ZDistLSSTSRD object. .. py:method:: distribution(z) Generate the inferred galaxy redshift distribution. :param z: The redshifts at which to evaluate the distribution :return: The inferred galaxy redshift distribution .. py:method:: distribution_zp(zp, sigma_z) Generate the Gaussian convolution of the distribution. :param sigma_z: The resolution parameter :param zp: The photometric redshift :return: The Gaussian distribution .. py:method:: 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. :param sigma_z: The resolution parameter :return: The inferred galaxy redshift distribution .. py:method:: compute_true_distribution() Generate the inferred galaxy redshift distribution. Computes the distribution without the convolution with the Gaussian. That is, the true redshift distribution. :return: The inferred galaxy redshift distribution .. py:method:: 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. :param n_bins: The number of bins :param sigma_z: The resolution parameter :param last_z: The last redshift to consider :param use_true_distribution: Whether to use the true distribution :return: The bin edges .. py:method:: binned_distribution(*, zpl, zpu, sigma_z, z, name, measurements) Generate the inferred galaxy redshift distribution in bins. :param zpl: The lower bound of the integration :param zpu: The upper bound of the integration :param sigma_z: The resolution parameter :param z: The redshifts at which to evaluate the distribution :param name: The name of the distribution :param measurements: The set of measurements of the distribution :return: The inferred galaxy redshift distribution .. py:class:: ZDistLSSTSRDBin(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.generators.ZDistLSSTSRDBin :parts: 1 LSST Inferred galaxy redshift distributions in bins. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: zpl :type: float .. py:attribute:: zpu :type: float .. py:attribute:: sigma_z :type: float .. py:attribute:: z :type: Annotated[Grid1D, Field(union_mode='left_to_right')] .. py:attribute:: bin_name :type: str .. py:attribute:: measurements :type: Annotated[set[firecrown.metadata_types.Measurement], BeforeValidator(make_measurements)] .. py:method:: serialize_measurements(value) :classmethod: Serialize the Measurement. .. py:method:: generate(zdist) Generate the inferred galaxy redshift distribution in bins. .. py:class:: ZDistLSSTSRDBinCollection(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.generators.ZDistLSSTSRDBinCollection :parts: 1 LSST Inferred galaxy redshift distributions in bins. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: alpha :type: float .. py:attribute:: beta :type: float .. py:attribute:: z0 :type: float .. py:attribute:: bins :type: list[ZDistLSSTSRDBin] .. py:attribute:: max_z :type: float :value: 5.0 .. py:attribute:: use_autoknot :type: bool :value: True .. py:attribute:: autoknots_reltol :type: float :value: 0.0001 .. py:attribute:: autoknots_abstol :type: float :value: 1e-15 .. py:method:: generate() Generate the inferred galaxy redshift distributions in bins. .. py:class:: LinearGrid1D(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.generators.LinearGrid1D :parts: 1 A 1D linear grid. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: start :type: float .. py:attribute:: end :type: float .. py:attribute:: num :type: int .. py:method:: generate() Generate the 1D linear grid. .. py:class:: RawGrid1D(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.generators.RawGrid1D :parts: 1 A 1D grid. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: values :type: list[float] .. py:method:: generate() Generate the 1D grid. .. py:data:: Grid1D .. py:class:: BinsType Bases: :py:obj:`TypedDict` .. autoapi-inheritance-diagram:: firecrown.generators.BinsType :parts: 1 Type defining redshift bin configuration. Contains bin edges array and photometric redshift scatter parameter. .. py:attribute:: edges :type: numpy.typing.NDArray .. py:attribute:: sigma_z :type: float .. py:class:: ZDistLSSTSRDOpt Bases: :py:obj:`TypedDict` .. autoapi-inheritance-diagram:: firecrown.generators.ZDistLSSTSRDOpt :parts: 1 Optional parameters for the LSST Inferred galaxy redshift distribution. .. py:attribute:: max_z :type: float .. py:attribute:: use_autoknot :type: bool .. py:attribute:: autoknots_reltol :type: float .. py:attribute:: autoknots_abstol :type: float .. py:data:: Y1_LENS_ALPHA :value: 0.94 .. py:data:: Y1_LENS_BETA :value: 2.0 .. py:data:: Y1_LENS_Z0 :value: 0.26 .. py:data:: Y1_SOURCE_ALPHA :value: 0.78 .. py:data:: Y1_SOURCE_BETA :value: 2.0 .. py:data:: Y1_SOURCE_Z0 :value: 0.13 .. py:data:: Y10_LENS_ALPHA :value: 0.9 .. py:data:: Y10_LENS_BETA :value: 2.0 .. py:data:: Y10_LENS_Z0 :value: 0.28 .. py:data:: Y10_SOURCE_ALPHA :value: 0.68 .. py:data:: Y10_SOURCE_BETA :value: 2.0 .. py:data:: Y10_SOURCE_Z0 :value: 0.11 .. py:data:: Y1_LENS_BINS :type: BinsType .. py:data:: Y1_SOURCE_BINS :type: BinsType .. py:data:: Y10_LENS_BINS :type: BinsType .. py:data:: Y10_SOURCE_BINS :type: BinsType .. py:data:: LSST_Y1_LENS_HARMONIC_BIN_COLLECTION :type: ZDistLSSTSRDBinCollection .. py:data:: LSST_Y1_SOURCE_HARMONIC_BIN_COLLECTION :type: ZDistLSSTSRDBinCollection .. py:data:: LSST_Y10_LENS_HARMONIC_BIN_COLLECTION :type: ZDistLSSTSRDBinCollection .. py:data:: LSST_Y10_SOURCE_HARMONIC_BIN_COLLECTION :type: ZDistLSSTSRDBinCollection