simulation module

Functions relating to processing the Takahashi et al HSC simulations, available at http://cosmo.phys.hirosaki-u.ac.jp/takahasi/allsky_raytracing/.

exception simulation.DLTimeOutError

Bases: Exception

Exception to raise when a download times out.

class simulation.ZSlice(id, z)

Bases: tuple

property id

Alias for field number 0

property z

Alias for field number 1

simulation.combine_sim_cl(input_filemask, n_real, n_zbin, lmax, lmin, output_path)

Combine all realisations into a single file.

Parameters
  • input_filemask (str) – Path to input files, with {realisation} placeholder.

  • n_real (int) – Number of realisations.

  • n_zbin (int) – Number of redshift bins.

  • lmax (int) – Maximum l.

  • lmin (int) – Minimum l.

  • output_path (str) – Path to save combined .npz file.

simulation.gaussian_sim(cl_in_path, lmax_in, lmin_in, nside, mask_path, lmax_out, lmin_out, n_real, save_path)

Produce repeated simulated realisations of a single Gaussian field, and save the power spectra to disk.

Parameters
  • cl_in_path (str) – Path to input power spectrum.

  • lmax_in (int) – Maximum l to read in.

  • lmin_in (int) – If > 0, input power spectrum will be padded with zeros to start at l = 0.

  • nside (int) – Healpix map resolution to use.

  • mask_path (str) – Path to mask fits file, or None for full sky.

  • lmax_out (int) – Maximum l to measure.

  • lmin_out (int) – Minimum l to measure.

  • n_real (int) – Number of realisations to produce.

  • save_path (str) – Path to save all power spectra to.

simulation.get_obs(theory_cl_dir, nl_path, mixmat_path, binmat_path, cov_tot_path, n_zbin, lmax_in, lmin_in, lmax_obs, lmin_obs, n_bandpower, save_path)

Generate a mock observation by sampling from a Gaussian likelihood with the total covariance.

Parameters
  • theory_cl_dir (str) – Path to directory containing theory shear power spectra.

  • nl_path (str) – Path to noise power spectrum.

  • mixmat_path (str) – Path to mixing matrix.

  • binmat_path (str) – Path to binning matrix.

  • cov_tot_path (str) – Path to total covariance matrix.

  • n_zbin (int) – Number of redshift bins.

  • lmax_in (int) – Maximum l to use as input pre-mixing.

  • lmin_int (int) – Minimum l to use as input pre-mixing.

  • lmax_obs (int) – Maximum l to use in the observation.

  • lmin_obs (int) – Minimum l to use in the observation.

  • n_bandpower (int) – Number of bandpowers.

  • save_path (str) – Path to save observed bandpowers to.

simulation.loop_realisations(first_real, last_real, z_mean, z_std, mask_path, slice_path, lmax, lmin, cl_save_path, delete_after_use=True)

Loop over realisations in serial from first_real to last_real (inclusive).

Parameters
  • first_real (int) – First realisation to process (between 0 and 107 inclusive).

  • last_real (int) – Last realisation to process (in same range).

  • z_mean (list) – List containing the mean redshift of each bin.

  • mask_path (str) – Path to mask fits file, or None for full sky.

  • slice_path (str) – Path to save each slice locally, including placeholders for {realisation_id} and {slice_id}.

  • lmax (int) – Maximum l to measure.

  • lmin (int) – Minimum l to measure.

  • cl_save_path (str) – Path to save measured power spectra, including placeholder for {realisation_id}.

  • delete_after_use (bool, optional) – If True, delete each downloaded slice file once it has been used (default True).

simulation.process_realisation(realisation_id, z_mean, z_std, mask_path, slice_path, lmax, lmin, cl_save_path, delete_after_use=True)

Process a single realisation of the Takhashi et al. HSC simulations.

Download all slices, combine into tomographic bins and measure the power spectra.

Parameters
  • realisation_id (string) – ID of the realisation, from ‘r000’ to ‘r107’.

  • z_mean (list) – List containing the mean redshift of each bin.

  • mask_path (str) – Path to mask fits file, or None for full sky.

  • slice_path (str) – Path to save each slice locally, including placeholders for {realisation_id} and {slice_id}.

  • lmax (int) – Maximum l to measure.

  • lmin (int) – Minimum l to measure.

  • cl_save_path (str) – Path to save measured power spectra, including placeholder for {realisation_id}.

  • delete_after_use (bool, optional) – If True, delete each downloaded slice file once it has been used (default True).

simulation.read_slice(input_path, verbose=True)

Read gamma1 and gamma2 from a slice of the Takahashi et al. HSC simulations.

Based on the script by Toshiya Namikawa / Ken Osato available at http://cosmo.phys.hirosaki-u.ac.jp/takahasi/allsky_raytracing/nres12.html.

Parameters
  • input_path (str) – Path to slice.

  • verbose (bool, optional) – Whether to output progress (default True).

Returns

(gamma1, gamma2) healpix maps.

Return type

(1D numpy array, 1D numpy array)

simulation.timeout_download(*_)

Raise a download timeout exception.

Raises

DLTimeOutError – download timeout exception.