Some updates to specutils.analysis functions
- Updated
_normalize_for_template_matching(): changednp.sumtonp.nansumon lines 60 and 61. Due to resampling of the spectra (resampling methods fill arrays with NaNs to have points beyond the edges set to NaN), all redshifts compared intemplate_redshift()were producing achi2of NaN (even for a test case using the correct redshift). - Updated
_chi_square_for_templates(): changednp.sumtonp.nansumon line 137 for the same reason as above. - Updated
template_redshift(): Addedfinal_spectrum = redshifted_spectrumon line 292 and addedfinal_spectrumto return instead ofredshifted spectrum. This is important specifically for if you feed a list of redshifts - the function was not returning the spectrum redshifted by the best-fitting redshift (i.e. the one corresponding tochi2_min), but rather was returning the spectrum redshifted by the last redshift in the list (not necessarily the best-fitting one).
Thanks @chloe-mt-cheng! I'll take a look at updating the failing tests, but these seem like sensible changes.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
08e77ce) 70.78% compared to head (34ad35d) 70.80%.
Additional details and impacted files
@@ Coverage Diff @@
## main #937 +/- ##
==========================================
+ Coverage 70.78% 70.80% +0.02%
==========================================
Files 61 61
Lines 4213 4216 +3
==========================================
+ Hits 2982 2985 +3
Misses 1231 1231
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@chloe-mt-cheng Sorry that I dropped the ball on this for so long! I updated the tests after confirming that the differences make sense, and made one more change to ensure that the same number of bins get summed for the numerator and denominator in the nansums.