yaw.config.BinningConfig#

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

Bases: YawConfig

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.

format_yaml_doc(*[, indentation, padding])

Format the parameter as YAML for documentation purposes.

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

Get a mapping of paramter name to parameter meta-data.

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

String indicating the side of the bin intervals that are closed.

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 compute the spacing of bin edges.

binning: Binning#

Container for the redshift bins.

property closed: Closed#

String indicating the side of the bin intervals that are closed.

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) Self[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 format_yaml_doc(*, indentation: TextIndenter | None = None, padding: int = 24) str#

Format the parameter as YAML for documentation purposes.

Writes a mapping of parameter names to default values (if given, otherwise blank) followed by comments containing the help messages, whether parameter are required and possible choices. If the class contains configuration sub-classes, include them hierarchically as a mapping sub-section.

Parameters:
  • indentation – Use this indenter to determine the appropriate line indentation.

  • padding – Padding in spaces between YAML text and comment.

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

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() dict[str, ConfigSection | Parameter]#

Get a mapping of paramter name to parameter meta-data.

property is_custom: bool#

Whether the bin edges are provided by the user.

method: BinMethod#

Method used to compute the spacing of bin edges.

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) Self[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.