Skip to content

get_turnaround_flags(scanspeed method) fails for regular simulations #1601

@Ankurdev-astro

Description

@Ankurdev-astro

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)])

approx_daz = np.median(daz[daz>np.percentile(daz, 95)])

In simulations with constant scan speed, daz is discrete and often: p95 == max(daz)

So:

  • daz > p95 --> empty array
  • median --> NaN
  • daz > p95 is too strict for regular simulations with stable scan speed where p95 == 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions