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.
This PR fixes a problem in
desispec.preproc.compute_background_between_fiber_blocks
where a row with a completely negative background resulted in the median of an empty array, causing the background model to have NaNs, which then broke things downstream like traceshift fitting.Example of this case occurring:
In current main, this results in NaN for row 3247 from columns 453-836 (spanning two bundles):
in this PR these the bkg is interpolated and subtracted without artifacts:
I think the original code was just because it was written to subtract positive scattered light and wasn't considering the negative case, but I think it's ok to let this absorb negative problems with the bias model too. @julienguy please check this logic for whether there might be other consequences that I'm not realizing.
Side note: this PR is into main because I was working on Perlmutter, but if approved we should also make this change to the daily branch for use on cori.