Skip to content

Commit

Permalink
Rework of log output for tracePinholeApertures(), minor formatting
Browse files Browse the repository at this point in the history
Docstring additions
  • Loading branch information
DBerke committed Apr 12, 2024
1 parent cc115b6 commit aeb863d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
21 changes: 14 additions & 7 deletions geminidr/core/primitives_spect.py
Original file line number Diff line number Diff line change
Expand Up @@ -4094,6 +4094,7 @@ def resampleToCommonFrame(self, adinputs=None, **params):
origin=origin_dict[iext],
output_shape=output_shape_dict[iext],
threshold=dq_threshold)

if iext == 0:
ad_out = new_ext
else:
Expand Down Expand Up @@ -4697,13 +4698,15 @@ def tracePinholeApertures(self, adinputs=None, **params):
data, widths=widths, mask=mask & DQ.not_signal,
variance=variance, min_snr=min_snr,
reject_bad=False)
log.fullinfo(f"Found {len(initial_peaks)} peaks")

in_traces, ref_traces = [], []
log.fullinfo(f"Starting trace at {direction} {start}")
log.debug(f"tracing from {min_trace_pos} to "
f"{max_trace_pos}")
for peak in initial_peaks[min_trace_pos:max_trace_pos]:
log.stdinfo(f"Found {len(initial_peaks)} peaks in extension "
f"{ext.id}, tracing "
f"numbers {min_trace_pos or 0} to "
f"{max_trace_pos or len(initial_peaks)} "
f"starting at {direction} {start}")

for j, peak in enumerate(initial_peaks[min_trace_pos:max_trace_pos]):
ref_coords, in_coords = tracing.trace_lines(
# Only need a single `start` value for all lines.
ext, axis=dispaxis,
Expand All @@ -4717,6 +4720,11 @@ def tracePinholeApertures(self, adinputs=None, **params):
in_traces.append(in_coords)
ref_traces.append(ref_coords)

min_value = in_coords[1 - dispaxis].min()
max_value = in_coords[1 - dispaxis].max()
log.fullinfo(f" Peak {j + (min_trace_pos or 0)} traced from "
f"{min_value} to {max_value}.")

tot_in_coords = np.concatenate(in_traces, axis=1)
tot_ref_coords = np.concatenate(ref_traces, axis=1)

Expand All @@ -4725,8 +4733,6 @@ def tracePinholeApertures(self, adinputs=None, **params):
x_degree=x_ord, y_degree=y_ord,
x_domain=[0, ext.shape[1]-1],
y_domain=[0, ext.shape[0]-1])
log.stdinfo("Creating distortion model for slit "
f"rectification for slit {i}")
# The `fixed_linear` parameter is False because we should
# have both edges for each slit.
model, m_final_2d, m_inverse_2d = create_distortion_model(
Expand All @@ -4742,6 +4748,7 @@ def tracePinholeApertures(self, adinputs=None, **params):
# Timestamp and update the filename
gt.mark_history(ad, primname=self.myself(), keyword=timestamp_key)
ad.update_filename(suffix=sfx, strip=True)

return adinputs

def write1DSpectra(self, adinputs=None, **params):
Expand Down
3 changes: 2 additions & 1 deletion gempy/gemini/gemini_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,8 @@ def cut_to_match_auxiliary_data(adinput=None, aux=None, aux_type=None,
aux_b_transform = auxext.wcs.get_transform('world', 'rectified')

# In the first or last two submodels of the forward and backward
# (respectively) transforms will be one or more Shift models.
# (respectively) transforms will be one or more Shift models
# representing the amount of rows or columns that have been cut.
# Set these Shifts to 0. It's not part of the WAVE & SKY paradigm
# so they will be dropped later anyway, but it's good to be
# consistent at each step.
Expand Down

0 comments on commit aeb863d

Please sign in to comment.