firecrown.metadata_types

This module deals with metadata types.

This module contains metadata types definitions.

Attributes

ALL_MEASUREMENTS

Comprehensive list of all measurement types.

ALL_MEASUREMENT_TYPES

Tuple of all measurement type classes.

CMB_TYPES

Tuple of all CMB measurement types.

GALAXY_LENS_TYPES

Galaxy measurements for lens tracers.

GALAXY_SOURCE_TYPES

Galaxy measurements for source tracers.

LENS_REGEX

Regular expression for lens tracer bin names.

SOURCE_REGEX

Regular expression for source tracer bin names.

Measurement

Type alias for any measurement type.

MeasurementPair

A pair of measurement types (e.g., galaxy_shear_plus, galaxy_density).

TomographicBinPair

A pair of tomographic bin distributions to be correlated.

MEASURED_TYPE_STRING_MAP

Mapping from SACC strings to measurement type pairs.

TRACER_NAMES_TOTAL

Special TracerNames instance for totals.

Classes

InferredGalaxyZDist

The class used to store the redshift resolution data for a sacc file.

CMB

This enumeration type for CMB measurements.

Clusters

This enumeration type for cluster measurements.

Galaxies

This enumeration type for galaxy measurements.

AndBinPairSelector

Logical AND combinator for bin pair selectors.

AutoBinPairSelector

Selector for auto-correlations based on both bin name and measurement type.

AutoMeasurementBinPairSelector

Selector for auto-correlations based on measurement type.

AutoNameBinPairSelector

Selector for auto-correlations based on bin names.

AutoNameDiffBinPairSelector

Selector for tomographic bins with identical prefix and nearby indices.

BinPairSelector

Base class for filtering pairs of tomographic bins in two-point measurements.

CompositeSelector

Base class for selectors composed from other selectors.

CrossBinPairSelector

Selector for cross-correlations: excludes auto-bin pairs.

CrossMeasurementBinPairSelector

Selector for cross-correlations: excludes auto-measurement pairs.

CrossNameBinPairSelector

Selector for cross-correlations: excludes auto-name pairs.

CrossNameDiffBinPairSelector

Selector for tomographic bins with different prefixes and nearby indices.

LeftMeasurementBinPairSelector

Selector filtering pairs by the left (x) measurement type.

LensBinPairSelector

Selector for galaxy lens (clustering) measurement pairs.

NamedBinPairSelector

Selector for explicitly specified bin name pairs.

NameDiffBinPairSelector

Selector for tomographic bins based on numeric index proximity.

NotBinPairSelector

Logical NOT combinator for bin pair selectors.

OrBinPairSelector

Logical OR combinator for bin pair selectors.

RightMeasurementBinPairSelector

Selector filtering pairs by the right (y) measurement type.

SourceBinPairSelector

Selector for galaxy source (weak lensing) measurement pairs.

SourceLensBinPairSelector

Selector for mixed source-lens measurement pairs.

ThreeTwoBinPairSelector

Selector for 3x2pt analysis bin pairs.

TypeSourceBinPairSelector

Selector for bins with matching type-source.

TwoPointCorrelationSpace

This class defines the two-point correlation space.

TwoPointFilterMethod

Defines methods for filtering two-point measurements.

TwoPointHarmonic

Class defining the metadata for an harmonic-space two-point measurement.

TwoPointReal

Class defining the metadata for a real-space two-point measurement.

TwoPointXY

Class defining a two-point correlation pair of redshift resolutions.

TracerNames

The names of the two tracers in the sacc file.

TypeSource

String to specify the subtype or origin of a measurement source.

Functions

measurement_is_compatible(a, b)

Check if two Measurement are compatible.

measurements_types(measurements)

Collect the types of the measurements in a set.

register_bin_pair_selector(cls)

Register a new bin pair selector class in the global registry.

Package Contents

firecrown.metadata_types.measurement_is_compatible(a, b)

Check if two Measurement are compatible.

Two Measurement are compatible if they can be correlated in a two-point function.

Parameters:
  • a (firecrown.metadata_types._measurements.Measurement)

  • b (firecrown.metadata_types._measurements.Measurement)

Return type:

bool

firecrown.metadata_types.measurements_types(measurements)

Collect the types of the measurements in a set.

Return a tuple (bool, list[str]) where the first element is True if the set of measurements contains more than one type of measurement, and the second element is a list of the types of the measurements.

Parameters:

measurements (set[firecrown.metadata_types._measurements.Measurement])

Return type:

tuple[bool, list[str]]

class firecrown.metadata_types.InferredGalaxyZDist

Bases: firecrown.utils.YAMLSerializable

Inheritance diagram of firecrown.metadata_types.InferredGalaxyZDist

The class used to store the redshift resolution data for a sacc file.

The sacc file is a complicated set of tracers (bins) and surveys. This class is used to store the redshift resolution data for a single photometric bin.

bin_name: str
z: numpy.ndarray
dndz: numpy.ndarray
measurements: set[firecrown.metadata_types._measurements.Measurement]
type_source: firecrown.metadata_types._utils.TypeSource
__post_init__()

Validate the redshift resolution data.

  • Make sure the z and dndz arrays have the same shape;

  • The measurement must be of type Measurement.

  • The bin_name should not be empty.

Return type:

None

__eq__(other)

Equality test for InferredGalaxyZDist.

Two InferredGalaxyZDist are equal if they have equal bin_name, z, dndz, and measurement.

property measurement_list: list[firecrown.metadata_types._measurements.Measurement]

Get the measurements as a sorted list.

Return type:

list[firecrown.metadata_types._measurements.Measurement]

firecrown.metadata_types.ALL_MEASUREMENTS: list[Measurement]

Comprehensive list of all measurement types.

Includes all measurement types across all categories (Galaxies, CMB, Clusters).

firecrown.metadata_types.ALL_MEASUREMENT_TYPES

Tuple of all measurement type classes.

Used for type checking and iteration over measurement categories.

class firecrown.metadata_types.CMB

Bases: firecrown.utils.YAMLSerializable, str, enum.Enum

Inheritance diagram of firecrown.metadata_types.CMB

This enumeration type for CMB measurements.

It provides identifiers for the different types of CMB-related types of measurement.

SACC has some notion of supporting other types, but incomplete implementation. When support for more types is added to SACC this enumeration needs to be updated.

CONVERGENCE
sacc_type_name()

Return the lower-case form of the main measurement type.

This is the first part of the SACC string used to denote a correlation between measurements of this type.

Return type:

str

sacc_measurement_name()

Return the lower-case form of the specific measurement type.

This is the second part of the SACC string used to denote the specific measurement type.

Return type:

str

polarization()

Return the SACC polarization code.

This is the third part of the SACC string used to denote the specific measurement type.

Return type:

str

__lt__(other)

Define a comparison function for the CMBMeasurement enumeration.

__eq__(other)

Define an equality test for CMBMeasurement enumeration.

__ne__(other)

Negation of __eq__.

__hash__()

Define a hash function that uses both type and value information.

Return type:

int

firecrown.metadata_types.CMB_TYPES

Tuple of all CMB measurement types.

firecrown.metadata_types.GALAXY_LENS_TYPES

Galaxy measurements for lens tracers.

Includes galaxy number counts (density) associated with lens (clustering) tracers.

firecrown.metadata_types.GALAXY_SOURCE_TYPES

Galaxy measurements for source tracers.

Includes all shear-related measurements associated with source (weak lensing) tracers.

firecrown.metadata_types.LENS_REGEX

Regular expression for lens tracer bin names.

Matches names like lens0, lens1, lens2, etc.

firecrown.metadata_types.SOURCE_REGEX

Regular expression for source tracer bin names.

Matches names like src0, src1, source0, source1, etc.

class firecrown.metadata_types.Clusters

Bases: firecrown.utils.YAMLSerializable, str, enum.Enum

Inheritance diagram of firecrown.metadata_types.Clusters

This enumeration type for cluster measurements.

It provides identifiers for the different types of cluster-related types of measurement.

SACC has some notion of supporting other types, but incomplete implementation. When support for more types is added to SACC this enumeration needs to be updated.

COUNTS
sacc_type_name()

Return the lower-case form of the main measurement type.

This is the first part of the SACC string used to denote a correlation between measurements of this type.

Return type:

str

sacc_measurement_name()

Return the lower-case form of the specific measurement type.

This is the second part of the SACC string used to denote the specific measurement type.

Return type:

str

polarization()

Return the SACC polarization code.

This is the third part of the SACC string used to denote the specific measurement type.

Return type:

str

__lt__(other)

Define a comparison function for the ClusterMeasurement enumeration.

__eq__(other)

Define an equality test for ClusterMeasurement enumeration.

__ne__(other)

Negation of __eq__.

__hash__()

Define a hash function that uses both type and value information.

Return type:

int

class firecrown.metadata_types.Galaxies

Bases: firecrown.utils.YAMLSerializable, str, enum.Enum

Inheritance diagram of firecrown.metadata_types.Galaxies

This enumeration type for galaxy measurements.

It provides identifiers for the different types of galaxy-related types of measurement.

SACC has some notion of supporting other types, but incomplete implementation. When support for more types is added to SACC this enumeration needs to be updated.

SHEAR_E
SHEAR_T
PART_OF_XI_MINUS
SHEAR_MINUS
PART_OF_XI_PLUS
SHEAR_PLUS
COUNTS
is_shear()

Return True if the measurement is a shear measurement, False otherwise.

Returns:

True if the measurement is a shear measurement, False otherwise

Return type:

bool

sacc_type_name()

Return the lower-case form of the main measurement type.

This is the first part of the SACC string used to denote a correlation between measurements of this type.

Return type:

str

sacc_measurement_name()

Return the lower-case form of the specific measurement type.

This is the second part of the SACC string used to denote the specific measurement type.

Return type:

str

polarization()

Return the SACC polarization code.

This is the third part of the SACC string used to denote the specific measurement type.

Return type:

str

__lt__(other)

Define a comparison function for the Galaxy Measurement enumeration.

__eq__(other)

Define an equality test for Galaxy Measurement enumeration.

__ne__(other)

Negation of __eq__.

__hash__()

Define a hash function that uses both type and value information.

Return type:

int

firecrown.metadata_types.Measurement

Type alias for any measurement type.

class firecrown.metadata_types.AndBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.AndBinPairSelector

Logical AND combinator for bin pair selectors.

This selector keeps a bin pair only if ALL contained selectors accept it. Nested AndBinPairSelectors are automatically flattened for efficiency.

Parameters:

data (Any)

kind: str = 'and'
pair_selectors: list[pydantic.SerializeAsAny[BinPairSelector]]
keep(zdist, m)

Return True if all of the bin pair selectors pass.

Parameters:
  • zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects.

  • m (MeasurementPair) – Pair of Measurement objects.

Returns:

True if all bin pair selectors pass, False otherwise.

Return type:

bool

model_post_init(_, /)

Flatten nested AndBinPairSelectors for efficiency.

This optimization reduces (A & B) & C to a single AndBinPairSelector containing [A, B, C], avoiding unnecessary nesting.

Return type:

None

class firecrown.metadata_types.AutoBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.AutoBinPairSelector

Selector for auto-correlations based on both bin name and measurement type.

This selector keeps only pairs where both bins have identical names and both measurements are identical, effectively selecting auto-correlations within the same tomographic bin and measurement type.

Parameters:

data (Any)

kind: str = 'auto-bin'
model_post_init(_, /)

Initialize as composite of auto-name and auto-measurement selectors.

Parameters:

_ (Any)

Return type:

None

class firecrown.metadata_types.AutoMeasurementBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.AutoMeasurementBinPairSelector

Selector for auto-correlations based on measurement type.

This selector keeps only pairs where both measurements are identical (e.g., both are galaxy_shear_plus or both are galaxy_density).

Parameters:

data (Any)

kind: str = 'auto-measurement'
keep(_zdist, m)

Return True if both measurements are the same.

Parameters:
  • _zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects (unused).

  • m (MeasurementPair) – Pair of Measurement objects.

Returns:

True if both measurements are identical, False otherwise.

Return type:

bool

class firecrown.metadata_types.AutoNameBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.AutoNameBinPairSelector

Selector for auto-correlations based on bin names.

This selector keeps only pairs where both bins have identical names, effectively selecting auto-correlations within the same tomographic bin.

Parameters:

data (Any)

kind: str = 'auto-name'
keep(zdist, _m)

Return True if both bins have the same bin name.

Parameters:
  • zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects.

  • _m (MeasurementPair) – Pair of Measurement objects (unused).

Returns:

True if both bins have the same name, False otherwise.

Return type:

bool

class firecrown.metadata_types.AutoNameDiffBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.AutoNameDiffBinPairSelector

Selector for tomographic bins with identical prefix and nearby indices.

This selector keeps bin pairs where: 1. Both bins have identical text prefixes (e.g., both start with “bin”) 2. Their numeric indices differ by one of the allowed amounts in neighbors_diff

This is useful for selecting bin combinations with similar properties while allowing for spatial or redshift proximity constraints.

Parameters:
  • neighbors_diff – An integer or list of integers specifying which index differences are allowed. For example, [0, 1, -1] allows identical indices and immediate neighbors.

  • data (Any)

Example:

With neighbors_diff=1 (same prefix, adjacent or identical indices): - Keeps: (“bin0”, “bin1”), (“bin1”, “bin0”), (“bin2”, “bin2”) - Rejects: (“bin0”, “bin2”), (“src0”, “bin0”)

kind: str = 'auto-name-diff'
neighbors_diff: int | list[int] = 1
model_post_init(_, /)

Initialize as NameDiffBinPairSelector with same_name_prefix=True.

Parameters:

_ (Any)

Return type:

None

class firecrown.metadata_types.BinPairSelector(/, **data)

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.metadata_types.BinPairSelector

Base class for filtering pairs of tomographic bins in two-point measurements.

A BinPairSelector determines which pairs of InferredGalaxyZDist bins should be included when constructing TwoPointXY objects. Concrete implementations define specific selection criteria (e.g., auto-correlations only, specific bin names, measurement types, etc.).

Selectors support logical composition via operators: - AND: selector1 & selector2 - OR: selector1 | selector2 - NOT: ~selector

Parameters:

data (Any)

kind: str
abstractmethod keep(zdist, m)

Return True if the pair should be kept.

Parameters:
  • zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects.

  • m (MeasurementPair) – Pair of Measurement objects.

Returns:

True if the pair should be kept, False otherwise.

Return type:

bool

__and__(other)

Return the AND combinator of this pair selector with another.

Example:

# Select auto-correlations that are also source measurements selector = AutoNameBinPairSelector() & SourceBinPairSelector()

Parameters:

other (BinPairSelector) – Another BinPairSelector to combine with.

Returns:

An AndBinPairSelector combining both pair selectors.

Return type:

BinPairSelector

__or__(other)

Return the OR combinator of this pair selector with another.

Example:

# Select either source or lens pairs selector = SourceBinPairSelector() | LensBinPairSelector()

Parameters:

other (BinPairSelector) – Another BinPairSelector to combine with.

Returns:

An OrBinPairSelector combining both pair selectors.

Return type:

BinPairSelector

__invert__()

Return the inverse of this bin pair selector.

Example:

# Select everything except auto-correlations selector = ~AutoNameBinPairSelector()

Returns:

A NotBinPairSelector inverting this pair selector.

Return type:

BinPairSelector

classmethod __get_pydantic_core_schema__(source_type, handler, /)

Get the Pydantic core schema for the BinPairSelector class.

Parameters:
  • source_type (Any)

  • handler (pydantic.GetCoreSchemaHandler)

Return type:

pydantic_core.core_schema.CoreSchema

class firecrown.metadata_types.CompositeSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.CompositeSelector

Base class for selectors composed from other selectors.

Parameters:

data (Any)

keep(zdist, m)

Delegate to the underlying selector implementation.

Parameters:
  • zdist (TomographicBinPair)

  • m (MeasurementPair)

class firecrown.metadata_types.CrossBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.CrossBinPairSelector

Selector for cross-correlations: excludes auto-bin pairs.

This selector keeps only pairs where the bin names differ, effectively selecting cross-correlations between different tomographic bins.

Parameters:

data (Any)

kind: str = 'cross-bin'
model_post_init(_, /)

Invert AutoBinPairSelector.

Parameters:

_ (Any)

Return type:

None

class firecrown.metadata_types.CrossMeasurementBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.CrossMeasurementBinPairSelector

Selector for cross-correlations: excludes auto-measurement pairs.

This selector keeps only pairs where both measurements differ.

Parameters:

data (Any)

kind: str = 'cross-measurement'
model_post_init(_, /)

Invert AutoMeasurementBinPairSelector.

Parameters:

_ (Any)

Return type:

None

class firecrown.metadata_types.CrossNameBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.CrossNameBinPairSelector

Selector for cross-correlations: excludes auto-name pairs.

This selector keeps only pairs where both bins have different names.

Parameters:

data (Any)

kind: str = 'cross-name'
model_post_init(_, /)

Invert AutoNameBinPairSelector.

Parameters:

_ (Any)

Return type:

None

class firecrown.metadata_types.CrossNameDiffBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.CrossNameDiffBinPairSelector

Selector for tomographic bins with different prefixes and nearby indices.

This selector keeps bin pairs where: 1. Both bins have different text prefixes (e.g., one “bin” and one “src”) 2. Their numeric indices differ by one of the allowed amounts in neighbors_diff

This is useful for selecting cross-type bin combinations (e.g., clustering-lensing pairs) with spatial or redshift proximity constraints.

Parameters:
  • neighbors_diff – An integer or list of integers specifying which index differences are allowed.

  • data (Any)

Example:

With neighbors_diff=[0, 1, -1] (different prefixes, nearby indices): - Keeps: (“src0”, “bin0”), (“src0”, “bin1”), (“bin1”, “src0”) - Rejects: (“bin0”, “bin1”), (“src0”, “src1”)

kind: str = 'cross-name-diff'
neighbors_diff: int | list[int] = 1
model_post_init(_, /)

Initialize as NameDiffBinPairSelector with same_name_prefix=False.

Parameters:

_ (Any)

Return type:

None

class firecrown.metadata_types.LeftMeasurementBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.LeftMeasurementBinPairSelector

Selector filtering pairs by the left (x) measurement type.

This selector keeps pairs where the left (x) measurement is one of the configured measurement types.

Example:

# Select pairs where left measurement is a source (shear) measurement selector = LeftMeasurementBinPairSelector(measurement_set=GALAXY_SOURCE_TYPES)

Parameters:

data (Any)

kind: str = 'left-measurement'
measurement_set: set[firecrown.metadata_types._measurements.Measurement]
keep(_zdist, m)

Return True if the left measurement is in the configured set.

Parameters:
  • _zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects (unused).

  • m (MeasurementPair) – Pair of Measurement objects.

Returns:

True if the left measurement is in the set, False otherwise.

Return type:

bool

class firecrown.metadata_types.LensBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.LensBinPairSelector

Selector for galaxy lens (clustering) measurement pairs.

This selector keeps pairs where both measurements are galaxy lens types, which correspond to galaxy number density or clustering measurements.

Implementation note: This is a composite selector combining LeftMeasurementBinPairSelector and RightMeasurementBinPairSelector with GALAXY_LENS_TYPES.

Parameters:

data (Any)

kind: str = 'lens'
model_post_init(_, /)

Initialize as composite of left and right lens measurement selectors.

Parameters:

_ (Any)

Return type:

None

firecrown.metadata_types.MeasurementPair

A pair of measurement types (e.g., galaxy_shear_plus, galaxy_density).

class firecrown.metadata_types.NamedBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.NamedBinPairSelector

Selector for explicitly specified bin name pairs.

This selector keeps bin pairs if their names match any entry in the configured list exactly, in the given order. The matching is order-dependent: (name1, name2) is different from (name2, name1).

Example:

names=[(“bin0”, “bin1”), (“bin2”, “bin2”)] # Matches in that exact order

Parameters:

data (Any)

kind: str = 'named'
names: list[tuple[str, str]]
classmethod serialize_names(value)

Serialize name tuples to lists for JSON/YAML compatibility.

Parameters:

value (list[tuple[str, str]]) – List of name tuples.

Returns:

List of name lists (tuples converted to lists).

Return type:

list[list[str]]

classmethod validate_names(value)

Validate and convert name lists to tuples.

Parameters:

value (list[list[str]]) – List of name lists (from deserialization).

Returns:

List of name tuples.

Raises:

AssertionError – If any name list doesn’t have exactly 2 elements.

Return type:

list[tuple[str, str]]

keep(zdist, m)

Return True if the bin name pair matches any configured pair.

Note: Matching is currently order-dependent. To achieve symmetric matching, include both (name1, name2) and (name2, name1) in the names list.

Parameters:
  • zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects.

  • m (MeasurementPair) – Pair of Measurement objects (unused).

Returns:

True if the bin name pair matches any configured name pair.

Return type:

bool

class firecrown.metadata_types.NameDiffBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.NameDiffBinPairSelector

Selector for tomographic bins based on numeric index proximity.

This selector filters bin pairs based on the numeric suffix of their names, with optional constraints on the text prefix. Bin names must follow the pattern <text><number>, where <text> is any text prefix and <number> is the bin index suffix.

The selector keeps pairs where the numeric indices differ by one of the allowed values in neighbors_diff. If same_name_prefix=True, the text prefixes must also be identical. If same_name_prefix=False, the text prefixes must differ.

Parameters:
  • same_name_prefix – If True, keep pairs with identical text prefixes; if False, keep pairs with different text prefixes.

  • neighbors_diff – An integer or list of integers specifying which index differences are allowed. Differences are computed as (left_index - right_index).

  • data (Any)

Example:

With same_name_prefix=True, neighbors_diff=1 (auto-pairs with adjacent indices):

  • Keeps: (“bin0”, “bin1”), (“bin1”, “bin0”), (“bin2”, “bin2”)

  • Rejects: (“bin0”, “bin2”), (“bin0”, “src0”)

With same_name_prefix=False, neighbors_diff=[1, -1] (cross-pairs with different prefixes):

  • Keeps: (“src0”, “bin1”), (“bin1”, “src0”)

  • Rejects: (“bin0”, “bin1”), (“src0”, “src1”)

kind: str = 'name-diff'
same_name_prefix: bool = True
neighbors_diff: int | list[int] = 1
keep(zdist, _m)

Return True if bin name indices differ by an allowed amount.

Both bin names must match the pattern <text><number>. The numeric parts are extracted and their difference is checked against the allowed values. If same_name_prefix is set, the text parts must also satisfy the constraint.

Parameters:
  • zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects.

  • _m (MeasurementPair) – Pair of Measurement objects (unused).

Returns:

True if bins are neighbors, False otherwise.

Return type:

bool

class firecrown.metadata_types.NotBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.NotBinPairSelector

Logical NOT combinator for bin pair selectors.

This selector inverts the result of the contained selector, accepting pairs that would be rejected and vice versa.

Parameters:

data (Any)

kind: str = 'not'
pair_selector: pydantic.SerializeAsAny[BinPairSelector]
keep(zdist, m)

Return the negation of the contained pair selector’s result.

Parameters:
  • zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects.

  • m (MeasurementPair) – Pair of Measurement objects.

Returns:

True if the contained pair selector returns False, False otherwise.

Return type:

bool

class firecrown.metadata_types.OrBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.OrBinPairSelector

Logical OR combinator for bin pair selectors.

This selector keeps a bin pair if ANY of the contained selectors accept it. Nested OrBinPairSelectors are automatically flattened for efficiency.

Parameters:

data (Any)

kind: str = 'or'
pair_selectors: list[pydantic.SerializeAsAny[BinPairSelector]]
keep(zdist, m)

Return True if any of the bin pair selectors pass.

Parameters:
  • zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects.

  • m (MeasurementPair) – Pair of Measurement objects.

Returns:

True if any bin pair selector passes, False otherwise.

Return type:

bool

model_post_init(_, /)

Flatten nested OrBinPairSelectors for efficiency.

This optimization reduces (A | B) | C to a single OrBinPairSelector containing [A, B, C], avoiding unnecessary nesting.

Return type:

None

class firecrown.metadata_types.RightMeasurementBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.RightMeasurementBinPairSelector

Selector filtering pairs by the right (y) measurement type.

This selector keeps pairs where the right (y) measurement is one of the configured measurement types.

Example:

# Select pairs where right measurement is a lens (density) measurement selector = RightMeasurementBinPairSelector(measurement_set=GALAXY_LENS_TYPES)

Parameters:

data (Any)

kind: str = 'right-measurement'
measurement_set: set[firecrown.metadata_types._measurements.Measurement]
keep(_zdist, m)

Return True if the right measurement is in the configured set.

Parameters:
  • _zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects (unused).

  • m (MeasurementPair) – Pair of Measurement objects.

Returns:

True if the right measurement is in the set, False otherwise.

Return type:

bool

class firecrown.metadata_types.SourceBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.SourceBinPairSelector

Selector for galaxy source (weak lensing) measurement pairs.

This selector keeps pairs where both measurements are galaxy source types, which correspond to weak lensing shear measurements (e.g., galaxy_shear_plus, galaxy_shear_minus).

Implementation note: This is a composite selector combining LeftMeasurementBinPairSelector and RightMeasurementBinPairSelector with GALAXY_SOURCE_TYPES.

Parameters:

data (Any)

kind: str = 'source'
model_post_init(_, /)

Initialize as composite of left and right source measurement selectors.

Parameters:

_ (Any)

Return type:

None

class firecrown.metadata_types.SourceLensBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.SourceLensBinPairSelector

Selector for mixed source-lens measurement pairs.

This selector keeps pairs where the left measurement is a galaxy source type (weak lensing shear) and the right measurement is a galaxy lens type (density/clustering). The measurement order follows the convention: source types are ordered before lens types.

Implementation note: This is a composite selector combining LeftMeasurementBinPairSelector with GALAXY_SOURCE_TYPES and RightMeasurementBinPairSelector with GALAXY_LENS_TYPES.

Parameters:

data (Any)

kind: str = 'source-lens'
model_post_init(_, /)

Initialize as composite of source-left and lens-right selectors.

Parameters:

_ (Any)

Return type:

None

class firecrown.metadata_types.ThreeTwoBinPairSelector(/, **data)

Bases: CompositeSelector

Inheritance diagram of firecrown.metadata_types.ThreeTwoBinPairSelector

Selector for 3x2pt analysis bin pairs.

This selector implements the standard 3x2pt cosmological analysis selection, which includes three types of two-point correlations:

  1. Source-source (cosmic shear): auto-correlations of weak lensing shear

  2. Lens-lens (galaxy clustering): auto-correlations of galaxy positions

  3. Source-lens (galaxy-galaxy lensing): cross-correlations between source and lens samples with different bin names

The galaxy-galaxy lensing component explicitly excludes auto-correlations (same bin name) to avoid mixing source and lens samples from the same tomographic bin, which is the standard practice in 3x2pt analyses.

Implementation note: This is a composite selector combining:

SourceBinPairSelector() | LensBinPairSelector() | (SourceLensBinPairSelector() & CrossNameBinPairSelector())

Example:

selector = ThreeTwoBinPairSelector() # Includes: source-source, lens-lens, and cross-name source-lens pairs

Parameters:
  • source_dist – Maximum allowed index separation (left minus right) for source-source bin pairs. The allowed differences are in the interval [-source_dist, source_dist] (both endpoints inclusive).

  • lens_dist – Maximum allowed index separation (left minus right) for lens-lens bin pairs. The allowed differences are in the interval [-lens_dist, lens_dist] (both endpoints inclusive).

  • source_lens_dist – Maximum positive index separation allowed for source-lens pairs. The allowed differences are {1, 2, ..., source_lens_dist}. Only pairs with different prefixes (enforced by CrossNameDiff) are kept.

  • data (Any)

kind: str = '3x2pt'
source_dist: int = 5
lens_dist: int = 5
source_lens_dist: int = 5
model_post_init(_, /)

Initialize as composite of source, lens, and source-lens selectors.

Parameters:

_ (Any)

Return type:

None

class firecrown.metadata_types.TypeSourceBinPairSelector(/, **data)

Bases: BinPairSelector

Inheritance diagram of firecrown.metadata_types.TypeSourceBinPairSelector

Selector for bins with matching type-source.

This selector keeps bin pairs where both bins have identical type-sources that also match the configured value. The type-source typically indicates whether data comes from spectroscopy or photometry.

Parameters:

data (Any)

kind: str = 'type-source'
type_source: firecrown.metadata_types._utils.TypeSource
keep(zdist, _m)

Return True if both bins have the same matching type-source.

Parameters:
  • zdist (TomographicBinPair) – Pair of InferredGalaxyZDist objects.

  • _m (MeasurementPair) – Pair of Measurement objects (unused).

Returns:

True if both bins have matching type-sources, False otherwise.

Return type:

bool

firecrown.metadata_types.TomographicBinPair

A pair of tomographic bin distributions to be correlated.

firecrown.metadata_types.register_bin_pair_selector(cls)

Register a new bin pair selector class in the global registry.

This decorator registers a BinPairSelector subclass using its Pydantic kind field default value as the registry key. This enables polymorphic deserialization from configuration files.

Parameters:

cls (type[BinPairSelector]) – The BinPairSelector class to register.

Returns:

The registered BinPairSelector class (for use as a decorator).

Raises:

ValueError – If the class has no default for ‘kind’ or if the kind is already registered.

Return type:

type[BinPairSelector]

firecrown.metadata_types.MEASURED_TYPE_STRING_MAP: dict[str, tuple[firecrown.metadata_types._measurements.Measurement, firecrown.metadata_types._measurements.Measurement]]

Mapping from SACC strings to measurement type pairs.

Maps SACC measurement type strings (like ‘galaxy_density_cl’ or ‘galaxy_shear_cl_ee’) to their corresponding pairs of Measurement types.

class firecrown.metadata_types.TwoPointCorrelationSpace

Bases: firecrown.utils.YAMLSerializable, enum.StrEnum

Inheritance diagram of firecrown.metadata_types.TwoPointCorrelationSpace

This class defines the two-point correlation space.

The two-point correlation space can be either real or harmonic. The real space corresponds measurements in terms of angular separation, while the harmonic space corresponds to measurements in terms of spherical harmonics decomposition.

REAL
HARMONIC
classmethod __get_pydantic_core_schema__(_source_type, _handler)

Get the Pydantic core schema for the TypeSource class.

Parameters:
  • _source_type (Any)

  • _handler (Any)

Return type:

pydantic_core.core_schema.CoreSchema

class firecrown.metadata_types.TwoPointFilterMethod

Bases: firecrown.utils.YAMLSerializable, enum.StrEnum

Inheritance diagram of firecrown.metadata_types.TwoPointFilterMethod

Defines methods for filtering two-point measurements.

When filtering a two-point measurement with an associated window, the filter is applied to the window first. The user must then choose how to proceed:

  • If filtering by LABEL, the window_ells labels are used to determine whether the observation should be kept.

  • If filtering by SUPPORT, the full ell support must lie within the allowed range.

  • If filtering by SUPPORT_95, only the 95% support region must lie within the range.

In all cases, filters define an interval of ells to retain.

LABEL
SUPPORT
SUPPORT_95
classmethod __get_pydantic_core_schema__(_source_type, _handler)

Get the Pydantic core schema for the TypeSource class.

Parameters:
  • _source_type (Any)

  • _handler (Any)

Return type:

pydantic_core.core_schema.CoreSchema

class firecrown.metadata_types.TwoPointHarmonic

Bases: firecrown.utils.YAMLSerializable

Inheritance diagram of firecrown.metadata_types.TwoPointHarmonic

Class defining the metadata for an harmonic-space two-point measurement.

The class used to store the metadata for a (spherical) harmonic-space two-point function measured on a sphere.

This includes the two redshift resolutions (one for each binned quantity) and the array of (integer) l’s at which the two-point function which has this metadata were calculated.

XY: TwoPointXY
ells: numpy.typing.NDArray[numpy.int64]
window: None | numpy.typing.NDArray[numpy.float64] = None
window_ells: None | numpy.typing.NDArray[numpy.float64] = None
__post_init__()

Validate the TwoPointHarmonic data.

Make sure the ells are a 1D array and X and Y are compatible with harmonic-space calculations.

Return type:

None

__eq__(other)

Equality test for TwoPointHarmonic objects.

Return type:

bool

__str__()

Return a string representation of the TwoPointHarmonic object.

Return type:

str

get_sacc_name()

Return the SACC name for the two-point function.

Return type:

str

n_observations()

Return the number of observations described by these metadata.

Returns:

The number of observations.

Return type:

int

class firecrown.metadata_types.TwoPointReal

Bases: firecrown.utils.YAMLSerializable

Inheritance diagram of firecrown.metadata_types.TwoPointReal

Class defining the metadata for a real-space two-point measurement.

The class used to store the metadata for a real-space two-point function measured on a sphere.

This includes the two redshift resolutions (one for each binned quantity) and the a array of (floating point) theta (angle) values at which the two-point function which has this metadata were calculated.

XY: TwoPointXY
thetas: numpy.typing.NDArray[numpy.float64]
__post_init__()

Validate the TwoPointReal data.

Make sure the window is

__str__()

Return a string representation of the TwoPointReal object.

Return type:

str

get_sacc_name()

Return the SACC name for the two-point function.

Return type:

str

__eq__(other)

Equality test for TwoPointReal objects.

Return type:

bool

n_observations()

Return the number of observations described by these metadata.

Returns:

The number of observations.

Return type:

int

class firecrown.metadata_types.TwoPointXY

Bases: firecrown.utils.YAMLSerializable

Inheritance diagram of firecrown.metadata_types.TwoPointXY

Class defining a two-point correlation pair of redshift resolutions.

It is used to store the two redshift resolutions for the two bins being correlated. The measurements must follow the canonical SACC ordering: CMB < Clusters < Galaxies, and within each type, the ordering defined by the Measurement enum (e.g., for Galaxies: shape measurements before counts).

x: firecrown.metadata_types._inferred_galaxy_zdist.InferredGalaxyZDist
y: firecrown.metadata_types._inferred_galaxy_zdist.InferredGalaxyZDist
x_measurement: firecrown.metadata_types._measurements.Measurement
y_measurement: firecrown.metadata_types._measurements.Measurement
__post_init__()

Validate that measurements are compatible and follow canonical ordering.

Return type:

None

__eq__(other)

Equality test for TwoPointXY objects.

Return type:

bool

__str__()

Return a string representation of the TwoPointXY object.

Return type:

str

get_tracer_names()

Return the TracerNames object for the TwoPointXY object.

Return type:

firecrown.metadata_types._utils.TracerNames

firecrown.metadata_types.TRACER_NAMES_TOTAL

Special TracerNames instance for totals.

Represents the total/sum over all tracers, indicated by empty tracer names.

class firecrown.metadata_types.TracerNames

Bases: firecrown.utils.YAMLSerializable

Inheritance diagram of firecrown.metadata_types.TracerNames

The names of the two tracers in the sacc file.

name1: str
name2: str
__getitem__(item)

Get the name of the tracer at the given index.

__iter__()

Iterate through the data members.

This is to allow automatic unpacking.

class firecrown.metadata_types.TypeSource

Bases: str

Inheritance diagram of firecrown.metadata_types.TypeSource

String to specify the subtype or origin of a measurement source.

This helps distinguish between different categories of sources within the same measurement type. For example:

  • In galaxy counts, this could differentiate between red and blue galaxies.

  • In CMB lensing, it could identify data from different instruments like Planck or SPT.

DEFAULT: TypeSource
classmethod __get_pydantic_core_schema__(_source_type, _handler)

Get the Pydantic core schema for the TypeSource class.

Parameters:
  • _source_type (Any)

  • _handler (Any)

Return type:

pydantic_core.core_schema.CoreSchema