Observables

galaxy clustering

class desilike.observables.galaxy_clustering.correlation_function.TracerCorrelationFunctionMultipolesObservable(*args, **kwargs)[source]

Bases: BaseCalculator

Tracer correlation function multipoles observable: compare measurement to theory.

Parameters:
  • data (str, Path, list, lsstypes.Count2Correlation, lsstypes.Count2CorrelationPoles, dict, default=None) – Data correlation function measurement: flat array (of all multipoles), lsstypes.Count2Correlation instance, or path to such instances, or list of such objects (in which case the average of them is taken). If dict, parameters to be passed to theory to generate mock measurement. If a (list of) flat array, additionally provide list of multipoles ells and separations s (see kwargs).

  • covariance (list, default=None) – 2D array, list of lsstypes.Count2Correlation instances, or paths to such instances; these are used to compute the covariance matrix.

  • slim (dict, default=None) – Separation limits: a dictionary mapping multipoles to (min separation, max separation, (optionally) step (float)), e.g. {0: (30., 160., 5.), 2: (30., 160., 5.)}. If None, no selection is applied for the given multipole.

  • **kwargs (dict) –

    Optional arguments for WindowedCorrelationFunctionMultipoles, e.g.:

    • theory: defaults to KaiserTracerCorrelationFunctionMultipoles.

    • fiber_collisions

    • systematic_templates

    • if one only provided simple arrays for data and covariance, one can provide the list of multipoles ells and the corresponding (list of) \(s\) separations as a (list of) array s.

plot(kw_theory=None, fig=None)[source]

Plot data and theory correlation function multipoles.

Parameters:
  • kw_theory (list of dict, default=None) – Change the default line parametrization of the theory, one dictionary for each ell or duplicate it.

  • fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least 1 + len(self.ells) axes.

  • fn (str, Path, default=None) – Optionally, path where to save figure. If not provided, figure is not saved.

  • kw_save (dict, default=None) – Optionally, arguments for matplotlib.figure.Figure.savefig().

  • show (bool, default=False) – If True, show figure.

  • interactive (bool, default=False) – If True, use interactive interface provided by ipywidgets.

Returns:

fig

Return type:

matplotlib.figure.Figure

plot_bao(fig=None)[source]

Plot data and theory BAO correlation function peak.

Parameters:
  • fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least len(self.ells) axes.

  • fn (str, Path, default=None) – Optionally, path where to save figure. If not provided, figure is not saved.

  • kw_save (dict, default=None) – Optionally, arguments for matplotlib.figure.Figure.savefig().

  • show (bool, default=False) – If True, show figure.

Returns:

fig

Return type:

matplotlib.figure.Figure

plot_covariance_matrix(corrcoef=True, **kwargs)[source]

Plot covariance matrix.

Parameters:
  • corrcoef (bool, default=True) – If True, plot the correlation matrix; else the covariance.

  • barlabel (str, default=None) – Optionally, label for the color bar.

  • figsize (int, tuple, default=None) – Optionally, figure size.

  • norm (matplotlib.colors.Normalize, default=None) – Scales the covariance / correlation to the canonical colormap range [0, 1] for mapping to colors. By default, the covariance / correlation range is mapped to the color bar range using linear scaling.

  • labelsize (int, default=None) – Optionally, size for labels.

  • fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least len(self.ells) * len(self.ells) axes.

Returns:

fig

Return type:

matplotlib.figure.Figure

to_lsstypes(kind)[source]

Return observable (data) and covariance.

class desilike.observables.galaxy_clustering.window.BaseFiberCollisionsCorrelationFunctionMultipoles(*args, **kwargs)[source]

Bases: BaseCalculator

plot(fig=None)[source]

Plot fiber collision effect on correlation function multipoles.

Parameters:
  • fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least 1 axis.

  • fn (str, Path, default=None) – Optionally, path where to save figure. If not provided, figure is not saved.

  • kw_save (dict, default=None) – Optionally, arguments for matplotlib.figure.Figure.savefig().

  • show (bool, default=False) – If True, show figure.

Returns:

fig

Return type:

matplotlib.figure.Figure

class desilike.observables.galaxy_clustering.window.BaseFiberCollisionsPowerSpectrumMultipoles(*args, **kwargs)[source]

Bases: BaseCalculator

plot(fig=None)[source]

Plot fiber collision effect on power spectrum multipoles.

Parameters:
  • fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least 1 axis.

  • fn (str, Path, default=None) – Optionally, path where to save figure. If not provided, figure is not saved.

  • kw_save (dict, default=None) – Optionally, arguments for matplotlib.figure.Figure.savefig().

  • show (bool, default=False) – If True, show figure.

class desilike.observables.galaxy_clustering.window.BaseSystematicTemplateMultipoles(*args, **kwargs)[source]

Bases: BaseCalculator

class desilike.observables.galaxy_clustering.window.FiberCollisionsCorrelationFunctionMultipoles(*args, **kwargs)[source]

Bases: BaseFiberCollisionsCorrelationFunctionMultipoles

Fiber collision effect on correlation function multipoles. Contrary to Hahn et al. 2016, the kernel is assumed to be a sum of top-hat functions.

Parameters:
  • s (array, default=None) – Output separations.

  • ells (tuple, default=(0, 2, 4)) – Multipoles.

  • sep (array, default=None) – Transverse separation values for kernel.

  • kernel (array, default=None) – Window representing the number of pairs lost as a function of separation.

  • theory (BaseTheoryPowerSpectrumMultipoles) – Theory correlation function multipoles, defaults to KaiserTracerCorrelationFunctionMultipoles.

  • with_uncorrelated (bool, default=True) – If False, do not include the uncorrelated part (due to not correcting the selection function for missing pairs).

  • Reference

  • ---------

  • https (//arxiv.org/abs/1609.01714)

class desilike.observables.galaxy_clustering.window.FiberCollisionsPowerSpectrumMultipoles(*args, **kwargs)[source]

Bases: BaseFiberCollisionsPowerSpectrumMultipoles

Fiber collision effect on power spectrum multipoles. Contrary to Hahn et al. 2016:

  • the kernel is assumed to be a sum of top-hat functions

  • no \(k D_{fc} \ll 1\) approximation, where \(D_{fc}\) is the fiber collision scale

Parameters:
  • k (array, default=None) – Output wavenumbers.

  • ells (tuple, default=(0, 2, 4)) – Multipoles.

  • sep (array, default=None) – Transverse separation values for kernel.

  • kernel (array, default=None) – Window representing the number of pairs lost as a function of separation.

  • theory (BaseTheoryPowerSpectrumMultipoles) – Theory power spectrum multipoles, defaults to KaiserTracerPowerSpectrumMultipoles.

  • with_uncorrelated (bool, default=True) – If False, do not include the uncorrelated part (due to not correcting the selection function for missing pairs).

Reference

https://arxiv.org/abs/1609.01714

class desilike.observables.galaxy_clustering.window.SystematicTemplateCorrelationFunctionMultipoles(*args, **kwargs)[source]

Bases: BaseSystematicTemplateMultipoles

Systematic templates for correlation function multipoles.

Parameters:
  • templates (callable, list or dict, default=()) – List of templates; one parameter called ‘syst_{i:d}’ will be created for each template i. or dict of templates; the key will be used as parameter name. Each template can be an array for all multipoles stacked, or a callable that takes (ell, s) as input and returns an array of size s.size.

  • s (array, list, default=None) – Output separations. If list, one array for each multipole.

  • ells (tuple, default=(0, 2, 4)) – Multipoles.

plot(fig=None)[source]

Plot systematic template multipoles.

Parameters:
  • fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least 1 axis.

  • fn (str, Path, default=None) – Optionally, path where to save figure. If not provided, figure is not saved.

  • kw_save (dict, default=None) – Optionally, arguments for matplotlib.figure.Figure.savefig().

  • show (bool, default=False) – If True, show figure.

Returns:

fig

Return type:

matplotlib.figure.Figure

class desilike.observables.galaxy_clustering.window.SystematicTemplatePowerSpectrumMultipoles(*args, **kwargs)[source]

Bases: BaseSystematicTemplateMultipoles

Systematic templates for power spectrum multipoles.

Parameters:
  • templates (callable, list or dict, default=()) – List of templates; one parameter called ‘syst_{i:d}’ will be created for each template i. or dict of templates; the key will be used as parameter name. Each template can be an array for all multipoles stacked, or a callable that takes (ell, k) as input and returns an array of size k.size.

  • k (array, list, default=None) – Output wavenumbers. If list, one array for each multipole.

  • ells (tuple, default=(0, 2, 4)) – Multipoles.

plot(fig=None)[source]

Plot systematic template multipoles.

Parameters:
  • fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least 1 axis.

  • fn (str, Path, default=None) – Optionally, path where to save figure. If not provided, figure is not saved.

  • kw_save (dict, default=None) – Optionally, arguments for matplotlib.figure.Figure.savefig().

  • show (bool, default=False) – If True, show figure.

Returns:

fig

Return type:

matplotlib.figure.Figure

class desilike.observables.galaxy_clustering.window.TopHatFiberCollisionsCorrelationFunctionMultipoles(*args, **kwargs)[source]

Bases: BaseFiberCollisionsCorrelationFunctionMultipoles

Fiber collision effect on correlation function multipoles, exactly following Hahn et al. 2016, assuming top-hat shape for the kernel.

Parameters:
  • s (array, default=None) – Output separations.

  • ells (tuple, default=(0, 2, 4)) – Multipoles.

  • fs (float, default=1.) – Fraction of pairs lost below the fiber collision scale Dfc.

  • Dfc (float, default=0.) – Fiber collision scale (transverse separation).

  • theory (BaseTheoryPowerSpectrumMultipoles) – Theory correlation function multipoles, defaults to KaiserTracerCorrelationFunctionMultipoles.

  • with_uncorrelated (bool, default=True) – If False, do not include the uncorrelated part (due to not correcting the selection function for missing pairs).

  • mu_range_cut (bool, default=False) – If True, normalize the Legendre integral by the uncut \(\mu\) range (instead of 2): in case the \(R1R2\) counts are cut by the tophat kernel in the estimation of correlation function multipoles.

Reference

https://arxiv.org/abs/1609.01714

class desilike.observables.galaxy_clustering.window.TopHatFiberCollisionsPowerSpectrumMultipoles(*args, **kwargs)[source]

Bases: BaseFiberCollisionsPowerSpectrumMultipoles

Fiber collision effect on power spectrum multipoles, exactly following Hahn et al. 2016:

  • top-hat shape is assumed for the kernel

  • \(k D_{fc} \ll 1\) approximation, where \(D_{fc}\) is the fiber collision scale

Parameters:
  • k (array, default=None) – Output wavenumbers.

  • ells (tuple, default=(0, 2, 4)) – Multipoles.

  • fs (float, default=1.) – Fraction of pairs lost below the fiber collision scale Dfc.

  • Dfc (float, default=0.) – Fiber collision scale (transverse separation).

  • theory (BaseTheoryPowerSpectrumMultipoles) – Theory power spectrum multipoles, defaults to KaiserTracerPowerSpectrumMultipoles.

  • with_uncorrelated (bool, default=True) – If False, do not include the uncorrelated part (due to not correcting the selection function for missing pairs).

Reference

https://arxiv.org/abs/1609.01714

class desilike.observables.galaxy_clustering.window.WindowedCorrelationFunctionMultipoles(*args, **kwargs)[source]

Bases: BaseCalculator

Window effect (for now, none) on correlation function multipoles.

Parameters:
  • slim (dict, default=None) – Optionally, separation limits: a dictionary mapping multipoles to (min separation, max separation, (optionally) step (float)), e.g. {0: (30., 160., 5.), 2: (30., 160., 5.)}. If None, no selection is applied for the given multipole.

  • s (array, default=None) – Optionally, observed separations \(s\), as an array or a list of such arrays (one for each multipole). If not specified, defaults to edge centers, based on slim if provided; else defaults to np.arange(20, 151, 5).

  • ells (tuple, default=None) – Observed multipoles, defaults to (0, 2, 4).

  • wmatrix (dict, default=None) – Can be e.g. {‘resolution’: 2}, specifying the number of theory \(s\) to integrate over per observed bin. Or {‘sedges’: sedges, ‘muedges’: muedges, ‘RR’: RR}, specifying the tabulated RR counts. If a 2D array (window matrix), output and input separations and multipoles s, ells, sin, ellsin should be provided.

  • sin (array, default=None) – If wmatrix is a 2D array, assume those are the input separations.

  • fiber_collisions (BaseFiberCollisionsCorrelationFunctionMultipoles, default=None) – Optionally, fiber collisions.

  • systematic_templates (SystematicTemplateCorrelationFunctionMultipoles, default=None) – Optionally, systematic templates.

  • theory (BaseTheoryCorrelationFunctionMultipoles) – Theory correlation function multipoles, defaults to KaiserTracerCorrelationFunctionMultipoles.

get()[source]

Return quantity of main interest, e.g. loglikelihood + logprior if self is a likelihood.

plot(fig=None)[source]

Plot window function effect on correlation function multipoles.

Parameters:
  • fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least 1 axis.

  • fn (str, Path, default=None) – Optionally, path where to save figure. If not provided, figure is not saved.

  • kw_save (dict, default=None) – Optionally, arguments for matplotlib.figure.Figure.savefig().

  • show (bool, default=False) – If True, show figure.

Returns:

fig

Return type:

matplotlib.figure.Figure

class desilike.observables.galaxy_clustering.window.WindowedPowerSpectrumMultipoles(*args, **kwargs)[source]

Bases: BaseCalculator

Window effect on the power spectrum multipoles.

Parameters:
  • klim (dict, default=None) – Optionally, wavenumber limits: a dictionary mapping multipoles to (min separation, max separation, step (float)), e.g. {0: (0.01, 0.2, 0.01), 2: (0.01, 0.15, 0.01)}. If None, no selection is applied for the given multipole.

  • k (array, default=None) – Optionally, observed wavenumbers \(k\), as an array or a list of such arrays (one for each multipole). If not specified, taken from wmatrix if provided; else defaults to edge centers, based on klim if provided; else defaults to np.arange(0.01, 0.205, 0.01).

  • ells (tuple, default=None) – Observed multipoles. Defaults to poles in klim, if provided; else (0, 2, 4).

  • wmatrix (str, Path, pypower.BaseMatrix, dict, array, default=None) – Optionally, window matrix. Can be e.g. {‘resolution’: 2}, specifying the number of theory \(k\) to integrate over per observed bin. If a 2D array (window matrix), output and input wavenumbers and multipoles k, ells, kin, ellsin should be provided.

  • kin (array, default=None) – If provided, linearly interpolate wmatrix along input wavenumbers to these wavenumbers, or if wmatrix is a 2D array, assume those are the input wavenumbers.

  • kinrebin (int, default=1) – If wmatrix (which is defined for input theory wavenumbers) is provided, rebin theory wavenumbers by this factor.

  • kinlim (tuple, default=None) – If wmatrix (which is defined for input theory wavenumbers) is provided, limit theory wavenumbers in the provided range.

  • ellsin (tuple, default=None) – Optionally, input theory multipoles. If not specified, taken from wmatrix if provided, else (0, 2, 4).

  • shotnoise (float, default=0.) – Shot noise (window matrix must be applied to power spectrum with shot noise).

  • wshotnoise (float, default=None) – Optionally, response of the window to a shot noise.

  • fiber_collisions (BaseFiberCollisionsPowerSpectrumMultipoles, default=None) – Optionally, fiber collisions.

  • systematic_templates (SystematicTemplatePowerSpectrumMultipoles, default=None) – Optionally, systematic templates.

  • theory (BaseTheoryPowerSpectrumMultipoles) – Theory power spectrum multipoles, defaults to KaiserTracerPowerSpectrumMultipoles.

get()[source]

Return quantity of main interest, e.g. loglikelihood + logprior if self is a likelihood.

plot(fig=None)[source]

Plot window function effect on power spectrum multipoles.

Parameters:
  • fig (matplotlib.figure.Figure, default=None) – Optionally, a figure with at least 1 axis.

  • fn (str, Path, default=None) – Optionally, path where to save figure. If not provided, figure is not saved.

  • kw_save (dict, default=None) – Optionally, arguments for matplotlib.figure.Figure.savefig().

  • show (bool, default=False) – If True, show figure.

Returns:

fig

Return type:

matplotlib.figure.Figure

desilike.observables.galaxy_clustering.window.window_matrix_RR(soutedges, sedges, muedges, wcounts, ellsin=(0, 2, 4), resolution=1)[source]

Build window matrix for binning, in the continuous limit, i.e. integral of \(\int dx x^2 f(x) / \int dx x^2\) over each bin.

Parameters:
  • soutedges (dict) – \(s\)-edges, for each output \(\ell\).

  • muedges (array) – \(\mu\)-edges.

  • wcounts (2D array) – RR (weighted) pair counts, of shape (len(sedges) - 1, len(muedges) - 1).

  • ellsin (tuple, default=(0, 2, 4)) – Input, theory, \(\ell\).

  • resolution (int, default=1) – Number of evaluation points in the integral, in addition to the rebinning factor (len(sedges) - 1) / (len(list_sedges[0]) - 1).

Returns:

  • sin (array) – Input theory coordinates.

  • full_matrix (array) – Window matrix.

desilike.observables.galaxy_clustering.window.window_matrix_bininteg(list_edges, resolution=1)[source]

Build window matrix for binning, in the continuous limit, i.e. integral of \(\int dx x^2 f(x) / \int dx x^2\) over each bin.

Parameters:
  • list_edges (list) – Original coarse edges.

  • resolution (int, default=1) – Number of evaluation points in the integral.

Returns:

  • xin (array) – Input theory coordinates.

  • full_matrix (array) – Window matrix.

lya