Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spectral extraction: improved logic for initial position of "Manual" background trace #1738

Merged
merged 2 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Specviz
Specviz2d
^^^^^^^^^

- Improved logic for initial guess for position of "Manual" background trace in spectral extraction
plugin. [#1738]

API Changes
-----------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,20 +318,24 @@ def _trace_dataset_selected(self, msg=None):
default_bg_width = int(np.ceil(width / 10))
default_width = min(default_bg_width, distance_from_edge * 2)

# sign for one-sided and single trace-pixel depending on whether the brightest pixel is
# above or below the middle of the image
if default_bg_width * 2 >= distance_from_edge:
sign = 1 if (brightest_pixel < width / 2) else -1
default_bg_separation = sign * default_bg_width * 2
Comment on lines +323 to +325
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lines will be covered by #1739 (coverage was lost when skipping the remote test in #1736)

else:
default_bg_separation = default_bg_width * 2

if self.trace_pixel == 0:
self.trace_pixel = brightest_pixel
if self.trace_window == 0:
self.trace_window = default_width
if self.bg_trace_pixel == 0:
self.bg_trace_pixel = brightest_pixel
self.bg_trace_pixel = brightest_pixel + default_bg_separation
if self.bg_separation == 0:
if default_bg_width * 2 >= distance_from_edge:
self.bg_type_selected = 'OneSided'
# we want positive separation if brightest_pixel near bottom
sign = 1 if (brightest_pixel < width / 2) else -1
self.bg_separation = sign * default_bg_width * 2
else:
self.bg_separation = default_bg_width * 2
self.bg_separation = default_bg_separation
if self.bg_width == 0:
self.bg_width = default_bg_width
if self.ext_width == 0:
Expand Down