Improper ell cuts when loading spectrum from file
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
The function pspy_utils.ps_lensed_theory_to_dict loads a plaintext file and returns a dictionary containing the power spectra, but the way in which the user-requested lmax is handled doesn't work properly. Cf. the code:
def ps_lensed_theory_to_dict(filename, output_type, lmax=None, start_at_zero=False):
fields = ["TT", "TE", "TB", "ET", "BT", "EE", "EB", "BE", "BB"]
ps = {}
l, ps["TT"], ps["EE"], ps["BB"], ps["TE"] = np.loadtxt(filename, unpack=True)
ps["ET"] = ps["TE"].copy()
ps["TB"], ps["BT"], ps["EB"], ps["BE"] = np.zeros((4, len(l)))
if lmax is not None:
l = l[:lmax]
scale = l * (l + 1) / (2 * np.pi)
for f in fields:
if lmax is not None:
ps[f] = ps[f][:lmax]
if output_type == "Cl":
ps[f] /= scale
if start_at_zero:
ps[f] = np.append(np.array([0, 0]), ps[f])
if start_at_zero:
l = np.append(np.array([0, 1]), l)
return l, ps
- The lmax cuts are parsed as
l = l[:lmax]andps[f] = ps[f][:lmax], both of which work fine if the array is zero-indexed. However, no check is made to see if the arrays actually start at l = 0. - If the user desires the arrays start at l = 0 instead of l = 2, then two zeros are prepended before the array, but no check is done whether this is needed.
Most other functions in pspy that take lmax as an argument will assume the user wants an array from l = 2 to lmax-1 inclusive, but this function will most likely create arrays from l=2 to lmax+1 inclusive because of the aforementioned design, and more often than not the resulting spectra will create issues when passed on to other functions that expect [2,lmax) arrays.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at pspy_utils.ps_lensed_theory_to_dict and compare its lmax and array-start conventions with the other pspy functions that accept lmax. Trace inputs beginning at l=0 or l=2, including start_at_zero, and verify that the returned multipoles and spectra consistently cover the requested range without unintended prepending or shifting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100