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

Fix for Issue # 1643 #1645

Merged
merged 3 commits into from
Aug 10, 2023
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
4 changes: 2 additions & 2 deletions pypeit/core/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,12 @@ def get_censpec(slit_cen, slitmask, arcimg, gpm=None, box_rad=3.0,
continue
# Check if this slit is masked
if slit_bpm is not None and slit_bpm[islit]:
msgs.info('Ignoring masked slit {}'.format(islit))
msgs.info('Ignoring masked slit {}'.format(islit+1))
# TODO -- Avoid using NaNs
arc_spec[:,islit] = np.nan
continue
if verbose:
msgs.info('Extracting approximate arc spectrum along the center of slit {0}'.format(islit))
msgs.info('Extracting approximate arc spectrum along the center of slit {0}'.format(islit+1))
# Create a mask for the pixels that will contribue to the arc
arcmask = _gpm & (np.absolute(spat[None,:] - slit_cen[:,islit,None]) < box_rad)
# Trimming the image makes this much faster
Expand Down
20 changes: 11 additions & 9 deletions pypeit/core/wavecal/autoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1736,10 +1736,12 @@ def run_brute(self, min_nlines=10):
self._det_weak = {}
self._det_stro = {}
for slit in range(self._nslit):
msgs.info("Working on slit: {}".format(slit))
if slit not in self._ok_mask:
self._all_final_fit[str(slit)] = None
msgs.info('Ignoring masked slit {}'.format(slit+1))
continue
else:
msgs.info("Working on slit: {}".format(slit+1))
# TODO Pass in all the possible params for detect_lines to arc_lines_from_spec, and update the parset
# Detect lines, and decide which tcent to use
sigdetect = wvutils.parse_param(self._par, 'sigdetect', slit)
Expand All @@ -1751,7 +1753,7 @@ def run_brute(self, min_nlines=10):

# Were there enough lines? This mainly deals with junk slits
if self._all_tcent.size < min_nlines:
msgs.warn("Not enough lines to identify in slit {0:d}!".format(slit))
msgs.warn("Not enough lines to identify in slit {0:d}!".format(slit+1))
self._det_weak[str(slit)] = [None,None]
self._det_stro[str(slit)] = [None,None]
# Remove from ok mask
Expand All @@ -1770,9 +1772,10 @@ def run_brute(self, min_nlines=10):
# Print preliminary report
good_fit[slit] = self.report_prelim(slit, best_patt_dict, best_final_fit)

# Now that all slits have been inspected, cross match to generate a
# Now that all slits have been inspected, cross match (if there are bad fit) to generate a
# list of all lines in every slit, and refit all spectra
if self._nslit > 1:
# in self.cross_match() good fits are cross correlate with each other, so we need to have at least 2 good fits
if np.where(good_fit[self._ok_mask])[0].size > 1 and np.any(np.logical_not(good_fit[self._ok_mask])):
rcooke-ast marked this conversation as resolved.
Show resolved Hide resolved
msgs.info('Checking wavelength solution by cross-correlating with all slits')

msgs.info('Cross-correlation iteration #1')
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are several options here, but I think the two information messages should be put above obad_slits = self.cross_match(...) blah. Alternatively, the second info message could be removed and change cntr=1. Otherwise, there appears to be printout that says iteration 1 and then immediately iteration 2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rcooke-ast thank you so much for your comments. They made me realize that the flow here was not completely correct, so I fixed it. Please take a look if you can.
I'm running the Dev Suite right now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good to me!

Expand Down Expand Up @@ -2034,7 +2037,7 @@ def cross_match(self, good_fit, detections):
# to be classified as a bad slit here. Is this the behavior we want?? Maybe we should be more
# conservative and call a bad any slit which results in an outlier here?
good_slits = np.sort(sort_idx[np.unique(slit_ids[gdmsk, :].flatten())])
bad_slits = np.setdiff1d(np.arange(self._nslit), good_slits, assume_unique=True)
bad_slits = np.setdiff1d(np.arange(self._nslit)[self._ok_mask], good_slits, assume_unique=True)
nbad = bad_slits.size
if nbad > 0:
msgs.info('Working on {:d}'.format(nbad) + ' bad slits: {:}'.format(bad_slits + 1))
Expand Down Expand Up @@ -2858,13 +2861,12 @@ def report_final(self):
for slit in range(self._nslit):
# Prepare a message for bad wavelength solutions
badmsg = '---------------------------------------------------' + msgs.newline() +\
'Final report for slit {0:d}/{1:d}:'.format(slit+1, self._nslit) + msgs.newline() +\
' Wavelength calibration not performed!'
'Final report for slit {0:d}/{1:d}:'.format(slit+1, self._nslit) + msgs.newline()
if slit not in self._ok_mask:
msgs.warn(badmsg)
msgs.warn(badmsg + 'Masked slit ignored')
continue
if self._all_patt_dict[str(slit)] is None:
msgs.warn(badmsg)
msgs.warn(badmsg + ' Wavelength calibration not performed!')
continue
st = str(slit)
if self._all_patt_dict[st]['sign'] == +1:
Expand Down