Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Nov 25, 2024
2 parents 3f20e58 + 85c8ca8 commit d850b27
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 44 deletions.
2 changes: 1 addition & 1 deletion autogalaxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@

conf.instance.register(__file__)

__version__ = "2024.11.6.1"
__version__ = "2024.11.13.2"
23 changes: 12 additions & 11 deletions autogalaxy/aggregator/dataset_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ def _dataset_model_from(
except AttributeError:
dataset_model = None

if len(fit.children) > 0:
logger.info(
"""
Using database for a fit with multiple summed Analysis objects.
DatasetModel objects do not fully support this yet (e.g. variables across Analysis objects may not be correct)
so proceed with caution!
"""
)

return [dataset_model] * len(fit.children)
if fit.children is not None:
if len(fit.children) > 0:
logger.info(
"""
Using database for a fit with multiple summed Analysis objects.
DatasetModel objects do not fully support this yet (e.g. variables across Analysis objects may not be correct)
so proceed with caution!
"""
)

return [dataset_model] * len(fit.children)

return [dataset_model]
6 changes: 3 additions & 3 deletions autogalaxy/analysis/plotter_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def should_plot(name):
reconstructed_image=should_plot("reconstructed_image"),
reconstruction=should_plot("reconstruction"),
mesh_pixels_per_image_pixels=should_plot("mesh_pixels_per_image_pixels"),
errors=should_plot("errors"),
reconstruction_noise_map=should_plot("reconstruction_noise_map"),
regularization_weights=should_plot("regularization_weights"),
)

Expand Down Expand Up @@ -347,7 +347,7 @@ def should_plot(name):
pixelization_index=0,
reconstructed_image=True,
reconstruction=True,
errors=True,
reconstruction_noise_map=True,
regularization_weights=True,
)

Expand All @@ -366,7 +366,7 @@ def should_plot(name):
pixelization_index=0,
reconstructed_image=True,
reconstruction=True,
errors=True,
reconstruction_noise_map=True,
regularization_weights=True,
interpolate_to_uniform=True,
)
Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/config/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ inversion: # Settings for plots of inversions (e
all_at_end_fits: true # Plot all individual plots listed below as .fits (even if False)?
all_at_end_pdf: false # Plot all individual plots listed below as publication-quality .pdf (even if False)?
data_subtracted: false # Plot individual plots of the data with the other inversion linear objects subtracted?
errors: false # Plot image of the errors of every mesh-pixel reconstructed value?
sub_pixels_per_image_pixels: false # Plot the number of sub pixels per masked data pixels?
mesh_pixels_per_image_pixels: false # Plot the number of image-plane mesh pixels per masked data pixels?
reconstruction_noise_map: false # Plot image of the noise of every mesh-pixel reconstructed value?
sub_pixels_per_image_pixels: false # Plot the number of sub pixels per masked data pixels?
mesh_pixels_per_image_pixels: false # Plot the number of image-plane mesh pixels per masked data pixels?
reconstructed_image: false # Plot image of the reconstructed data (e.g. in the image-plane)?
reconstruction: false # Plot the reconstructed inversion (e.g. the pixelization's mesh in the source-plane)?
regularization_weights: false # Plot the effective regularization weight of every inversion mesh pixel?
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/gui/clicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Clicker:
def __init__(self, image, pixel_scales, search_box_size, in_pixels : bool = False):
def __init__(self, image, pixel_scales, search_box_size, in_pixels: bool = False):
self.image = image

pixel_scales = aa.util.geometry.convert_pixel_scales_2d(
Expand Down
16 changes: 7 additions & 9 deletions autogalaxy/gui/scribbler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.colors as colors

from skimage.transform import rescale


class Scribbler:
Expand All @@ -16,6 +13,7 @@ def __init__(
cmap=None,
brush_width=0.05,
backend="TkAgg",
mask_overlay=None
):
"""
Expand All @@ -33,18 +31,18 @@ def __init__(
# create initial plot
self.figure = plt.figure()
self.ax = self.figure.add_subplot(111)

if cmap is None:
plt.imshow(image, interpolation="none")
else:
norm = cmap.norm_from(array=image)
plt.imshow(image, cmap=cmap.config_dict["cmap"], norm=norm)

if cmap.config_dict["cmap"] == "default":
from matplotlib.colors import LinearSegmentedColormap
from autoarray.plot.wrap.segmentdata import segmentdata

cmap = LinearSegmentedColormap(name="default", segmentdata=segmentdata)
if mask_overlay is not None:
grid = mask_overlay.derive_grid.edge
grid = mask_overlay.geometry.grid_pixel_centres_2d_from(grid_scaled_2d=grid)
plt.scatter(y=grid[:, 0], x=grid[:, 1], c="k", marker="x", s=10)

plt.imshow(image, cmap=cmap, norm=norm)
plt.axis([0, image.shape[1], image.shape[0], 0])
plt.axis("off")
# if title:
Expand Down
20 changes: 15 additions & 5 deletions autogalaxy/imaging/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,29 @@ def via_galaxies_from(
self, galaxies: List[Galaxy], grid: aa.type.Grid2DLike
) -> aa.Imaging:
"""
Simulate an `Imaging` dataset from an input plane and grid.
Simulate an `Imaging` dataset from an input list of `Galaxy` objects and a 2D grid of (y,x) coordinates.
The planbe is used to generate the image of the galaxies which is simulated.
The light profiles of each galaxy are used to generate the image of the galaxies which is simulated.
The steps of the `SimulatorImaging` simulation process (e.g. PSF convolution, noise addition) are
described in the `SimulatorImaging` `__init__` method docstring.
described in the `SimulatorImaging` `__init__` method docstring, found in the PyAutoArray project.
If one of more galaxy light profiles are a `LightProfileSNR` object, the `intensity` of the light profile is
automatically set such that the signal-to-noise ratio of the light profile is equal to its input
`signal_to_noise_ratio` value.
For example, if a `LightProfileSNR` object has a `signal_to_noise_ratio` of 5.0, the intensity of the light
profile is set such that the peak surface brightness of the profile is 5.0 times the background noise level of
the image.
Parameters
----------
galaxies
The galaxies whose light is simulated.
The galaxies whose light profiles are evaluated using the input 2D grid of (y,x) coordinates in order to
generate the image of the galaxies which is then simulated.
grid
The image-plane grid which the image of the strong lens is generated on.
The 2D grid of (y,x) coordinates which the light profiles of the galaxies are evaluated using in order
to generate the image of the galaxies.
"""

galaxies = Galaxies(galaxies=galaxies)
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/interferometer/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def via_galaxies_from(self, galaxies: List[Galaxy], grid: aa.type.Grid2DLike):
An arrays representing the effective exposure time of each pixel.
psf: PSF
An arrays describing the PSF the simulated image is blurred with.
add_poisson_noise: Bool
add_poisson_noise_to_data: Bool
If `True` poisson noise_maps is simulated and added to the image, based on the total counts in each image
pixel
noise_seed: int
Expand Down
1 change: 1 addition & 0 deletions autogalaxy/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
VectorYXQuiver,
PatchOverlay,
InterpolatedReconstruction,
DelaunayDrawer,
VoronoiDrawer,
OriginScatter,
MaskScatter,
Expand Down
4 changes: 4 additions & 0 deletions autogalaxy/plot/mat_plot/two_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
vector_yx_quiver: Optional[aplt.VectorYXQuiver] = None,
patch_overlay: Optional[aplt.PatchOverlay] = None,
interpolated_reconstruction: Optional[aplt.InterpolatedReconstruction] = None,
delaunay_drawer: Optional[aplt.DelaunayDrawer] = None,
voronoi_drawer: Optional[aplt.VoronoiDrawer] = None,
origin_scatter: Optional[aplt.OriginScatter] = None,
mask_scatter: Optional[aplt.MaskScatter] = None,
Expand Down Expand Up @@ -120,6 +121,8 @@ def __init__(
voronoi_drawer
Interpolations the reconstruction of a `Mapper` object from its irregular grid (e.g. Delaunay, Voronoi) to a
uniform 2D array and plots it via `plt.imshow()`.
delaunay_drawer
Draws a colored Delaunay mesh of pixels using `plt.tripcolor`.
voronoi_drawer
Draws a colored Voronoi mesh of pixels using `plt.fill`.
origin_scatter
Expand Down Expand Up @@ -203,6 +206,7 @@ def __init__(
contour=contour,
grid_plot=grid_plot,
interpolated_reconstruction=interpolated_reconstruction,
delaunay_drawer=delaunay_drawer,
voronoi_drawer=voronoi_drawer,
use_log10=use_log10,
)
4 changes: 2 additions & 2 deletions autogalaxy/profiles/mass/total/power_law_multipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def deflections_yx_2d_from(
* self.einstein_radius ** (self.slope - 1.0)
* radial_grid ** (2.0 - self.slope)
)
/ (self.m**2.0 - (3.0 - self.slope)**2.0)
/ (self.m**2.0 - (3.0 - self.slope) ** 2.0)
* self.k_m
* np.cos(self.m * (polar_angle_grid - self.angle_m))
)
Expand All @@ -182,7 +182,7 @@ def deflections_yx_2d_from(
* self.einstein_radius ** (self.slope - 1.0)
* radial_grid ** (2.0 - self.slope)
)
/ (self.m**2.0 - (3.0 - self.slope)**2.0)
/ (self.m**2.0 - (3.0 - self.slope) ** 2.0)
* self.k_m
* np.sin(self.m * (polar_angle_grid - self.angle_m))
)
Expand Down
2 changes: 1 addition & 1 deletion docs/overview/overview_1_start_here.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ object.
exposure_time=300.0,
background_sky_level=1.0,
psf=ag.Kernel2D.from_gaussian(shape_native=(11, 11), sigma=0.1, pixel_scales=0.05),
add_poisson_noise=True,
add_poisson_noise_to_data=True,
)
Expand Down
5 changes: 4 additions & 1 deletion test_autogalaxy/analysis/test_plotter_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def test__inversion(

assert path.join(plot_path, "reconstructed_image.png") in plot_patch.paths
assert path.join(plot_path, "reconstruction.png") in plot_patch.paths
assert path.join(plot_path, "inversion", "errors.png") not in plot_patch.paths
assert (
path.join(plot_path, "inversion", "reconstruction_noise_map.png")
not in plot_patch.paths
)
assert path.join(plot_path, "regularization_weights.png") not in plot_patch.paths


Expand Down
2 changes: 1 addition & 1 deletion test_autogalaxy/config/visualize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ plots:
inversion:
all_at_end_png: false
chi_squared_map: true
errors: false
reconstruction_noise_map: false
interpolated_errors: true
interpolated_reconstruction: true
normalized_residual_map: false
Expand Down
4 changes: 2 additions & 2 deletions test_autogalaxy/imaging/test_simulate_and_fit_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test__perfect_fit__chi_squared_0():
)

simulator = ag.SimulatorImaging(
exposure_time=300.0, psf=psf, add_poisson_noise=False
exposure_time=300.0, psf=psf, add_poisson_noise_to_data=False
)

dataset = simulator.via_galaxies_from(galaxies=[galaxy_0, galaxy_1], grid=grid)
Expand Down Expand Up @@ -146,7 +146,7 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standa
)

simulator = ag.SimulatorImaging(
exposure_time=300.0, psf=psf, add_poisson_noise=False
exposure_time=300.0, psf=psf, add_poisson_noise_to_data=False
)

dataset = simulator.via_galaxies_from(galaxies=[galaxy], grid=grid)
Expand Down
5 changes: 3 additions & 2 deletions test_autogalaxy/imaging/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def test__simulator__via_galaxies_from():
psf=psf,
exposure_time=10000.0,
background_sky_level=100.0,
add_poisson_noise=False,
add_poisson_noise_to_data=False,
include_poisson_noise_in_noise_map=False,
)

dataset = simulator.via_galaxies_from(galaxies=[galaxy_0, galaxy_1], grid=grid)
Expand Down Expand Up @@ -130,7 +131,7 @@ def test__simulator__simulate_imaging_from_galaxy__source_galaxy__compare_to_ima
psf=psf,
exposure_time=10000.0,
background_sky_level=100.0,
add_poisson_noise=True,
add_poisson_noise_to_data=True,
noise_seed=1,
)

Expand Down
2 changes: 1 addition & 1 deletion test_autogalaxy/plot/mat_wrap/config/visualize/plots.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ all_at_end_png=False
subplot_inversion=True
reconstructed_image=False
reconstruction=False
errors=False
reconstruction_noise_map=False
residual_map=False
normalized_residual_map=False
chi_squared_map=False
Expand Down

0 comments on commit d850b27

Please sign in to comment.