astropy / astropy/specutils

Handle uncertainties of 0 in fitting weights

Open
#996 0 comments 0 reactions 0 assignees View on GitHub
bug fitting
Dominant language
Python
Stars
204
Forks
134
Avg merge
12h 55m
Merged PRs (30d)
1

Description

Currently, if given weights="unc" in fitting, specutils naively tries to convert the spectrum's `uncertainty` attribute to `StdDevUncertainty` and then invert those values to use for weights in the model fit. This leads to a failed `np.isfinite` check in astropy model fitting if some/all of the uncertainties are 0. We need to handle these cases more elegantly, and potentially provide a couple arguments to let the users define how they want them handled.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the fitting path for weights="unc", including conversion of the spectrum's uncertainty attribute to StdDevUncertainty and inversion for model-fit weights. Confirm how zero or all-zero uncertainties reach Astropy's np.isfinite check; done means these cases no longer fail, with any user-configurable handling defined by the issue resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.