Seed the jackknife k-means and drop the patch-centre file - #367
Draft
cailmdaley wants to merge 1 commit into
Draft
cailmdaley wants to merge 1 commit into
cailmdaley wants to merge 1 commit into
Conversation
…tre file
TreeCorr seeds its k-means afresh on every unseeded call, so the jackknife
patches, and with them the ξ± jackknife covariance, differed between runs
that did not share a {ver}_patches_npatch=N.dat. The k-means is now seeded
with a fixed generator, which makes the patches a pure function of the
catalogue's positions and weights on any thread count; the centre file and
its reuse logic go. The aperture-mass ξ± takes the same seed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
calculate_2pcfbuilds the jackknife patches for ξ± with TreeCorr's k-means, which picks a fresh random seed on every unseeded call. Develop hides this by drawing the centres once per output tree and reusing{ver}_patches_npatch=N.dat, but a fresh tree, a rerun elsewhere, or two jobs racing to write the file all split the sky differently, so the ξ± jackknife covariance changed from run to run. It is the same class of bug that moved ρ/τ statistics by up to ~3σ between reruns (fixed in shear_psf_leakage #43).This PR seeds the k-means (
rng=np.random.default_rng(0)). Seeded, the patches are a pure function of the catalogue's positions and weights, so the centre file has no job left and goes too.What changes
calculate_2pcf: seeded k-means; the patch-centre file, its reuse and its write are removed.calculate_aperture_mass_dispersionbuilds its own patched catalogue and gets the same seed.Effect on results
bin_slopapproximates; not measured against develop's draws._patches_npatch=*.datfiles are no longer read. They can be deleted.Cost
The k-means runs on every measurement. On 16 threads it takes about 1 s per 10⁶ objects (≈10–15 s at 10⁷ for 20–200 patches), which is small next to the pair counting.
Verified
— Claude (Opus) on behalf of Cail.
🤖 Generated with Claude Code