Skip to content

Commit

Permalink
estimate slope and intercept for Linear1D
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Dec 21, 2022
1 parent 2ea6dd6 commit 291c32d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ New Features
- Resetting viewer limits (via ``reset_limits`` or the zoom home button) now accounts for all visible
data layers instead of just the reference data. [#1897]

- Linear1D model component now estimates slope and intercept. [#1947]

Cubeviz
^^^^^^^

Expand Down
12 changes: 3 additions & 9 deletions jdaviz/configs/default/plugins/model_fitting/initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,10 @@ def initialize(self, instance, x, y):
instance : `~astropy.modeling.Model`
The initialized model.
"""
slope, intercept = np.polyfit(x.value.flatten(), y.value.flatten(), 1)

# y_range = np.max(y) - np.min(y)
# x_range = x[-1] - x[0]
# slope = y_range / x_range
# y0 = y[0]

y_mean = np.mean(y)

instance.slope.value = 0.0
instance.intercept.value = y_mean.value
instance.slope.value = slope
instance.intercept.value = intercept

return instance

Expand Down

0 comments on commit 291c32d

Please sign in to comment.