CorrHOD.cutsky#

class CorrHOD.cutsky.CorrHOD_cutsky(path2config: str, HOD_params: Optional[dict] = None, los: str = 'z', boxsize: float = 2000, cosmo: int = 0)[source][source]#

Bases: CorrHOD_cubic

This class is used to compute the 2PCF and the autocorrelation and cross-correlation of the quantiles of the DensitySplit. It takes HOD parameters and a cosmology as input and uses AbacusHOD to generate a DESI cutsky mock. It then uses DensitySplit to compute the density field and the quantiles. Finally, it uses pycorr to compute the 2PCF and the autocorrelation and cross-correlation of the quantiles.

If a cutsky file is to be provided, the cutsky must be in the form of a dictionary in sky coordinates. Every computation in this class is done in sky coordinates, except for the densitysplit. The conversion is done using the densitysplit package. Unless the name of the variable indicates it, the positions are in (ra, dec, comoving distance) coordinates. If the name of the variable contains ‘sky’, the positions are in (ra, dec, z) coordinates.

Initialises the CorrHOD object. Note that the ‘tracer’ parameter is fixed to ‘LRG’ by default. It can be changed later by manually reassigning the parameter. This tracer is chosen to study LRG and BGS. It can be changed but the code is not guaranteed to work.

Parameters:
  • path2config (str) – Path to the config file of AbacusHOD. It is used to load the simulation. See the documentation for more details.

  • HOD_params (dict, optional) – Dictionary containing the HOD parameters. The keys must be the same as the ones used in AbacusHOD. If not provided, the default parameters of AbacusHOD are used. Defaults to None.

  • los (str, optional) – Line-of-sight direction in which to apply the RSD. Defaults to ‘z’.

  • boxsize (float, optional) – Size of the simulation box in Mpc/h. Defaults to 2000.

  • cosmo (int, optional) – Index of the cosmology to use. This index is used to load the cosmology from the AbacusSummit object. Defaults to 0. See the documentation of AbacusSummit for more details.

Raises:

ValueError – If the simulation is not precomputed. See the documentation of AbacusHOD for more details.

get_tracer_positions(return_cartesian: bool = False)[source][source]#

Get the positions of the tracers (data and randoms) in cartesian coordinates. Note : For now, we assume that the RSD are already applied to the data

Returns:

  • data_positions (array_like) – The positions of the galaxies in cartesian coordinates.

  • randoms_positions (array_like) – The positions of the randoms in cartesian coordinates.

get_tracer_weights(edges: Optional[list] = None, area: Optional[float] = None, fsky: Optional[float] = None, P0: float = 7000)[source][source]#

Compute the weights for the tracer and the randoms. Note : If neither area nor fsky are set, the sky fraction of the data will be computed, using the current data sky positions.

Parameters:
  • edges (list, optional) – The edges of the bins used to compute the number density. If set to None, the edges are computed using Scott’s rule. Defaults to None.

  • area (float, optional) – The area of the survey in square degrees. Defaults to None.

  • fsky (float, optional) – The fraction of the sky covered by the survey. Defaults to None.

  • P0 (float, optional) – The power spectrum normalization (TODO : Check this definition). Defaults to 7000 for the BGS.

Returns:

  • data_weights (array_like) – The weights of the galaxies.

  • randoms_weights (array_like) – The weights of the randoms.

compute_DensitySplit(smooth_radius: float = 10, cellsize: float = 5, nquantiles: int = 10, sampling: str = 'randoms', randoms=None, filter_shape: str = 'Gaussian', return_density: bool = True, nthread=16)[source][source]#

Compute the density field and the quantiles using DensitySplit. (see epaillas/densitysplit for more details)

Parameters:
  • smooth_radius (float, optional) – The radius of the Gaussian smoothing in Mpc/h. Defaults to 10.

  • cellsize (float, optional) – The size of the cells in the mesh. Defaults to 10.

  • nquantiles (int, optional) – The number of quantiles to compute. Defaults to 10.

  • sampling (str, optional) – The sampling to use. Can be ‘randoms’ or ‘data’. Defaults to ‘randoms’.

  • randoms (np.ndarray, optional) – The positions of the randoms. It is a (N,3) array of points in the range [0, boxsize] for each coordinate. If set to none, a the randoms positions of the data will be used. Defaults to None.

  • filter_shape (str, optional) – The shape of the filter to use. Can be ‘Gaussian’ or ‘TopHat’. Defaults to ‘Gaussian’.

  • return_density (bool, optional) – If True, the density field is returned. Defaults to True.

  • nthread (int, optional) – The number of threads to use. Defaults to 16.

Returns:

  • quantiles (np.ndarray) – The quantiles. It is a (nquantiles,N,3) array.

  • density (np.ndarray, optional) – The density field. It is a (N,3) array.

get_nz(edges: Optional[list] = None, area: Optional[float] = None, fsky: Optional[float] = None)[source][source]#

Computes the n(z) function of the data and the quantiles (if they exist). Note : If neither area nor fsky are set, the sky fraction of the data will be computed, using the current data sky positions.

Parameters:
  • edges (list, optional) – The edges of the bins used to compute the number density. If set to None, the edges are computed using Scott’s rule. Defaults to None.

  • area (float, optional) – The area of the survey in square degrees. Defaults to None.

  • fsky (float, optional) – The fraction of the sky covered by the survey. Defaults to None.

Returns:

  • nz_data (InterpolatedUnivariateSpline) – The n(z) function of the data.

  • nz_randoms (InterpolatedUnivariateSpline) – The n(z) function of the randoms.

  • nz_functions (list, optional) – The n(z) function for each quantile. It is a list of InterpolatedUnivariateSpline objects.

downsample_data(frac: Optional[float] = None, new_n: Optional[float] = None, npoints: Optional[int] = None)[source][source]#

Downsamples the data to a given number density. The number of points in the randoms and the quantiles will be adjusted accordingly. (i.e. if the number density of the data is 10 times smaller, the number of points in the randoms and the quantiles will be 10 times smaller, while keeping the proportionality to the data)

Since the number density varies with the redshift, the downsampling to the new number density is done by taking the mean n(z) of the data as reference. This should have n(z) remaining approx. the same. (TODO : Test this ?)

Parameters:

new_n (float) – The wanted number density of the data after downsampling. The number density of the randoms and the quantiles will be adjusted accordingly.

Returns:

  • data_positions (np.ndarray) – The positions of the data after downsampling.

  • randoms_positions (np.ndarray) – The positions of the randoms after downsampling.

  • quantiles (np.ndarray, optional) – The quantiles after downsampling.

compute_auto_corr(quantile: int, mode: str = 'smu', edges: list = [np.linspace(0.1, 200, 50), np.linspace(-1, 1, 60)], mpicomm=None, mpiroot=None, nthread: int = 16)[source][source]#

Compute the auto-correlation of a quantile. The result will also be saved in the class, as self.CF[‘Auto’][f’DS{quantile}’]

Parameters:
  • quantile (int) – Index of the quantile to compute. It must be between 0 and nquantiles-1.

  • mode (str, optional) – The mode to use for the 2PCF. Defaults to ‘smu’. See pycorr for more details .

  • edges (list, optional) – The edges to use for the 2PCF. Defaults to [np.linspace(0.1, 200, 50), np.linspace(-1, 1, 60)]. See pycorr for more details.

  • mpicomm (_type_, optional) – The MPI communicator. Defaults to None.

  • mpiroot (_type_, optional) – The MPI root. Defaults to None.

  • nthread (int, optional) – The number of threads to use. Defaults to 16.

Returns:

xi_quantile – The auto-correlation of the quantile.

Return type:

pycorr.TwoPointCorrelationFunction

compute_cross_corr(quantile: int, mode: str = 'smu', edges: list = [np.linspace(0.1, 200, 50), np.linspace(-1, 1, 60)], mpicomm=None, mpiroot=None, nthread: int = 16)[source][source]#

Compute the cross-correlation of a quantile with the galaxies. The result will also be saved in the class, as self.CF[‘Cross’][f’DS{quantile}’]

Parameters:
  • quantile (int) – Index of the quantile to compute. It must be between 0 and nquantiles-1.

  • mode (str, optional) – The mode to use for the 2PCF. Defaults to ‘smu’. See pycorr for more details .

  • edges (list, optional) – The edges to use for the 2PCF. Defaults to [np.linspace(0.1, 200, 50), np.linspace(-1, 1, 60)]. See pycorr for more details.

  • mpicomm (_type_, optional) – The MPI communicator. Defaults to None.

  • mpiroot (_type_, optional) – The MPI root. Defaults to None.

  • nthread (int, optional) – The number of threads to use. Defaults to 16.

Returns:

xi_quantile – The cross-correlation of the quantile.

Return type:

pycorr.TwoPointCorrelationFunction

compute_2pcf(mode: str = 'smu', edges: list = [np.linspace(0.1, 200, 50), np.linspace(-1, 1, 60)], mpicomm=None, mpiroot=None, nthread: int = 16)[source][source]#

Compute the 2PCF of the galaxies. The result will also be saved in the class, as self.CF[‘2PCF’]

Parameters:
  • mode (str, optional) – The mode to use for the 2PCF. Defaults to ‘smu’. See pycorr for more details .

  • edges (list, optional) – The edges to use for the 2PCF. Defaults to [np.linspace(0.1, 200, 50), np.linspace(-1, 1, 60)]. See pycorr for more details.

  • mpicomm (_type_, optional) – The MPI communicator. Defaults to None.

  • mpiroot (_type_, optional) – The MPI root. Defaults to None.

  • nthread (int, optional) – The number of threads to use. Defaults to 16.

Returns:

xi – The 2PCF of the galaxies.

Return type:

pycorr.TwoPointCorrelationFunction

save(hod_indice: int = 0, path: Optional[str] = None, save_HOD: bool = True, save_pos: bool = True, save_density: bool = True, save_quantiles: bool = True, save_CF: bool = True, save_xi: bool = True, los: str = 'average', save_all: bool = False)[source][source]#

Save the results of the CorrHOD object. Some of the results are saved as dictionaries in numpy files. They can be accessed using the np.load function, and the .item() method of the loaded object.

Parameters:
  • hod_indice (int, optional) – The indice of the set of HOD parameters provided to the CorrHOD Object. Defaults to 0. Be careful to set the right indice if you want to save the HOD parameters !

  • path (str, optional) – The path where to save the results. If None, the path is set to the output_dir of config file. Defaults to None.

  • save_HOD (bool, optional) – If True, the HOD parameters are saved. File saved as hod{hod_indice}_c{cosmo}_p{phase}.npy. Defaults to True.

  • save_pos (bool, optional) – If True, the cubic mock dictionary is saved. File saved as pos_hod{hod_indice}_c{cosmo}_p{phase}.npy. Defaults to True.

  • save_density (bool, optional) – If True, the density PDF is saved. File saved as density_hod{hod_indice}_c{cosmo}_p{phase}.npy. Defaults to True.

  • save_quantiles (bool, optional) – If True, the quantiles of the densitysplit are saved. File saved as quantiles_hod{hod_indice}_c{cosmo}_p{phase}.npy. Defaults to True.

  • save_CF (bool, optional) – If True, the 2PCF, the autocorrelation and cross-correlation of the quantiles are saved. The 2PCF is saved as tpcf_hod{hod_indice}_c{cosmo}_p{phase}.npy. It contains the separation bins in the s key and the poles in the 2PCF key. The Auto and Corr dictionaries are saved as ds_auto_hod{hod_indice}_c{cosmo}_p{phase}.npy and ds_cross_hod{hod_indice}_c{cosmo}_p{phase}.npy. Each dictionnary contains DS{quantile} keys with the CF of the quantile. The s key contains the separation bins. Defaults to True.

  • save_xi (bool, optional) – If True, the pycorr objects are saved in an unique dictionary. The 2PCF can be accessed using the xi[los][‘2PCF’] key. The auto and cross-correlations of the quantiles can be accessed using the xi[los][‘Auto’][‘DS{i}’] and xi[los][‘Cross’][‘DS{i}’] keys. Defaults to True.

  • los (str, optional) – The line of sight along which to save the 2PCF, the autocorrelation and cross-correlation of the quantiles. Can be ‘x’, ‘y’, ‘z’ or ‘average’. Defaults to ‘average’.

  • save_all (bool, optional) – If True, all the results are saved. This overrides the other options. Defaults to False.