Skip to content

Commit fd1482c

Browse files
author
NiekWielders
committed
solved merging conflict cnfw.py
2 parents d665f7a + df482ce commit fd1482c

48 files changed

Lines changed: 255 additions & 359 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

autogalaxy/__init__.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,17 @@
1010
from autoarray.dataset.imaging.dataset import Imaging # noqa
1111
from autoarray.dataset.interferometer.dataset import Interferometer # noqa
1212
from autoarray.dataset.dataset_model import DatasetModel
13-
from autoarray.inversion.pixelization import mesh # noqa
13+
from autoarray.inversion.mesh import mesh # noqa
1414
from autoarray.inversion import regularization as reg # noqa
15-
from autoarray.inversion.pixelization import image_mesh
16-
from autoarray.inversion.pixelization.mappers.abstract import AbstractMapper # noqa
17-
from autoarray.inversion.inversion.settings import SettingsInversion # noqa
15+
from autoarray.inversion.mesh import image_mesh
16+
from autoarray.inversion.mappers.abstract import Mapper # noqa
17+
from autoarray.settings import Settings # noqa
1818
from autoarray.inversion.inversion.factory import inversion_from as Inversion # noqa
19-
from autoarray.inversion.pixelization.image_mesh.abstract import AbstractImageMesh
20-
from autoarray.inversion.pixelization.mesh.abstract import AbstractMesh
19+
from autoarray.inversion.mesh.image_mesh.abstract import AbstractImageMesh
20+
from autoarray.inversion.mesh.mesh.abstract import AbstractMesh
2121
from autoarray.inversion.regularization.abstract import AbstractRegularization
22-
from autoarray.inversion.pixelization.pixelization import Pixelization # noqa
23-
from autoarray.inversion.pixelization.mappers.abstract import AbstractMapper
24-
from autoarray.inversion.pixelization.mappers.mapper_grids import MapperGrids # noqa
25-
from autoarray.inversion.pixelization.mappers.factory import (
26-
mapper_from as Mapper,
27-
) # noqa
28-
from autoarray.inversion.pixelization.border_relocator import BorderRelocator
29-
from autoarray.preloads import Preloads
30-
from autoarray.preloads import mapper_indices_from
22+
from autoarray.inversion.pixelization import Pixelization # noqa
23+
from autoarray.inversion.mesh.border_relocator import BorderRelocator
3124
from autoarray.mask.mask_1d import Mask1D # noqa
3225
from autoarray.mask.mask_2d import Mask2D # noqa
3326
from autoarray.mask.derive.zoom_2d import Zoom2D
@@ -43,18 +36,22 @@
4336
from autoarray.structures.grids.uniform_2d import Grid2D # noqa
4437
from autoarray.structures.grids.irregular_2d import Grid2DIrregular # noqa
4538
from autoarray.operators.over_sampling.over_sampler import OverSampler # noqa
46-
from autoarray.structures.mesh.rectangular_2d import Mesh2DRectangular # noqa
47-
from autoarray.structures.mesh.rectangular_2d_uniform import (
48-
Mesh2DRectangularUniform,
39+
from autoarray.operators.convolver import Convolver
40+
from autoarray.inversion.mesh.interpolator.rectangular import (
41+
InterpolatorRectangular,
42+
) # noqa
43+
from autoarray.inversion.mesh.interpolator.delaunay import (
44+
InterpolatorDelaunay,
4945
) # noqa
50-
from autoarray.structures.mesh.delaunay_2d import Mesh2DDelaunay # noqa
5146
from autoarray.structures.vectors.uniform import VectorYX2D # noqa
5247
from autoarray.structures.vectors.irregular import VectorYX2DIrregular # noqa
5348
from autoarray.layout.region import Region1D # noqa
5449
from autoarray.layout.region import Region2D # noqa
55-
from autoarray.structures.arrays.kernel_2d import Kernel2D # noqa
5650
from autoarray.structures.visibilities import Visibilities # noqa
5751
from autoarray.structures.visibilities import VisibilitiesNoiseMap # noqa
52+
from autoarray.inversion.mesh.mesh_geometry.rectangular import (
53+
rectangular_edge_pixel_list_from,
54+
)
5855

5956
from .analysis import model_util
6057
from .analysis.adapt_images.adapt_images import AdaptImages

autogalaxy/abstract_fit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
class AbstractFitInversion:
18-
def __init__(self, model_obj, settings_inversion: aa.SettingsInversion, xp=np):
18+
def __init__(self, model_obj, settings: aa.Settings, xp=np):
1919
"""
2020
An abstract fit object which fits to datasets (e.g. imaging, interferometer) inherit from.
2121
@@ -28,11 +28,11 @@ def __init__(self, model_obj, settings_inversion: aa.SettingsInversion, xp=np):
2828
The object which contains the model components (e.g. light profiles, galaxies, etc) which are used to
2929
create the model-data that fits the data. In PyAutoGalaxy this is a list of galaxies and PyAutoLens
3030
it is a `Tracer`.
31-
settings_inversion
31+
settings
3232
Settings controlling how an inversion is fitted for example which linear algebra formalism is used.
3333
"""
3434
self.model_obj = model_obj
35-
self.settings_inversion = settings_inversion
35+
self.settings = settings or aa.Settings()
3636
self.use_jax = xp is not np
3737

3838
@property
@@ -75,7 +75,7 @@ def perform_inversion(self) -> bool:
7575
def sparse_operator(self) -> Optional[aa.ImagingSparseOperator]:
7676
"""
7777
Only call the `sparse_operator` property of a dataset used to perform efficient linear algebra calculations if
78-
the SettingsInversion()` object has `use_sparse_operator=True`, to avoid unnecessary computation.
78+
the Settings()` object has `use_sparse_operator=True`, to avoid unnecessary computation.
7979
8080
Returns
8181
-------

autogalaxy/aggregator/agg_util.py

Lines changed: 7 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def adapt_images_from(
172172

173173

174174
def mesh_grids_of_planes_list_from(
175-
fit: af.Fit, total_fits: int, use_preloaded_grid: bool
175+
fit: af.Fit, total_fits: int
176176
) -> List[Optional[aa.Grid2D]]:
177177
"""
178178
Returns the image-plane pixelization grid(s) used by the fit.
@@ -196,69 +196,15 @@ def mesh_grids_of_planes_list_from(
196196
an output directory or from an sqlite database..
197197
total_fits
198198
The total number of `Analysis` objects summed to create the fit.
199-
use_preloaded_grid
200-
Certain pixelization's construct their mesh in the source-plane from a stochastic KMeans algorithm. This grid
201-
may be output to hard-disk after the model-fit and loaded via the database to ensure the same grid is used
202-
as the fit.
203199
204200
Returns
205201
-------
206202
The list of image-plane mesh centres used when creating the overall fit.
207203
"""
208-
209-
if use_preloaded_grid:
210-
if not fit.children:
211-
return [fit.value(name="preload_mesh_grids_of_planes")]
212-
else:
213-
try:
214-
return fit.child_values(name="preload_mesh_grids_of_planes")
215-
except AttributeError:
216-
return [None] * total_fits
204+
if not fit.children:
205+
return [fit.value(name="preload_mesh_grids_of_planes")]
217206
else:
218-
return [None] * total_fits
219-
220-
221-
def preloads_from(
222-
preloads_cls,
223-
use_preloaded_grid: bool,
224-
mesh_grids_of_planes: List,
225-
) -> aa.Preloads:
226-
"""
227-
Returns a `Preloads` object associated with a fit loaded via the database.
228-
229-
When loading results via the database, the preloads class may have certain attributes associated with it
230-
in order to perform the fit. The main purpose is to use the same image-plane mesh centres for pixelization where
231-
the mesh is computed in the image-plane (see `agg_util.mesh_grids_of_planes_list_from`).
232-
233-
Parameters
234-
----------
235-
preloads_cls
236-
The `Preloads` object used to create the preloads (this varies across
237-
projects like `autogalaxy` and `autolens`).
238-
use_preloaded_grid
239-
Certain pixelization's construct their mesh in the source-plane from a stochastic KMeans algorithm. This grid
240-
may be output to hard-disk after the model-fit and loaded via the database to ensure the same grid is used
241-
as the fit.
242-
mesh_grids_of_planes
243-
The list of image-plane mesh centres used when creating the overall fit which are associated with the
244-
preloads.
245-
246-
Returns
247-
-------
248-
The preloads object associated with the fit loaded via the database.
249-
"""
250-
preloads = preloads_cls()
251-
252-
if use_preloaded_grid:
253-
if mesh_grids_of_planes is not None:
254-
preloads = preloads_cls(
255-
image_plane_mesh_grid_pg_list=mesh_grids_of_planes,
256-
)
257-
258-
if len(preloads.image_plane_mesh_grid_pg_list) == 2:
259-
if type(preloads.image_plane_mesh_grid_pg_list[1]) != list:
260-
preloads.image_plane_mesh_grid_pg_list[1] = [
261-
preloads.image_plane_mesh_grid_pg_list[1]
262-
]
263-
264-
return preloads
207+
try:
208+
return fit.child_values(name="preload_mesh_grids_of_planes")
209+
except AttributeError:
210+
return [None] * total_fits

autogalaxy/aggregator/ellipse/fit_ellipse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _fit_ellipse_from(
3333
is instead used to load lists of the data, noise-map, PSF and mask and combine them into a list of
3434
`FitEllipse` objects.
3535
36-
The settings of an inversion can be overwritten by inputting a `settings_inversion` object, for example
36+
The settings of an inversion can be overwritten by inputting a `settings` object, for example
3737
if you want to use a grid with a different inversion solver.
3838
3939
Parameters

autogalaxy/aggregator/imaging/fit_imaging.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
def _fit_imaging_from(
1717
fit: af.Fit,
1818
instance: Optional[af.ModelInstance] = None,
19-
settings_inversion: aa.SettingsInversion = None,
19+
settings: aa.Settings = None,
2020
) -> List[FitImaging]:
2121
"""
2222
Returns a list of `FitImaging` objects from a `PyAutoFit` loaded directory `Fit` or sqlite database `Fit` object.
@@ -26,7 +26,7 @@ def _fit_imaging_from(
2626
2727
- The imaging data, noise-map, PSF and settings as .fits files (e.g. `dataset/data.fits`).
2828
- The mask used to mask the `Imaging` data structure in the fit (`dataset.fits[hdu=0]`).
29-
- The settings of inversions used by the fit (`dataset/settings_inversion.json`).
29+
- The settings of inversions used by the fit (`dataset/settings.json`).
3030
3131
Each individual attribute can be loaded from the database via the `fit.value()` method.
3232
@@ -37,7 +37,7 @@ def _fit_imaging_from(
3737
is instead used to load lists of the data, noise-map, PSF and mask and combine them into a list of
3838
`FitImaging` objects.
3939
40-
The settings of an inversion can be overwritten by inputting a `settings_inversion` object, for example
40+
The settings of an inversion can be overwritten by inputting a `settings` object, for example
4141
if you want to use a grid with a different inversion solver.
4242
4343
Parameters
@@ -48,8 +48,8 @@ def _fit_imaging_from(
4848
instance
4949
A manual instance that overwrites the max log likelihood instance in fit (e.g. for drawing the instance
5050
randomly from the PDF).
51-
settings_inversion
52-
Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit.
51+
settings
52+
Optionally overwrite the `Settings` of the `Inversion` object that is created from the fit.
5353
"""
5454

5555
from autogalaxy.imaging.fit_imaging import FitImaging
@@ -62,7 +62,7 @@ def _fit_imaging_from(
6262

6363
adapt_images_list = agg_util.adapt_images_from(fit=fit)
6464

65-
settings_inversion = settings_inversion or fit.value(name="settings_inversion")
65+
settings = settings or fit.value(name="settings")
6666

6767
fit_dataset_list = []
6868

@@ -79,7 +79,7 @@ def _fit_imaging_from(
7979
galaxies=galaxies,
8080
dataset_model=dataset_model,
8181
adapt_images=adapt_images,
82-
settings_inversion=settings_inversion,
82+
settings=settings,
8383
)
8484
)
8585

@@ -90,7 +90,7 @@ class FitImagingAgg(af.AggBase):
9090
def __init__(
9191
self,
9292
aggregator: af.Aggregator,
93-
settings_inversion: Optional[aa.SettingsInversion] = None,
93+
settings: Optional[aa.Settings] = None,
9494
):
9595
"""
9696
Interfaces with an `PyAutoFit` aggregator object to create instances of `FitImaging` objects from the results
@@ -101,7 +101,7 @@ def __init__(
101101
102102
- The imaging data, noise-map, PSF and settings as .fits files (e.g. `dataset/data.fits`).
103103
- The mask used to mask the `Imaging` data structure in the fit (`dataset.fits[hdu=0]`).
104-
- The settings of inversions used by the fit (`dataset/settings_inversion.json`).
104+
- The settings of inversions used by the fit (`dataset/settings.json`).
105105
106106
The `aggregator` contains the path to each of these files, and they can be loaded individually. This class
107107
can load them all at once and create an `FitImaging` object via the `_fit_imaging_from` method.
@@ -123,19 +123,19 @@ def __init__(
123123
----------
124124
aggregator
125125
A `PyAutoFit` aggregator object which can load the results of model-fits.
126-
settings_inversion
127-
Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit.
126+
settings
127+
Optionally overwrite the `Settings` of the `Inversion` object that is created from the fit.
128128
129129
Parameters
130130
----------
131131
aggregator
132132
A `PyAutoFit` aggregator object which can load the results of model-fits.
133-
settings_inversion
134-
Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit.
133+
settings
134+
Optionally overwrite the `Settings` of the `Inversion` object that is created from the fit.
135135
"""
136136
super().__init__(aggregator=aggregator)
137137

138-
self.settings_inversion = settings_inversion
138+
self.settings = settings
139139

140140
def object_via_gen_from(
141141
self, fit, instance: Optional[af.ModelInstance] = None
@@ -157,5 +157,5 @@ def object_via_gen_from(
157157
return _fit_imaging_from(
158158
fit=fit,
159159
instance=instance,
160-
settings_inversion=self.settings_inversion,
160+
settings=self.settings,
161161
)

autogalaxy/aggregator/imaging/imaging.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ def values_from(hdu: int, cls):
5959
noise_map = values_from(hdu=2, cls=aa.Array2D)
6060

6161
try:
62-
psf = values_from(hdu=3, cls=aa.Kernel2D)
62+
kernel = values_from(hdu=3, cls=aa.Array2D)
63+
psf = aa.Convolver(kernel=kernel)
6364
except (TypeError, IndexError):
65+
kernel = None
6466
psf = None
6567

6668
dataset = aa.Imaging(

0 commit comments

Comments
 (0)