firecrown.likelihood.source =========================== .. py:module:: firecrown.likelihood.source .. autoapi-nested-parse:: Abstract base classes for TwoPoint Statistics sources. Attributes ---------- .. autoapisummary:: firecrown.likelihood.source.SOURCE_GALAXY_SYSTEMATIC_DEFAULT_DELTA_Z firecrown.likelihood.source.SOURCE_GALAXY_SYSTEMATIC_DEFAULT_SIGMA_Z Classes ------- .. autoapisummary:: firecrown.likelihood.source.SourceSystematic firecrown.likelihood.source.Source firecrown.likelihood.source.Tracer firecrown.likelihood.source.SourceGalaxyArgs firecrown.likelihood.source.SourceGalaxySystematic firecrown.likelihood.source.SourceGalaxyPhotoZShift firecrown.likelihood.source.PhotoZShift firecrown.likelihood.source.PhotoZShiftFactory firecrown.likelihood.source.SourceGalaxyPhotoZShiftandStretch firecrown.likelihood.source.PhotoZShiftandStretch firecrown.likelihood.source.PhotoZShiftandStretchFactory firecrown.likelihood.source.SourceGalaxySelectField firecrown.likelihood.source.SourceGalaxy Functions --------- .. autoapisummary:: firecrown.likelihood.source.dndz_shift_and_stretch_active firecrown.likelihood.source.dndz_shift_and_stretch_passive Module Contents --------------- .. py:class:: SourceSystematic(parameter_prefix = None) Bases: :py:obj:`firecrown.updatable.Updatable` .. autoapi-inheritance-diagram:: firecrown.likelihood.source.SourceSystematic :parts: 1 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. .. py:method:: read(sacc_data) Call to allow this object to read from the appropriate sacc data. :param sacc_data: The SACC data object to be read .. py:class:: Source(sacc_tracer) Bases: :py:obj:`firecrown.updatable.Updatable` .. autoapi-inheritance-diagram:: firecrown.likelihood.source.Source :parts: 1 The abstract base class for all sources. .. py:attribute:: cosmo_hash :type: None | int .. py:attribute:: tracers :type: collections.abc.Sequence[Tracer] .. py:attribute:: sacc_tracer .. py:method:: read_systematics(sacc_data) :abstractmethod: Abstract method to read the systematics for this source from the SACC file. :param sacc_data: The SACC data object to be read .. py:method:: read(sacc_data) Read the data for this source from the SACC file. :param sacc_data: The SACC data object to be read .. py:method:: get_scale() :abstractmethod: Abstract method to return the scale for this `Source`. :return: the scale .. py:method:: create_tracers(tools) :abstractmethod: Abstract method to create tracers for this Source. :param tools: The modeling tools used for creating the tracers .. py:method:: get_tracers(tools) 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. :param tools: The modeling tools used for creating the tracers :return: the list of tracers .. py:class:: Tracer(tracer, tracer_name = None, field = None, pt_tracer = None, halo_profile = None, halo_2pt = None) 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. .. py:method:: determine_field_name(field, tracer) :staticmethod: Gets a field name for a tracer. This function encapsulates the policy for determining the value to be assigned to the :attr:`field` attribute of a :class:`Tracer`. It is a static method only to keep it grouped with the class for which it is defining the initialization policy. :param field: the (stub) name of the field :param tracer: the name of the tracer :return: the full name of the field .. py:attribute:: ccl_tracer .. py:attribute:: tracer_name :type: str .. py:attribute:: field .. py:attribute:: pt_tracer :value: None .. py:attribute:: halo_profile :value: None .. py:attribute:: halo_2pt :value: None .. py:property:: has_pt :type: bool Answer whether we have a perturbation theory tracer. :return: True if we have a pt_tracer, and False if not. .. py:property:: has_hm :type: bool Answer whether we have a halo model profile. Return True if we have a halo_profile, and False if not. .. py:class:: SourceGalaxyArgs Class for galaxy based sources arguments. .. py:attribute:: z :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: dndz :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: scale :type: float :value: 1.0 .. py:attribute:: field :type: str :value: 'delta_matter' .. py:class:: SourceGalaxySystematic(parameter_prefix = None) Bases: :py:obj:`SourceSystematic`, :py:obj:`Generic`\ [\ :py:obj:`_SourceGalaxyArgsT`\ ] .. autoapi-inheritance-diagram:: firecrown.likelihood.source.SourceGalaxySystematic :parts: 1 Abstract base class for all galaxy-based source systematics. .. py:method:: apply(tools, tracer_arg) :abstractmethod: Apply method to include systematics in the tracer_arg. :param tools: the modeling tools use to update the tracer arg :param tracer_arg: the original source galaxy tracer arg to which we apply the systematic. :return: a new source galaxy tracer arg with the systematic applied .. py:data:: SOURCE_GALAXY_SYSTEMATIC_DEFAULT_DELTA_Z :value: 0.0 .. py:data:: SOURCE_GALAXY_SYSTEMATIC_DEFAULT_SIGMA_Z :value: 1.0 .. py:class:: SourceGalaxyPhotoZShift(sacc_tracer, active = True) Bases: :py:obj:`SourceGalaxySystematic`\ [\ :py:obj:`_SourceGalaxyArgsT`\ ], :py:obj:`Generic`\ [\ :py:obj:`_SourceGalaxyArgsT`\ ] .. autoapi-inheritance-diagram:: firecrown.likelihood.source.SourceGalaxyPhotoZShift :parts: 1 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: :ivar delta_z: the photo-z shift. .. py:attribute:: delta_z .. py:method:: apply(tools, tracer_arg) Apply a shift to the photo-z distribution of a source. :param tools: the modeling tools use to update the tracer arg :param tracer_arg: the original source galaxy tracer arg to which we apply the systematic. :return: a new source galaxy tracer arg with the systematic applied .. py:class:: PhotoZShift(sacc_tracer, active = True) Bases: :py:obj:`SourceGalaxyPhotoZShift` .. autoapi-inheritance-diagram:: firecrown.likelihood.source.PhotoZShift :parts: 1 Photo-z shift systematic. .. py:class:: PhotoZShiftFactory(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.likelihood.source.PhotoZShiftFactory :parts: 1 Factory class for PhotoZShift objects. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: type :type: Annotated[Literal['PhotoZShiftFactory'], Field(description='The type of the systematic.')] :value: 'PhotoZShiftFactory' .. py:method:: create(bin_name) Create a PhotoZShift object with the given tracer name. .. py:method:: create_global() Create a PhotoZShift object with the given tracer name. .. py:function:: dndz_shift_and_stretch_active(z, dndz, delta_z, sigma_z) 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. :param z: the redshifts :param dndz: the dndz :param delta_z: the photo-z shift :param sigma_z: the photo-z stretch :return: the shifted and stretched dndz .. py:function:: dndz_shift_and_stretch_passive(z, dndz, delta_z, sigma_z) Shift and stretch the photo-z distribution using a passive transformation. :param z: the redshifts :param dndz: the dndz :param delta_z: the photo-z shift :param sigma_z: the photo-z stretch :return: the shifted and stretched dndz .. py:class:: SourceGalaxyPhotoZShiftandStretch(sacc_tracer, active = True) Bases: :py:obj:`SourceGalaxyPhotoZShift`\ [\ :py:obj:`_SourceGalaxyArgsT`\ ] .. autoapi-inheritance-diagram:: firecrown.likelihood.source.SourceGalaxyPhotoZShiftandStretch :parts: 1 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: :ivar delta_z: the photo-z shift. :ivar sigma_z: the photo-z stretch. .. py:attribute:: sigma_z .. py:method:: apply(_, tracer_arg) Apply a shift & stretch to the photo-z distribution of a source. .. py:class:: PhotoZShiftandStretch(sacc_tracer, active = True) Bases: :py:obj:`SourceGalaxyPhotoZShiftandStretch` .. autoapi-inheritance-diagram:: firecrown.likelihood.source.PhotoZShiftandStretch :parts: 1 Photo-z shift and stretch systematic. .. py:class:: PhotoZShiftandStretchFactory(/, **data) Bases: :py:obj:`pydantic.BaseModel` .. autoapi-inheritance-diagram:: firecrown.likelihood.source.PhotoZShiftandStretchFactory :parts: 1 Factory class for PhotoZShiftandStretch objects. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: type :type: Annotated[Literal['PhotoZShiftandStretchFactory'], Field(description='The type of the systematic.')] :value: 'PhotoZShiftandStretchFactory' .. py:method:: create(bin_name) Create a PhotoZShiftandStretch object with the given tracer name. .. py:method:: create_global() Create a PhotoZShiftandStretch object with the given tracer name. .. py:class:: SourceGalaxySelectField(field = 'delta_matter') Bases: :py:obj:`SourceGalaxySystematic`\ [\ :py:obj:`_SourceGalaxyArgsT`\ ], :py:obj:`Generic`\ [\ :py:obj:`_SourceGalaxyArgsT`\ ] .. autoapi-inheritance-diagram:: firecrown.likelihood.source.SourceGalaxySelectField :parts: 1 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. .. py:attribute:: field :value: 'delta_matter' .. py:method:: apply(tools, tracer_arg) Apply method to include systematics in the tracer_arg. :param tools: the modeling tools used to update the tracer_arg :param tracer_arg: the original source galaxy tracer arg to which we apply the systematics. :return: a new source galaxy tracer arg with the systematic applied .. py:class:: SourceGalaxy(*, sacc_tracer, systematics = None) Bases: :py:obj:`Source`, :py:obj:`Generic`\ [\ :py:obj:`_SourceGalaxyArgsT`\ ] .. autoapi-inheritance-diagram:: firecrown.likelihood.source.SourceGalaxy :parts: 1 Source class for galaxy based sources. .. py:attribute:: sacc_tracer .. py:attribute:: current_tracer_args :type: None | _SourceGalaxyArgsT :value: None .. py:attribute:: systematics :type: firecrown.updatable.UpdatableCollection[SourceGalaxySystematic] .. py:attribute:: tracer_args :type: _SourceGalaxyArgsT .. py:method:: read_systematics(sacc_data) Read the systematics for this source from the SACC file. :param sacc_data: The SACC data object to be read