-
Notifications
You must be signed in to change notification settings - Fork 5
Tomographic 2pcf calculation with treecorr #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LisaGoh
wants to merge
3
commits into
feature/sp_validation-extend-to-tomography
Choose a base branch
from
296-tomographic-2pcf-calculation-with-treecorr
base: feature/sp_validation-extend-to-tomography
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ def calculate_cosebis( | |
| cov_path=None, | ||
| scale_cuts=None, | ||
| evaluate_all_scale_cuts=False, | ||
| compute_tomography=False, | ||
| min_sep=None, | ||
| max_sep=None, | ||
| nbins=None, | ||
|
|
@@ -68,6 +69,8 @@ def calculate_cosebis( | |
| If True, evaluates COSEBIs for all possible scale cut combinations | ||
| using the reporting binning parameters. Ignored when scale_cuts is | ||
| provided. Defaults to False. | ||
| compute_tomography : bool, optional | ||
| If True, computes COSEBIs for all tomographic bin combinations. Defaults to False.s | ||
| min_sep : float, optional | ||
| Minimum separation for reporting binning (only used when | ||
| evaluate_all_scale_cuts=True). Defaults to self.treecorr_config["min_sep"]. | ||
|
|
@@ -99,44 +102,63 @@ def calculate_cosebis( | |
| f"Computing fine-binned 2PCF with {nbins_int} bins from {min_sep_int} to " | ||
| f"{max_sep_int} arcmin" | ||
| ) | ||
| gg = self.calculate_2pcf(version, npatch=npatch, **treecorr_config) | ||
|
|
||
| if scale_cuts is not None: | ||
| # Explicit scale cuts provided | ||
| print(f"Evaluating {len(scale_cuts)} explicit scale cuts") | ||
| results = calculate_cosebis( | ||
| gg=gg, nmodes=nmodes, scale_cuts=scale_cuts, cov_path=cov_path | ||
| ) | ||
| elif evaluate_all_scale_cuts: | ||
| # Use reporting binning parameters or inherit from class config | ||
| binning = self._binning(min_sep, max_sep, nbins) | ||
| min_sep, max_sep, nbins = ( | ||
| binning["min_sep"], | ||
| binning["max_sep"], | ||
| binning["nbins"], | ||
| ) | ||
| ggs = self.calculate_2pcf( | ||
| version, | ||
| npatch=npatch, | ||
| compute_tomography=compute_tomography, | ||
| **treecorr_config, | ||
| ) | ||
| results = { | ||
| bin_key: None for bin_key in ggs.keys() | ||
| } # Initialize results dictionary | ||
|
|
||
| # Generate scale cuts using np.geomspace (no TreeCorr needed) | ||
| bin_edges = np.geomspace(min_sep, max_sep, nbins + 1) | ||
| generated_cuts = [ | ||
| (bin_edges[start], bin_edges[stop]) | ||
| for start in range(nbins) | ||
| for stop in range(start + 1, nbins + 1) | ||
| ] | ||
| for bin_key in ggs.keys(): | ||
| # LG TO-DO: account for tomographic scale-cuts | ||
| if scale_cuts is not None: | ||
| # Explicit scale cuts provided | ||
| print(f"Evaluating {len(scale_cuts)} explicit scale cuts") | ||
| results[bin_key] = calculate_cosebis( | ||
| gg=ggs[bin_key], | ||
| nmodes=nmodes, | ||
| scale_cuts=scale_cuts, | ||
| cov_path=cov_path, | ||
| ) | ||
| elif evaluate_all_scale_cuts: | ||
| # Use reporting binning parameters or inherit from class config | ||
| binning = self._binning(min_sep, max_sep, nbins) | ||
| min_sep, max_sep, nbins = ( | ||
| binning["min_sep"], | ||
| binning["max_sep"], | ||
| binning["nbins"], | ||
| ) | ||
|
|
||
| print(f"Evaluating {len(generated_cuts)} scale cut combinations") | ||
| # Generate scale cuts using np.geomspace (no TreeCorr needed) | ||
| bin_edges = np.geomspace(min_sep, max_sep, nbins + 1) | ||
| generated_cuts = [ | ||
| (bin_edges[start], bin_edges[stop]) | ||
| for start in range(nbins) | ||
| for stop in range(start + 1, nbins + 1) | ||
| ] | ||
|
|
||
| # Call b_modes function with scale cuts list | ||
| results = calculate_cosebis( | ||
| gg=gg, nmodes=nmodes, scale_cuts=generated_cuts, cov_path=cov_path | ||
| ) | ||
| else: | ||
| # Single scale cut behavior: use full range | ||
| results = calculate_cosebis( | ||
| gg=gg, nmodes=nmodes, scale_cuts=None, cov_path=cov_path | ||
| ) | ||
| # Extract single results dict from scale_cuts dictionary | ||
| results = next(iter(results.values())) | ||
| print(f"Evaluating {len(generated_cuts)} scale cut combinations") | ||
|
|
||
| # Call b_modes function with scale cuts list | ||
| results = calculate_cosebis( | ||
| gg=ggs[bin_key], | ||
| nmodes=nmodes, | ||
| scale_cuts=generated_cuts, | ||
| cov_path=cov_path, | ||
| ) | ||
| else: | ||
| # Single scale cut behavior: use full range | ||
| results = calculate_cosebis( | ||
| gg=ggs[bin_key], nmodes=nmodes, scale_cuts=None, cov_path=cov_path | ||
| ) | ||
| # Extract single results dict from scale_cuts dictionary | ||
| results = next(iter(results.values())) | ||
|
|
||
| results[bin_key] = results # Store results for this bin_key | ||
|
|
||
| return results | ||
|
|
||
|
|
@@ -152,6 +174,7 @@ def plot_cosebis( | |
| cov_path=None, | ||
| scale_cuts=None, # Explicit scale cuts | ||
| evaluate_all_scale_cuts=False, # Grid-based scale cuts | ||
| compute_tomography=False, | ||
| min_sep=None, | ||
| max_sep=None, | ||
| nbins=None, # Reporting binning | ||
|
|
@@ -228,6 +251,7 @@ def plot_cosebis( | |
| cov_path=cov_path, | ||
| scale_cuts=scale_cuts, | ||
| evaluate_all_scale_cuts=evaluate_all_scale_cuts, | ||
| compute_tomography=False, # LG: Hardcoded to False for now | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine to leave for the future PR — just noting |
||
| min_sep=min_sep, | ||
| max_sep=max_sep, | ||
| nbins=nbins, | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rebinding clobbers the accumulator dict initialized above (
results = {bin_key: None …}), and then line 161'sresults[bin_key] = resultsself-references — even the plain non-tomo single-scale-cut case returns a mangled dict. A differently-named inner variable (res = calculate_cosebis(...);results[bin_key] = res) should fix it — same in theelsebranch below.