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. |
|
Create an interval from a list of values. |
|
Return the bin spec from the metadata. |
|
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. |
|
Extract the two-point function metadata and data from a sacc file. |
|
Extract the two-point function metadata and data from a sacc file. |
Package Contents
- firecrown.data_functions.cov_hash(sacc_data)
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
- class firecrown.data_functions.TwoPointTracerSpec(/, **data)
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)]
- classmethod serialize_measurement(value)
Serialize the Measurement.
- Parameters:
value (firecrown.metadata_types.Measurement)
- Return type:
dict[str, str]
- class firecrown.data_functions.TwoPointBinFilter(/, **data)
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.')]
- check_bin_filter()
Check the bin filter.
- Return type:
- classmethod serialize_interval(value)
Serialize the Measurement.
- Parameters:
value (tuple[float, float])
- Return type:
list[float]
- classmethod from_args(name1, measurement1, name2, measurement2, lower, upper, method=TwoPointFilterMethod.SUPPORT)
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:
- classmethod from_args_auto(name, measurement, lower, upper, method=TwoPointFilterMethod.SUPPORT)
Create a TwoPointBinFilter from the arguments.
- Parameters:
name (str)
measurement (firecrown.metadata_types.Measurement)
lower (float)
upper (float)
- Return type:
- firecrown.data_functions.BinSpec
- firecrown.data_functions.make_interval_from_list(values)
Create an interval from a list of values.
- Parameters:
values (list[float] | tuple[float, float])
- Return type:
tuple[float, float]
- firecrown.data_functions.bin_spec_from_metadata(metadata)
Return the bin spec from the metadata.
- Parameters:
metadata (firecrown.metadata_types.TwoPointReal | firecrown.metadata_types.TwoPointHarmonic)
- firecrown.data_functions.ensure_no_overlaps(measurement, index_set, index_sets, other_measurements)
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)
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)
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)
Check the indices of the real-space two-point functions.
- Parameters:
two_point_reals (collections.abc.Sequence[firecrown.data_types.TwoPointMeasurement])
- Return type:
None
- firecrown.data_functions.extract_all_harmonic_data(sacc_data, allow_mixed_types=False, allowed_data_type=None, normalize=True)
Extract the two-point function metadata and data from a sacc file.
- Parameters:
sacc_data (sacc.Sacc) – The SACC file containing the data.
allow_mixed_types (bool) – Whether to allow mixed tracer types.
allowed_data_type (None | list[str]) – List of allowed data types to extract.
normalize (bool) – If True, normalize the window function weights to sum to 1.
- Returns:
A list of TwoPointMeasurement objects.
- Return type:
- firecrown.data_functions.extract_all_real_data(sacc_data, allow_mixed_types=False, allowed_data_type=None)
Extract the two-point function metadata and data from a sacc file.
- Parameters:
sacc_data (sacc.Sacc)
allow_mixed_types (bool)
allowed_data_type (None | list[str])
- Return type:
- class firecrown.data_functions.TwoPointBinFilterCollection(/, **data)
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[firecrown.data_functions._types.TwoPointBinFilter] = None
- check_bin_filters()
Check the bin filters.
- Return type:
- property bin_filter_dict: dict[firecrown.data_functions._types.BinSpec, firecrown.data_functions._types.TwoPointBinFilter]
Return the bin filter dictionary.
- Return type:
dict[firecrown.data_functions._types.BinSpec, firecrown.data_functions._types.TwoPointBinFilter]
- filter_match(tpm)
Check if the TwoPointMeasurement matches the filter.
- Parameters:
- Return type:
bool
- run_bin_filter(bin_filter, vals)
Run the filter merge.
- Parameters:
bin_filter (firecrown.data_functions._types.TwoPointBinFilter)
vals (numpy.typing.NDArray[numpy.float64] | numpy.typing.NDArray[numpy.int64])
- Return type:
numpy.typing.NDArray[numpy.bool_]
- apply_filter_single(tpm)
Apply the filter to a single TwoPointMeasurement.
- Parameters:
- Return type:
tuple[numpy.typing.NDArray[numpy.bool_], numpy.typing.NDArray[numpy.bool_]]
- __call__(tpms)
Filter the two-point measurements.
- Parameters:
tpms (collections.abc.Sequence[firecrown.data_types.TwoPointMeasurement])
- Return type: