Skip to content

Commit

Permalink
Fix an indentation glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
Olesja Smirnova committed Feb 8, 2023
1 parent d2d2038 commit 713a560
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions geminidr/interactive/fit/wavecal.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,42 +337,42 @@ def identify_line(self, key, x, y, peak=None):
range(len(self.spectrum.data["wavelengths"])))(x)
new_peaks = np.setdiff1d(self.model.meta["peaks"],
self.model.x, assume_unique=True)
# This will fail if no line was deleted before user attempts to identify a line,
# so do it only if there are new_peaks
if len(new_peaks) > 0:
index = np.argmin(abs(new_peaks - pixel))

# If we've clicked "close" to a real peak (based on viewport size),
# then select that
if len(new_peaks) > 0 and \
(abs(self.model.evaluate(new_peaks[index]) - x) < 0.025 * (x2 - x1)):
peak = new_peaks[index]
print(f"Retrieved peak from list at {peak}")
else:
# TODO: Check this behaves sensibly, and doesn't find
# all tiny bumps
if self.absorption:
pinpoint_data = cwt_ricker(-self.spectrum.data["spectrum"],
[0.42466 * fwidth])[0]
# This will fail if no line was deleted before user attempts to identify a line,
# so do it only if there are new_peaks
if len(new_peaks) > 0:
index = np.argmin(abs(new_peaks - pixel))

# If we've clicked "close" to a real peak (based on viewport size),
# then select that
if len(new_peaks) > 0 and \
(abs(self.model.evaluate(new_peaks[index]) - x) < 0.025 * (x2 - x1)):
peak = new_peaks[index]
print(f"Retrieved peak from list at {peak}")
else:
pinpoint_data = cwt_ricker(self.spectrum.data["spectrum"],
[0.42466 * fwidth])[0]
eps = np.finfo(np.float32).eps # Minimum representative data
pinpoint_data[np.nan_to_num(pinpoint_data) < eps] = eps
try:
peak = pinpoint_peaks(pinpoint_data, peaks=[pixel], mask=None)[0][0]
print(f"Found peak at pixel {peak}")
except IndexError: # no peak
print("Couldn't find a peak")
# TODO: Check this behaves sensibly, and doesn't find
# all tiny bumps
if self.absorption:
pinpoint_data = cwt_ricker(-self.spectrum.data["spectrum"],
[0.42466 * fwidth])[0]
else:
pinpoint_data = cwt_ricker(self.spectrum.data["spectrum"],
[0.42466 * fwidth])[0]
eps = np.finfo(np.float32).eps # Minimum representative data
pinpoint_data[np.nan_to_num(pinpoint_data) < eps] = eps
try:
peak = pinpoint_peaks(pinpoint_data, [pixel], None)[0][0]
print(f"Found peak at pixel {peak}")
except IndexError: # no peak
print("Couldn't find a peak")
return
est_wave = self.model.evaluate(peak)[0]
if not (x1 < est_wave < x2): # peak outside viewport
return
est_wave = self.model.evaluate(peak)[0]
if not (x1 < est_wave < x2): # peak outside viewport
return
else:
est_wave = self.model.evaluate(peak)[0] # evaluate always returns array

# Find all unidentified arc lines that this could be, maintaining
# monotonicity
# Find all unidentified arc lines that this could be, maintaining
# monotonicity
all_lines = self.model.meta["linelist"].wavelengths(
in_vacuo=self.visualizer.ui_params.in_vacuo, units="nm")
lower_limit, upper_limit = get_closest(self.model.y, est_wave)
Expand Down

0 comments on commit 713a560

Please sign in to comment.