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 1 commit
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,17 +318,19 @@ 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
sign = 1 if (brightest_pixel < width / 2) else -1

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 + sign * default_bg_width * 2
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
Expand Down