astropy / specreduce

Tools for the reduction of spectroscopic observations from Optical and NIR instruments
https://specreduce.readthedocs.io
61 stars 38 forks source link

fix input for background.traces, raise error in FlatTrace for negative trace #211

Closed cshanahan1 closed 8 months ago

cshanahan1 commented 8 months ago

This PR cleans up a few things in Background.

  1. Added a condition to FlatTrace that trace position must be negative. This check was originally done in Background when a FlatTrace was being used, but should generally be done. Before, if trace_pos was negative, a fully masked trace was being returned.

  2. Previously, Background produced an unrelated error if 'traces' was None. Now, if no trace/number is passed in, a FlatTrace in the middle of the image will be used.

  3. There was some other inconsistencies with inputs - the docstring said 'traces' must be a list, but the logic in the code implied that it could be a Trace object not in a list. Also, a FlatTrace object can be defined with either a float or an int, where previously 'Background' allowed only integer inputs. I fixed this to allow either single trace/int/float or list trace/int/float inputs. The only condition is that lists must all be of the same type (either numeric or Trace). I also added some checks for input to make sure something valid is passed in for traces (either None, int/float or list of int/float to define FlatTraces, or a Trace object, or a list of Trace objects). I also added tests for all of these allowed inputs.

codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.16%. Comparing base (85e1b20) to head (ddc7aab).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #211 +/- ## ========================================== + Coverage 81.94% 82.16% +0.22% ========================================== Files 10 10 Lines 1008 1015 +7 ========================================== + Hits 826 834 +8 + Misses 182 181 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

cshanahan1 commented 8 months ago

fixed the failing docstring