Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Plane Object #256

Merged
merged 51 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4b673b0
plane redshifts now computed more concisely
Jammy2211 Mar 6, 2024
9495d0d
implemented planes more concisely
Jammy2211 Mar 6, 2024
f427774
remove image_plane, source_plane
Jammy2211 Mar 6, 2024
3e91e63
remove all_planes_have_redshifts
Jammy2211 Mar 6, 2024
9c2e3a2
remove plane_with_galaxy
Jammy2211 Mar 6, 2024
690fd72
updated tracer grid list to work on list, need a better unit test
Jammy2211 Mar 6, 2024
3029e2a
docs for traced_grid_2d_list_from
Jammy2211 Mar 7, 2024
8974439
move unit test
Jammy2211 Mar 7, 2024
7f3456d
plane_redshifts_from add to plane_util
Jammy2211 Mar 7, 2024
be8f800
tracer uses util plane_redshifts_from
Jammy2211 Mar 7, 2024
a343f7e
tracer now uses ag.util.plane.planes_from
Jammy2211 Mar 7, 2024
cdf1044
grid_2d_at_redshift_from
Jammy2211 Mar 7, 2024
ce0f931
move image_2d_list_from
Jammy2211 Mar 7, 2024
f64872d
image_2d_from unit tests
Jammy2211 Mar 7, 2024
f69ff44
image_2d methods in tracer now work
Jammy2211 Mar 7, 2024
d15b054
docstrings on image functions
Jammy2211 Mar 7, 2024
22e1a7f
add tests for image_2d_via_input_plane_image_fro and galaxy_image_2d_…
Jammy2211 Mar 7, 2024
01e4f62
test for set_snr_of_snr_light_profiles
Jammy2211 Mar 7, 2024
24d937d
unit test for padded_image_2d_from
Jammy2211 Mar 7, 2024
5ba18ea
add mass profile unit tests
Jammy2211 Mar 7, 2024
6acf481
mass profile unit tests now pass
Jammy2211 Mar 7, 2024
54e33b6
docstrings
Jammy2211 Mar 7, 2024
a681529
has tested and documented
Jammy2211 Mar 7, 2024
e2ae6f8
extract_attribute tested and docuemnted
Jammy2211 Mar 7, 2024
e4a51db
extract_attributes_of_planes documented
Jammy2211 Mar 7, 2024
92dbb9b
extract_attributes_of_galaxies docs
Jammy2211 Mar 7, 2024
f728c9c
extract_profile
Jammy2211 Mar 7, 2024
b6ec402
typing of extract methofds
Jammy2211 Mar 7, 2024
95f89e4
docs
Jammy2211 Mar 8, 2024
85ba956
Merge branch 'main' into feature/plane_remove
Jammy2211 Mar 8, 2024
400779f
fix extract unit tests
Jammy2211 Mar 8, 2024
4e35658
test__sliced_tracer_from
Jammy2211 Mar 8, 2024
67585c5
test__regression__centre_of_profile_in_right_place
Jammy2211 Mar 8, 2024
9737608
decorator tests
Jammy2211 Mar 8, 2024
82c0f5c
test__instance_into_tracer__retains_dictionary_access
Jammy2211 Mar 8, 2024
b38c151
test__output_to_and_load_from_json
Jammy2211 Mar 8, 2024
a5ea512
delete test_dict
Jammy2211 Mar 8, 2024
87d8e5f
test__galaxies_ascending_redshift
Jammy2211 Mar 8, 2024
e2eeb77
test__upper_plane_index_with_light_profile
Jammy2211 Mar 8, 2024
4a58bca
delete test_ray_tracing
Jammy2211 Mar 8, 2024
c0e5850
ray tracing -> tracer
Jammy2211 Mar 8, 2024
f98e7de
move functionality to tracer_util and unit test
Jammy2211 Mar 8, 2024
a76b2e2
fix tracer plots
Jammy2211 Mar 8, 2024
de8a1f9
move plane image from unit test
Jammy2211 Mar 8, 2024
f914a7c
fixed sliced tracer unit test
Jammy2211 Mar 8, 2024
3a9b0bf
fix to inversion
Jammy2211 Mar 8, 2024
5163603
fix test operate
Jammy2211 Mar 8, 2024
7608774
fix fit imaging
Jammy2211 Mar 8, 2024
ae08a84
fix final unit tests
Jammy2211 Mar 8, 2024
e5ef3cd
blck
Jammy2211 Mar 8, 2024
805b21f
black
Jammy2211 Mar 9, 2024
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
4 changes: 2 additions & 2 deletions autolens/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
from autogalaxy.gui.clicker import Clicker
from autogalaxy.gui.scribbler import Scribbler
from autogalaxy.galaxy.galaxy import Galaxy
from autogalaxy.galaxy.galaxies import Galaxies
from autogalaxy.galaxy.redshift import Redshift
from autogalaxy.analysis.clump_model import ClumpModel
from autogalaxy.analysis.clump_model import ClumpModelDisabled

from autogalaxy.quantity.dataset_quantity import DatasetQuantity
from autogalaxy.quantity.dataset_quantity import SettingsQuantity
from autogalaxy.plane.plane import Plane
from autogalaxy.profiles.geometry_profiles import EllProfile
from autogalaxy.profiles import (
point_sources as ps,
Expand All @@ -82,7 +82,7 @@
from . import plot
from . import aggregator as agg
from .lens import subhalo
from .lens.ray_tracing import Tracer
from .lens.tracer import Tracer
from .lens.to_inversion import TracerToInversion
from .analysis.positions import PositionsLHResample
from .analysis.positions import PositionsLHPenalty
Expand Down
2 changes: 1 addition & 1 deletion autolens/aggregator/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import autofit as af

from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions autolens/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
from autolens.analysis.positions import PositionsLHResample
from autolens.analysis.positions import PositionsLHPenalty
from autolens.analysis.visualizer import Visualizer
from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer

from autolens.lens import ray_tracing_util
from autolens.lens import tracer_util

from autolens import exc

Expand Down Expand Up @@ -88,7 +88,7 @@ def tracer_via_instance_from(
# TODO : A Subhalo class that extends the Galaxy class maybe?

if hasattr(instance.galaxies, "subhalo"):
subhalo_centre = ray_tracing_util.grid_2d_at_redshift_from(
subhalo_centre = tracer_util.grid_2d_at_redshift_from(
galaxies=instance.galaxies,
redshift=instance.galaxies.subhalo.redshift,
grid=aa.Grid2DIrregular(values=[instance.galaxies.subhalo.mass.centre]),
Expand Down
2 changes: 1 addition & 1 deletion autolens/analysis/positions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from autogalaxy.analysis.analysis import AnalysisDataset

from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer
from autolens.point.fit_point.max_separation import FitPositionsSourceMaxSeparation

from autolens import exc
Expand Down
4 changes: 2 additions & 2 deletions autolens/analysis/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from autolens.analysis.positions import PositionsLHResample
from autolens.analysis.positions import PositionsLHPenalty
from autolens.point.fit_point.max_separation import FitPositionsSourceMaxSeparation
from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer
from autolens.point.point_solver import PointSolver


Expand Down Expand Up @@ -62,7 +62,7 @@ def source_plane_light_profile_centre(self) -> aa.Grid2DIrregular:
These centres are used by automatic position updating to determine the best-fit lens model's image-plane
multiple-image positions.
"""
centre = self.max_log_likelihood_tracer.source_plane.extract_attribute(
centre = self.max_log_likelihood_tracer.planes[-1].extract_attribute(
cls=ag.LightProfile, attr_name="centre"
)
if centre is not None:
Expand Down
22 changes: 11 additions & 11 deletions autolens/analysis/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from autogalaxy.analysis.visualizer import Visualizer as AgVisualizer

from autolens.lens.ray_tracing import Tracer
from autolens.lens.plot.ray_tracing_plotters import TracerPlotter
from autolens.lens.tracer import Tracer
from autolens.lens.plot.tracer_plotters import TracerPlotter


class Visualizer(AgVisualizer):
Expand All @@ -33,15 +33,15 @@ def visualize_tracer(
"""
Visualizes a `Tracer` object.

Images are output to the `image` folder of the `visualize_path` in a subfolder called `ray_tracing`. When
Images are output to the `image` folder of the `visualize_path` in a subfolder called `tracer`. When
used with a non-linear search the `visualize_path` points to the search's results folder and this function
visualizes the maximum log likelihood `Tracer` inferred by the search so far.

Visualization includes individual images of attributes of the tracer (e.g. its image, convergence, deflection
angles) and a subplot of all these attributes on the same figure.

The images output by the `Visualizer` are customized using the file `config/visualize/plots.ini` under the
[ray_tracing] header.
[tracer] header.

Parameters
----------
Expand All @@ -55,9 +55,9 @@ def visualize_tracer(
"""

def should_plot(name):
return plot_setting(section="ray_tracing", name=name)
return plot_setting(section="tracer", name=name)

mat_plot_2d = self.mat_plot_2d_from(subfolders="ray_tracing")
mat_plot_2d = self.mat_plot_2d_from(subfolders="tracer")

tracer_plotter = TracerPlotter(
tracer=tracer,
Expand All @@ -66,8 +66,8 @@ def should_plot(name):
include_2d=self.include_2d,
)

if should_plot("subplot_plane_images"):
tracer_plotter.subplot_plane_images()
if should_plot("subplot_galaxies_images"):
tracer_plotter.subplot_galaxies_images()

tracer_plotter.figures_2d(
image=should_plot("image"),
Expand All @@ -93,7 +93,7 @@ def should_plot(name):

if not during_analysis and should_plot("all_at_end_png"):
mat_plot_2d = self.mat_plot_2d_from(
subfolders=path.join("ray_tracing", "end"),
subfolders=path.join("tracer", "end"),
)

tracer_plotter = TracerPlotter(
Expand Down Expand Up @@ -126,7 +126,7 @@ def should_plot(name):

if not during_analysis and should_plot("all_at_end_fits"):
mat_plot_2d = self.mat_plot_2d_from(
subfolders=path.join("ray_tracing", "fits"), format="fits"
subfolders=path.join("tracer", "fits"), format="fits"
)

tracer_plotter = TracerPlotter(
Expand Down Expand Up @@ -159,7 +159,7 @@ def visualize_image_with_positions(
The visualization is an image of the strong lens with the positions overlaid.

The images output by the `Visualizer` are customized using the file `config/visualize/plots.ini` under the
[ray_tracing] header.
[tracer] header.

Parameters
----------
Expand Down
14 changes: 7 additions & 7 deletions autolens/config/visualize/plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
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)?
subplot_of_planes: false # Plot subplot of the model-image, subtracted image and other quantities of each plane?
subplot_plane_images: false # Plot subplot of the image of each plane in the model?
subplot_galaxies_images: false # Plot subplot of the image of each plane in the model?
data: false
noise_map: false
signal_to_noise_map: false
Expand All @@ -25,20 +25,20 @@
subtracted_images_of_planes: false # Plot individual plots of each plane's subtracted image?
plane_images_of_planes: false # Plot individual plots of each plane's image (e.g. in the source plane)?
fit_imaging: {} # Settings for plots of fits to imaging datasets (e.g. FitImagingPlotter).
ray_tracing: # Settings for plots of tracers (e.g. TracerPlotter).
subplot_ray_tracing: true # Plot subplot of all quantities in each tracer (e.g. images, convergence)?
tracer: # Settings for plots of tracers (e.g. TracerPlotter).
subplot_tracer: true # Plot subplot of all quantities in each tracer (e.g. images, convergence)?
all_at_end_png: true # Plot all individual plots listed below as .png (even if False)?
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)?
subplot_plane_images: false # Plot subplot of the image of each plane in the tracer?
subplot_galaxies_images: false # Plot subplot of the image of each plane in the tracer?
image: false # Plot image of the tracer (e.g. lens and lensed source in the image-plane)?
source_plane_image: false # Plot image of the tracer's source-plane?
lens_image: false # Plot image of the foreground lens galaxy (log10)?
convergence: false # Plot image of the tracer's convergence (log10)?
potential: false # Plot image of the tracer's potential (log10)?
deflections: false # Plot images of the tracer's y and x deflections?
magnification: false # Plot image of the tracer's magnification?
galaxies: # Settings for plots of galaxies (e.g GalaxyPlotter).
galaxies_1d: # Settings for 1D plots of galaxies (e.g. GalaxiesPlotter).
image: false
convergence: false
potential: false
Expand Down Expand Up @@ -84,8 +84,8 @@
noise_map: false
residual_map: false
normalized_residual_map: false
plane: # Settings for plots of planes (e.g. PlanePlotter).
subplot_plane: true # Plot subplot of all quantities in each plane (e.g. images, convergence)?
galaxies: # Settings for plots of galaxies (e.g. GalaxiesPlotter).
subplot_galaxies: true # Plot subplot of all quantities in each galaxies group (e.g. images, convergence)?
all_at_end_png: true # Plot all individual plots listed below as .png (even if False)?
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)?
Expand Down
2 changes: 1 addition & 1 deletion autolens/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class RayTracingException(af.exc.FitException):
"""
Raises exceptions associated with the `lens/ray_tracing.py` module and `Tracer` class.
Raises exceptions associated with the `lens/tracer.py` module and `Tracer` class.

For example if the multiple image positions do not trace without a threshold of one another, in order to
resample inaccurate mass models during a model-fit.
Expand Down
6 changes: 3 additions & 3 deletions autolens/imaging/fit_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from autogalaxy.abstract_fit import AbstractFitInversion

from autolens.analysis.preloads import Preloads
from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer
from autolens.lens.to_inversion import TracerToInversion

from autolens import exc
Expand Down Expand Up @@ -247,8 +247,8 @@ def model_images_of_planes_list(self) -> List[aa.Array2D]:
for i in range(self.tracer.total_planes)
]

for plane_index, plane in enumerate(self.tracer.planes):
for galaxy in plane.galaxies:
for plane_index, galaxies in enumerate(self.tracer.planes):
for galaxy in galaxies:
model_images_of_planes_list[plane_index] += galaxy_model_image_dict[
galaxy
]
Expand Down
2 changes: 1 addition & 1 deletion autolens/imaging/model/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import autoarray as aa

from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer
from autolens.imaging.fit_imaging import FitImaging
from autolens.analysis.result import ResultDataset
from autolens.analysis.preloads import Preloads
Expand Down
2 changes: 1 addition & 1 deletion autolens/imaging/model/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def visualize_fit_imaging(
profiles).
"""

if plot_setting(section="ray_tracing", name="subplot_ray_tracing"):
if plot_setting(section="tracer", name="subplot_tracer"):

mat_plot_2d = self.mat_plot_2d_from(subfolders="")

Expand Down
2 changes: 1 addition & 1 deletion autolens/imaging/plot/fit_imaging_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from autolens.plot.abstract_plotters import Plotter
from autolens.imaging.fit_imaging import FitImaging
from autolens.lens.plot.ray_tracing_plotters import TracerPlotter
from autolens.lens.plot.tracer_plotters import TracerPlotter


class FitImagingPlotter(Plotter):
Expand Down
2 changes: 1 addition & 1 deletion autolens/imaging/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import autoarray as aa
import autogalaxy as ag

from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer

class SimulatorImaging(aa.SimulatorImaging):

Expand Down
6 changes: 3 additions & 3 deletions autolens/interferometer/fit_interferometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from autogalaxy.abstract_fit import AbstractFitInversion

from autolens.analysis.preloads import Preloads
from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer
from autolens.lens.to_inversion import TracerToInversion


Expand Down Expand Up @@ -216,8 +216,8 @@ def model_visibilities_of_planes_list(self) -> List[aa.Visibilities]:
for i in range(self.tracer.total_planes)
]

for plane_index, plane in enumerate(self.tracer.planes):
for galaxy in plane.galaxies:
for plane_index, galaxies in enumerate(self.tracer.planes):
for galaxy in galaxies:
model_visibilities_of_planes_list[
plane_index
] += galaxy_model_visibilities_dict[galaxy]
Expand Down
2 changes: 1 addition & 1 deletion autolens/interferometer/model/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from autolens.analysis.preloads import Preloads
from autolens.analysis.positions import PositionsLHResample
from autolens.analysis.positions import PositionsLHPenalty
from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer
from autolens.interferometer.model.result import ResultInterferometer
from autolens.interferometer.model.visualizer import VisualizerInterferometer
from autolens.interferometer.fit_interferometer import FitInterferometer
Expand Down
2 changes: 1 addition & 1 deletion autolens/interferometer/model/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import autogalaxy as ag

from autogalaxy.analysis.adapt_images import AdaptImages
from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer
from autolens.interferometer.fit_interferometer import FitInterferometer
from autolens.analysis.result import ResultDataset

Expand Down
4 changes: 2 additions & 2 deletions autolens/interferometer/plot/fit_interferometer_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from autoarray.fit.plot.fit_interferometer_plotters import FitInterferometerPlotterMeta

from autolens.interferometer.fit_interferometer import FitInterferometer
from autolens.lens.ray_tracing import Tracer
from autolens.lens.plot.ray_tracing_plotters import TracerPlotter
from autolens.lens.tracer import Tracer
from autolens.lens.plot.tracer_plotters import TracerPlotter
from autolens.plot.abstract_plotters import Plotter


Expand Down
2 changes: 1 addition & 1 deletion autolens/interferometer/simulator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import autoarray as aa

from autolens.lens.ray_tracing import Tracer
from autolens.lens.tracer import Tracer


class SimulatorInterferometer(aa.SimulatorInterferometer):
Expand Down
Loading
Loading