Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
84b5893
Switched the scripts to argparse
misharash Nov 13, 2025
ff9c0fb
Merge branch 'fix_power' into fix_3pcf
misharash Nov 13, 2025
60d291c
Reverted to 3PCF mode compilation
misharash Nov 13, 2025
fec9508
Merge branch 'quickfix' into fix_3pcf
misharash Dec 7, 2025
082db82
Started the 3PCF interface
misharash Dec 17, 2025
4b170cd
3PCF interface work in progress
misharash Dec 17, 2025
c65bdef
Merge branch 'quickfix' into fix_3pcf
misharash Dec 17, 2025
0713372
Merge branch 'fix_3pcf' into interface_3pcf
misharash Dec 17, 2025
c058084
Added the 3PCF binary to library build
misharash Dec 18, 2025
3bc30e5
Added triple_counts binary to library build
misharash Dec 18, 2025
f7be42e
Integral loop timing for 3PCF
misharash Dec 18, 2025
f82b92b
Copied random seed logic for 3PCF
misharash Dec 18, 2025
09d245a
Copied integral output logic for 3PCF
misharash Dec 18, 2025
2b47f44
Copied verbose logic for 3PCF
misharash Dec 18, 2025
0b42c7a
Added RRR counts computation via triple_counts
misharash Dec 18, 2025
bdd3e16
Copied random seed logic for triple_counts
misharash Dec 18, 2025
bf52b7e
Copied verbose logic for triple_counts
misharash Dec 18, 2025
371c09c
triple_counts Makefile cleanup
misharash Dec 18, 2025
7cc99c3
Fix for the periodic case
misharash Dec 18, 2025
44387f8
Rearrangements in 3PCF survey correction function
misharash Dec 19, 2025
d57b09b
Vectorized the 3PCF correction function computation
misharash Dec 19, 2025
2020d5b
3PCF correction function conversion from ENCORE
misharash Dec 19, 2025
a447424
Remove normalize_wcounts logic for 3PCF
misharash Dec 19, 2025
b31b771
Fixes for 3PCF correction function from ENCORE
misharash Dec 19, 2025
e21d159
Merge branch 'master' into fix_3pcf
misharash Dec 19, 2025
68859b2
Merge branch 'fix_3pcf' into interface_3pcf
misharash Dec 19, 2025
910471d
Fixed misprint in the ENCORE multipole conversion factor
misharash Dec 19, 2025
5321201
More hints about ENCORE RRR counts
misharash Dec 19, 2025
4caf63f
Changed the 3PCF wrapper name and description
misharash Dec 19, 2025
b33de4c
Note about ENCORE vs triple_counts
misharash Dec 19, 2025
5beae0d
Correction on above/below the diagonal
misharash Dec 19, 2025
558be43
More fixes and explanations
misharash Dec 19, 2025
98aa11f
Added checks for negative RRR counts
misharash Dec 20, 2025
c0f6ca6
Separated RRR counts positivity check as function
misharash Dec 20, 2025
42a4d74
Docstring correction
misharash Dec 20, 2025
bacd8d0
Separated the 3PCF survey correction value check
misharash Dec 20, 2025
63dd453
Improved the inter/extrapolation robustness
misharash Dec 20, 2025
c8aa8ec
Updated usage notes for 3PCF wrapper
misharash Dec 20, 2025
fabfbd9
Import fix
karimpsi22 Jan 20, 2026
f3b4bab
Iteration numbers fix for 3PCF
misharash Jan 20, 2026
11e48d8
Decorations/explanations for 2PCF iteration numbers
misharash Jan 20, 2026
31dcd67
Cosmetic fixes about iteration numer
misharash Jan 22, 2026
3166bcd
Options to skip some of the 2 3PCF integrals
misharash Jan 22, 2026
fd8aab2
Adapted extra convergence check to 3PCF
misharash Jan 22, 2026
8147096
3PCF post-processing fixes
misharash Jan 22, 2026
e8b2aa5
3PCF cov conversion/loading/export
misharash Jan 27, 2026
44fc9e1
Raw 3PCF cov collection/loading/catenation
misharash Jan 28, 2026
41f48c3
Small fixes for raw 3PCF cov utils
misharash Jan 29, 2026
62c3182
Improved some NumPy type annotations
misharash Jan 29, 2026
8e7126e
Rewritten 3PCF post-processing
misharash Jan 29, 2026
2091fdb
3PCF post-processing fixes
misharash Feb 2, 2026
23f81e5
Rewritten cov filter application
misharash Feb 2, 2026
2367ace
Simple convergence diagnostic for 3PCF cov
misharash Feb 2, 2026
3651f63
Comment corrections
misharash Feb 2, 2026
00cedaa
Fixed top docstring for 3PCF cov utils
misharash Feb 9, 2026
ca60753
3PCF library docs outline
misharash Feb 9, 2026
3a71110
Docstring and slight change for 3PCF post-processing
misharash Feb 9, 2026
96e01d2
Option to exclude odd ell for 3PCF
misharash Feb 9, 2026
9877308
Merge branch 'master' into interface_3pcf
misharash Feb 9, 2026
bf87c73
Version bump
misharash Feb 9, 2026
39cac65
Merge branch 'master' into interface_3pcf
misharash Feb 20, 2026
e60ed2b
Merge branch 'master' into interface_3pcf
misharash Mar 11, 2026
9cf61b0
Enhanced finished run check for 3PCF
misharash Mar 11, 2026
a4e45f9
Comment fixes
misharash Mar 11, 2026
017b101
Fix 3PCF cov load/export/conversion
misharash Mar 26, 2026
de11a7a
Option to enable c6_0 term
misharash Apr 1, 2026
b1391c8
Merge branch 'lsstypes' into interface_3pcf
misharash Apr 17, 2026
995e201
lsstypes support for the 3PCF interface
misharash Apr 17, 2026
7ba7205
Merge branch 'lsstypes' into interface_3pcf
misharash Apr 17, 2026
46d76d7
Merge branch 'lsstypes' into interface_3pcf
misharash Apr 20, 2026
0b4b7a1
Note on structure of raw cov matrices collection
misharash Apr 20, 2026
6a7044e
Little clarifications in the C++ code
misharash Apr 20, 2026
6035170
Revert "Option to enable c6_0 term"
misharash Apr 21, 2026
991b69c
Excluded c6_0 term and explained why
misharash Apr 21, 2026
9e58a36
Skip c6_0 term computation
misharash Apr 21, 2026
ef8e8c9
Small corrections in comments
misharash Apr 21, 2026
4a696b6
Merge branch 'master' into interface_3pcf
misharash Apr 26, 2026
6741119
Version bump
misharash Apr 26, 2026
0fd031c
Merge branch 'master' into interface_3pcf
misharash Apr 27, 2026
838c349
Merge branch 'master' into interface_3pcf
misharash May 22, 2026
df817e4
Earlier tmp files cleanup (3PCF interface)
misharash May 22, 2026
c445692
Merge branch 'master' into interface_3pcf
misharash May 22, 2026
1c2c357
Merge branch 'master' into interface_3pcf
misharash May 26, 2026
1b2d8e1
Added effective number option in the 3PCF interface
misharash May 26, 2026
518c60b
Merge branch 'master' into interface_3pcf
misharash May 26, 2026
d8271c8
Type hints for start/last_integral_index (3PCF)
misharash May 26, 2026
e69cdf7
Merge branch 'master' into interface_3pcf
misharash May 26, 2026
fc0dd27
Propagated check_finished logic to 3PCF post-processing
misharash Jun 5, 2026
7b4c922
Separated 3PCF post utility function
misharash Jun 5, 2026
1041af4
Near-final draft of 3PCF mock post-processing
misharash Jun 5, 2026
ab4cd86
Merge branch 'master' into interface_3pcf
misharash Jun 5, 2026
316e95a
Implemented conversion of the 3PCF mock cov
misharash Jun 5, 2026
4f905e2
Merge branch 'master' into interface_3pcf
misharash Jun 5, 2026
56a5de4
Small edits in comments
misharash Jun 5, 2026
6f83e7e
Fixed the name for the new function
misharash Jun 8, 2026
32544d1
Option for different max_l in the mock cov
misharash Jun 8, 2026
b422ed5
Corrected explanation on mock_cov_file
misharash Jun 8, 2026
73839db
Merge branch 'master' into interface_3pcf
misharash Jun 12, 2026
173a5bb
Fixed mu_min issue for triple_counts
misharash Jun 25, 2026
314ed0a
Fixed triple mbin with a new define flag
misharash Jun 25, 2026
f6f8fe5
Cleanup/fixes in parameters and usage
misharash Jun 25, 2026
f6b4e7b
Comments on the 3PCF survey correction
misharash Jun 25, 2026
13259c8
Disabled more irrelevant chunks for triple_counts
misharash Jul 1, 2026
23bc58d
Disabled early integration stop for predictability (3PCF)
misharash Jul 1, 2026
aeede82
Frobenius reporting format consistent with 2PCF
misharash Jul 1, 2026
d746077
More consistent progress reporting (3PCF)
misharash Jul 1, 2026
211a507
Eliminated another irrelevant parameter for triple_counts
misharash Jul 1, 2026
471c8fd
Removed loops_per_sample from triple_counts call
misharash Jul 1, 2026
5403a57
Fix: elimination of early stop variables
misharash Jul 1, 2026
b1355fa
Small fixes to free memory
misharash Jul 1, 2026
bb1d81b
Merge branch 'master' into interface_3pcf
misharash Jul 1, 2026
1ec533a
Numpy array typing fixes for 3PCF
misharash Jul 1, 2026
a68bd80
Merge branch 'master' into interface_3pcf
misharash Jul 1, 2026
1b4769c
Avoid changing the tripe_counts array outside the function
misharash Jul 1, 2026
a455cd8
Brief and consistent diagnostic of the 3PCF survey correction function
misharash Jul 1, 2026
c16f371
Added option for normalized RRR counts
misharash Jul 1, 2026
e383c26
Renamed the inv sqrt matrix
misharash Jul 2, 2026
6c71739
Merge branch 'master' into interface_3pcf
misharash Jul 3, 2026
198b38e
Tiny correction for 3PCF integral number
misharash Jul 9, 2026
b6bef83
Disabled directory creation for triple_counts
misharash Jul 9, 2026
408473e
Corrected equation reference
misharash Aug 24, 2026
e9ce24e
Reference for RascalC Legendre basis
misharash Aug 24, 2026
b36cd06
Inserted factor of 6 found by Karim with LLM assistance
misharash Aug 24, 2026
701372b
Open questions/remarks on 3PCF correction function
misharash Aug 25, 2026
dd750db
Note on the volume estimate accuracy
misharash Aug 26, 2026
2bc2437
Merge branch 'master' into interface_3pcf
misharash Aug 26, 2026
35f8775
Clarifications on the 3PCF correction function
misharash Aug 26, 2026
386e11c
Further observations on correction factors
misharash Aug 26, 2026
8333f1d
Remark on triple_counts symmetry
misharash Aug 27, 2026
c493d3b
Remark on the bin volume factors
misharash Aug 27, 2026
778fa47
Implemented fix for the ENCORE correction factor
misharash Aug 27, 2026
8299911
Remark on (2*p+1) factors for posterity
misharash Aug 27, 2026
3cdf5b8
Remark on 3PCF conversion vs RRR
misharash Aug 27, 2026
48e61ab
Slightly expanded remark
misharash Sep 1, 2026
36e2a01
Further explanations for the 3PCF correction function
misharash Sep 3, 2026
1e6c893
Fix for xi_s_edges filler (3PCF)
misharash Sep 3, 2026
854065b
Merge branch 'master' into interface_3pcf
misharash Sep 3, 2026
989f174
Simplified 3PCF symmetrization
misharash Sep 10, 2026
d6929df
Added factor to scale 3PCF covs (temporarily?)
misharash Sep 10, 2026
a5f6fcb
Small fix in a C++ comment
misharash Sep 10, 2026
0935370
Refactored hard-coded line size
misharash Sep 10, 2026
5b9c0a4
Function to fit best overall scaling for 3PCF cov
misharash Sep 21, 2026
edd5d27
Revert "Added factor to scale 3PCF covs (temporarily?)"
misharash Sep 21, 2026
808f5fe
Reimplemented the overall scaling of the 3PCF covs
misharash Sep 21, 2026
be15fdd
Small fix/clarification on best overall 3PCF scaling
misharash Sep 21, 2026
c350039
Fixed the overall scaling fit function
misharash Sep 22, 2026
3700273
Avoid extra Legendre polynomial sometimes
misharash Sep 22, 2026
6f51d32
Merge branch 'master' into interface_3pcf
misharash Sep 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CC = gcc
CFLAGS = -O3 -Wall -MMD
CXX = g++
CXXFLAGS = -O3 -Wall -MMD -std=c++11 -ffast-math $(shell pkg-config --cflags gsl)
CXXFLAGS += -DOPENMP -DLEGENDRE_MIX -DJACKKNIFE -DPRINTPERCENTS
CXXFLAGS += -DOPENMP -DTHREE_PCF -DPRINTPERCENTS
#-DOPENMP # use this to run multi-threaded with OPENMP
#-DPERIODIC # use this to enable periodic behavior
#-DLEGENDRE # use this to compute 2PCF covariances in Legendre bins (original mode, corresponding to direct accumulation into multipoles from pair counts)
Expand Down
36 changes: 34 additions & 2 deletions RascalC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ endif

LD = $(CXX)

# The code below compiles all the valid variants for the 2PCF covariance
# The code below compiles all the valid variants for the 2PCF covariance, and one for 3PCF

BASE_VARIANTS = s_mu s_mu_jackknife legendre_accumulated legendre_projected legendre_projected_jackknife
BASE_VARIANTS = s_mu s_mu_jackknife legendre_accumulated legendre_projected legendre_projected_jackknife 3pcf_legendre_accumulated

DEFINES_FOR_s_mu=
DEFINES_FOR_s_mu_jackknife=-DJACKKNIFE
DEFINES_FOR_legendre_accumulated=-DLEGENDRE
DEFINES_FOR_legendre_projected=-DLEGENDRE_MIX
DEFINES_FOR_legendre_projected_jackknife=-DLEGENDRE_MIX -DJACKKNIFE
DEFINES_FOR_3pcf_legendre_accumulated=-DTHREE_PCF

define add_periodic_variant
DEFINES_FOR_$(1)_periodic = $$(DEFINES_FOR_$(1)) -DPERIODIC
Expand Down Expand Up @@ -90,6 +91,37 @@ endef

$(foreach variant,$(VARIANTS),$(eval $(call make_targets,$(variant))))

# end of variants for the covariance

# The code below compiles all the valid variants for the triple_counts

VARIANTS2 = s_mu s_mu_verbose s_mu_periodic s_mu_periodic_verbose

DEFINES2 = -DTRIPLE # triple_counts needs this to have mumin=-1 and not 0 to be consistent with the 3PCF covariance

VAR_SRC2_BASE = triple_counts
VAR_SRC2 = ../$(VAR_SRC2_BASE)/$(VAR_SRC2_BASE).cpp
VAR_OBJ2_BASE = $(OBJDIR)/$(VAR_SRC2_BASE)

EXEC2_BASE = $(EXECDIR)/triple

define make_targets2
OBJ2_$(1) = $$(VAR_OBJ2_BASE).$(1).o
ALL_OBJS += $$(OBJ2_$(1))
EXEC2_$(1) = $$(EXEC2_BASE).$(1)
ALL_EXECS += $$(EXEC2_$(1))

$$(OBJ2_$(1)): $$(VAR_SRC2) | $$(OBJDIR)
$$(CXX) $$(CXXFLAGS) $$(DEFINES2) $$(DEFINES_FOR_$(1)) -c $$(VAR_SRC2) -o $$@

$$(EXEC2_$(1)): $$(OBJ2_$(1)) $$(COMMON_OBJS) | $$(EXECDIR)
$$(LD) $$(OBJ2_$(1)) $$(COMMON_OBJS) $$(LFLAGS) -o $$@
endef

$(foreach variant,$(VARIANTS2),$(eval $(call make_targets2,$(variant))))

# end of variants for the triple_counts

.PHONY: all clean

all: $(ALL_EXECS)
Expand Down
6 changes: 4 additions & 2 deletions RascalC/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
__version__ = "3.2"
__version__ = "3.3.alpha1"

from .interface import run_cov
from .post_process import post_process_auto
from .raw_covariance_matrices import cat_raw_covariance_matrices
from .raw_covariance_matrices import cat_raw_covariance_matrices

from .interface_3pcf import run_cov_3pcf
2 changes: 1 addition & 1 deletion RascalC/convergence_check_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ def convergence_check_extra_file(rascalc_results_filename: str, n_samples: int |
Further optionally, use ``print_function`` to report the results.
"""
with np.load(rascalc_results_filename) as f:
return convergence_check_extra(f, n_samples, print_function)
return convergence_check_extra(f, n_samples, print_function)
281 changes: 200 additions & 81 deletions RascalC/correction_function_3pcf.py

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions RascalC/cov_utils_3pcf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""
This module contains convenience functions that

- read RascalC results (checking eigenvalues of the inversion bias matrix. If they are much smaller than 1, it is safe to simply invert the covariance matrix. Otherwise, a correction factor is necessary.
- convert (reorder) 3PCF covariance matrices (as is usually needed for Legendre moments)
- and/or export (save) the full 3PCF covariance matrix to a text file.
"""

import numpy as np
import numpy.typing as npt
from typing import Callable
from .get_shot_noise_rescaling import get_shot_noise_rescaling # for convenience
from .cov_utils import get_cov_header, load_cov


def convert_cov_3pcf_legendre(cov: npt.NDArray[np.float64], max_l: int, exclude_odd_l: bool = False, apply_scaling: bool = True) -> npt.NDArray[np.float64]:
"""
Change the bin ordering of the 3PCF covariance matrix in Legendre mode for a single tracer.
The bin ordering in ``RascalC`` ``.npy`` files is by radial bin pairs (top-level) and then by multipoles.
The resulting bin ordering (for text files) is by multipoles (top-level) and then by radial bin pairs.
By default, the ell-dependent scaling factor is applied to convert to ENCORE basis functions from RascalC Legendre polynomial basis, this can be disabled with ``apply_scaling=False``.
"""
n_l = max_l // (1 + exclude_odd_l) + 1
n_bins = len(cov)
if n_bins % n_l != 0: raise ValueError("Number of bins in the Legendre covariance must be divisible by the number of multipoles (even and odd)")
n_r_bin_pairs = n_bins // n_l
cov = cov.reshape(n_r_bin_pairs, n_l, n_r_bin_pairs, n_l) # convert to 4D from 2D with [r_bin_pair, l] ordering for both rows and columns
if apply_scaling: # prepare to apply the ell-dependent factor between RascalC and ENCORE basis functions
ells = np.arange(0, max_l + 1, 1 + exclude_odd_l)
ell_factor = ((-1)**ells * np.sqrt(2 * ells + 1) / (4 * np.pi)) # the ell-dependent factor between the ENCORE 3-point basis functions and Legendre polynomials given by Equation (17) in https://arxiv.org/pdf/2105.08722. RascalC uses Legendre polynomial basis according to Equation (4.11) in https://arxiv.org/pdf/1910.04764
cov /= ell_factor[:, None, None] * ell_factor[None, None, :] # apply the factor, NumPy broadcasting matches trailing dimensions. need to check if it is not multiplication; there might also be a factor of 2 or something similar
cov = cov.transpose(1, 0, 3, 2) # change ordering to [l, r_pair] for both rows and columns
cov = cov.reshape(n_bins, n_bins) # convert back from 4D to 2D
return cov


def load_cov_3pcf_legendre(rascalc_results_file: str, max_l: int, exclude_odd_l: bool = False, apply_scaling: bool = True, print_function: Callable[[str], None] = print) -> npt.NDArray[np.float64]:
"Load the theoretical covariance matrix from RascalC results file, change the bin ordering and apply scaling as in :func:`convert_cov_3pcf_legendre`; intended for 3PCF Legendre single-tracer mode."
return convert_cov_3pcf_legendre(load_cov(rascalc_results_file, print_function), max_l, exclude_odd_l=exclude_odd_l, apply_scaling=apply_scaling)


def export_cov_3pcf_legendre(rascalc_results_file: str, max_l: int, output_cov_file: str, exclude_odd_l: bool = False, apply_scaling: bool = True, print_function: Callable[[str], None] = print) -> None:
"Export the theoretical covariance matrix from RascalC results file to a text file with conversion appropriate for 3PCF single-tracer Legendre mode (see :func:`convert_cov_3pcf_legendre`)."
np.savetxt(output_cov_file, load_cov_3pcf_legendre(rascalc_results_file, max_l, exclude_odd_l=exclude_odd_l, apply_scaling=apply_scaling, print_function = print_function), header = get_cov_header(rascalc_results_file))
Loading
Loading