firecrown.likelihood.source

Abstract base classes for TwoPoint Statistics sources.

Attributes

SOURCE_GALAXY_SYSTEMATIC_DEFAULT_DELTA_Z

SOURCE_GALAXY_SYSTEMATIC_DEFAULT_SIGMA_Z

Classes

SourceSystematic

An abstract systematic class (e.g., shear biases, photo-z shifts, etc.).

Source

The abstract base class for all sources.

Tracer

Extending the pyccl.Tracer object with additional information.

SourceGalaxyArgs

Class for galaxy based sources arguments.

SourceGalaxySystematic

Abstract base class for all galaxy-based source systematics.

SourceGalaxyPhotoZShift

A photo-z shift bias.

PhotoZShift

Photo-z shift systematic.

PhotoZShiftFactory

Factory class for PhotoZShift objects.

SourceGalaxyPhotoZShiftandStretch

A photo-z shift & stretch bias.

PhotoZShiftandStretch

Photo-z shift and stretch systematic.

PhotoZShiftandStretchFactory

Factory class for PhotoZShiftandStretch objects.

SourceGalaxySelectField

The source galaxy select field systematic.

SourceGalaxy

Source class for galaxy based sources.

Functions

dndz_shift_and_stretch_active(z, dndz, delta_z, sigma_z)

Shift and stretch the photo-z distribution using an active transformation.

dndz_shift_and_stretch_passive(z, dndz, delta_z, sigma_z)

Shift and stretch the photo-z distribution using a passive transformation.

Module Contents

class firecrown.likelihood.source.SourceSystematic(parameter_prefix=None)[source]

Bases: firecrown.updatable.Updatable

Inheritance diagram of firecrown.likelihood.source.SourceSystematic

An abstract systematic class (e.g., shear biases, photo-z shifts, etc.).

This class currently has no methods at all, because the argument types for the apply method of different subclasses are different.

Parameters:

parameter_prefix (None | str)

read(sacc_data)[source]

Call to allow this object to read from the appropriate sacc data.

Parameters:

sacc_data (sacc.Sacc) – The SACC data object to be read

Return type:

None

class firecrown.likelihood.source.Source(sacc_tracer)[source]

Bases: firecrown.updatable.Updatable

Inheritance diagram of firecrown.likelihood.source.Source

The abstract base class for all sources.

Parameters:

sacc_tracer (str)

cosmo_hash: None | int
tracers: collections.abc.Sequence[Tracer]
sacc_tracer
abstractmethod read_systematics(sacc_data)[source]

Abstract method to read the systematics for this source from the SACC file.

Parameters:

sacc_data (sacc.Sacc) – The SACC data object to be read

Return type:

None

read(sacc_data)[source]

Read the data for this source from the SACC file.

Parameters:

sacc_data (sacc.Sacc) – The SACC data object to be read

Return type:

None

abstractmethod get_scale()[source]

Abstract method to return the scale for this Source.

Returns:

the scale

Return type:

float

abstractmethod create_tracers(tools)[source]

Abstract method to create tracers for this Source.

Parameters:

tools (firecrown.modeling_tools.ModelingTools) – The modeling tools used for creating the tracers

get_tracers(tools)[source]

Return the tracer for the given cosmology.

This method caches its result, so if called a second time with the same cosmology, no calculation needs to be done.

Parameters:

tools (firecrown.modeling_tools.ModelingTools) – The modeling tools used for creating the tracers

Returns:

the list of tracers

Return type:

collections.abc.Sequence[Tracer]

class firecrown.likelihood.source.Tracer(tracer, tracer_name=None, field=None, pt_tracer=None, halo_profile=None, halo_2pt=None)[source]

Extending the pyccl.Tracer object with additional information.

Bundles together a pyccl.Tracer object with optional information about the underlying 3D field, or a pyccl.nl_pt.PTTracer and halo profiles.

Parameters:
  • tracer (pyccl.Tracer)

  • tracer_name (None | str)

  • field (None | str)

  • pt_tracer (None | pyccl.nl_pt.PTTracer)

  • halo_profile (None | pyccl.halos.HaloProfile)

  • halo_2pt (None | pyccl.halos.Profile2pt)

static determine_field_name(field, tracer)[source]

Gets a field name for a tracer.

This function encapsulates the policy for determining the value to be assigned to the field attribute of a Tracer.

It is a static method only to keep it grouped with the class for which it is defining the initialization policy.

Parameters:
  • field (None | str) – the (stub) name of the field

  • tracer (None | str) – the name of the tracer

Returns:

the full name of the field

Return type:

str

ccl_tracer
tracer_name: str
field
pt_tracer = None
halo_profile = None
halo_2pt = None
property has_pt: bool[source]

Answer whether we have a perturbation theory tracer.

Returns:

True if we have a pt_tracer, and False if not.

Return type:

bool

property has_hm: bool[source]

Answer whether we have a halo model profile.

Return True if we have a halo_profile, and False if not.

Return type:

bool

class firecrown.likelihood.source.SourceGalaxyArgs[source]

Class for galaxy based sources arguments.

z: numpy.typing.NDArray[numpy.float64]
dndz: numpy.typing.NDArray[numpy.float64]
scale: float = 1.0
field: str = 'delta_matter'
class firecrown.likelihood.source.SourceGalaxySystematic(parameter_prefix=None)[source]

Bases: SourceSystematic, Generic[_SourceGalaxyArgsT]

Inheritance diagram of firecrown.likelihood.source.SourceGalaxySystematic

Abstract base class for all galaxy-based source systematics.

Parameters:

parameter_prefix (None | str)

abstractmethod apply(tools, tracer_arg)[source]

Apply method to include systematics in the tracer_arg.

Parameters:
  • tools (firecrown.modeling_tools.ModelingTools) – the modeling tools use to update the tracer arg

  • tracer_arg (_SourceGalaxyArgsT) – the original source galaxy tracer arg to which we apply the systematic.

Returns:

a new source galaxy tracer arg with the systematic applied

Return type:

_SourceGalaxyArgsT

firecrown.likelihood.source.SOURCE_GALAXY_SYSTEMATIC_DEFAULT_DELTA_Z = 0.0
firecrown.likelihood.source.SOURCE_GALAXY_SYSTEMATIC_DEFAULT_SIGMA_Z = 1.0
class firecrown.likelihood.source.SourceGalaxyPhotoZShift(sacc_tracer, active=True)[source]

Bases: SourceGalaxySystematic[_SourceGalaxyArgsT], Generic[_SourceGalaxyArgsT]

Inheritance diagram of firecrown.likelihood.source.SourceGalaxyPhotoZShift

A photo-z shift bias.

This systematic shifts the photo-z distribution by some amount delta_z.

The following parameters are special Updatable parameters, which means that they can be updated by the sampler, sacc_tracer is going to be used as a prefix for the parameters:

Variables:

delta_z – the photo-z shift.

Parameters:
  • sacc_tracer (str)

  • active (bool)

delta_z
apply(tools, tracer_arg)[source]

Apply a shift to the photo-z distribution of a source.

Parameters:
  • tools (firecrown.modeling_tools.ModelingTools) – the modeling tools use to update the tracer arg

  • tracer_arg (_SourceGalaxyArgsT) – the original source galaxy tracer arg to which we apply the systematic.

Returns:

a new source galaxy tracer arg with the systematic applied

Return type:

_SourceGalaxyArgsT

class firecrown.likelihood.source.PhotoZShift(sacc_tracer, active=True)[source]

Bases: SourceGalaxyPhotoZShift

Inheritance diagram of firecrown.likelihood.source.PhotoZShift

Photo-z shift systematic.

Parameters:
  • sacc_tracer (str)

  • active (bool)

class firecrown.likelihood.source.PhotoZShiftFactory(/, **data)[source]

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.likelihood.source.PhotoZShiftFactory

Factory class for PhotoZShift objects.

Parameters:

data (Any)

model_config

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

type: Annotated[Literal['PhotoZShiftFactory'], Field(description='The type of the systematic.')] = 'PhotoZShiftFactory'
create(bin_name)[source]

Create a PhotoZShift object with the given tracer name.

Parameters:

bin_name (str)

Return type:

PhotoZShift

create_global()[source]

Create a PhotoZShift object with the given tracer name.

Return type:

PhotoZShift

firecrown.likelihood.source.dndz_shift_and_stretch_active(z, dndz, delta_z, sigma_z)[source]

Shift and stretch the photo-z distribution using an active transformation.

We use “makima” interpolation, a cubic spline method based on the modified Akima algorithm. This approach prevents overshooting when the data remains constant for more than two consecutive nodes. Additionally, we set extrapolate=False and we set extrapolated values to zero.

The active transformation preserves the redshift array and modifies the dndz array. This transformation introduces an interpolation error on dndz.

Parameters:
  • z (numpy.typing.NDArray[numpy.float64]) – the redshifts

  • dndz (numpy.typing.NDArray[numpy.float64]) – the dndz

  • delta_z (float) – the photo-z shift

  • sigma_z (float) – the photo-z stretch

Returns:

the shifted and stretched dndz

Return type:

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

firecrown.likelihood.source.dndz_shift_and_stretch_passive(z, dndz, delta_z, sigma_z)[source]

Shift and stretch the photo-z distribution using a passive transformation.

Parameters:
  • z (numpy.typing.NDArray[numpy.float64]) – the redshifts

  • dndz (numpy.typing.NDArray[numpy.float64]) – the dndz

  • delta_z (float) – the photo-z shift

  • sigma_z (float) – the photo-z stretch

Returns:

the shifted and stretched dndz

Return type:

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

class firecrown.likelihood.source.SourceGalaxyPhotoZShiftandStretch(sacc_tracer, active=True)[source]

Bases: SourceGalaxyPhotoZShift[_SourceGalaxyArgsT]

Inheritance diagram of firecrown.likelihood.source.SourceGalaxyPhotoZShiftandStretch

A photo-z shift & stretch bias.

This systematic shifts and widens the photo-z distribution by some amount delta_z.

The following parameters are special Updatable parameters, which means that they can be updated by the sampler, sacc_tracer is going to be used as a prefix for the parameters:

Variables:
  • delta_z – the photo-z shift.

  • sigma_z – the photo-z stretch.

Parameters:
  • sacc_tracer (str)

  • active (bool)

sigma_z
apply(_, tracer_arg)[source]

Apply a shift & stretch to the photo-z distribution of a source.

Parameters:
class firecrown.likelihood.source.PhotoZShiftandStretch(sacc_tracer, active=True)[source]

Bases: SourceGalaxyPhotoZShiftandStretch

Inheritance diagram of firecrown.likelihood.source.PhotoZShiftandStretch

Photo-z shift and stretch systematic.

Parameters:
  • sacc_tracer (str)

  • active (bool)

class firecrown.likelihood.source.PhotoZShiftandStretchFactory(/, **data)[source]

Bases: pydantic.BaseModel

Inheritance diagram of firecrown.likelihood.source.PhotoZShiftandStretchFactory

Factory class for PhotoZShiftandStretch objects.

Parameters:

data (Any)

model_config

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

type: Annotated[Literal['PhotoZShiftandStretchFactory'], Field(description='The type of the systematic.')] = 'PhotoZShiftandStretchFactory'
create(bin_name)[source]

Create a PhotoZShiftandStretch object with the given tracer name.

Parameters:

bin_name (str)

Return type:

PhotoZShiftandStretch

create_global()[source]

Create a PhotoZShiftandStretch object with the given tracer name.

Return type:

PhotoZShiftandStretch

class firecrown.likelihood.source.SourceGalaxySelectField(field='delta_matter')[source]

Bases: SourceGalaxySystematic[_SourceGalaxyArgsT], Generic[_SourceGalaxyArgsT]

Inheritance diagram of firecrown.likelihood.source.SourceGalaxySelectField

The source galaxy select field systematic.

A systematic that allows specifying the 3D field that will be used to select the 3D power spectrum when computing the angular power spectrum.

Parameters:

field (str)

field = 'delta_matter'
apply(tools, tracer_arg)[source]

Apply method to include systematics in the tracer_arg.

Parameters:
  • tools (firecrown.modeling_tools.ModelingTools) – the modeling tools used to update the tracer_arg

  • tracer_arg (_SourceGalaxyArgsT) – the original source galaxy tracer arg to which we apply the systematics.

Returns:

a new source galaxy tracer arg with the systematic applied

Return type:

_SourceGalaxyArgsT

class firecrown.likelihood.source.SourceGalaxy(*, sacc_tracer, systematics=None)[source]

Bases: Source, Generic[_SourceGalaxyArgsT]

Inheritance diagram of firecrown.likelihood.source.SourceGalaxy

Source class for galaxy based sources.

Parameters:
sacc_tracer
current_tracer_args: None | _SourceGalaxyArgsT = None
systematics: firecrown.updatable.UpdatableCollection[SourceGalaxySystematic]
tracer_args: _SourceGalaxyArgsT
read_systematics(sacc_data)[source]

Read the systematics for this source from the SACC file.

Parameters:

sacc_data (sacc.Sacc) – The SACC data object to be read

Return type:

None