desihub / fastspecfit

Fast spectral synthesis and emission-line fitting of DESI spectra.
https://fastspecfit.readthedocs.org
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

handle variable pixel size in camera-overlap region #157

Closed moustakas closed 9 months ago

moustakas commented 10 months ago

Fixes #156.

Also adds one more round of fitting if initial line-sigma doesn't change by more than 1 km/s, to help numerical convergence. E.g., consider

fastspec /global/cfs/cdirs/desi/spectro/redux/fuji/healpix/sv3/bright/259/25955/redrock-sv3-bright-25955.fits \
  --targetids 39627782325535150 -o fastspec.fits

with this branch:

Screenshot 2023-10-15 at 7 14 16 PM

vs main:

Screenshot 2023-10-15 at 7 15 54 PM

In this example with main, the initial line-sigma is 121.58 km/s. The Balmer line-width moves to 64 km/s after the initial round of fitting, but the forbidden line-width changes negligibly, to 121.57 km/s and then gets stuck there.

With this branch, we identify the lack of "movement" on line-sigma and therefore multiply the initial value by 0.9 (another magic number, I know). However, that's enough to move things in the right direction, and the Balmer and forbidden line-widths converge on their final, correct values of 26 and 27 km/s, respectively.

I'll need to do more tests to make sure this latter change doesn't make things worse before merging.

github-actions[bot] commented 10 months ago

Pull Request Test Coverage Report for Build 6527290316


Changes Missing Coverage Covered Lines Changed/Added Lines %
py/fastspecfit/emlines.py 19 29 65.52%
<!-- Total: 19 29 65.52% -->
Totals Coverage Status
Change from base Build 6523920591: -0.05%
Covered Lines: 2492
Relevant Lines: 4212

💛 - Coveralls