yaw.Configuration#

class yaw.Configuration(scales: ScalesConfig, binning: BinningConfig, cosmology: FLRW | CustomCosmology | str | None = None, max_workers: int | None = None)[source]#

Bases: BaseConfig, Immutable

Configuration for correlation function measurements.

This is the top-level configuration class for yet_another_wizz, defining correlation scales, redshift binning, and the cosmological model used for distance calculations.

Note

The preferred way to create a new configuration instance is using the create() constructor.

All configuration objects are immutable. To modify an existing configuration, create a new instance with updated values by using the modify() method. The bin edges are recomputed when necessary.

Methods

__init__(scales, binning[, cosmology, ...])

create(*, rmin, rmax[, unit, rweight, ...])

Create a new instance with the given parameters.

from_dict(the_dict, **kwargs)

Restore the class instance from a python dictionary.

from_file(path)

Restore the class instance from a YAML file.

get_paramspec()

Generate a listing of parameters that may be used by external tool to auto-generate an interface to this configuration class.

modify(*[, rmin, rmax, unit, rweight, ...])

Create a new configuration instance with updated parameter values.

to_dict()

Serialise the class instances into a dictionary.

to_file(path)

Serialise the class instances into a YAML file.

Attributes

scales

Organises the configuration of correlation scales.

binning

Organises the configuration of redshift bins.

cosmology

Optional cosmological model to use for distance computations.

max_workers

Limit the number of workers for parallel operations (all by default).

binning: BinningConfig#

Organises the configuration of redshift bins.

cosmology: FLRW | CustomCosmology | str#

Optional cosmological model to use for distance computations.

classmethod create(*, rmin: Iterable[float] | float, rmax: Iterable[float] | float, unit: Unit = Unit.kpc, rweight: float | None = None, resolution: int | None = None, zmin: float | None = None, zmax: float | None = None, num_bins: int = 30, method: BinMethod | str = BinMethod.linear, edges: Iterable[float] | None = None, closed: Closed | str = Closed.right, cosmology: TypeCosmology | str | None = 'Planck15', max_workers: int | None = None) Configuration[source]#

Create a new instance with the given parameters.

Keyword Arguments:
  • rmin – Single or multiple lower scale limits in kpc (angular diameter distance).

  • rmax – Single or multiple upper scale limits in kpc (angular diameter distance).

  • unit – String describing the angular, physical, or comoving unit of correlation scales, see Unit for valid options (default: kpc).

  • rweight – Optional power-law exponent \(\alpha\) used to weight pairs by their separation.

  • resolution – Optional number of radial logarithmic bin used to approximate the weighting by separation.

  • zmin – Lowest redshift bin edge to generate.

  • zmax – Highest redshift bin edge to generate.

  • num_bins – Number of redshift bins to generate.

  • method – Method used to generate the bin edges, see BinMethod for valid options.

  • edges – Use these custom bin edges instead of generating them.

  • closed – Indicating which side of the bin edges is a closed interval, see Closed for valid options.

  • cosmology – Optional cosmological model to use for distance computations.

  • max_workers – Limit the number of parallel workers for this operation (all by default).

Returns:

New configuration instance.

Note

Although the function parameters are optional, either zmin and zmax (generate bin edges), or edges (custom bin edges) must be provided.

classmethod from_dict(the_dict: dict[str, Any], **kwargs) Configuration[source]#

Restore the class instance from a python dictionary.

Parameters:

the_dict – Dictionary containing all required data attributes to restore the instance, see also to_dict().

Returns:

Restored class instance.

classmethod from_file(path: Path | str) Configuration[source]#

Restore the class instance from a YAML file.

Parameters:

path – Path (str or pathlib.Path) to YAML file to restore from, see also to_file().

Returns:

Restored class instance.

classmethod get_paramspec() ParamSpec[source]#

Generate a listing of parameters that may be used by external tool to auto-generate an interface to this configuration class.

Returns:

A ParamSpec instance, that is a key-value mapping from parameter name to the parameter meta data for this configuration class.

max_workers: int | None#

Limit the number of workers for parallel operations (all by default).

modify(*, rmin: Iterable[float] | float | NotSet = NotSet, rmax: Iterable[float] | float | NotSet = NotSet, unit: Unit | NotSet = NotSet, rweight: float | None | NotSet = NotSet, resolution: int | None | NotSet = NotSet, zmin: float | NotSet = NotSet, zmax: float | NotSet = NotSet, num_bins: int | NotSet = NotSet, method: BinMethod | str | NotSet = NotSet, edges: Iterable[float] | None = NotSet, closed: Closed | str | NotSet = NotSet, cosmology: TypeCosmology | str | None | NotSet = NotSet, max_workers: int | None | NotSet = NotSet) Configuration[source]#

Create a new configuration instance with updated parameter values.

Parameter values are only updated if they are provided as inputs to this function and retained from the original instance otherwise.

Keyword Arguments:
  • rmin – Single or multiple lower scale limits in kpc (angular diameter distance).

  • rmax – Single or multiple upper scale limits in kpc (angular diameter distance).

  • unit – String describing the angular, physical, or comoving unit of correlation scales, see Unit for valid options (default: kpc).

  • rweight – Optional power-law exponent \(\alpha\) used to weight pairs by their separation.

  • resolution – Optional number of radial logarithmic bin used to approximate the weighting by separation.

  • zmin – Lowest redshift bin edge to generate.

  • zmax – Highest redshift bin edge to generate.

  • num_bins – Number of redshift bins to generate.

  • method – Method used to generate the bin edges, see BinMethod for valid options.

  • edges – Use these custom bin edges instead of generating them.

  • closed – Indicating which side of the bin edges is a closed interval, see Closed for valid options.

  • cosmology – Optional cosmological model to use for distance computations.

  • max_workers – Limit the number of parallel workers for this operation (all by default).

Returns:

New instance with updated parameter values.

scales: ScalesConfig#

Organises the configuration of correlation scales.

to_dict() dict[str, Any][source]#

Serialise the class instances into a dictionary.

Returns:

A dictionary containnig the minimal set of data attributes to restore the instance with from_dict().

to_file(path: Path | str) None[source]#

Serialise the class instances into a YAML file.

Parameters:

path – Path (str or pathlib.Path) to YAML file to serialise into, see also from_file().