Skip to content

Commit

Permalink
Merge branch 'develop' into cf_naming
Browse files Browse the repository at this point in the history
  • Loading branch information
kbwestfall committed Aug 10, 2023
2 parents 68f7d31 + dd9fc7a commit 9c61063
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
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])):
msgs.info('Checking wavelength solution by cross-correlating with all slits')

msgs.info('Cross-correlation iteration #1')
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

0 comments on commit 9c61063

Please sign in to comment.