Skip to content

Commit

Permalink
comment out debugging print functions
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-simpson committed Dec 3, 2024
1 parent cc4d98f commit 8a68dd5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions gempy/library/wavecal.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,15 +683,15 @@ def find_solution(init_models, config, peaks=None, peak_weights=None,
fit1d.mask = np.array([], dtype=bool)
initial_model_fit = fit1d

print("MAKING INIT MODELS")
print(model)
print(fit1d.evaluate([0, 1021]))
#print("MAKING INIT MODELS")
#print(model)
#print(fit1d.evaluate([0, 1021]))

best_fit1d = None
# Iterate over start position models most rapidly
for min_lines_per_fit, model, loc_start in cart_product(
min_lines, init_models_1d, (0.5, 0.3, 0.7)):
print("STARTING", model.parameters, loc_start)
#print("STARTING", model.parameters, loc_start)
domain = model.meta["domain"]
len_data = np.diff(domain)[0] # actually len(data)-1
pixel_start = domain[0] + loc_start * len_data
Expand All @@ -718,8 +718,8 @@ def find_solution(init_models, config, peaks=None, peak_weights=None,
matched_peaks = peaks[matched]
matched_arc_lines = arc_lines[matches[matched]]
m_final = fit_it(m_init, matched_peaks, matched_arc_lines)
for p, l in zip(matched_peaks, matched_arc_lines):
print(f"{p:.2f} => {l:.2f}")
#for p, l in zip(matched_peaks, matched_arc_lines):
# print(f"{p:.2f} => {l:.2f}")

# We're close to the correct solution, perform a KDFit
m_init = models.Chebyshev1D(degree=config["order"], domain=domain)
Expand Down Expand Up @@ -765,7 +765,7 @@ def find_solution(init_models, config, peaks=None, peak_weights=None,

# Trial and error suggests this criterion works well
if fit1d.rms < 0.8 / config["order"] * fwidth * abs(dw) and nmatched >= min_matches_required:
print("RETURNING", fit1d.model.parameters)
#print("RETURNING", fit1d.model.parameters)
return fit1d, True

# This seems to be a reasonably ranking for poor models
Expand Down Expand Up @@ -853,7 +853,7 @@ def perform_piecewise_fit(model, peaks, arc_lines, pixel_start, kdsigma,
#narc_lines = i2 - i1
narc_lines = [x not in matches for x in range(i1, i2)].count(True)
c1 = p1 * dw
print(f"Pixel={p0:6.1f} p1={p1:6.1f} c0={c0:9.4f} dw={dw:8.4f} {min_lines_this_fit}")
#print(f"Pixel={p0:6.1f} p1={p1:6.1f} c0={c0:9.4f} dw={dw:8.4f} {min_lines_this_fit}")

if p1 > 0.25 * len_data and order >= 2:
m_init = models.Chebyshev1D(2, c0=c0, c1=c1,
Expand All @@ -864,9 +864,9 @@ def perform_piecewise_fit(model, peaks, arc_lines, pixel_start, kdsigma,
bounds_setter(m_init)
if not first:
m_init.c0.bounds = (c0 - 5 * abs(dw), c0 + 5 * abs(dw))
print("INPUT MODEL")
print(m_init.parameters)
print(m_init.bounds)
#print("INPUT MODEL")
#print(m_init.parameters)
#print(m_init.bounds)
#print(datetime.now() - start)

# Need to set in_weights=None as there aren't many lines so
Expand All @@ -887,7 +887,7 @@ def perform_piecewise_fit(model, peaks, arc_lines, pixel_start, kdsigma,
# automatically removes old (bad) match
matches[i] = m
found_new_matches = True
print(f"Pixel {p} => {arc_lines[m]}")
#print(f"Pixel {p} => {arc_lines[m]}")
try:
p_lo = peaks[matches > -1].min()
except ValueError:
Expand Down

0 comments on commit 8a68dd5

Please sign in to comment.