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
9 changes: 5 additions & 4 deletions config/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
# For example, if `plots: fit: subplot_fit=True``, the ``subplot_fit.png`` subplot file will
# be plotted every time visualization is performed.

# There are two settings which are important for inspecting results via the dataset after a fit is complete which are:
# One setting is important for inspecting results via the dataset after a fit is complete:

# - `fits_dataset`: This outputs `dataset.fits` which the database functionality may use to reperform fits.
# -`fits_adapt_images`, This outputs `adapt_images.fits` which the database functionality may use to reperform fits.

# These can be disabled to save on hard-disk space but will lead to certain database functionality being disabled.
# It can be disabled to save on hard-disk space but will lead to certain database functionality being disabled.

# The dataset itself is always output as `dataset.fits` to the `image` folder of every fit, and is not controlled
# by any setting here.

subplot_format: [png] # Output format of all subplots, can be png, pdf or both (e.g. [png, pdf])
fits_are_zoomed: false # If true, output .fits files are zoomed in on the center of the unmasked region image, saving hard-disk space.

dataset: # Settings for plots of all datasets (e.g. Imaging, Interferometer).
subplot_dataset: true # Plot subplot containing all dataset quantities (e.g. the data, noise-map, etc.)?
fits_dataset: true # Output a .fits file containing the dataset data, noise-map and other quantities?

positions: # Settings for plots with resampling image-positions on (e.g. the image).
image_with_positions: true
Expand Down
1 change: 0 additions & 1 deletion scripts/imaging/config/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ fits_are_zoomed: false

dataset:
subplot_dataset: true
fits_dataset: true

positions:
image_with_positions: true
Expand Down
1 change: 0 additions & 1 deletion scripts/imaging/config_source/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ fits_are_zoomed: false

dataset:
subplot_dataset: false
fits_dataset: false

positions:
image_with_positions: false
Expand Down
25 changes: 9 additions & 16 deletions scripts/imaging/visualization/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@

Uses the parametric source (fastest) for all before-fit outputs.

Calls PlotterImaging.imaging() -> dataset.png, dataset.fits
Calls PlotterImaging.imaging() -> dataset.png
Plotter.image_with_positions() -> image_with_positions.png
Plotter.adapt_images() -> adapt_images.png, adapt_images.fits
"""
Expand All @@ -268,24 +268,17 @@
__Assertions: visualize_before_fit__
"""

# ---- dataset.fits ----
# Source: PlotterImaging.imaging() -> hdu_list_for_output_from with ext_name_list:
# ["mask", "data", "noise_map", "psf", "over_sample_size_lp", "over_sample_size_pixelization"]
# HDU 0 is PrimaryHDU (first value), HDUs 1-5 are ImageHDU.

assert (image_path / "dataset.png").exists(), "dataset.png missing"
print("dataset.png OK")

with astropy_fits.open(image_path / "dataset.fits") as hdul:
assert len(hdul) == 6, f"dataset.fits: expected 6 HDUs, got {len(hdul)}"
assert hdul[0].name == "MASK"
assert hdul[1].name == "DATA"
assert hdul[2].name == "NOISE_MAP"
assert hdul[3].name == "PSF"
assert hdul[4].name == "OVER_SAMPLE_SIZE_LP"
assert hdul[5].name == "OVER_SAMPLE_SIZE_PIXELIZATION"
assert hdul[1].data.ndim == 2, "DATA HDU should be 2D"
print("dataset.fits OK")
# ---- dataset.fits (must NOT be written by the plotter) ----
# Since PyAutoGalaxy#608 `dataset.fits` is written once per search by
# `Analysis.save_attributes` (to the search's `image/` folder) and the plotter
# no longer writes it; the HDU layout is covered by the library
# `save_attributes` tests. Assert the plotter left no copy behind, so a
# reintroduced plotter write (a duplicate) fails here.
assert not (image_path / "dataset.fits").exists(), "plotter must not write dataset.fits"
print("dataset.fits not written by plotter OK")

# ---- image_with_positions.png ----
# Source: Plotter.image_with_positions() -> image_plotter.set_filename("image_with_positions")
Expand Down
1 change: 0 additions & 1 deletion scripts/interferometer/config/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ fits_are_zoomed: false

dataset:
subplot_dataset: true
fits_dataset: true

positions:
image_with_positions: true
Expand Down
1 change: 0 additions & 1 deletion scripts/interferometer/config_source/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ fits_are_zoomed: false

dataset:
subplot_dataset: false
fits_dataset: false

positions:
image_with_positions: false
Expand Down
22 changes: 9 additions & 13 deletions scripts/interferometer/visualization/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@

Uses the parametric source (fastest) for all before-fit outputs.

Calls PlotterInterferometer.interferometer() -> dataset.png, dataset.fits
Calls PlotterInterferometer.interferometer() -> dataset.png
Plotter.image_with_positions() -> image_with_positions.png
Plotter.adapt_images() -> adapt_images.png, adapt_images.fits
"""
Expand All @@ -263,21 +263,17 @@
__Assertions: visualize_before_fit__
"""

# ---- dataset.png / dataset.fits ----
# Source: PlotterInterferometer.interferometer() -> hdu_list_for_output_from with ext_name_list:
# ["mask", "data", "noise_map", "uv_wavelengths"]
# HDU 0 is PrimaryHDU (mask), HDUs 1-3 are ImageHDU.

assert (image_path / "dataset.png").exists(), "dataset.png missing"
print("dataset.png OK")

with astropy_fits.open(image_path / "dataset.fits") as hdul:
assert len(hdul) == 4, f"dataset.fits: expected 4 HDUs, got {len(hdul)}"
assert hdul[0].name == "MASK"
assert hdul[1].name == "DATA"
assert hdul[2].name == "NOISE_MAP"
assert hdul[3].name == "UV_WAVELENGTHS"
print("dataset.fits OK")
# ---- dataset.fits (must NOT be written by the plotter) ----
# Since PyAutoGalaxy#608 `dataset.fits` is written once per search by
# `Analysis.save_attributes` (to the search's `image/` folder) and the plotter
# no longer writes it; the HDU layout is covered by the library
# `save_attributes` tests. Assert the plotter left no copy behind, so a
# reintroduced plotter write (a duplicate) fails here.
assert not (image_path / "dataset.fits").exists(), "plotter must not write dataset.fits"
print("dataset.fits not written by plotter OK")

# ---- image_with_positions.png ----
# Source: Plotter.image_with_positions() -> uses dataset.dirty_image as base
Expand Down
Loading