Skip to content

Commit 36e2832

Browse files
committed
Fixes in the docs
1 parent 6a22f13 commit 36e2832

4 files changed

Lines changed: 46 additions & 39 deletions

File tree

RascalC/interface.py

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ def run_cov(mode: Literal["s_mu", "legendre_projected", "legendre_accumulated"],
5858
mode : string
5959
Choice of binning setup, one of:
6060
61-
- ``"s_mu"``: compute covariance of the correlation function in s, µ bins. Only linear µ binning between 0 and 1 supported.
62-
- ``"legendre_projected"``: compute covariance of the correlation function Legendre multipoles in separation (s) bins projected from µ bins (only linear µ binning supported between 0 and 1). Procedure matches ``pycorr``. Works with jackknives, may be less efficient in periodic geometry.
63-
- ``"legendre_accumulated"``: compute covariance of the correlation function Legendre multipoles in separation (s) bins accumulated directly, without first doing µ-binned counts. Incompatible with jackknives.
61+
- ``"s_mu"``: compute covariance of the correlation function in separation (s), and angular (:math:`\mu`) bins. Only linear :math:`\mu` binning between 0 and 1 supported.
62+
- ``"legendre_projected"``: compute covariance of the correlation function Legendre multipoles in separation (s) bins projected from :math:`\mu` bins (only linear :math:`\mu` binning supported between 0 and 1). Procedure matches ``pycorr``. Works with jackknives, may be less efficient in periodic geometry.
63+
- ``"legendre_accumulated"``: compute covariance of the correlation function Legendre multipoles in separation (s) bins accumulated directly, without first doing :math:`\mu`-binned counts. Incompatible with jackknives.
6464
6565
max_l : integer
6666
Max Legendre multipole index (required in both Legendre ``mode``\s).
@@ -94,35 +94,42 @@ def run_cov(mode: Literal["s_mu", "legendre_projected", "legendre_accumulated"],
9494
If given and not None, enables the multi-tracer functionality (full two-tracer covariance estimation).
9595
9696
randoms_weights2 : None or array of floats of length N_randoms2
97-
(Optional) weights of random points for the second tracer (required for multi-tracer functionality).
97+
(Only for for multi-tracer functionality) weights of random points for the second tracer.
9898
9999
randoms_samples2 : None or array of integers of length N_randoms2
100-
(Optional) jackknife region numbers for the second tracer (required for multi-tracer + jackknife functionality, although this combination has not been used yet).
100+
(Only for multi-tracer + jackknife functionality, although this combination has not been used yet) jackknife region numbers for the second tracer.
101101
The jackknife assignment must match the jackknife counts in ``pycorr_allcounts_12`` and ``pycorr_allcounts_22``.
102102
103-
pycorr_allcounts_11 : ``pycorr.TwoPointEstimator``
104-
``pycorr.TwoPointEstimator`` with auto-counts for the first tracer.
103+
pycorr_allcounts_11 : :class:`pycorr.TwoPointEstimator`
104+
:class:`pycorr.TwoPointEstimator` with auto-counts for the first tracer.
105105
Must be rebinned and/or cut to the separation (s) bins desired for the covariance.
106106
Note that more bins result in slower convergence. A typical configuration has been 4 Mpc/h wide bins between 20 and 200 Mpc/h.
107-
The counts will be wrapped to positive µ, so if the µ range in them is from -1 to 1, the number of µ bins must be even.
108-
Providing unwrapped counts (µ from -1 to 1) is preferrable, because some issues can be fixed by assuming symmetry.
107+
The counts will be wrapped to positive :math:`\mu`, so if the :math:`\mu` range in them is from -1 to 1, the number of :math:`\mu` bins must be even.
108+
Providing unwrapped counts (:math:`\mu` from -1 to 1) is preferrable, because some issues can be fixed by assuming symmetry.
109109
110-
- In "s_mu" ``mode``, the covariance will be done for the given number of µ bins (after wrapping).
111-
- In "legendre_projected" ``mode``, it will be assumed that Legendre multipoles are projected from the same number of µ bins as present in these counts. One might consider rebinning more coarsely for faster performance but less guaranteed accuracy (neither effect has been tested yet).
112-
- In "legendre_accumulated" ``mode``, all the present µ bins (after wrapping) will be used to fit the survey correction functions.
110+
- In "s_mu" ``mode``, the covariance will be done for the given number of :math:`\mu` bins (after wrapping).
111+
- In "legendre_projected" ``mode``, it will be assumed that Legendre multipoles are projected from the same number of :math:`\mu` bins as present in these counts. One might consider rebinning more coarsely for faster performance but less guaranteed accuracy (neither effect has been tested yet).
112+
- In "legendre_accumulated" ``mode``, all the present :math:`\mu` bins (after wrapping) will be used to fit the survey correction functions.
113113
114114
For jackknife functionality, ``pycorr_allcounts_11`` must contain jackknife RR counts and correlation function. The jackknife assigment must match ``randoms_samples1``.
115115
116-
pycorr_allcounts_12 : ``pycorr.TwoPointEstimator``
117-
(Optional) ``pycorr.TwoPointEstimator`` with cross-counts between the two tracers (order does not matter, because they will be wrapped).
116+
**NB**: If ``pycorr_allcounts_11.D1D2.size1`` is zero, you need to provide ``no_data_galaxies1``.
117+
118+
pycorr_allcounts_12 : :class:`pycorr.TwoPointEstimator`
119+
(Only for the multi-tracer functionality) :class:`pycorr.TwoPointEstimator` with cross-counts between the two tracers (order does not matter, because absolute value of :math:`\mu` will be taken).
118120
Must have the same bin configuration as ``pycorr_allcounts_11``.
119121
For jackknife functionality, must contain jackknife RR counts and correlation function. The jackknife assigment must match ``randoms_samples1`` and ``randoms_samples2``.
122+
123+
If both ``pycorr_allcounts_11.D1D2.size1`` and ``pycorr_allcounts_12.D1D2.size1`` are set to zeros, you need to provide ``no_data_galaxies1``.
120124
121-
pycorr_allcounts_22 : ``pycorr.TwoPointEstimator``
122-
(Optional) ``pycorr.TwoPointEstimator`` with auto-counts for the second tracer.
125+
pycorr_allcounts_22 : :class:`pycorr.TwoPointEstimator`
126+
(Only for the multi-tracer functionality) :class:`pycorr.TwoPointEstimator` with auto-counts for the second tracer.
127+
Required for the multi-tracer functionality (full two-tracer covariance estimation).
123128
Must have the same bin configuration as ``pycorr_allcounts_11``.
124129
For jackknife functionality, must contain jackknife RR counts and correlation function. The jackknife assigment must match ``randoms_samples2``.
125130
131+
If ``pycorr_allcounts_22.D1D2.size1`` is zero, you need to provide ``no_data_galaxies2``.
132+
126133
normalize_wcounts : boolean
127134
(Optional) whether to normalize the weights and weighted counts.
128135
If False, the provided RR counts must match what can be obtained from given randoms, otherwise the covariance matrix will be off by a constant factor.
@@ -137,27 +144,27 @@ def run_cov(mode: Literal["s_mu", "legendre_projected", "legendre_accumulated"],
137144
(Optional) number of second tracer data (not random!) points for the covariance rescaling.
138145
If None (default), the code will attempt to obtain it from ``pycorr_allcounts_22``.
139146
140-
xi_table_11 : ``pycorr.TwoPointEstimator``, or sequence (tuple or list) of 3 elements: (s_values, mu_values, xi_values), or sequence (tuple or list) of 4 elements: (s_values, mu_values, xi_values, s_edges)
141-
Table of first tracer auto-correlation function in separation (s) and µ bins.
147+
xi_table_11 : :class:`pycorr.TwoPointEstimator`, or sequence (tuple or list) of 3 elements: ``(s_values, mu_values, xi_values)``, or sequence (tuple or list) of 4 elements: ``(s_values, mu_values, xi_values, s_edges)``
148+
Table of first tracer auto-correlation function in separation (s) and :math:`\mu` bins.
142149
The code will use it for interpolation in the covariance matrix integrals.
143-
Important: if the given correlation function is an average in s, µ bins, the separation bin edges need to be provided (and the µ bins are assumed to be linear) for rescaling procedure which ensures that the interpolation results averaged over s, µ bins returns the given correlation function. In case of ``pycorr.TwoPointEstimator``, the edges will be recovered automatically. Unwrapped estimators (µ from -1 to 1) are preferred, because symmetry allows to fix some issues.
150+
Important: if the given correlation function is an average in :math:`(s, \mu)` bins, the separation bin edges need to be provided (and the :math:`\mu` bins are assumed to be linear) for rescaling procedure which ensures that the interpolation results averaged over :math:`(s, \mu)` bins returns the given correlation function. In case of ``pycorr.TwoPointEstimator``, the edges will be recovered automatically. Unwrapped estimators (:math:`\mu` from -1 to 1) are preferred, because symmetry allows to fix some issues.
144151
In the sequence format:
145152
146-
- s_values must be a 1D array of reference separation (s) values for the table, of length N;
147-
- mu_values must be a 1D array of reference µ values (covering the range from 0 to 1) for the table, of length M;
148-
- xi_values must be an array of correlation function values at those s, µ values of shape (N, M);
149-
- s_edges, if given, must be a 1D array of separation bin edges of length N+1. The bins must come close to zero separation (say start at ``s <= 0.01``).
153+
- ``s_values`` must be a 1D array of reference separation (s) values for the table, of length N;
154+
- ``mu_values`` must be a 1D array of reference :math:`\mu` values (covering the range from 0 to 1) for the table, of length M;
155+
- ``xi_values`` must be an array of correlation function values at those :math:`(s, \mu)` values of shape (N, M);
156+
- ``s_edges``, if given, must be a 1D array of separation bin edges of length N+1. The bins must come close to zero separation (say start at ``s <= 0.01``).
150157
151158
The sequence containing 3 elements should be used for theoretical models evaluated at a grid of s, mu values.
152-
The 4-element format should be used for bin-averaged estimates.
159+
The 4-element format should be used for bin-averaged estimates (unless they are in a :class:`pycorr.TwoPointEstimator`).
153160
154161
xi_table_12 : None or the same format as ``xi_table_11``
155-
Table of the two tracer's cross-correlation function in separation (s) and µ bins.
162+
Table of the two tracer's cross-correlation function in separation (s) and :math:`\mu` bins.
156163
The code will use it for interpolation in the covariance matrix integrals.
157164
Required for multi-tracer functionality.
158165
159166
xi_table_22 : None or the same format as ``xi_table_11``
160-
Table of second tracer auto-correlation function in separation (s) and µ bins.
167+
Table of second tracer auto-correlation function in separation (s) and :math:`\mu` bins.
161168
The code will use it for interpolation in the covariance matrix integrals.
162169
Required for multi-tracer functionality.
163170
@@ -191,7 +198,7 @@ def run_cov(mode: Literal["s_mu", "legendre_projected", "legendre_accumulated"],
191198
Number of integration loops.
192199
For optimal balancing and minimal idle time, should be a few times (at least twice) ``nthread`` and exactly divisible by it.
193200
The runtime roughly scales as the number of quads per the number of threads, :math:`\mathcal{O}`\(``N_randoms * N2 * N3 * N4 * n_loops / nthread``).
194-
For reference, on NERSC Perlmutter CPU half-node the code processed about 27 millions (2.7e7) quads per second per thread (using 64 threads on half a node) as of December 2024. (In Legendre projected mode, which is probably the slowest, with ``N2 = 5``, ``N3 = 10``, ``N4 = 20``.)
201+
For reference, on NERSC Perlmutter CPU half-node the code processed about 27 millions (``2.7e7``) quads per second per thread (using 64 threads on half a node) as of December 2024. (In Legendre projected mode, which is probably the slowest, with ``N2 = 5``, ``N3 = 10``, ``N4 = 20``.)
195202
In single-tracer mode, the number of quads is ``N_randoms * N2 * N3 * N4 * n_loops``.
196203
In two-tracer mode, the number of quads is ``(5 * N_randoms1 + 2 * N_randoms2) * N2 * N3 * N4 * n_loops``.
197204
@@ -248,7 +255,7 @@ def run_cov(mode: Literal["s_mu", "legendre_projected", "legendre_accumulated"],
248255
post_processing_results : dict[str, np.ndarray[float]]
249256
Post-processing results as a dictionary with string keys and Numpy array values. All this information is also saved in a ``Rescaled_Covariance_Matrices*.npz`` file in the output directory.
250257
Selected common keys are: ``"full_theory_covariance"`` for the final covariance matrix and ``"shot_noise_rescaling"`` for the shot-noise rescaling value(s).
251-
There will also be a ``Raw_Covariance_Matices*.npz`` file in the output directory (as long as the C++ code has run without errors), which can be post-processed separately in a different way.
258+
There will also be a ``Raw_Covariance_Matices*.npz`` file in the output directory (as long as the C++ code has run without errors), which can be post-processed separately in a different way using e.g. :func:`RascalC.post_process_auto`.
252259
"""
253260

254261
if mode not in ("s_mu", "legendre_accumulated", "legendre_projected"): raise ValueError("Given mode not supported")
@@ -368,10 +375,10 @@ def print_and_log(s: object) -> None:
368375
if c and not np.allclose(pycorr_allcounts.edges[0], pycorr_allcounts_11.edges[0]): raise ValueError(f"pycorr_allcounts_{indices_corr[c]} separation/radial binning is not consistent with pycorr_allcounts_11")
369376
if pycorr_allcounts.edges[1][0] < 0: # try to fix and wrap
370377
pycorr_allcounts = fix_bad_bins_pycorr(pycorr_allcounts)
371-
print_and_log(f"Wrapping pycorr_allcounts_{indices_corr[c]} to µ>=0")
378+
print_and_log(f"Wrapping pycorr_allcounts_{indices_corr[c]} to mu>=0")
372379
pycorr_allcounts = pycorr_allcounts.wrap()
373-
if len(pycorr_allcounts.edges[1]) != n_mu_bins + 1: raise ValueError(f"The number of angular/µ bins in pycorr_allcounts_{indices_corr[c]} is not consistent with the number determined from pycorr_allcounts_11")
374-
if not np.allclose(pycorr_allcounts.edges[1], np.linspace(0, 1, n_mu_bins + 1)): raise ValueError(f"pycorr_allcounts_{indices_corr[c]} mu binning is not consistent with linear between 0 and 1 (after wrapping)")
380+
if len(pycorr_allcounts.edges[1]) != n_mu_bins + 1: raise ValueError(f"The number of angular/mu bins in pycorr_allcounts_{indices_corr[c]} is not consistent with the number determined from pycorr_allcounts_11")
381+
if not np.allclose(pycorr_allcounts.edges[1], np.linspace(0, 1, n_mu_bins + 1)): raise ValueError(f"pycorr_allcounts_{indices_corr[c]} mu binning is not consistent with linear between 0 and 1 (after wrapping)")
375382
RR_counts = get_counts_from_pycorr(pycorr_allcounts, counts_factor)
376383
np.savetxt(binned_pair_names[c], RR_counts.reshape(-1, 1)) # the file needs to have 1 column
377384
if jackknife:
@@ -403,13 +410,13 @@ def print_and_log(s: object) -> None:
403410
refine_xi = True
404411
if xi.edges[1][0] < 0:
405412
xi = fix_bad_bins_pycorr(xi)
406-
print_and_log(f"Wrapping xi_table_{indices_corr[c]} to µ>=0")
413+
print_and_log(f"Wrapping xi_table_{indices_corr[c]} to mu>=0")
407414
xi = xi.wrap()
408415
if c == 0:
409416
xi_n_mu_bins = xi.shape[1]
410417
xi_s_edges = xi.edges[0]
411418
elif not np.allclose(xi_s_edges, xi.edges[0]): raise ValueError("Different binning for different correlation functions not supported")
412-
if not np.allclose(xi.edges[1], np.linspace(0, 1, xi_n_mu_bins + 1)): raise ValueError(f"xi_table_{indices_corr[c]} µ binning is not consistent with linear between 0 and 1 (after wrapping)")
419+
if not np.allclose(xi.edges[1], np.linspace(0, 1, xi_n_mu_bins + 1)): raise ValueError(f"xi_table_{indices_corr[c]} mu binning is not consistent with linear between 0 and 1 (after wrapping)")
413420
write_xi_file(cornames[c], xi.sepavg(axis = 0), xi.sepavg(axis = 1), get_input_xi_from_pycorr(xi))
414421
elif isinstance(xi, Iterable):
415422
if len(xi) == 4: # the last element is the edges

RascalC/post_process/auto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def post_process_auto(file_root: str, out_dir: str | None = None, skip_s_bins: i
4141
By default, no bins are skipped.
4242
4343
skip_l : integer
44-
(Optional) number of higher multipoles to skip (from the end).
44+
(Optional) number of higher multipoles to skip (from the end and counting only even multipoles).
4545
4646
tracer : 1 or 2
4747
(Optional) if the RascalC output directory contains two-tracer results, ``tracer = 2`` together with ``two_tracers = False`` allows to select the second tracer for single-tracer post-processing.

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ For general usage, we provide :doc:`library/essential-functions` and :doc:`libra
2121

2222
.. toctree::
2323
:maxdepth: 2
24-
:caption: Python library
24+
:caption: Python library (2PCF)
2525

2626
library/installation
2727
library/essential-functions

0 commit comments

Comments
 (0)