yaw.config.BinningConfig#

class yaw.config.BinningConfig(binning: Binning, method: BinMethod | str = BinMethod.linear)[source]#

Bases: BaseConfig, Immutable

Configuration of the redshift binning for correlation function measurements.

Correlations are measured in bins of redshift, which determines the redshift-resolution of the clustering redshift estimate. This configuration class offers three automatic methods to generate these bins between a minimum and maximum redshift:

  • linear (default): bin edges spaced linearly in redshift \(z\),

  • comoving: bin edges spaced linearly in comoving distance \(\chi(z)\), and

  • logspace: bin edges spaced linearly in \(1+\ln(z)\).

Alternatively, custom bin edges may be provided.

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__(binning[, method])

create(*[, zmin, zmax, num_bins, method, ...])

Create a new instance with the given parameters.

from_dict(the_dict[, cosmology])

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(*[, zmin, zmax, num_bins, method, ...])

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

closed

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

edges

Array of redshift bin edges.

is_custom

Whether the bin edges are provided by the user.

num_bins

Number of redshift bins.

zmax

Highest redshift bin edge.

zmin

Lowest redshift bin edge.

binning

Container for the redshift bins.

method

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

binning: Binning#

Container for the redshift bins.

property closed: Closed#

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

classmethod create(*, 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 | None = None) BinningConfig[source]#

Create a new instance with the given parameters.

Keyword Arguments:
  • 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.

Returns:

New configuration instance.

Note

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

Caution

This cosmology object is not stored with this instance, but should be managed by the top level Configuration class.

property edges: NDArray#

Array of redshift bin edges.

classmethod from_dict(the_dict: dict[str, Any], cosmology: TypeCosmology | None = None) BinningConfig[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().

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

Returns:

Restored class instance.

Caution

This cosmology object is not stored with this instance, but should be managed by the top level Configuration class.

classmethod from_file(path: Path | str) TypeYamlSerialisable#

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.

property is_custom: bool#

Whether the bin edges are provided by the user.

method: BinMethod#

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

modify(*, zmin: float | NotSet = NotSet, zmax: float | NotSet = NotSet, num_bins: int | NotSet = NotSet, method: BinMethod | str | NotSet = NotSet, edges: Iterable[float] | NotSet = NotSet, closed: Closed | str | NotSet = NotSet, cosmology: TypeCosmology | None | NotSet = NotSet) BinningConfig[source]#

Create a new configuration instance with updated parameter values.

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

Keyword Arguments:
  • 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.

Returns:

New instance with updated redshift bins.

Caution

This cosmology object is not stored with this instance, but should be managed by the top level Configuration class.

property num_bins: int#

Number of redshift bins.

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#

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().

property zmax: float#

Highest redshift bin edge.

property zmin: float#

Lowest redshift bin edge.