From 9733d25858581fb08b58d44cdfc6dc1d012e495f Mon Sep 17 00:00:00 2001 From: "Lucia F. de la Bella" <55983939+Lucia-Fonseca@users.noreply.github.com> Date: Fri, 1 Jul 2022 15:48:54 +0100 Subject: [PATCH] MAINT: Delete classy function (#560) --- docs/power_spectrum/index.rst | 2 +- skypy/power_spectrum/__init__.py | 2 +- skypy/power_spectrum/_classy.py | 71 -------------------------------- 3 files changed, 2 insertions(+), 73 deletions(-) diff --git a/docs/power_spectrum/index.rst b/docs/power_spectrum/index.rst index e122b721..81356c67 100644 --- a/docs/power_spectrum/index.rst +++ b/docs/power_spectrum/index.rst @@ -5,7 +5,7 @@ This module contains methods to model the matter power spectrum. SkyPy provides wrappers to a number of external codes for calculating the matter power spectrum, including `~skypy.power_spectrum.CAMB` and -`~skypy.power_spectrum.classy`. Here we demonstrate calculating the linear +`~skypy.power_spectrum.CLASSY`. Here we demonstrate calculating the linear matter power spectrum using `~skypy.power_spectrum.eisenstein_hu` and the non-linear corrections using `~skypy.power_spectrum.halofit_smith`: diff --git a/skypy/power_spectrum/__init__.py b/skypy/power_spectrum/__init__.py index 922b2373..25ffee91 100644 --- a/skypy/power_spectrum/__init__.py +++ b/skypy/power_spectrum/__init__.py @@ -9,7 +9,7 @@ :toctree: ../api/ CAMB - classy + CLASSY eisenstein_hu transfer_no_wiggles transfer_with_wiggles diff --git a/skypy/power_spectrum/_classy.py b/skypy/power_spectrum/_classy.py index ffc89c67..c0257b7e 100644 --- a/skypy/power_spectrum/_classy.py +++ b/skypy/power_spectrum/_classy.py @@ -3,80 +3,9 @@ __all__ = [ 'CLASSY', - 'classy', ] -def classy(wavenumber, redshift, cosmology, **kwargs): - """ Return the CLASS computation of the linear matter power spectrum, on a - two dimensional grid of wavenumber and redshift. - - Additional CLASS parameters can be passed via keyword arguments. - - Parameters - ---------- - wavenumber : (nk,) array_like - Array of wavenumbers in units of Mpc-1 at which to - evaluate the linear matter power spectrum. - redshift : (nz,) array_like - Array of redshifts at which to evaluate the linear matter power - spectrum. - cosmology : astropy.cosmology.Cosmology - Cosmology object providing omega_matter, omega_baryon, Hubble - parameter and CMB temperature in the present day - - Returns - ------- - power_spectrum : (nz, nk) array_like - Array of values for the linear matter power spectrum in Mpc3 - evaluated at the input wavenumbers for the given primordial power - spectrum parameters, cosmology. For nz redshifts and nk wavenumbers - the returned array will have shape (nz, nk). - - References - ---------- - doi : 10.1088/1475-7516/2011/07/034 - arXiv: 1104.2932, 1104.2933 - - """ - try: - from classy import Class - except ImportError: - raise Exception("classy is required to use skypy.linear.classy") - - h2 = cosmology.h * cosmology.h - - params = { - 'output': 'mPk', - 'P_k_max_1/Mpc': np.max(wavenumber), - 'z_pk': ', '.join(str(z) for z in np.atleast_1d(redshift)), - 'H0': cosmology.H0.value, - 'omega_b': cosmology.Ob0 * h2, - 'omega_cdm': cosmology.Odm0 * h2, - 'T_cmb': cosmology.Tcmb0.value, - 'N_eff': cosmology.Neff, - } - - params.update(kwargs) - - classy_obj = Class() - classy_obj.set(params) - classy_obj.compute() - - z = np.expand_dims(redshift, (-1,)*np.ndim(wavenumber)) - k = np.expand_dims(wavenumber, (0,)*np.ndim(redshift)) - z, k = np.broadcast_arrays(z, k) - pzk = np.empty(z.shape) - - for i in np.ndindex(*pzk.shape): - pzk[i] = classy_obj.pk_lin(k[i], z[i]) - - if pzk.ndim == 0: - pzk = pzk.item() - - return pzk - - class CLASSY(TabulatedPowerSpectrum): def __init__(self, kmax, redshift, cosmology, **kwargs):