firecrown.data_functions

This module deals with two-point data functions.

It contains functions to manipulate two-point data objects.

Attributes

BinSpec

Classes

TwoPointTracerSpec

Class defining a tracer bin specification.

TwoPointBinFilter

Class defining a filter for a bin.

TwoPointBinFilterCollection

Class defining a collection of bin filters.

Functions

cov_hash(sacc_data)

Return a hash of the covariance matrix.

extract_all_harmonic_data(sacc_data[, ...])

Extract the two-point function metadata and data from a sacc file.

extract_all_real_data(sacc_data[, allowed_data_type, ...])

Extract the two-point function metadata and data from a sacc file.

ensure_no_overlaps(measurement, index_set, index_sets, ...)

Check if the indices of the measurement-space two-point functions overlap.

check_consistence(measurements, is_type_func, type_name)

Check the indices of the two-point functions.

check_two_point_consistence_harmonic(two_point_harmonics)

Check the indices of the harmonic-space two-point functions.

check_two_point_consistence_real(two_point_reals)

Check the indices of the real-space two-point functions.

make_interval_from_list(values)

Create an interval from a list of values.

bin_spec_from_metadata(metadata)

Return the bin spec from the metadata.

Module Contents

firecrown.data_functions.cov_hash(sacc_data)[source]

Return a hash of the covariance matrix.

Parameters:

sacc_data (sacc.Sacc) – The SACC data object containing the covariance matrix.

Returns:

The hash of the covariance matrix.

Return type:

str

firecrown.data_functions.extract_all_harmonic_data(sacc_data, allowed_data_type=None, include_maybe_types=False)[source]

Extract the two-point function metadata and data from a sacc file.

Parameters:
  • sacc_data (sacc.Sacc)

  • allowed_data_type (None | list[str])

Return type:

list[firecrown.data_types.TwoPointMeasurement]

firecrown.data_functions.extract_all_real_data(sacc_data, allowed_data_type=None, include_maybe_types=False)[source]

Extract the two-point function metadata and data from a sacc file.

Parameters:
  • sacc_data (sacc.Sacc)

  • allowed_data_type (None | list[str])

Return type:

list[firecrown.data_types.TwoPointMeasurement]

firecrown.data_functions.ensure_no_overlaps(measurement, index_set, index_sets, other_measurements)[source]

Check if the indices of the measurement-space two-point functions overlap.

Raises a ValueError if they do.

Parameters:
  • measurement (str) – The TwoPointHarmonic to check.

  • index_set (set[int]) – The indices of the current TwoPointHarmonic.

  • index_sets (list[set[int]]) – The indices of the other TwoPointHarmonics.

  • other_measurements (list[str]) – The other TwoPointHarmonics.

Return type:

None

firecrown.data_functions.check_consistence(measurements, is_type_func, type_name)[source]

Check the indices of the two-point functions.

Make sure the indices of the two-point functions are consistent.

Parameters:
Return type:

None

firecrown.data_functions.check_two_point_consistence_harmonic(two_point_harmonics)[source]

Check the indices of the harmonic-space two-point functions.

Parameters:

two_point_harmonics (collections.abc.Sequence[firecrown.data_types.TwoPointMeasurement])

Return type:

None

firecrown.data_functions.check_two_point_consistence_real(two_point_reals)[source]

Check the indices of the real-space two-point functions.

Parameters:

two_point_reals (collections.abc.Sequence[firecrown.data_types.TwoPointMeasurement])

Return type:

None

class firecrown.data_functions.TwoPointTracerSpec(/, **data)[source]

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.data_functions.TwoPointTracerSpec

Class defining a tracer bin specification.

Parameters:

data (Any)

model_config

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

name: Annotated[str, Field(description='The name of the tracer bin.')]
measurement: Annotated[firecrown.metadata_types.Measurement, Field(description='The measurement of the tracer bin.'), BeforeValidator(make_measurement)]
classmethod serialize_measurement(value)[source]

Serialize the Measurement.

Parameters:

value (firecrown.metadata_types.Measurement)

Return type:

dict[str, str]

firecrown.data_functions.make_interval_from_list(values)[source]

Create an interval from a list of values.

Parameters:

values (list[float] | tuple[float, float])

Return type:

tuple[float, float]

class firecrown.data_functions.TwoPointBinFilter(/, **data)[source]

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.data_functions.TwoPointBinFilter

Class defining a filter for a bin.

Parameters:
  • spec – The two-point bin specification.

  • interval – The range of the bin to filter.

  • method – The filter method.

  • data (Any)

model_config

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

spec: Annotated[list[TwoPointTracerSpec], Field(description='The two-point bin specification.')]
interval: Annotated[tuple[float, float], BeforeValidator(make_interval_from_list), Field(description='The range of the bin to filter.')]
method: Annotated[firecrown.metadata_types.TwoPointFilterMethod, Field(description='The filter method.')]
check_bin_filter()[source]

Check the bin filter.

Return type:

TwoPointBinFilter

classmethod serialize_interval(value)[source]

Serialize the Measurement.

Parameters:

value (tuple[float, float])

Return type:

list[float]

classmethod from_args(name1, measurement1, name2, measurement2, lower, upper, method=TwoPointFilterMethod.SUPPORT)[source]

Create a TwoPointBinFilter from the arguments.

Parameters:
Return type:

TwoPointBinFilter

classmethod from_args_auto(name, measurement, lower, upper, method=TwoPointFilterMethod.SUPPORT)[source]

Create a TwoPointBinFilter from the arguments.

Parameters:
Return type:

TwoPointBinFilter

firecrown.data_functions.BinSpec
firecrown.data_functions.bin_spec_from_metadata(metadata)[source]

Return the bin spec from the metadata.

Parameters:

metadata (firecrown.metadata_types.TwoPointReal | firecrown.metadata_types.TwoPointHarmonic)

Return type:

BinSpec

class firecrown.data_functions.TwoPointBinFilterCollection(/, **data)[source]

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.data_functions.TwoPointBinFilterCollection

Class defining a collection of bin filters.

Parameters:

data (Any)

model_config

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

require_filter_for_all: bool = None
allow_empty: bool = None
filters: list[TwoPointBinFilter] = None
check_bin_filters()[source]

Check the bin filters.

Return type:

TwoPointBinFilterCollection

property bin_filter_dict: dict[BinSpec, TwoPointBinFilter][source]

Return the bin filter dictionary.

Return type:

dict[BinSpec, TwoPointBinFilter]

filter_match(tpm)[source]

Check if the TwoPointMeasurement matches the filter.

Parameters:

tpm (firecrown.data_types.TwoPointMeasurement)

Return type:

bool

run_bin_filter(bin_filter, vals)[source]

Run the filter merge.

Parameters:
  • bin_filter (TwoPointBinFilter)

  • vals (numpy.typing.NDArray[numpy.float64] | numpy.typing.NDArray[numpy.int64])

Return type:

numpy.typing.NDArray[numpy.bool_]

apply_filter_single(tpm)[source]

Apply the filter to a single TwoPointMeasurement.

Parameters:

tpm (firecrown.data_types.TwoPointMeasurement)

Return type:

tuple[numpy.typing.NDArray[numpy.bool_], numpy.typing.NDArray[numpy.bool_]]

__call__(tpms)[source]

Filter the two-point measurements.

Parameters:

tpms (collections.abc.Sequence[firecrown.data_types.TwoPointMeasurement])

Return type:

list[firecrown.data_types.TwoPointMeasurement]