gphist.evolution module

Cosmological evolution variables.

Variables are defined by a function s(z) that must be invertible and increase monotonically from s(0) = 0 to s(zmax) = 1, where usually zmax ~ z*, the redshift of last scattering. The function s(z) and its inverse z(s) are assumed to be independent of the expansion history, for efficiency, but this could probably be relaxed if necessary.

class gphist.evolution.LogScale(nsteps, oversampling, zpost)

Bases: object

Represents evolution using the logarithm of the scale factor a(t).

LogScale evolution uses s(z) = log(1+z)/log(1+zmax) which is a scaled version of -log(a) where a = 1/(1+z) is the scale factor.

Parameters:
  • nsteps (int) – Number of equally spaced steps to use between s=0 and s=1. Actual number of steps can be larger to include values in zpost.
  • oversampling (int) – Oversampling factor relative to histogram sampling.
  • zpost (ndarray) – Array of redshifts where prior must be sampled in order to evaluate posterior constraints. The maximum value of zpost will be mapped to s=1.
Raises:

AssertionError – Invalid oversampling for nsteps. Used the initialize() method to ensure correct values, for which oversampling is a divisor of nsteps-1.

get_DC(DH)

Converts Hubble distances DH(z) to comoving distances DC(z).

Performs the integral DC(z) = Integrate[DH(zz),{zz,0,z}] using linear interpolation of DH in s.

Parameters:DH (ndarray) – 2D array of tabulated Hubble distances DH with shape (nsamples,nsteps). DH[i,j] is interpreted as the distance to zvalues[j] for sample i.
Returns:
2D array of tabulated comoving distances DC with the same
shape as the input DH array. The [i,j] value gives DC at zvalues[j].
Return type:ndarray
get_accel(DH, svalues)

Calculates accel parameter q.

Parameters:
  • DH (ndarray) – 2D array of tabulated Hubble distances DH with shape (nsamples,nsteps). DH[i,j] is interpreted as the distance to zvalues[j] for sample i.
  • svalues (ndarray) – scaled lna
Returns:

2D array of tabulated q(a) with the same

shape as the input DH array. The [i,j] value gives mu at zvalues[j].

Return type:

ndarray

get_apar(DH, DH_zstar_fid, rs_fid, z)

Calculates apar assuming rsdrag scales as DH(zstar) for that history.

Parameters:
  • DH (ndarray) – 2D array of tabulated Hubble distances DH with shape (nsamples,nsteps). DH[i,j] is interpreted as the distance to zvalues[j] for sample i.
  • DH_zstar_fid (float) – DH0[-1] fiducial DH at last scattering
  • rs_fid (float) – fiducial rsdrag
  • z (ndarray) – redshifts
Returns:

2D array of tabulated apar with the same

shape as the input DH array. The [i,j] value gives mu at zvalues[j].

Return type:

ndarray

get_aperp(DH, DA, DH_zstar_fid, rs_fid, z)

Calculates aperp assuming rsdrag scales as DH(zstar) for that history.

Parameters:
  • DH (ndarray) – 2D array of tabulated Hubble distances DH with shape (nsamples,nsteps). DH[i,j] is interpreted as the distance to zvalues[j] for sample i.
  • DH – 2D array of tabulated angular diameter distances DA with shape (nsamples,nsteps). DA[i,j] is interpreted as the distance to zvalues[j] for sample i.
  • DH_zstar_fid (float) – DH0[-1] fiducial DH at last scattering
  • rs_fid (float) – fiducial rsdrag
  • z (ndarray) – redshifts
Returns:

2D array of tabulated apar with the same

shape as the input DH array. The [i,j] value gives mu at zvalues[j].

Return type:

ndarray

get_mu(DH, DC, z)

Converts comoving distances DC(z) to mu(z).

Parameters:
  • DH (ndarray) – 2D array of tabulated Hubble distances DH with shape (nsamples,nsteps). DH[i,j] is interpreted as the distance to zvalues[j] for sample i.
  • DC (ndarray) – 2D array of tabulated Hubble distances DH with shape (nsamples,nsteps). DH[i,j] is interpreted as the distance to zvalues[j] for sample i.
  • z (ndarray) –
Returns:

2D array of tabulated mu with the same

shape as the input DC array. The [i,j] value gives mu at zvalues[j].

Return type:

ndarray

get_phi_take2(DH, svalues)

Calculates growth functions phi and f.

Parameters:
  • DH (ndarray) – 2D array of tabulated Hubble distances DH with shape (nsamples,nsteps). DH[i,j] is interpreted as the distance to zvalues[j] for sample i.
  • svalues (ndarray) – scaled lna
Returns:

2 2D arrays of tabulated phi(a) and f = dlnphi/dlna with the same

shape as the input DH array. The [i,j] value gives mu at zvalues[j].

Return type:

ndarray

s_of_z(z)

Evaluate the function s(z).

Automatically broadcasts over an input array.

Parameters:z (ndarray) – Array of redshifts for calculating s(z).
Returns:Array of evolution variable values s(z).
Return type:ndarray
z_of_s(s)

Evaluate the inverse function z(s).

Automatically broadcasts over an input array.

Parameters:s (ndarray) – Array of evolution variable values for calculating z(s).
Returns:Array of redshifts z(s).
Return type:ndarray
gphist.evolution.initialize(min_num_evol, num_evol_hist, num_samples, max_array_size)

Initialize evolution calculations.

Parameters:
  • min_num_evol (int) – Minimum number of equally spaced evolution steps required.
  • num_evol_hist (int) – Number of downsampled equally spaced evolution steps required.
  • num_samples (int) – Number of prior samples to generate.
  • max_array_size (float) – Target size of arrays allocated for generated samples in gigabytes.
Returns:

Total number of equally spaced evolution steps to use, oversampling factor, and number of samples to generate per cycle.

Return type:

tuple