firecrown.data_functions
This module deals with two-point data functions.
It contains functions to manipulate two-point data objects.
Attributes
Classes
Class defining a tracer bin specification. |
|
Class defining a filter for a bin. |
|
Class defining a collection of bin filters. |
Functions
|
Return a hash of the covariance matrix. |
|
Extract the two-point function metadata and data from a sacc file. |
|
Extract the two-point function metadata and data from a sacc file. |
|
Check if the indices of the measurement-space two-point functions overlap. |
|
Check the indices of the two-point functions. |
|
Check the indices of the harmonic-space two-point functions. |
|
Check the indices of the real-space two-point functions. |
|
Create an interval from a list of values. |
|
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:
- 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:
- 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:
measurements (collections.abc.Sequence[firecrown.data_types.TwoPointMeasurement]) – The measurements to check.
is_type_func (collections.abc.Callable[[firecrown.data_types.TwoPointMeasurement], bool]) – A function to verify the type of the measurements.
type_name (str) – The type of the measurements.
- 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
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)]
- 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
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.')]
- 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:
name1 (str)
measurement1 (firecrown.metadata_types.Measurement)
name2 (str)
measurement2 (firecrown.metadata_types.Measurement)
lower (float)
upper (float)
- Return type:
- 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
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
- 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:
- 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:
- 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: