Skip to content
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

Only select cte if have 120s flat in proc_night #2254

Merged
merged 2 commits into from
May 15, 2024
Merged

Conversation

akremin
Copy link
Member

@akremin akremin commented May 15, 2024

This fixes a bug introduced by me in PR #2221 that is causing crashes in determine_calibrations_to_proc() when no valid flats are available on a night.

The fix is simple, we now check that there is at least one valid 120s flat before trying to add the cte flats. Given that we need a 120s flat to do the cte correction, this is a reasonable thing to do.

The traceback was the following:

Traceback (most recent call last):
  File "/global/common/software/desi/perlmutter/desiconda/20240425-2.2.0/code/desispec/0.63.0/bin/desi_proc_night", line 137, in <module>
    proc_night(**args.__dict__)
  File "/global/common/software/desi/perlmutter/desiconda/20240425-2.2.0/code/desispec/0.63.0/lib/python3.10/site-packages/desispec/scripts/proc_night.py", line 429, in proc_night
    cal_etable = determine_calibrations_to_proc(etable,
  File "/global/common/software/desi/perlmutter/desiconda/20240425-2.2.0/code/desispec/0.63.0/lib/python3.10/site-packages/desispec/workflow/calibration_selection.py", line 92, in determine_calibrations_to_proc
    lastflattime = np.max(best_arcflat_set['MJD-OBS'][best_arcflat_set['OBSTYPE']=='flat'])
  File "<__array_function__ internals>", line 180, in amax
  File "/global/common/software/desi/perlmutter/desiconda/20240425-2.2.0/conda/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 2791, in amax
    return _wrapreduction(a, np.maximum, 'max', axis, None, out,
  File "/global/common/software/desi/perlmutter/desiconda/20240425-2.2.0/conda/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 84, in _wrapreduction
    return reduction(axis=axis, out=out, **passkwargs)
  File "/global/common/software/desi/perlmutter/desiconda/20240425-2.2.0/conda/lib/python3.10/site-packages/numpy/core/_methods.py", line 40, in _amax
    return umr_maximum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation maximum which has no identity

@akremin akremin requested a review from sbailey May 15, 2024 23:06
@akremin
Copy link
Member Author

akremin commented May 15, 2024

I also fixed a typo in the initialization of z_submit_types in desi_proc_night that has never been an issue because it only occurs when it is run as a python function rather than as a bash script via argparse.

@sbailey
Copy link
Contributor

sbailey commented May 15, 2024

Looks good; thanks for including unit test.

@sbailey sbailey merged commit b8b9f59 into main May 15, 2024
26 checks passed
@sbailey sbailey deleted the cteselect_bugfix branch May 15, 2024 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants