simonsobs / simonsobs/sotodlib
get_turnaround_flags(scanspeed method) fails for regular simulations
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 19
- Forks
- 23
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 14
Description
get_turnaround_flags(method="scanspeed") can fail with:
ValueError: cannot convert float NaN to integer
packages/sotodlib/tod_ops/flags.py", in
get_turnaround_flags
approx_samps_onescan = int(np.ptp(az) / approx_daz)
ValueError: cannot convert float NaN to integer
Cause: in line 220: approx_daz = np.median(daz[daz>np.percentile(daz, 95)])
https://github.com/simonsobs/sotodlib/blob/f915bfab48483efa7d794c9a139172a5b0977136/sotodlib/tod_ops/flags.py#L220
In simulations with constant scan speed, daz is discrete and often: p95 == max(daz)
So:
- daz > p95 --> empty array
- median --> NaN
daz > p95is too strict for regular simulations with stable scan speed wherep95 == max(daz), leading to an empty selection and NaN; using>=avoids this.
I noted in simulations:
count(daz > p95) = 0
count(daz >= p95) > 0
Fix:
Use: approx_daz = np.median(daz[daz >= np.percentile(daz, 95)])
I checked that this solves the ValueError that often fails for my simulations. If this solution is accepted, I can open a PR.
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
Open sotodlib/tod_ops/flags.py and inspect get_turnaround_flags(method="scanspeed"), especially the approx_daz calculation around line 220. Reproduce the regular-simulation failure, then verify that the calculation no longer produces NaN and the ValueError is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100