Skip to content
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
19 changes: 2 additions & 17 deletions scripts/chapter_3_pixelizations/tutorial_3_fit_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,11 @@ def fit_source(dataset, coefficient):

values = np.array([trial_evidences[float(c)] for c in coefficient_grid])

if not np.all(np.isfinite(values)):
raise ValueError(f"{label}: inspect non-finite evidence values.")

best_index = int(np.argmax(values))
if best_index in (0, len(coefficient_grid) - 1):
raise ValueError(f"{label}: extend the coefficient range before continuing.")

refined_grid = np.geomspace(
coefficient_grid[best_index - 1],
coefficient_grid[best_index + 1],
coefficient_grid[max(best_index - 1, 0)],
coefficient_grid[min(best_index + 1, len(coefficient_grid) - 1)],
15,
)

Expand All @@ -289,9 +284,6 @@ def fit_source(dataset, coefficient):
if evidence > best_evidence:
best_fit, best_evidence = current_fit, evidence

if not np.all(np.isfinite(list(trial_evidences.values()))):
raise ValueError(f"{label}: inspect non-finite evidence values.")

preferred_coefficient = max(trial_evidences, key=trial_evidences.get)
preferred_coefficients[label] = preferred_coefficient
preferred_fits[label] = best_fit
Expand Down Expand Up @@ -658,11 +650,4 @@ def fit_source(dataset, coefficient):
Tutorial 5 then returns to search chaining and combines an MGE with a pixelization. That alternative can let analytic profiles describe the smooth central light while a mesh supplies additional spatial freedom.

**🤖 Ask AI:** How would you distinguish insufficient galaxy-mesh resolution from over-smoothing when compact-galaxy residuals remain at the evidence-preferred coefficient?

__Env__

Keep full-size datasets during automated runs so compact galaxies remain resolved
and the evidence scans test the same examples as the lesson.

ENV: full_datasets
"""
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,8 @@ def fit_delaunay_overlay(coefficient):
overlay_fit = current_fit

overlay_evidences = np.asarray(overlay_evidences)
if not np.all(np.isfinite(overlay_evidences)):
raise ValueError("Inspect non-finite evidence values before continuing.")

best_index = int(np.argmax(overlay_evidences))
if best_index in (0, len(overlay_coefficients) - 1):
raise ValueError("Extend the coefficient range to bracket the overlay peak.")

overlay_coefficient = float(overlay_coefficients[best_index])

Expand Down Expand Up @@ -646,12 +642,8 @@ def fit_delaunay_hilbert(coefficient):
hilbert_fit = current_fit

hilbert_evidences = np.asarray(hilbert_evidences)
if not np.all(np.isfinite(hilbert_evidences)):
raise ValueError("Inspect non-finite evidence values before continuing.")

best_index = int(np.argmax(hilbert_evidences))
if best_index in (0, len(overlay_coefficients) - 1):
raise ValueError("Extend the coefficient range to bracket the hilbert peak.")

hilbert_coefficient = float(overlay_coefficients[best_index])

Expand Down Expand Up @@ -789,12 +781,8 @@ def fit_hilbert_with_regularization(regularization):
split_fit = current_fit

split_evidences = np.asarray(split_evidences)
if not np.all(np.isfinite(split_evidences)):
raise ValueError("Inspect non-finite evidence values before continuing.")

best_index = int(np.argmax(split_evidences))
if best_index in (0, len(overlay_coefficients) - 1):
raise ValueError("Extend the coefficient range to bracket the split peak.")

split_coefficient = float(overlay_coefficients[best_index])

Expand Down Expand Up @@ -968,11 +956,6 @@ def fit_hilbert_with_regularization(regularization):
)
log_evidence = float(current_fit.log_evidence)

if not np.isfinite(log_evidence):
raise ValueError(
"Inspect the non-finite adaptive evidence before continuing."
)

parameters = (
float(inner_coefficient),
float(outer_coefficient),
Expand Down Expand Up @@ -1087,10 +1070,4 @@ def fit_hilbert_with_regularization(regularization):

**🤖 Ask AI:** How do brightness-weighted mesh placement and adaptive regularization address different limitations,
and why can neither recover information erased by telescope blurring?

__Env__

Keep full-size datasets so the compact-galaxy experiment retains its resolved structure and evidence peaks.

ENV: full_datasets
"""
Loading