From 97000660ae71bd37243c724ccaca183069dd8e40 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Thu, 3 Oct 2024 13:32:23 +0100 Subject: [PATCH 1/5] remove preloads --- autolens/__init__.py | 6 +- autolens/aggregator/fit_imaging.py | 20 +- autolens/aggregator/fit_interferometer.py | 20 +- autolens/aggregator/subhalo.py | 2 - autolens/analysis/analysis.py | 27 -- autolens/analysis/analysis/dataset.py | 29 -- autolens/analysis/maker.py | 9 - autolens/analysis/preloads.py | 276 ------------------ autolens/imaging/fit_imaging.py | 23 +- autolens/imaging/model/analysis.py | 11 - autolens/interferometer/fit_interferometer.py | 49 ---- autolens/interferometer/model/analysis.py | 14 - autolens/lens/to_inversion.py | 12 +- autolens/lens/tracer.py | 8 +- docs/overview/overview_2_new_user_guide.rst | 6 +- .../analysis/test_analysis_dataset.py | 25 -- test_autolens/analysis/test_analysis.py | 25 -- test_autolens/analysis/test_preloads.py | 203 ------------- test_autolens/config/general.yaml | 3 - test_autolens/config/visualize.yaml | 2 +- test_autolens/imaging/test_fit_imaging.py | 44 --- .../imaging/test_simulate_and_fit_imaging.py | 44 --- 22 files changed, 23 insertions(+), 835 deletions(-) delete mode 100644 autolens/analysis/maker.py delete mode 100644 autolens/analysis/preloads.py delete mode 100644 test_autolens/analysis/test_preloads.py diff --git a/autolens/__init__.py b/autolens/__init__.py index cc519be0a..17c878c45 100644 --- a/autolens/__init__.py +++ b/autolens/__init__.py @@ -42,6 +42,10 @@ from autoarray.structures.mesh.rectangular_2d import Mesh2DRectangular from autoarray.structures.mesh.voronoi_2d import Mesh2DVoronoi from autoarray.structures.mesh.delaunay_2d import Mesh2DDelaunay +from autoarray.structures.triangles.shape import Circle +from autoarray.structures.triangles.shape import Triangle +from autoarray.structures.triangles.shape import Square +from autoarray.structures.triangles.shape import Polygon from autoarray.structures.vectors.uniform import VectorYX2D from autoarray.structures.vectors.irregular import VectorYX2DIrregular from autoarray.structures.arrays.kernel_2d import Kernel2D @@ -90,7 +94,6 @@ from .lens.to_inversion import TracerToInversion from .analysis.positions import PositionsLHResample from .analysis.positions import PositionsLHPenalty -from .analysis.preloads import Preloads from .imaging.simulator import SimulatorImaging from .imaging.fit_imaging import FitImaging from .imaging.model.analysis import AnalysisImaging @@ -108,6 +111,7 @@ from .point.fit.positions.source.max_separation import FitPositionsSourceMaxSeparation from .point.model.analysis import AnalysisPoint from .point.solver import PointSolver +from .point.solver.shape_solver import ShapeSolver from .quantity.fit_quantity import FitQuantity from .quantity.model.analysis import AnalysisQuantity from . import exc diff --git a/autolens/aggregator/fit_imaging.py b/autolens/aggregator/fit_imaging.py index f37c6208b..0cbae78bc 100644 --- a/autolens/aggregator/fit_imaging.py +++ b/autolens/aggregator/fit_imaging.py @@ -4,7 +4,6 @@ import autoarray as aa from autolens.imaging.fit_imaging import FitImaging -from autolens.analysis.preloads import Preloads from autogalaxy.aggregator.imaging.imaging import _imaging_from from autogalaxy.aggregator.dataset_model import _dataset_model_from @@ -17,7 +16,6 @@ def _fit_imaging_from( fit: af.Fit, instance: Optional[af.ModelInstance] = None, settings_inversion: aa.SettingsInversion = None, - use_preloaded_grid: bool = True, ) -> List[FitImaging]: """ Returns a list of `FitImaging` object from a `PyAutoFit` sqlite database `Fit` object. @@ -49,10 +47,6 @@ def _fit_imaging_from( randomly from the PDF). settings_inversion Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit. - use_preloaded_grid - Certain pixelization's construct their mesh in the source-plane from a stochastic KMeans algorithm. This grid - may be output to hard-disk after the model-fit and loaded via the database to ensure the same grid is used - as the fit. """ dataset_list = _imaging_from(fit=fit) @@ -65,25 +59,14 @@ def _fit_imaging_from( settings_inversion = settings_inversion or fit.value(name="settings_inversion") - mesh_grids_of_planes_list = agg_util.mesh_grids_of_planes_list_from( - fit=fit, total_fits=len(dataset_list), use_preloaded_grid=use_preloaded_grid - ) - fit_dataset_list = [] - for dataset, tracer, dataset_model, adapt_images, mesh_grids_of_planes in zip( + for dataset, tracer, dataset_model, adapt_images in zip( dataset_list, tracer_list, dataset_model_list, adapt_images_list, - mesh_grids_of_planes_list, ): - preloads = agg_util.preloads_from( - preloads_cls=Preloads, - use_preloaded_grid=use_preloaded_grid, - mesh_grids_of_planes=mesh_grids_of_planes, - use_w_tilde=False, - ) fit_dataset_list.append( FitImaging( @@ -92,7 +75,6 @@ def _fit_imaging_from( dataset_model=dataset_model, adapt_images=adapt_images, settings_inversion=settings_inversion, - preloads=preloads, ) ) diff --git a/autolens/aggregator/fit_interferometer.py b/autolens/aggregator/fit_interferometer.py index a9aa77615..6cb0d9ca7 100644 --- a/autolens/aggregator/fit_interferometer.py +++ b/autolens/aggregator/fit_interferometer.py @@ -7,7 +7,6 @@ from autogalaxy.aggregator.dataset_model import _dataset_model_from from autolens.interferometer.fit_interferometer import FitInterferometer -from autolens.analysis.preloads import Preloads from autogalaxy.aggregator import agg_util from autolens.aggregator.tracer import _tracer_from @@ -18,7 +17,6 @@ def _fit_interferometer_from( instance: Optional[af.ModelInstance] = None, real_space_mask: Optional[aa.Mask2D] = None, settings_inversion: aa.SettingsInversion = None, - use_preloaded_grid: bool = True, ) -> List[FitInterferometer]: """ Returns a list of `FitInterferometer` objects from a `PyAutoFit` sqlite database `Fit` object. @@ -51,10 +49,6 @@ def _fit_interferometer_from( randomly from the PDF). settings_inversion Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit. - use_preloaded_grid - Certain pixelization's construct their mesh in the source-plane from a stochastic KMeans algorithm. This grid - may be output to hard-disk after the model-fit and loaded via the database to ensure the same grid is used - as the fit. """ dataset_list = _interferometer_from( fit=fit, @@ -67,25 +61,14 @@ def _fit_interferometer_from( settings_inversion = settings_inversion or fit.value(name="settings_inversion") - mesh_grids_of_planes_list = agg_util.mesh_grids_of_planes_list_from( - fit=fit, total_fits=len(dataset_list), use_preloaded_grid=use_preloaded_grid - ) - fit_dataset_list = [] - for dataset, tracer, dataset_model, adapt_images, mesh_grids_of_planes in zip( + for dataset, tracer, dataset_model, adapt_images in zip( dataset_list, tracer_list, dataset_model_list, adapt_images_list, - mesh_grids_of_planes_list, ): - preloads = agg_util.preloads_from( - preloads_cls=Preloads, - use_preloaded_grid=use_preloaded_grid, - mesh_grids_of_planes=mesh_grids_of_planes, - use_w_tilde=False, - ) fit_dataset_list.append( FitInterferometer( @@ -94,7 +77,6 @@ def _fit_interferometer_from( dataset_model=dataset_model, adapt_images=adapt_images, settings_inversion=settings_inversion, - preloads=preloads, ) ) diff --git a/autolens/aggregator/subhalo.py b/autolens/aggregator/subhalo.py index 62ebe03f2..a8bd5518f 100644 --- a/autolens/aggregator/subhalo.py +++ b/autolens/aggregator/subhalo.py @@ -11,7 +11,6 @@ def __init__( self, aggregator_grid_search: af.GridSearchAggregator, settings_inversion: Optional[aa.SettingsInversion] = None, - use_preloaded_grid: bool = True, ): """ Wraps a PyAutoFit aggregator in order to create generators of fits to imaging data, corresponding to the @@ -20,7 +19,6 @@ def __init__( self.aggregator_grid_search = aggregator_grid_search self.settings_inversion = settings_inversion - self.use_preloaded_grid = use_preloaded_grid if len(aggregator_grid_search) == 0: raise exc.AggregatorException( diff --git a/autolens/analysis/analysis.py b/autolens/analysis/analysis.py index 7bc065912..fcd85afe1 100644 --- a/autolens/analysis/analysis.py +++ b/autolens/analysis/analysis.py @@ -13,8 +13,6 @@ from autogalaxy.analysis.analysis.dataset import AnalysisDataset as AgAnalysisDataset from autolens.analysis.result import ResultDataset -from autolens.analysis.maker import FitMaker -from autolens.analysis.preloads import Preloads from autolens.analysis.positions import PositionsLHResample from autolens.analysis.positions import PositionsLHPenalty from autolens.lens.tracer import Tracer @@ -196,8 +194,6 @@ def __init__( cosmology=cosmology, ) - self.preloads = self.preloads_cls() - self.raise_inversion_positions_likelihood_exception = ( raise_inversion_positions_likelihood_exception ) @@ -257,14 +253,6 @@ def raise_exceptions(self, model): "https://pyautolens.readthedocs.io/en/latest/general/demagnified_solutions.html" ) - @property - def preloads_cls(self): - return Preloads - - @property - def fit_maker_cls(self): - return FitMaker - def save_results(self, paths: af.DirectoryPaths, result: ResultDataset): """ At the end of a model-fit, this routine saves attributes of the `Analysis` object to the `files` @@ -291,18 +279,3 @@ def save_results(self, paths: af.DirectoryPaths, result: ResultDataset): pass image_mesh_list = [] - - for galaxy in result.instance.galaxies: - pixelization_list = galaxy.cls_list_from(cls=aa.Pixelization) - - for pixelization in pixelization_list: - if pixelization is not None: - image_mesh_list.append(pixelization.image_mesh) - - if len(image_mesh_list) > 0: - paths.save_json( - name="preload_mesh_grids_of_planes", - object_dict=to_dict( - result.max_log_likelihood_fit.tracer_to_inversion.image_plane_mesh_grid_pg_list - ), - ) diff --git a/autolens/analysis/analysis/dataset.py b/autolens/analysis/analysis/dataset.py index 718a6fd84..6457d647e 100644 --- a/autolens/analysis/analysis/dataset.py +++ b/autolens/analysis/analysis/dataset.py @@ -13,8 +13,6 @@ from autolens.analysis.analysis.lens import AnalysisLens from autolens.analysis.result import ResultDataset -from autolens.analysis.maker import FitMaker -from autolens.analysis.preloads import Preloads from autolens.analysis.positions import PositionsLHResample from autolens.analysis.positions import PositionsLHPenalty @@ -84,8 +82,6 @@ def __init__( cosmology=cosmology, ) - self.preloads = self.preloads_cls() - self.raise_inversion_positions_likelihood_exception = ( raise_inversion_positions_likelihood_exception ) @@ -147,14 +143,6 @@ def raise_exceptions(self, model): """ ) - @property - def preloads_cls(self): - return Preloads - - @property - def fit_maker_cls(self): - return FitMaker - def save_results(self, paths: af.DirectoryPaths, result: ResultDataset): """ At the end of a model-fit, this routine saves attributes of the `Analysis` object to the `files` @@ -179,20 +167,3 @@ def save_results(self, paths: af.DirectoryPaths, result: ResultDataset): ) except AttributeError: pass - - image_mesh_list = [] - - for galaxy in result.instance.galaxies: - pixelization_list = galaxy.cls_list_from(cls=aa.Pixelization) - - for pixelization in pixelization_list: - if pixelization is not None: - image_mesh_list.append(pixelization.image_mesh) - - if len(image_mesh_list) > 0: - paths.save_json( - name="preload_mesh_grids_of_planes", - object_dict=to_dict( - result.max_log_likelihood_fit.tracer_to_inversion.image_plane_mesh_grid_pg_list - ), - ) diff --git a/autolens/analysis/maker.py b/autolens/analysis/maker.py deleted file mode 100644 index 737e504b6..000000000 --- a/autolens/analysis/maker.py +++ /dev/null @@ -1,9 +0,0 @@ -import autogalaxy as ag - -from autolens.analysis.preloads import Preloads - - -class FitMaker(ag.FitMaker): - @property - def preloads_cls(self): - return Preloads diff --git a/autolens/analysis/preloads.py b/autolens/analysis/preloads.py deleted file mode 100644 index 664b057b3..000000000 --- a/autolens/analysis/preloads.py +++ /dev/null @@ -1,276 +0,0 @@ -import logging -import numpy as np -from typing import Dict, Optional, List - -import autoarray as aa -import autogalaxy as ag - -logger = logging.getLogger(__name__) - -logger.setLevel(level="INFO") - - -class Preloads(ag.Preloads): - def __init__( - self, - w_tilde: Optional[aa.WTildeImaging] = None, - use_w_tilde: Optional[bool] = None, - blurred_image: Optional[aa.Array2D] = None, - traced_grids_of_planes_for_inversion: Optional[aa.Grid2D] = None, - image_plane_mesh_grid_pg_list: Optional[List[List[aa.Grid2D]]] = None, - relocated_grid: Optional[aa.Grid2D] = None, - mapper_list: Optional[aa.AbstractMapper] = None, - mapper_galaxy_dict: Optional[Dict[aa.AbstractMapper, ag.Galaxy]] = None, - operated_mapping_matrix: Optional[np.ndarray] = None, - linear_func_operated_mapping_matrix_dict=None, - data_linear_func_matrix_dict=None, - mapper_operated_mapping_matrix_dict=None, - regularization_matrix: Optional[np.ndarray] = None, - log_det_regularization_matrix_term: Optional[float] = None, - traced_mesh_grids_list_of_planes=None, - image_plane_mesh_grid_list=None, - failed=False, - ): - """ - Class which offers a concise API for settings up the preloads, which before a model-fit are set up via - a comparison of two fits using two different models. If a quantity in these two fits is identical, it does - not change throughout the model-fit and can therefore be preloaded to avoid computation, speeding up - the analysis. - - For example, the image-plane source-plane pixelization grid (which may be computationally expensive to compute - via a KMeans algorithm) does not change for the majority of model-fits, because the associated model parameters - are fixed. Preloading avoids rerruning the KMeans algorithm for every model fitted, by preloading it in memory - and using this preload in every fit. - - Parameters - ---------- - blurred_image - The preloaded array of values containing the blurred image of a model fit (e.g. that light profile of - every galaxy in the model). This can be preloaded when no light profiles in the model vary. - w_tilde - A class containing values that enable an inversion's linear algebra to use the w-tilde formalism. This can - be preloaded when no component of the model changes the noise map (e.g. galaxies are fixed). - use_w_tilde - Whether to use the w tilde formalism, which superseeds the value in `SettingsInversions` such that w tilde - will be disabled for model-fits it is not applicable (e.g. because the noise-map changes). - traced_grids_of_planes_for_inversion - The two dimensional grids corresponding to the traced grids in a lens fit. This can be preloaded when no - mass profiles in the model vary. - image_plane_mesh_grid_pg_list - The two dimensional grids corresponding to the sparse image plane grids in a lens fit, that is ray-traced to - the source plane to form the source pixelization. This can be preloaded when no pixelizations in the model - vary. - relocated_grid - The two dimensional grids corresponding to the grid that has had its border pixels relocated for a - pixelization in a lens fit. This can be preloaded when no mass profiles in the model vary. - mapper_list - The mapper of a fit, which preloading avoids recalculation of the mapping matrix and image to source - pixel mappings. This can be preloaded when no pixelizations in the model vary. - operated_mapping_matrix - A matrix containing the mappings between PSF blurred image pixels and source pixels used in the linear - algebra of an inversion. This can be preloaded when no mass profiles and pixelizations in the model vary. - - Returns - ------- - Preloads - The preloads object used to skip certain calculations in the log likelihood function. - """ - super().__init__( - w_tilde=w_tilde, - use_w_tilde=use_w_tilde, - blurred_image=blurred_image, - relocated_grid=relocated_grid, - image_plane_mesh_grid_pg_list=image_plane_mesh_grid_pg_list, - mapper_list=mapper_list, - mapper_galaxy_dict=mapper_galaxy_dict, - operated_mapping_matrix=operated_mapping_matrix, - linear_func_operated_mapping_matrix_dict=linear_func_operated_mapping_matrix_dict, - data_linear_func_matrix_dict=data_linear_func_matrix_dict, - mapper_operated_mapping_matrix_dict=mapper_operated_mapping_matrix_dict, - regularization_matrix=regularization_matrix, - log_det_regularization_matrix_term=log_det_regularization_matrix_term, - traced_mesh_grids_list_of_planes=traced_mesh_grids_list_of_planes, - image_plane_mesh_grid_list=image_plane_mesh_grid_list, - ) - - self.traced_grids_of_planes_for_inversion = traced_grids_of_planes_for_inversion - self.failed = failed - - @classmethod - def setup_all_via_fits(cls, fit_0, fit_1) -> "Preloads": - """ - Setup the Preloads from two fits which use two different lens model of a model-fit. - - Parameters - ---------- - fit_0 - The first fit corresponding to a model with a specific set of unit-values. - fit_1 - The second fit corresponding to a model with a different set of unit-values. - - Returns - ------- - Preloads - Preloads which are set up based on the fit's passed in specific to a lens model. - - """ - - preloads = cls() - - if isinstance(fit_0, aa.FitImaging): - preloads.set_w_tilde_imaging(fit_0=fit_0, fit_1=fit_1) - preloads.set_blurred_image(fit_0=fit_0, fit_1=fit_1) - - preloads.set_traced_grids_of_planes_for_inversion(fit_0=fit_0, fit_1=fit_1) - preloads.set_image_plane_mesh_grid_pg_list(fit_0=fit_0, fit_1=fit_1) - preloads.set_relocated_grid(fit_0=fit_0, fit_1=fit_1) - preloads.set_mapper_list(fit_0=fit_0, fit_1=fit_1) - - if preloads.mapper_list is not None: - preloads.mapper_galaxy_dict = fit_0.tracer_to_inversion.mapper_galaxy_dict - - preloads.set_operated_mapping_matrix_with_preloads(fit_0=fit_0, fit_1=fit_1) - preloads.set_linear_func_inversion_dicts(fit_0=fit_0, fit_1=fit_1) - preloads.set_curvature_matrix(fit_0=fit_0, fit_1=fit_1) - preloads.set_regularization_matrix_and_term(fit_0=fit_0, fit_1=fit_1) - - return preloads - - def set_traced_grids_of_planes_for_inversion(self, fit_0, fit_1): - """ - If the `MassProfiles`'s in a model are fixed their deflection angles and therefore corresponding traced grids - do not change during the model-fit and can therefore be preloaded. - - This function compares the traced grids of two fit's corresponding to two model instances, and preloads the - traced grids if the grids of both fits are the same. This preloaded grid is only used when constructing an - inversion, because the `blurred_image` preload accounts for light profiles. - - The preload is typically used in adapt searches, where the mass model is fixed and the adapt-parameters are - varied. - - Parameters - ---------- - fit_0 - The first fit corresponding to a model with a specific set of unit-values. - fit_1 - The second fit corresponding to a model with a different set of unit-values. - """ - - self.traced_grids_of_planes_for_inversion = None - - over_sampled_grid = fit_0.grids.pixelization.over_sampling.over_sampler_from(mask=fit_0.grids.pixelization.mask).over_sampled_grid - - traced_grids_of_planes_0 = fit_0.tracer.traced_grid_2d_list_from( - grid=over_sampled_grid - ) - - traced_grids_of_planes_1 = fit_1.tracer.traced_grid_2d_list_from( - grid=over_sampled_grid - ) - - if traced_grids_of_planes_0[-1] is not None: - if ( - traced_grids_of_planes_0[-1].shape[0] - == traced_grids_of_planes_1[-1].shape[0] - ): - if ( - np.max( - abs(traced_grids_of_planes_0[-1] - traced_grids_of_planes_1[-1]) - ) - < 1e-8 - ): - self.traced_grids_of_planes_for_inversion = traced_grids_of_planes_0 - - logger.info( - "PRELOADS - Traced grid of planes (for inversion) preloaded for this model-fit." - ) - - def set_image_plane_mesh_grid_pg_list(self, fit_0, fit_1): - """ - If the `Pixelization`'s in a model are fixed their image-plane sparse grid (which defines the set of pixels - that are ray-traced to construct the source-plane pixelization) do not change during the model=fit and - can therefore be preloaded. - - This function compares the image plane sparse grid of two fit's corresponding to two model instances, and p - reloads the grid if the grids of both fits are the same. - - The preload is typically used throughout search chaining pipelines which use inversions, as it is common to - for the pixelization's parameters to only vary in the adapt-searches. - - Parameters - ---------- - fit_0 - The first fit corresponding to a model with a specific set of unit-values. - fit_1 - The second fit corresponding to a model with a different set of unit-values. - """ - - self.image_plane_mesh_grid_pg_list = None - - image_plane_mesh_grid_pg_list_0 = ( - fit_0.tracer_to_inversion.image_plane_mesh_grid_pg_list - ) - - image_plane_mesh_grid_pg_list_1 = ( - fit_1.tracer_to_inversion.image_plane_mesh_grid_pg_list - ) - - if image_plane_mesh_grid_pg_list_0[-1] is not None: - if image_plane_mesh_grid_pg_list_0[-1][0] is not None: - if ( - image_plane_mesh_grid_pg_list_0[-1][0].shape[0] - == image_plane_mesh_grid_pg_list_1[-1][0].shape[0] - ): - if ( - np.max( - abs( - image_plane_mesh_grid_pg_list_0[-1][0] - - image_plane_mesh_grid_pg_list_1[-1][0] - ) - ) - < 1e-8 - ): - self.image_plane_mesh_grid_pg_list = ( - image_plane_mesh_grid_pg_list_0 - ) - - logger.info( - "PRELOADS - Sparse image-plane grids of planes is preloaded for this model-fit." - ) - - @property - def info(self) -> List[str]: - """ - The information on what has or has not been preloaded, which is written to the file `preloads.summary`. - - Returns - ------- - A list of strings containing True and False values as to whether a quantity has been preloaded. - """ - line = [f"W Tilde = {self.w_tilde is not None}\n"] - line += [f"Use W Tilde = {self.use_w_tilde}\n\n"] - line += [f"Blurred Image = {np.count_nonzero(self.blurred_image) != 0}\n"] - line += [ - f"Traced Grids of Planes (For LEq) = {self.traced_grids_of_planes_for_inversion is not None}\n" - ] - line += [ - f"Sparse Image-Plane Grids of Planes = {self.image_plane_mesh_grid_pg_list is not None}\n" - ] - line += [f"Relocated Grid = {self.relocated_grid is not None}\n"] - line += [f"Mapper = {self.mapper_list is not None}\n"] - line += [ - f"Blurred Mapping Matrix = {self.operated_mapping_matrix is not None}\n" - ] - line += [ - f"Inversion Linear Func (Linear Light Profile) Dicts = {self.linear_func_operated_mapping_matrix_dict is not None}\n" - ] - line += [f"Curvature Matrix = {self.curvature_matrix is not None}\n"] - line += [ - f"Curvature Matrix Mapper Diag = {self.curvature_matrix_mapper_diag is not None}\n" - ] - line += [f"Regularization Matrix = {self.regularization_matrix is not None}\n"] - line += [ - f"Log Det Regularization Matrix Term = {self.log_det_regularization_matrix_term is not None}\n" - ] - - return line diff --git a/autolens/imaging/fit_imaging.py b/autolens/imaging/fit_imaging.py index c07f8f3aa..827c5eefd 100644 --- a/autolens/imaging/fit_imaging.py +++ b/autolens/imaging/fit_imaging.py @@ -9,7 +9,6 @@ from autogalaxy.abstract_fit import AbstractFitInversion -from autolens.analysis.preloads import Preloads from autolens.lens.tracer import Tracer from autolens.lens.to_inversion import TracerToInversion @@ -24,7 +23,6 @@ def __init__( dataset_model : Optional[aa.DatasetModel] = None, adapt_images: Optional[ag.AdaptImages] = None, settings_inversion: aa.SettingsInversion = aa.SettingsInversion(), - preloads: Preloads = Preloads(), run_time_dict: Optional[Dict] = None, ): """ @@ -64,9 +62,6 @@ def __init__( reconstructed galaxy's morphology. settings_inversion Settings controlling how an inversion is fitted for example which linear algebra formalism is used. - preloads - Contains preloaded calculations (e.g. linear algebra matrices) which can skip certain calculations in - the fit. run_time_dict A dictionary which if passed to the fit records how long function calls which have the `profile_func` decorator take to run. @@ -82,8 +77,6 @@ def __init__( self.adapt_images = adapt_images self.settings_inversion = settings_inversion - self.preloads = preloads - @cached_property def grids(self) -> aa.GridsInterface: @@ -115,16 +108,11 @@ def blurred_image(self) -> aa.Array2D: For certain lens models the blurred image does not change (for example when all light profiles in the tracer are fixed in the lens model). For faster run-times the blurred image can be preloaded. """ - - if self.preloads.blurred_image is None: - - return self.tracer.blurred_image_2d_from( - grid=self.grids.uniform, - convolver=self.dataset.convolver, - blurring_grid=self.grids.blurring, - ) - - return self.preloads.blurred_image + return self.tracer.blurred_image_2d_from( + grid=self.grids.uniform, + convolver=self.dataset.convolver, + blurring_grid=self.grids.blurring, + ) @property def profile_subtracted_image(self) -> aa.Array2D: @@ -150,7 +138,6 @@ def tracer_to_inversion(self) -> TracerToInversion: tracer=self.tracer, adapt_images=self.adapt_images, settings_inversion=self.settings_inversion, - preloads=self.preloads, run_time_dict=self.run_time_dict ) diff --git a/autolens/imaging/model/analysis.py b/autolens/imaging/model/analysis.py index 3f1bca1d9..32fa82019 100644 --- a/autolens/imaging/model/analysis.py +++ b/autolens/imaging/model/analysis.py @@ -10,7 +10,6 @@ from autoarray.exc import PixelizationException from autolens.analysis.analysis.dataset import AnalysisDataset -from autolens.analysis.preloads import Preloads from autolens.imaging.model.result import ResultImaging from autolens.imaging.model.visualizer import VisualizerImaging from autolens.imaging.fit_imaging import FitImaging @@ -52,10 +51,6 @@ def modify_before_fit(self, paths: af.DirectoryPaths, model: af.Collection): """ super().modify_before_fit(paths=paths, model=model) - if not paths.is_complete: - - self.set_preloads(paths=paths, model=model) - return self def log_likelihood_function(self, instance: af.ModelInstance) -> float: @@ -127,7 +122,6 @@ def log_likelihood_function(self, instance: af.ModelInstance) -> float: def fit_from( self, instance: af.ModelInstance, - preload_overwrite: Optional[Preloads] = None, run_time_dict: Optional[Dict] = None, ) -> FitImaging: """ @@ -141,8 +135,6 @@ def fit_from( instance An instance of the model that is being fitted to the data by this analysis (whose parameters have been set via a non-linear search). - preload_overwrite - If a `Preload` object is input this is used instead of the preloads stored as an attribute in the analysis. check_positions Whether the multiple image positions of the lensed source should be checked, i.e. whether they trace within the position threshold of one another in the source plane. @@ -163,15 +155,12 @@ def fit_from( adapt_images = self.adapt_images_via_instance_from(instance=instance) - preloads = preload_overwrite or self.preloads - return FitImaging( dataset=self.dataset, tracer=tracer, dataset_model=dataset_model, adapt_images=adapt_images, settings_inversion=self.settings_inversion, - preloads=preloads, run_time_dict=run_time_dict, ) diff --git a/autolens/interferometer/fit_interferometer.py b/autolens/interferometer/fit_interferometer.py index 3d03f5f04..e0d624db5 100644 --- a/autolens/interferometer/fit_interferometer.py +++ b/autolens/interferometer/fit_interferometer.py @@ -8,7 +8,6 @@ from autogalaxy.abstract_fit import AbstractFitInversion -from autolens.analysis.preloads import Preloads from autolens.lens.tracer import Tracer from autolens.lens.to_inversion import TracerToInversion @@ -21,7 +20,6 @@ def __init__( dataset_model: Optional[aa.DatasetModel] = None, adapt_images: Optional[ag.AdaptImages] = None, settings_inversion: aa.SettingsInversion = aa.SettingsInversion(), - preloads: Preloads = Preloads(), run_time_dict: Optional[Dict] = None, ): """ @@ -62,9 +60,6 @@ def __init__( reconstructed galaxy's morphology. settings_inversion Settings controlling how an inversion is fitted for example which linear algebra formalism is used. - preloads - Contains preloaded calculations (e.g. linear algebra matrices) which can skip certain calculations in - the fit. run_time_dict A dictionary which if passed to the fit records how long function calls which have the `profile_func` decorator take to run. @@ -81,8 +76,6 @@ def __init__( self.settings_inversion = settings_inversion - self.preloads = preloads - self.run_time_dict = run_time_dict super().__init__( @@ -125,7 +118,6 @@ def tracer_to_inversion(self) -> TracerToInversion: tracer=self.tracer, adapt_images=self.adapt_images, settings_inversion=self.settings_inversion, - preloads=self.preloads, ) @cached_property @@ -242,44 +234,3 @@ def tracer_linear_light_profiles_to_light_profiles(self) -> Tracer: or `GalaxyPlotter` objects. """ return self.model_obj_linear_light_profiles_to_light_profiles - - def refit_with_new_preloads( - self, - preloads: Preloads, - settings_inversion: Optional[aa.SettingsInversion] = None, - ) -> "FitInterferometer": - """ - Returns a new fit which uses the dataset, tracer and other objects of this fit, but uses a different set of - preloads input into this function. - - This is used when setting up the preloads objects, to concisely test how using different preloads objects - changes the attributes of the fit. - - Parameters - ---------- - preloads - The new preloads which are used to refit the data using the - settings_inversion - Settings controlling how an inversion is fitted for example which linear algebra formalism is used. - - Returns - ------- - A new fit which has used new preloads input into this function but the same dataset, tracer and other settings. - """ - if self.run_time_dict is not None: - run_time_dict = {} - else: - run_time_dict = None - - if settings_inversion is None: - settings_inversion = self.settings_inversion - - return FitInterferometer( - dataset=self.dataset, - tracer=self.tracer, - dataset_model=self.dataset_model, - adapt_images=self.adapt_images, - settings_inversion=settings_inversion, - preloads=preloads, - run_time_dict=run_time_dict, - ) diff --git a/autolens/interferometer/model/analysis.py b/autolens/interferometer/model/analysis.py index 2dd2b1bfd..165709319 100644 --- a/autolens/interferometer/model/analysis.py +++ b/autolens/interferometer/model/analysis.py @@ -11,7 +11,6 @@ from autoarray.exc import PixelizationException from autolens.analysis.analysis.dataset import AnalysisDataset -from autolens.analysis.preloads import Preloads from autolens.analysis.positions import PositionsLHResample from autolens.analysis.positions import PositionsLHPenalty from autolens.interferometer.model.result import ResultInterferometer @@ -115,13 +114,6 @@ def modify_before_fit(self, paths: af.DirectoryPaths, model: af.Collection): """ super().modify_before_fit(paths=paths, model=model) - if not paths.is_complete: - logger.info( - "PRELOADS - Setting up preloads, may take a few minutes for fits using an inversion." - ) - - self.set_preloads(paths=paths, model=model) - return self def log_likelihood_function(self, instance): @@ -190,7 +182,6 @@ def log_likelihood_function(self, instance): def fit_from( self, instance: af.ModelInstance, - preload_overwrite: Optional[Preloads] = None, run_time_dict: Optional[Dict] = None, ) -> FitInterferometer: """ @@ -204,8 +195,6 @@ def fit_from( instance An instance of the model that is being fitted to the data by this analysis (whose parameters have been set via a non-linear search). - preload_overwrite - If a `Preload` object is input this is used instead of the preloads stored as an attribute in the analysis. check_positions Whether the multiple image positions of the lensed source should be checked, i.e. whether they trace within the position threshold of one another in the source plane. @@ -224,14 +213,11 @@ def fit_from( adapt_images = self.adapt_images_via_instance_from(instance=instance) - preloads = self.preloads if preload_overwrite is None else preload_overwrite - return FitInterferometer( dataset=self.dataset, tracer=tracer, adapt_images=adapt_images, settings_inversion=self.settings_inversion, - preloads=preloads, run_time_dict=run_time_dict, ) diff --git a/autolens/lens/to_inversion.py b/autolens/lens/to_inversion.py index 9bac26971..d2d264aed 100644 --- a/autolens/lens/to_inversion.py +++ b/autolens/lens/to_inversion.py @@ -9,8 +9,6 @@ from autoarray.inversion.inversion.factory import inversion_from -from autolens.analysis.preloads import Preloads - class TracerToInversion(ag.AbstractToInversion): def __init__( @@ -19,7 +17,6 @@ def __init__( tracer, adapt_images: Optional[ag.AdaptImages] = None, settings_inversion: aa.SettingsInversion = aa.SettingsInversion(), - preloads=Preloads(), run_time_dict: Optional[Dict] = None, ): """ @@ -55,8 +52,6 @@ def __init__( the pixelization's pixels to the brightest regions of the image. settings_inversion The settings of the inversion, which controls how the linear algebra calculation is performed. - preloads - Preloads of the inversion, which are used to speed up the linear algebra calculation. run_time_dict A dictionary of run-time values used to compute the inversion, for example the noise-map normalization. """ @@ -66,7 +61,6 @@ def __init__( dataset=dataset, adapt_images=adapt_images, settings_inversion=settings_inversion, - preloads=preloads, run_time_dict=run_time_dict, ) @@ -374,11 +368,7 @@ def traced_mesh_grid_pg_list(self) -> List[List]: ------- The list of lists of traced mesh grids grouped by plane. """ - if self.preloads.image_plane_mesh_grid_pg_list is None: - image_plane_mesh_grid_pg_list = self.image_plane_mesh_grid_pg_list - - else: - image_plane_mesh_grid_pg_list = self.preloads.image_plane_mesh_grid_pg_list + image_plane_mesh_grid_pg_list = self.image_plane_mesh_grid_pg_list traced_mesh_grid_pg_list = [] diff --git a/autolens/lens/tracer.py b/autolens/lens/tracer.py index 2ef985406..5b4f93114 100644 --- a/autolens/lens/tracer.py +++ b/autolens/lens/tracer.py @@ -413,9 +413,11 @@ def upper_plane_index_with_light_profile(self) -> int: """ return max( [ - plane_index - if any([galaxy.has(cls=ag.LightProfile) for galaxy in galaxies]) - else 0 + ( + plane_index + if any([galaxy.has(cls=ag.LightProfile) for galaxy in galaxies]) + else 0 + ) for (plane_index, galaxies) in enumerate(self.planes) ] ) diff --git a/docs/overview/overview_2_new_user_guide.rst b/docs/overview/overview_2_new_user_guide.rst index 9b3a8ce94..3399edb65 100644 --- a/docs/overview/overview_2_new_user_guide.rst +++ b/docs/overview/overview_2_new_user_guide.rst @@ -125,9 +125,11 @@ The ``autolens_workspace/guides`` package has many useful guides, including conc and unit conversion guides (``guides/units``). Quickly navigate to this part of the workspace and skim read the guides quickly. You do not need to understand them in detail now -so don't spend long reading them. T +so don't spend long reading them. -he purpose of looking at them now is you know they exist and can refer to them if you get stuck using **PyAutoLens**. +**If your dataset type is a point source, you should read the ``guides/point_source.ipynb`` guide now, which covers many details of point source modeling.** + +The purpose of looking at them now is you know they exist and can refer to them if you get stuck using **PyAutoLens**. GitHub Links: diff --git a/test_autolens/analysis/analysis/test_analysis_dataset.py b/test_autolens/analysis/analysis/test_analysis_dataset.py index daba9832d..4f93db1c4 100644 --- a/test_autolens/analysis/analysis/test_analysis_dataset.py +++ b/test_autolens/analysis/analysis/test_analysis_dataset.py @@ -40,31 +40,6 @@ def test__modify_before_fit__inversion_no_positions_likelihood__raises_exception analysis.modify_before_fit(paths=af.DirectoryPaths(), model=model) -def test__check_preloads(masked_imaging_7x7): - conf.instance["general"]["test"]["check_preloads"] = True - - lens_galaxy = al.Galaxy(redshift=0.5, light=al.lp.Sersic(intensity=0.1)) - - model = af.Collection(galaxies=af.Collection(lens=lens_galaxy)) - - analysis = al.AnalysisImaging(dataset=masked_imaging_7x7) - - instance = model.instance_from_unit_vector([]) - tracer = analysis.tracer_via_instance_from(instance=instance) - fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) - - analysis.preloads.check_via_fit(fit=fit) - - analysis.preloads.blurred_image = fit.blurred_image - - analysis.preloads.check_via_fit(fit=fit) - - analysis.preloads.blurred_image = fit.blurred_image + 1.0 - - with pytest.raises(exc.PreloadsException): - analysis.preloads.check_via_fit(fit=fit) - - def test__save_results__tracer_output_to_json(analysis_imaging_7x7): lens = al.Galaxy(redshift=0.5) source = al.Galaxy(redshift=1.0) diff --git a/test_autolens/analysis/test_analysis.py b/test_autolens/analysis/test_analysis.py index f3b6ae07e..ee76d14e1 100644 --- a/test_autolens/analysis/test_analysis.py +++ b/test_autolens/analysis/test_analysis.py @@ -150,31 +150,6 @@ def test__modify_before_fit__inversion_no_positions_likelihood__raises_exception analysis.modify_before_fit(paths=af.DirectoryPaths(), model=model) -def test__check_preloads(masked_imaging_7x7): - conf.instance["general"]["test"]["check_preloads"] = True - - lens_galaxy = al.Galaxy(redshift=0.5, light=al.lp.Sersic(intensity=0.1)) - - model = af.Collection(galaxies=af.Collection(lens=lens_galaxy)) - - analysis = al.AnalysisImaging(dataset=masked_imaging_7x7) - - instance = model.instance_from_unit_vector([]) - tracer = analysis.tracer_via_instance_from(instance=instance) - fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) - - analysis.preloads.check_via_fit(fit=fit) - - analysis.preloads.blurred_image = fit.blurred_image - - analysis.preloads.check_via_fit(fit=fit) - - analysis.preloads.blurred_image = fit.blurred_image + 1.0 - - with pytest.raises(exc.PreloadsException): - analysis.preloads.check_via_fit(fit=fit) - - def test__save_results__tracer_output_to_json(analysis_imaging_7x7): lens = al.Galaxy(redshift=0.5) source = al.Galaxy(redshift=1.0) diff --git a/test_autolens/analysis/test_preloads.py b/test_autolens/analysis/test_preloads.py deleted file mode 100644 index bb73ccd4f..000000000 --- a/test_autolens/analysis/test_preloads.py +++ /dev/null @@ -1,203 +0,0 @@ -import numpy as np -from os import path - -import autofit as af - -import autolens as al - - -def test__set_traced_grids_of_planes(): - - grid = al.Grid2D.no_mask( - values=np.array([[[1.0, 1.0]]]), - pixel_scales=1.0, - over_sampling=al.OverSamplingUniform(sub_size=1) - ) - - # traced grids is None so no Preloading. - - tracer_0 = al.m.MockTracer(traced_grid_2d_list_from=[None, None]) - tracer_1 = al.m.MockTracer(traced_grid_2d_list_from=[None, None]) - - fit_0 = al.m.MockFitImaging(tracer=tracer_0, grid=grid) - fit_1 = al.m.MockFitImaging(tracer=tracer_1, grid=grid) - - preloads = al.Preloads(traced_grids_of_planes_for_inversion=1) - preloads.set_traced_grids_of_planes_for_inversion(fit_0=fit_0, fit_1=fit_1) - - assert preloads.traced_grids_of_planes_for_inversion is None - - # traced grids are different, indicating the model parameters change the grid, so no preloading. - - tracer_0 = al.m.MockTracer(traced_grid_2d_list_from=[None, np.array([[1.0]])]) - tracer_1 = al.m.MockTracer(traced_grid_2d_list_from=[None, np.array([[2.0]])]) - - fit_0 = al.m.MockFitImaging(tracer=tracer_0, grid=grid) - fit_1 = al.m.MockFitImaging(tracer=tracer_1, grid=grid) - - preloads = al.Preloads(traced_grids_of_planes_for_inversion=1) - preloads.set_traced_grids_of_planes_for_inversion(fit_0=fit_0, fit_1=fit_1) - - assert preloads.traced_grids_of_planes_for_inversion is None - - # traced grids are the same meaning they are fixed in the model, so do preload. - - tracer_0 = al.m.MockTracer(traced_grid_2d_list_from=[None, np.array([[1.0]])]) - tracer_1 = al.m.MockTracer(traced_grid_2d_list_from=[None, np.array([[1.0]])]) - - fit_0 = al.m.MockFitImaging(tracer=tracer_0, grid=grid) - fit_1 = al.m.MockFitImaging(tracer=tracer_1, grid=grid) - - preloads = al.Preloads(traced_grids_of_planes_for_inversion=1) - preloads.set_traced_grids_of_planes_for_inversion(fit_0=fit_0, fit_1=fit_1) - - assert preloads.traced_grids_of_planes_for_inversion[0] is None - assert (preloads.traced_grids_of_planes_for_inversion[1] == np.array([[1.0]])).all() - - -def test__set_mesh_grid_of_planes(): - # sparse image plane of grids is None so no Preloading. - - tracer_0 = al.m.MockTracer(image_plane_mesh_grid_pg_list=[None, None]) - tracer_1 = al.m.MockTracer(image_plane_mesh_grid_pg_list=[None, None]) - - fit_0 = al.m.MockFitImaging(tracer=tracer_0) - fit_1 = al.m.MockFitImaging(tracer=tracer_1) - - preloads = al.Preloads(image_plane_mesh_grid_pg_list=1) - preloads.set_image_plane_mesh_grid_pg_list(fit_0=fit_0, fit_1=fit_1) - - assert preloads.image_plane_mesh_grid_pg_list is None - - # sparse image plane of grids are different, indicating the model parameters change the grid, so no preloading. - - tracer_0 = al.m.MockTracer(image_plane_mesh_grid_pg_list=[None, np.array([[1.0]])]) - tracer_1 = al.m.MockTracer(image_plane_mesh_grid_pg_list=[None, np.array([[2.0]])]) - - fit_0 = al.m.MockFitImaging(tracer=tracer_0) - fit_1 = al.m.MockFitImaging(tracer=tracer_1) - - preloads = al.Preloads(image_plane_mesh_grid_pg_list=1) - preloads.set_image_plane_mesh_grid_pg_list(fit_0=fit_0, fit_1=fit_1) - - assert preloads.image_plane_mesh_grid_pg_list is None - - # sparse image plane of grids are the same meaning they are fixed in the model, so do preload. - - tracer_0 = al.m.MockTracer(image_plane_mesh_grid_pg_list=[None, np.array([[1.0]])]) - tracer_1 = al.m.MockTracer(image_plane_mesh_grid_pg_list=[None, np.array([[1.0]])]) - - fit_0 = al.m.MockFitImaging(tracer=tracer_0) - fit_1 = al.m.MockFitImaging(tracer=tracer_1) - - preloads = al.Preloads(image_plane_mesh_grid_pg_list=1) - preloads.set_image_plane_mesh_grid_pg_list(fit_0=fit_0, fit_1=fit_1) - - assert preloads.image_plane_mesh_grid_pg_list[0] is None - assert (preloads.image_plane_mesh_grid_pg_list[1] == np.array([[1.0]])).all() - - -def test__info(): - file_path = path.join("{}".format(path.dirname(path.realpath(__file__))), "files") - - file_preloads = path.join(file_path, "preloads.summary") - - preloads = al.Preloads( - blurred_image=np.zeros(3), - w_tilde=None, - use_w_tilde=False, - traced_grids_of_planes_for_inversion=None, - image_plane_mesh_grid_pg_list=None, - relocated_grid=None, - mapper_list=None, - operated_mapping_matrix=None, - ) - - af.formatter.output_list_of_strings_to_file( - file=file_preloads, list_of_strings=preloads.info - ) - - results = open(file_preloads) - lines = results.readlines() - - i = 0 - - assert lines[i] == f"W Tilde = False\n" - i += 1 - assert lines[i] == f"Use W Tilde = False\n" - i += 1 - assert lines[i] == f"\n" - i += 1 - assert lines[i] == f"Blurred Image = False\n" - i += 1 - assert lines[i] == f"Traced Grids of Planes (For LEq) = False\n" - i += 1 - assert lines[i] == f"Sparse Image-Plane Grids of Planes = False\n" - i += 1 - assert lines[i] == f"Relocated Grid = False\n" - i += 1 - assert lines[i] == f"Mapper = False\n" - i += 1 - assert lines[i] == f"Blurred Mapping Matrix = False\n" - i += 1 - assert lines[i] == f"Inversion Linear Func (Linear Light Profile) Dicts = False\n" - i += 1 - assert lines[i] == f"Curvature Matrix = False\n" - i += 1 - assert lines[i] == f"Curvature Matrix Mapper Diag = False\n" - i += 1 - assert lines[i] == f"Regularization Matrix = False\n" - i += 1 - assert lines[i] == f"Log Det Regularization Matrix Term = False\n" - i += 1 - - preloads = al.Preloads( - blurred_image=1, - w_tilde=1, - use_w_tilde=True, - traced_grids_of_planes_for_inversion=1, - relocated_grid=1, - image_plane_mesh_grid_pg_list=1, - mapper_list=1, - operated_mapping_matrix=1, - regularization_matrix=1, - log_det_regularization_matrix_term=1, - ) - - af.formatter.output_list_of_strings_to_file( - file=file_preloads, list_of_strings=preloads.info - ) - - results = open(file_preloads) - lines = results.readlines() - - i = 0 - - assert lines[i] == f"W Tilde = True\n" - i += 1 - assert lines[i] == f"Use W Tilde = True\n" - i += 1 - assert lines[i] == f"\n" - i += 1 - assert lines[i] == f"Blurred Image = True\n" - i += 1 - assert lines[i] == f"Traced Grids of Planes (For LEq) = True\n" - i += 1 - assert lines[i] == f"Sparse Image-Plane Grids of Planes = True\n" - i += 1 - assert lines[i] == f"Relocated Grid = True\n" - i += 1 - assert lines[i] == f"Mapper = True\n" - i += 1 - assert lines[i] == f"Blurred Mapping Matrix = True\n" - i += 1 - assert lines[i] == f"Inversion Linear Func (Linear Light Profile) Dicts = False\n" - i += 1 - assert lines[i] == f"Curvature Matrix = False\n" - i += 1 - assert lines[i] == f"Curvature Matrix Mapper Diag = False\n" - i += 1 - assert lines[i] == f"Regularization Matrix = True\n" - i += 1 - assert lines[i] == f"Log Det Regularization Matrix Term = True\n" - i += 1 diff --git a/test_autolens/config/general.yaml b/test_autolens/config/general.yaml index e06e1b19d..58138096d 100644 --- a/test_autolens/config/general.yaml +++ b/test_autolens/config/general.yaml @@ -1,6 +1,5 @@ analysis: n_cores: 1 - preload_attempts: 250 fits: flip_for_ds9: true grid: @@ -37,7 +36,5 @@ profiling: repeats: 1 test: check_likelihood_function: false # if True, when a search is resumed the likelihood of a previous sample is recalculated to ensure it is consistent with the previous run. - check_preloads: false exception_override: false - preloads_check_threshold: 1.0 # If the figure of merit of a fit with and without preloads is greater than this threshold, the check preload test fails and an exception raised for a model-fit. disable_positions_lh_inversion_check: false diff --git a/test_autolens/config/visualize.yaml b/test_autolens/config/visualize.yaml index 9a249a24f..9405d0ced 100644 --- a/test_autolens/config/visualize.yaml +++ b/test_autolens/config/visualize.yaml @@ -5,7 +5,7 @@ general: zoom_around_mask: true include: include_2d: - border: true + border: false tangential_caustics: false radial_caustics: false tangential_critical_curves: false diff --git a/test_autolens/imaging/test_fit_imaging.py b/test_autolens/imaging/test_fit_imaging.py index 8ee67b66a..1279198a1 100644 --- a/test_autolens/imaging/test_fit_imaging.py +++ b/test_autolens/imaging/test_fit_imaging.py @@ -790,50 +790,6 @@ def test__tracer_linear_light_profiles_to_light_profiles(masked_imaging_7x7): assert tracer.galaxies[2].bulge.intensity == pytest.approx(0.08393533428, 1.0e-4) -def test__preloads__refit_with_new_preloads(masked_imaging_7x7): - - g0 = al.Galaxy( - redshift=0.5, - bulge=al.lp.Sersic(intensity=1.0), - mass_profile=al.mp.IsothermalSph(einstein_radius=1.0), - ) - - g1 = al.Galaxy(redshift=1.0, bulge=al.lp.Sersic(intensity=1.0)) - - tracer = al.Tracer(galaxies=[g0, g1]) - - fit = al.FitImaging(dataset=masked_imaging_7x7, tracer=tracer) - - refit = fit.refit_with_new_preloads(preloads=al.Preloads()) - - assert fit.figure_of_merit == refit.figure_of_merit - - refit = fit.refit_with_new_preloads( - preloads=al.Preloads(blurred_image=fit.blurred_image + 1.0) - ) - - assert fit.figure_of_merit != refit.figure_of_merit - - -def test__preloads__blurred_image_uses_preload_when_passed(masked_imaging_7x7_no_blur): - - g0 = al.Galaxy(redshift=0.5, bulge=al.lp.Sersic(intensity=1.0)) - - tracer = al.Tracer(galaxies=[g0]) - - fit = al.FitImaging(dataset=masked_imaging_7x7_no_blur, tracer=tracer) - - assert fit.blurred_image[0] == pytest.approx(0.15987, 1.0e-4) - - blurred_image = np.array([2.0]) - preloads = al.Preloads(blurred_image=blurred_image) - - fit = al.FitImaging( - dataset=masked_imaging_7x7_no_blur, tracer=tracer, preloads=preloads - ) - - assert (fit.blurred_image == np.array([2.0])).all() - def test__total_mappers(masked_imaging_7x7): diff --git a/test_autolens/imaging/test_simulate_and_fit_imaging.py b/test_autolens/imaging/test_simulate_and_fit_imaging.py index 7ddf91706..8e1f2759f 100644 --- a/test_autolens/imaging/test_simulate_and_fit_imaging.py +++ b/test_autolens/imaging/test_simulate_and_fit_imaging.py @@ -692,50 +692,6 @@ def test__simulate_imaging_data_and_fit__complex_fit_compare_mapping_matrix_w_ti 1.0e-4, ) - preloads = al.Preloads( - linear_func_operated_mapping_matrix_dict=fit_mapping.inversion.linear_func_operated_mapping_matrix_dict, - data_linear_func_matrix_dict=fit_mapping.inversion.data_linear_func_matrix_dict - ) - - fit_w_tilde = al.FitImaging( - dataset=masked_dataset, - tracer=tracer, - preloads=preloads, - settings_inversion=al.SettingsInversion(use_w_tilde=True), - ) - - assert fit_mapping.inversion.curvature_matrix == pytest.approx( - fit_w_tilde.inversion.curvature_matrix, - 1.0e-4, - ) - - assert fit_mapping.inversion.regularization_matrix == pytest.approx( - fit_w_tilde.inversion.regularization_matrix, - 1.0e-4, - ) - - preloads = al.Preloads( - mapper_operated_mapping_matrix_dict=fit_mapping.inversion.mapper_operated_mapping_matrix_dict, - ) - - fit_w_tilde = al.FitImaging( - dataset=masked_dataset, - tracer=tracer, - preloads=preloads, - settings_inversion=al.SettingsInversion(use_w_tilde=True), - ) - - assert fit_mapping.inversion.curvature_matrix == pytest.approx( - fit_w_tilde.inversion.curvature_matrix, - 1.0e-4, - ) - - assert fit_mapping.inversion.regularization_matrix == pytest.approx( - fit_w_tilde.inversion.regularization_matrix, - 1.0e-4, - ) - - def test__perfect_fit__chi_squared_0__non_uniform_over_sampling(): over_sampling = al.OverSamplingUniform(sub_size=8) From 73e2234b2de8b03362e30cee3d06e476773de95c Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Thu, 3 Oct 2024 13:46:53 +0100 Subject: [PATCH 2/5] remove more preload stuff --- autolens/aggregator/fit_imaging.py | 3 -- autolens/aggregator/fit_interferometer.py | 3 -- autolens/imaging/fit_imaging.py | 44 ----------------------- autolens/imaging/model/analysis.py | 5 +-- autolens/interferometer/model/analysis.py | 5 +-- autolens/lens/to_inversion.py | 19 ++-------- 6 files changed, 5 insertions(+), 74 deletions(-) diff --git a/autolens/aggregator/fit_imaging.py b/autolens/aggregator/fit_imaging.py index 0cbae78bc..b750b12ef 100644 --- a/autolens/aggregator/fit_imaging.py +++ b/autolens/aggregator/fit_imaging.py @@ -86,7 +86,6 @@ def __init__( self, aggregator: af.Aggregator, settings_inversion: Optional[aa.SettingsInversion] = None, - use_preloaded_grid: bool = True, ): """ Interfaces with an `PyAutoFit` aggregator object to create instances of `FitImaging` objects from the results @@ -128,7 +127,6 @@ def __init__( super().__init__(aggregator=aggregator) self.settings_inversion = settings_inversion - self.use_preloaded_grid = use_preloaded_grid def object_via_gen_from( self, fit, instance: Optional[af.ModelInstance] = None @@ -150,5 +148,4 @@ def object_via_gen_from( fit=fit, instance=instance, settings_inversion=self.settings_inversion, - use_preloaded_grid=self.use_preloaded_grid, ) diff --git a/autolens/aggregator/fit_interferometer.py b/autolens/aggregator/fit_interferometer.py index 6cb0d9ca7..50c953c42 100644 --- a/autolens/aggregator/fit_interferometer.py +++ b/autolens/aggregator/fit_interferometer.py @@ -88,7 +88,6 @@ def __init__( self, aggregator: af.Aggregator, settings_inversion: Optional[aa.SettingsInversion] = None, - use_preloaded_grid: bool = True, real_space_mask: Optional[aa.Mask2D] = None, ): """ @@ -127,7 +126,6 @@ def __init__( super().__init__(aggregator=aggregator) self.settings_inversion = settings_inversion - self.use_preloaded_grid = use_preloaded_grid self.real_space_mask = real_space_mask def object_via_gen_from( @@ -150,5 +148,4 @@ def object_via_gen_from( fit=fit, instance=instance, settings_inversion=self.settings_inversion, - use_preloaded_grid=self.use_preloaded_grid, ) diff --git a/autolens/imaging/fit_imaging.py b/autolens/imaging/fit_imaging.py index 827c5eefd..8a08c9c1e 100644 --- a/autolens/imaging/fit_imaging.py +++ b/autolens/imaging/fit_imaging.py @@ -104,9 +104,6 @@ def grids(self) -> aa.GridsInterface: def blurred_image(self) -> aa.Array2D: """ Returns the image of all light profiles in the fit's tracer convolved with the imaging dataset's PSF. - - For certain lens models the blurred image does not change (for example when all light profiles in the tracer - are fixed in the lens model). For faster run-times the blurred image can be preloaded. """ return self.tracer.blurred_image_2d_from( grid=self.grids.uniform, @@ -344,44 +341,3 @@ def tracer_linear_light_profiles_to_light_profiles(self) -> Tracer: or `GalaxyPlotter` objects. """ return self.model_obj_linear_light_profiles_to_light_profiles - - def refit_with_new_preloads( - self, - preloads: Preloads, - settings_inversion: Optional[aa.SettingsInversion] = None, - ) -> "FitImaging": - """ - Returns a new fit which uses the dataset, tracer and other objects of this fit, but uses a different set of - preloads input into this function. - - This is used when setting up the preloads objects, to concisely test how using different preloads objects - changes the attributes of the fit. - - Parameters - ---------- - preloads - The new preloads which are used to refit the data using the - settings_inversion - Settings controlling how an inversion is fitted for example which linear algebra formalism is used. - - Returns - ------- - A new fit which has used new preloads input into this function but the same dataset, tracer and other settings. - """ - run_time_dict = {} if self.run_time_dict is not None else None - - settings_inversion = ( - self.settings_inversion - if settings_inversion is None - else settings_inversion - ) - - return FitImaging( - dataset=self.dataset, - tracer=self.tracer, - dataset_model=self.dataset_model, - adapt_images=self.adapt_images, - settings_inversion=settings_inversion, - preloads=preloads, - run_time_dict=run_time_dict, - ) \ No newline at end of file diff --git a/autolens/imaging/model/analysis.py b/autolens/imaging/model/analysis.py index 32fa82019..df556205c 100644 --- a/autolens/imaging/model/analysis.py +++ b/autolens/imaging/model/analysis.py @@ -184,9 +184,6 @@ def save_attributes(self, paths: af.DirectoryPaths): - Its PSF. - Its mask. - The positions of the brightest pixels in the lensed source which are used to discard mass models. - - The preloaded image-plane source plane pixelization if used by the analysis. This ensures that differences in - the scikit-learn library do not lead to different pixelizations being computed if results are transferred from - a HPC to laptop. It is common for these attributes to be loaded by many of the template aggregator functions given in the `aggregator` modules. For example, when using the database tools to perform a fit, the default behaviour is for @@ -227,7 +224,7 @@ def profile_log_likelihood_function( An `info_dict` is also created which stores information on aspects of the model and dataset that dictate run times, so the profiled times can be interpreted with this context. - The results of this profiling are then output to hard-disk in the `preloads` folder of the model-fit results, + The results of this profiling are then output to hard-disk in the `profiling` folder of the model-fit results, which they can be inspected to ensure run-times are as expected. Parameters diff --git a/autolens/interferometer/model/analysis.py b/autolens/interferometer/model/analysis.py index 165709319..ff8331693 100644 --- a/autolens/interferometer/model/analysis.py +++ b/autolens/interferometer/model/analysis.py @@ -241,9 +241,6 @@ def save_attributes(self, paths: af.DirectoryPaths): - Its uv-wavelengths - Its real space mask. - The positions of the brightest pixels in the lensed source which are used to discard mass models. - - The preloaded image-plane source plane pixelization if used by the analysis. This ensures that differences in - the scikit-learn library do not lead to different pixelizations being computed if results are transferred from - a HPC to laptop. It is common for these attributes to be loaded by many of the template aggregator functions given in the `aggregator` modules. For example, when using the database tools to perform a fit, the default behaviour is for @@ -283,7 +280,7 @@ def profile_log_likelihood_function( An `info_dict` is also created which stores information on aspects of the model and dataset that dictate run times, so the profiled times can be interpreted with this context. - The results of this profiling are then output to hard-disk in the `preloads` folder of the model-fit results, + The results of this profiling are then output to hard-disk in the `profiling` folder of the model-fit results, which they can be inspected to ensure run-times are as expected. Parameters diff --git a/autolens/lens/to_inversion.py b/autolens/lens/to_inversion.py index d2d264aed..da50371d3 100644 --- a/autolens/lens/to_inversion.py +++ b/autolens/lens/to_inversion.py @@ -422,28 +422,16 @@ def mapper_galaxy_dict(self) -> Dict[aa.AbstractMapper, ag.Galaxy]: mapper_galaxy_dict = {} - if self.preloads.traced_grids_of_planes_for_inversion is None: - traced_grids_of_planes_list = self.traced_grid_2d_list_of_inversion - else: - traced_grids_of_planes_list = ( - self.preloads.traced_grids_of_planes_for_inversion - ) + traced_grids_of_planes_list = self.traced_grid_2d_list_of_inversion - if self.preloads.traced_mesh_grids_list_of_planes is None: - traced_mesh_grids_list_of_planes = self.traced_mesh_grid_pg_list - image_plane_mesh_grid_list = self.image_plane_mesh_grid_pg_list - else: - traced_mesh_grids_list_of_planes = ( - self.preloads.traced_mesh_grids_list_of_planes - ) - image_plane_mesh_grid_list = self.preloads.image_plane_mesh_grid_list + traced_mesh_grids_list_of_planes = self.traced_mesh_grid_pg_list + image_plane_mesh_grid_list = self.image_plane_mesh_grid_pg_list for plane_index, galaxies in enumerate(self.planes): if galaxies.has(cls=aa.Pixelization): to_inversion = ag.GalaxiesToInversion( dataset=self.dataset, galaxies=galaxies, - preloads=self.preloads, adapt_images=self.adapt_images, settings_inversion=self.settings_inversion, run_time_dict=self.run_time_dict, @@ -510,7 +498,6 @@ def inversion(self): dataset=self.dataset, linear_obj_list=self.linear_obj_list, settings=self.settings_inversion, - preloads=self.preloads, run_time_dict=self.tracer.run_time_dict, ) From df3abe3abfff7b623e05e920e60994e7699a02ab Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 8 Nov 2024 16:35:43 +0000 Subject: [PATCH 3/5] use the new jax coordinate array triangles --- test_autolens/point/triangles/test_solver_jax.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test_autolens/point/triangles/test_solver_jax.py b/test_autolens/point/triangles/test_solver_jax.py index 1667a634f..ff01ae9a7 100644 --- a/test_autolens/point/triangles/test_solver_jax.py +++ b/test_autolens/point/triangles/test_solver_jax.py @@ -9,9 +9,11 @@ from autolens import PointSolver try: - from autoarray.structures.triangles.jax_array import ArrayTriangles + from autoarray.structures.triangles.coordinate_array import CoordinateArrayTriangles except ImportError: - from autoarray.structures.triangles.array import ArrayTriangles + from autoarray.structures.triangles.jax_coordinate_array import ( + CoordinateArrayTriangles, + ) from autolens.mock import NullTracer @@ -28,7 +30,7 @@ def solver(grid): return PointSolver.for_grid( grid=grid, pixel_scale_precision=0.01, - array_triangles_cls=ArrayTriangles, + array_triangles_cls=CoordinateArrayTriangles, ) @@ -72,7 +74,7 @@ def test_real_example(grid, tracer): solver = PointSolver.for_grid( grid=grid, pixel_scale_precision=0.001, - array_triangles_cls=ArrayTriangles, + array_triangles_cls=CoordinateArrayTriangles, ) result = solver.solve(tracer, (0.07, 0.07)) @@ -89,7 +91,7 @@ def _test_jax(grid): solver = PointSolver.for_grid( grid=grid, pixel_scale_precision=0.001, - array_triangles_cls=ArrayTriangles, + array_triangles_cls=CoordinateArrayTriangles, max_containing_size=size, ) From 4d031d6b28ef49c21249679ccf84b01af47ac6d4 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 11 Nov 2024 11:21:28 +0000 Subject: [PATCH 4/5] use jax coordinate array in more tests --- test_autolens/point/triangles/test_solver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index e9e25716e..6a5334bbe 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -4,7 +4,7 @@ import autolens as al import autogalaxy as ag -from autoarray.structures.triangles.array import ArrayTriangles +from autoarray.structures.triangles.jax_coordinate_array import ArrayTriangles from autolens.mock import NullTracer from autolens.point.solver import PointSolver From f8985ba55d3ef942848d1333eaa3ba1d779cad83 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Wed, 22 Jan 2025 19:38:05 +0000 Subject: [PATCH 5/5] changes for merge --- .github/workflows/main.yml | 198 +-- autolens/config/general.yaml | 8 +- autolens/config/non_linear.yaml | 132 +- autolens/point/solver/__init__.py | 2 +- autolens/point/solver/point_solver.py | 176 +-- autolens/point/solver/shape_solver.py | 682 +++++----- autolens/point/solver/step.py | 106 +- autolens/point/visualise.py | 48 +- eden.ini | 6 +- optional_requirements.txt | 14 +- release.sh | 62 +- test_autolens/config/general.yaml | 80 +- test_autolens/config/grids.yaml | 432 +++--- test_autolens/config/non_linear.yaml | 166 +-- test_autolens/config/notation.yaml | 168 +-- test_autolens/config/output.yaml | 126 +- .../config/priors/dark_mass_profiles.yaml | 676 +++++----- test_autolens/config/priors/galaxy.yaml | 34 +- .../config/priors/geometry_profiles.yaml | 96 +- .../config/priors/light_profiles.yaml | 532 ++++---- test_autolens/config/priors/mass_sheets.yaml | 42 +- .../config/priors/pixelizations.yaml | 250 ++-- .../config/priors/regularization.yaml | 78 +- .../config/priors/stellar_mass_profiles.yaml | 1192 ++++++++--------- .../config/priors/total_mass_profiles.yaml | 982 +++++++------- test_autolens/config/visualize.yaml | 306 ++--- test_autolens/point/files/point_dict.json | 70 +- .../point/test_point_source_dataset.py | 28 +- test_autolens/point/triangles/conftest.py | 60 +- .../point/triangles/test_extended.py | 48 +- test_autolens/point/triangles/test_jax.py | 24 +- .../point/triangles/test_regressions.py | 152 +-- test_autolens/point/triangles/test_solver.py | 164 +-- .../point/triangles/test_solver_jax.py | 238 ++-- 34 files changed, 3689 insertions(+), 3689 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb33428c5..ccdd8205f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,99 +1,99 @@ -name: Tests - -on: [push, pull_request] - -jobs: - unittest: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.9, '3.10', '3.11', '3.12'] - steps: - - name: Checkout PyAutoConf - uses: actions/checkout@v2 - with: - repository: rhayes777/PyAutoConf - path: PyAutoConf - - name: Checkout PyAutoFit - uses: actions/checkout@v2 - with: - repository: rhayes777/PyAutoFit - path: PyAutoFit - - name: Checkout PyAutoArray - uses: actions/checkout@v2 - with: - repository: Jammy2211/PyAutoArray - path: PyAutoArray - - name: Checkout PyAutoGalaxy - uses: actions/checkout@v2 - with: - repository: Jammy2211/PyAutoGalaxy - path: PyAutoGalaxy - - name: Checkout PyAutoLens - uses: actions/checkout@v2 - with: - path: PyAutoLens - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Extract branch name - shell: bash - run: | - cd PyAutoLens - echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - name: Change to same branch if exists in deps - shell: bash - run: | - export PACKAGES=("PyAutoConf" "PyAutoArray" "PyAutoFit" "PyAutoGalaxy") - export BRANCH="${{ steps.extract_branch.outputs.branch }}" - for PACKAGE in ${PACKAGES[@]}; do - pushd $PACKAGE - export existed_in_remote=$(git ls-remote --heads origin ${BRANCH}) - - if [[ -z ${existed_in_remote} ]]; then - echo "Branch $BRANCH did not exist in $PACKAGE" - else - echo "Branch $BRANCH did exist in $PACKAGE" - git fetch - git checkout $BRANCH - fi - popd - done - - name: Install dependencies - run: | - pip3 install --upgrade pip - pip3 install setuptools - pip3 install wheel - pip3 install pytest coverage pytest-cov - pip3 install -r PyAutoConf/requirements.txt - pip3 install -r PyAutoFit/requirements.txt - pip3 install -r PyAutoArray/requirements.txt - pip3 install -r PyAutoArray/optional_requirements.txt - pip3 install -r PyAutoGalaxy/requirements.txt - pip3 install -r PyAutoGalaxy/optional_requirements.txt - pip3 install -r PyAutoLens/requirements.txt - pip3 install -r PyAutoLens/optional_requirements.txt - - name: Run tests - run: | - export ROOT_DIR=`pwd` - export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoConf - export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoFit - export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoArray - export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoGalaxy - export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoLens - pushd PyAutoLens - pytest --cov autolens --cov-report xml:coverage.xml - - name: Slack send - if: ${{ failure() }} - id: slack - uses: slackapi/slack-github-action@v1.21.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - channel-id: C03S98FEDK2 - payload: | - { - "text": "${{ github.repository }}/${{ github.ref_name }} (Python ${{ matrix.python-version }}) build result: ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } +name: Tests + +on: [push, pull_request] + +jobs: + unittest: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9, '3.10', '3.11', '3.12'] + steps: + - name: Checkout PyAutoConf + uses: actions/checkout@v2 + with: + repository: rhayes777/PyAutoConf + path: PyAutoConf + - name: Checkout PyAutoFit + uses: actions/checkout@v2 + with: + repository: rhayes777/PyAutoFit + path: PyAutoFit + - name: Checkout PyAutoArray + uses: actions/checkout@v2 + with: + repository: Jammy2211/PyAutoArray + path: PyAutoArray + - name: Checkout PyAutoGalaxy + uses: actions/checkout@v2 + with: + repository: Jammy2211/PyAutoGalaxy + path: PyAutoGalaxy + - name: Checkout PyAutoLens + uses: actions/checkout@v2 + with: + path: PyAutoLens + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Extract branch name + shell: bash + run: | + cd PyAutoLens + echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + - name: Change to same branch if exists in deps + shell: bash + run: | + export PACKAGES=("PyAutoConf" "PyAutoArray" "PyAutoFit" "PyAutoGalaxy") + export BRANCH="${{ steps.extract_branch.outputs.branch }}" + for PACKAGE in ${PACKAGES[@]}; do + pushd $PACKAGE + export existed_in_remote=$(git ls-remote --heads origin ${BRANCH}) + + if [[ -z ${existed_in_remote} ]]; then + echo "Branch $BRANCH did not exist in $PACKAGE" + else + echo "Branch $BRANCH did exist in $PACKAGE" + git fetch + git checkout $BRANCH + fi + popd + done + - name: Install dependencies + run: | + pip3 install --upgrade pip + pip3 install setuptools + pip3 install wheel + pip3 install pytest coverage pytest-cov + pip3 install -r PyAutoConf/requirements.txt + pip3 install -r PyAutoFit/requirements.txt + pip3 install -r PyAutoArray/requirements.txt + pip3 install -r PyAutoArray/optional_requirements.txt + pip3 install -r PyAutoGalaxy/requirements.txt + pip3 install -r PyAutoGalaxy/optional_requirements.txt + pip3 install -r PyAutoLens/requirements.txt + pip3 install -r PyAutoLens/optional_requirements.txt + - name: Run tests + run: | + export ROOT_DIR=`pwd` + export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoConf + export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoFit + export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoArray + export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoGalaxy + export PYTHONPATH=$PYTHONPATH:$ROOT_DIR/PyAutoLens + pushd PyAutoLens + pytest --cov autolens --cov-report xml:coverage.xml + - name: Slack send + if: ${{ failure() }} + id: slack + uses: slackapi/slack-github-action@v1.21.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + channel-id: C03S98FEDK2 + payload: | + { + "text": "${{ github.repository }}/${{ github.ref_name }} (Python ${{ matrix.python-version }}) build result: ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } diff --git a/autolens/config/general.yaml b/autolens/config/general.yaml index 32229bf70..75e85a7dd 100644 --- a/autolens/config/general.yaml +++ b/autolens/config/general.yaml @@ -1,4 +1,4 @@ -output: - fit_dill: false -test: - disable_positions_lh_inversion_check: false +output: + fit_dill: false +test: + disable_positions_lh_inversion_check: false diff --git a/autolens/config/non_linear.yaml b/autolens/config/non_linear.yaml index 334c3448e..2ed0f9508 100644 --- a/autolens/config/non_linear.yaml +++ b/autolens/config/non_linear.yaml @@ -1,66 +1,66 @@ -nest: - DynestyDynamic: - initialize: - method: prior - parallel: - force_x1_cpu: false - number_of_cores: 1 - printing: - silence: false - run: - dlogz_init: 0.01 - logl_max_init: .inf - maxcall: null - maxcall_init: null - maxiter: null - maxiter_init: null - n_effective: .inf - n_effective_init: .inf - nlive_init: 500 - search: - bootstrap: null - bound: multi - enlarge: null - facc: 0.2 - first_update: null - fmove: 0.9 - max_move: 100 - sample: rwalk - slices: 5 - update_interval: null - walks: 5 - updates: - iterations_per_update: 2500 - remove_state_files_at_end: true - DynestyStatic: - initialize: - method: prior - parallel: - number_of_cores: 1 - printing: - silence: false - run: - dlogz: null - logl_max: .inf - maxcall: null - maxiter: null - n_effective: null - search: - bootstrap: null - bound: multi - enlarge: null - facc: 0.2 - first_update: null - fmove: 0.9 - max_move: 100 - nlive: 50 - sample: rwalk - slices: 5 - update_interval: null - walks: 5 - updates: - iterations_per_update: 5000 - log_every_update: 1 - model_results_every_update: 1 - remove_state_files_at_end: true - visualize_every_update: 1 +nest: + DynestyDynamic: + initialize: + method: prior + parallel: + force_x1_cpu: false + number_of_cores: 1 + printing: + silence: false + run: + dlogz_init: 0.01 + logl_max_init: .inf + maxcall: null + maxcall_init: null + maxiter: null + maxiter_init: null + n_effective: .inf + n_effective_init: .inf + nlive_init: 500 + search: + bootstrap: null + bound: multi + enlarge: null + facc: 0.2 + first_update: null + fmove: 0.9 + max_move: 100 + sample: rwalk + slices: 5 + update_interval: null + walks: 5 + updates: + iterations_per_update: 2500 + remove_state_files_at_end: true + DynestyStatic: + initialize: + method: prior + parallel: + number_of_cores: 1 + printing: + silence: false + run: + dlogz: null + logl_max: .inf + maxcall: null + maxiter: null + n_effective: null + search: + bootstrap: null + bound: multi + enlarge: null + facc: 0.2 + first_update: null + fmove: 0.9 + max_move: 100 + nlive: 50 + sample: rwalk + slices: 5 + update_interval: null + walks: 5 + updates: + iterations_per_update: 5000 + log_every_update: 1 + model_results_every_update: 1 + remove_state_files_at_end: true + visualize_every_update: 1 diff --git a/autolens/point/solver/__init__.py b/autolens/point/solver/__init__.py index 2751beef9..d9cf14301 100644 --- a/autolens/point/solver/__init__.py +++ b/autolens/point/solver/__init__.py @@ -1 +1 @@ -from .point_solver import PointSolver +from .point_solver import PointSolver diff --git a/autolens/point/solver/point_solver.py b/autolens/point/solver/point_solver.py index 9cdecfd00..15040d869 100644 --- a/autolens/point/solver/point_solver.py +++ b/autolens/point/solver/point_solver.py @@ -1,88 +1,88 @@ -import logging -from typing import Tuple, Optional - -from autoarray.numpy_wrapper import np - -import autoarray as aa -from autoarray.numpy_wrapper import use_jax -from autoarray.structures.triangles.shape import Point - -from autofit.jax_wrapper import jit, register_pytree_node_class -from autogalaxy import OperateDeflections -from .shape_solver import AbstractSolver - - -logger = logging.getLogger(__name__) - - -@register_pytree_node_class -class PointSolver(AbstractSolver): - @jit - def solve( - self, - tracer: OperateDeflections, - source_plane_coordinate: Tuple[float, float], - source_plane_redshift: Optional[float] = None, - ) -> aa.Grid2DIrregular: - """ - Solve for the image plane coordinates that are traced to the source plane coordinate. - - This is done by tiling the image plane with triangles and checking if the source plane coordinate is contained - within the triangle. The triangles are subsampled to increase the resolution with only the triangles that - contain the source plane coordinate and their neighbours being kept. - - The means of the triangles are then filtered to keep only those with an absolute magnification above the - threshold. - - Parameters - ---------- - source_plane_coordinate - The source plane coordinate to trace to the image plane. - tracer - The tracer that traces the image plane coordinates to the source plane - source_plane_redshift - The redshift of the source plane coordinate. - - Returns - ------- - A list of image plane coordinates that are traced to the source plane coordinate. - """ - kept_triangles = super().solve_triangles( - tracer=tracer, - shape=Point(*source_plane_coordinate), - source_plane_redshift=source_plane_redshift, - ) - filtered_means = self._filter_low_magnification( - tracer=tracer, points=kept_triangles.means - ) - if use_jax: - return aa.Grid2DIrregular([pair for pair in filtered_means]) - - filtered_means = [ - pair for pair in filtered_means if not np.any(np.isnan(pair)).all() - ] - - difference = len(kept_triangles.means) - len(filtered_means) - if difference > 0: - logger.debug( - f"Filtered one multiple-image with magnification below threshold." - ) - elif difference > 1: - logger.warning( - f"Filtered {difference} multiple-images with magnification below threshold." - ) - - filtered_close = [] - - for mean in filtered_means: - if any( - np.linalg.norm(np.array(mean) - np.array(other)) - <= self.pixel_scale_precision - for other in filtered_close - ): - continue - filtered_close.append(mean) - - return aa.Grid2DIrregular( - [pair for pair in filtered_close if not np.isnan(pair).all()] - ) +import logging +from typing import Tuple, Optional + +from autoarray.numpy_wrapper import np + +import autoarray as aa +from autoarray.numpy_wrapper import use_jax +from autoarray.structures.triangles.shape import Point + +from autofit.jax_wrapper import jit, register_pytree_node_class +from autogalaxy import OperateDeflections +from .shape_solver import AbstractSolver + + +logger = logging.getLogger(__name__) + + +@register_pytree_node_class +class PointSolver(AbstractSolver): + @jit + def solve( + self, + tracer: OperateDeflections, + source_plane_coordinate: Tuple[float, float], + source_plane_redshift: Optional[float] = None, + ) -> aa.Grid2DIrregular: + """ + Solve for the image plane coordinates that are traced to the source plane coordinate. + + This is done by tiling the image plane with triangles and checking if the source plane coordinate is contained + within the triangle. The triangles are subsampled to increase the resolution with only the triangles that + contain the source plane coordinate and their neighbours being kept. + + The means of the triangles are then filtered to keep only those with an absolute magnification above the + threshold. + + Parameters + ---------- + source_plane_coordinate + The source plane coordinate to trace to the image plane. + tracer + The tracer that traces the image plane coordinates to the source plane + source_plane_redshift + The redshift of the source plane coordinate. + + Returns + ------- + A list of image plane coordinates that are traced to the source plane coordinate. + """ + kept_triangles = super().solve_triangles( + tracer=tracer, + shape=Point(*source_plane_coordinate), + source_plane_redshift=source_plane_redshift, + ) + filtered_means = self._filter_low_magnification( + tracer=tracer, points=kept_triangles.means + ) + if use_jax: + return aa.Grid2DIrregular([pair for pair in filtered_means]) + + filtered_means = [ + pair for pair in filtered_means if not np.any(np.isnan(pair)).all() + ] + + difference = len(kept_triangles.means) - len(filtered_means) + if difference > 0: + logger.debug( + f"Filtered one multiple-image with magnification below threshold." + ) + elif difference > 1: + logger.warning( + f"Filtered {difference} multiple-images with magnification below threshold." + ) + + filtered_close = [] + + for mean in filtered_means: + if any( + np.linalg.norm(np.array(mean) - np.array(other)) + <= self.pixel_scale_precision + for other in filtered_close + ): + continue + filtered_close.append(mean) + + return aa.Grid2DIrregular( + [pair for pair in filtered_close if not np.isnan(pair).all()] + ) diff --git a/autolens/point/solver/shape_solver.py b/autolens/point/solver/shape_solver.py index 2a8dd3afe..88d7e379a 100644 --- a/autolens/point/solver/shape_solver.py +++ b/autolens/point/solver/shape_solver.py @@ -1,341 +1,341 @@ -import logging -import math - -from typing import Tuple, List, Iterator, Type, Optional - -import autoarray as aa - -from autoarray.structures.triangles.shape import Shape -from autofit.jax_wrapper import jit, use_jax, numpy as np, register_pytree_node_class - -try: - if use_jax: - from autoarray.structures.triangles.jax_array import ( - ArrayTriangles, - MAX_CONTAINING_SIZE, - ) - else: - from autoarray.structures.triangles.array import ArrayTriangles - - MAX_CONTAINING_SIZE = None - -except ImportError: - from autoarray.structures.triangles.array import ArrayTriangles - - MAX_CONTAINING_SIZE = None - -from autoarray.structures.triangles.abstract import AbstractTriangles - -from autogalaxy import OperateDeflections -from .step import Step - -logger = logging.getLogger(__name__) - - -class AbstractSolver: - # noinspection PyPep8Naming - def __init__( - self, - scale: float, - initial_triangles: AbstractTriangles, - pixel_scale_precision: float, - magnification_threshold=0.1, - ): - """ - Determine the image plane coordinates that are traced to be a source plane coordinate. - - This is performed efficiently by iteratively subdividing the image plane into triangles and checking if the - source plane coordinate is contained within the triangle. The triangles are subsampled to increase the - resolution - - Parameters - ---------- - pixel_scale_precision - The target pixel scale of the image grid. - """ - self.scale = scale - self.pixel_scale_precision = pixel_scale_precision - self.magnification_threshold = magnification_threshold - - self.initial_triangles = initial_triangles - - # noinspection PyPep8Naming - @classmethod - def for_grid( - cls, - grid: aa.Grid2D, - pixel_scale_precision: float, - magnification_threshold=0.1, - array_triangles_cls: Type[AbstractTriangles] = ArrayTriangles, - max_containing_size=MAX_CONTAINING_SIZE, - ): - """ - Create a solver for a given grid. - - The grid defines the limits of the image plane and the pixel scale. - - Parameters - ---------- - grid - The grid to use. - pixel_scale_precision - The precision to which the triangles should be subdivided. - magnification_threshold - The threshold for the magnification under which multiple images are filtered. - array_triangles_cls - The class to use for the triangles. JAX is used implicitly if USE_JAX=1 and - jax is installed. - max_containing_size - Only applies to JAX. This is the maximum number of multiple images expected. - We need to know this in advance to allocate memory for the JAX array. - - Returns - ------- - The solver. - """ - scale = grid.pixel_scale - - y = grid[:, 0] - x = grid[:, 1] - - y_min = y.min() - y_max = y.max() - x_min = x.min() - x_max = x.max() - - initial_triangles = array_triangles_cls.for_limits_and_scale( - y_min=y_min, - y_max=y_max, - x_min=x_min, - x_max=x_max, - scale=scale, - max_containing_size=max_containing_size, - ) - - return cls( - scale=scale, - initial_triangles=initial_triangles, - pixel_scale_precision=pixel_scale_precision, - magnification_threshold=magnification_threshold, - ) - - @property - def n_steps(self) -> int: - """ - How many times should triangles be subdivided? - """ - return math.ceil(math.log2(self.scale / self.pixel_scale_precision)) - - @staticmethod - def _source_plane_grid( - tracer: OperateDeflections, - grid: aa.type.Grid2DLike, - source_plane_redshift: Optional[float] = None, - ) -> aa.type.Grid2DLike: - """ - Calculate the source plane grid from the image plane grid. - - Parameters - ---------- - grid - The image plane grid. - - Returns - ------- - The source plane grid computed by applying the deflections to the image plane grid. - """ - - source_plane_index = -1 - - if source_plane_redshift is not None: - for redshift in tracer.plane_redshifts: - source_plane_index += 1 - if redshift == source_plane_redshift: - break - - deflections = tracer.deflections_between_planes_from( - grid=grid, plane_i=0, plane_j=source_plane_index - ) - # noinspection PyTypeChecker - return grid.grid_2d_via_deflection_grid_from(deflection_grid=deflections) - - @jit - def solve_triangles( - self, - tracer: OperateDeflections, - shape: Shape, - source_plane_redshift: Optional[float] = None, - ) -> AbstractTriangles: - """ - Solve for the image plane coordinates that are traced to the source plane coordinate. - - This is done by tiling the image plane with triangles and checking if the source plane coordinate is contained - within the triangle. The triangles are subsampled to increase the resolution with only the triangles that - contain the source plane coordinate and their neighbours being kept. - - The means of the triangles are then filtered to keep only those with an absolute magnification above the - threshold. - - Parameters - ---------- - tracer - The tracer to use to trace the image plane coordinates to the source plane. - shape - The shape in the source plane for which we want to identify the image plane coordinates. - source_plane_redshift - The redshift of the source plane. - - Returns - ------- - A list of image plane coordinates that are traced to the source plane coordinate. - """ - if self.n_steps == 0: - raise ValueError( - "The target pixel scale is too large to subdivide the triangles." - ) - - steps = list( - self.steps( - tracer=tracer, - shape=shape, - source_plane_redshift=source_plane_redshift, - ) - ) - final_step = steps[-1] - return final_step.filtered_triangles - - def _filter_low_magnification( - self, tracer: OperateDeflections, points: List[Tuple[float, float]] - ) -> List[Tuple[float, float]]: - """ - Filter the points to keep only those with an absolute magnification above the threshold. - - Parameters - ---------- - points - The points to filter. - - Returns - ------- - The points with an absolute magnification above the threshold. - """ - points = np.array(points) - magnifications = tracer.magnification_2d_via_hessian_from( - grid=aa.Grid2DIrregular(points), - buffer=self.scale, - ) - mask = np.abs(magnifications.array) > self.magnification_threshold - return np.where(mask[:, None], points, np.nan) - - def _filtered_triangles( - self, - tracer: OperateDeflections, - triangles: aa.AbstractTriangles, - source_plane_redshift, - shape: Shape, - ): - """ - Filter the triangles to keep only those that meet the solver condition - """ - source_plane_grid = self._source_plane_grid( - tracer=tracer, - grid=aa.Grid2DIrregular(triangles.vertices), - source_plane_redshift=source_plane_redshift, - ) - source_triangles = triangles.with_vertices(source_plane_grid.array) - - indexes = source_triangles.containing_indices(shape=shape) - - return triangles.for_indexes(indexes=indexes) - - def steps( - self, - tracer: OperateDeflections, - shape: Shape, - source_plane_redshift: Optional[float] = None, - ) -> Iterator[Step]: - """ - Iterate over the steps of the triangle solver algorithm. - - Parameters - ---------- - tracer - The tracer to use to trace the image plane coordinates to the source plane. - source_plane_redshift - The redshift of the source plane. - shape - The shape in the source plane for which we want to identify the image plane coordinates. - - Returns - ------- - An iterator over the steps of the triangle solver algorithm. - """ - initial_triangles = self.initial_triangles - for number in range(self.n_steps): - kept_triangles = self._filtered_triangles( - tracer=tracer, - triangles=initial_triangles, - source_plane_redshift=source_plane_redshift, - shape=shape, - ) - neighbourhood = kept_triangles.neighborhood() - up_sampled = neighbourhood.up_sample() - - yield Step( - number=number, - initial_triangles=initial_triangles, - filtered_triangles=kept_triangles, - neighbourhood=neighbourhood, - up_sampled=up_sampled, - ) - - initial_triangles = up_sampled - - def tree_flatten(self): - return (), ( - self.scale, - self.pixel_scale_precision, - self.magnification_threshold, - self.initial_triangles, - ) - - @classmethod - def tree_unflatten(cls, aux_data, children): - return cls( - scale=aux_data[0], - pixel_scale_precision=aux_data[1], - magnification_threshold=aux_data[2], - initial_triangles=aux_data[3], - ) - - -@register_pytree_node_class -class ShapeSolver(AbstractSolver): - def find_magnification( - self, - tracer: OperateDeflections, - shape: Shape, - source_plane_redshift: Optional[float] = None, - ) -> float: - """ - Find the magnification of the shape in the source plane. - - Parameters - ---------- - tracer - A tracer that traces the image plane to the source plane. - shape - The shape of an image plane pixel. - source_plane_redshift - The redshift of the source plane. - - Returns - ------- - The magnification of the shape in the source plane. - """ - kept_triangles = super().solve_triangles( - tracer=tracer, - shape=shape, - source_plane_redshift=source_plane_redshift, - ) - return kept_triangles.area / shape.area +import logging +import math + +from typing import Tuple, List, Iterator, Type, Optional + +import autoarray as aa + +from autoarray.structures.triangles.shape import Shape +from autofit.jax_wrapper import jit, use_jax, numpy as np, register_pytree_node_class + +try: + if use_jax: + from autoarray.structures.triangles.jax_array import ( + ArrayTriangles, + MAX_CONTAINING_SIZE, + ) + else: + from autoarray.structures.triangles.array import ArrayTriangles + + MAX_CONTAINING_SIZE = None + +except ImportError: + from autoarray.structures.triangles.array import ArrayTriangles + + MAX_CONTAINING_SIZE = None + +from autoarray.structures.triangles.abstract import AbstractTriangles + +from autogalaxy import OperateDeflections +from .step import Step + +logger = logging.getLogger(__name__) + + +class AbstractSolver: + # noinspection PyPep8Naming + def __init__( + self, + scale: float, + initial_triangles: AbstractTriangles, + pixel_scale_precision: float, + magnification_threshold=0.1, + ): + """ + Determine the image plane coordinates that are traced to be a source plane coordinate. + + This is performed efficiently by iteratively subdividing the image plane into triangles and checking if the + source plane coordinate is contained within the triangle. The triangles are subsampled to increase the + resolution + + Parameters + ---------- + pixel_scale_precision + The target pixel scale of the image grid. + """ + self.scale = scale + self.pixel_scale_precision = pixel_scale_precision + self.magnification_threshold = magnification_threshold + + self.initial_triangles = initial_triangles + + # noinspection PyPep8Naming + @classmethod + def for_grid( + cls, + grid: aa.Grid2D, + pixel_scale_precision: float, + magnification_threshold=0.1, + array_triangles_cls: Type[AbstractTriangles] = ArrayTriangles, + max_containing_size=MAX_CONTAINING_SIZE, + ): + """ + Create a solver for a given grid. + + The grid defines the limits of the image plane and the pixel scale. + + Parameters + ---------- + grid + The grid to use. + pixel_scale_precision + The precision to which the triangles should be subdivided. + magnification_threshold + The threshold for the magnification under which multiple images are filtered. + array_triangles_cls + The class to use for the triangles. JAX is used implicitly if USE_JAX=1 and + jax is installed. + max_containing_size + Only applies to JAX. This is the maximum number of multiple images expected. + We need to know this in advance to allocate memory for the JAX array. + + Returns + ------- + The solver. + """ + scale = grid.pixel_scale + + y = grid[:, 0] + x = grid[:, 1] + + y_min = y.min() + y_max = y.max() + x_min = x.min() + x_max = x.max() + + initial_triangles = array_triangles_cls.for_limits_and_scale( + y_min=y_min, + y_max=y_max, + x_min=x_min, + x_max=x_max, + scale=scale, + max_containing_size=max_containing_size, + ) + + return cls( + scale=scale, + initial_triangles=initial_triangles, + pixel_scale_precision=pixel_scale_precision, + magnification_threshold=magnification_threshold, + ) + + @property + def n_steps(self) -> int: + """ + How many times should triangles be subdivided? + """ + return math.ceil(math.log2(self.scale / self.pixel_scale_precision)) + + @staticmethod + def _source_plane_grid( + tracer: OperateDeflections, + grid: aa.type.Grid2DLike, + source_plane_redshift: Optional[float] = None, + ) -> aa.type.Grid2DLike: + """ + Calculate the source plane grid from the image plane grid. + + Parameters + ---------- + grid + The image plane grid. + + Returns + ------- + The source plane grid computed by applying the deflections to the image plane grid. + """ + + source_plane_index = -1 + + if source_plane_redshift is not None: + for redshift in tracer.plane_redshifts: + source_plane_index += 1 + if redshift == source_plane_redshift: + break + + deflections = tracer.deflections_between_planes_from( + grid=grid, plane_i=0, plane_j=source_plane_index + ) + # noinspection PyTypeChecker + return grid.grid_2d_via_deflection_grid_from(deflection_grid=deflections) + + @jit + def solve_triangles( + self, + tracer: OperateDeflections, + shape: Shape, + source_plane_redshift: Optional[float] = None, + ) -> AbstractTriangles: + """ + Solve for the image plane coordinates that are traced to the source plane coordinate. + + This is done by tiling the image plane with triangles and checking if the source plane coordinate is contained + within the triangle. The triangles are subsampled to increase the resolution with only the triangles that + contain the source plane coordinate and their neighbours being kept. + + The means of the triangles are then filtered to keep only those with an absolute magnification above the + threshold. + + Parameters + ---------- + tracer + The tracer to use to trace the image plane coordinates to the source plane. + shape + The shape in the source plane for which we want to identify the image plane coordinates. + source_plane_redshift + The redshift of the source plane. + + Returns + ------- + A list of image plane coordinates that are traced to the source plane coordinate. + """ + if self.n_steps == 0: + raise ValueError( + "The target pixel scale is too large to subdivide the triangles." + ) + + steps = list( + self.steps( + tracer=tracer, + shape=shape, + source_plane_redshift=source_plane_redshift, + ) + ) + final_step = steps[-1] + return final_step.filtered_triangles + + def _filter_low_magnification( + self, tracer: OperateDeflections, points: List[Tuple[float, float]] + ) -> List[Tuple[float, float]]: + """ + Filter the points to keep only those with an absolute magnification above the threshold. + + Parameters + ---------- + points + The points to filter. + + Returns + ------- + The points with an absolute magnification above the threshold. + """ + points = np.array(points) + magnifications = tracer.magnification_2d_via_hessian_from( + grid=aa.Grid2DIrregular(points), + buffer=self.scale, + ) + mask = np.abs(magnifications.array) > self.magnification_threshold + return np.where(mask[:, None], points, np.nan) + + def _filtered_triangles( + self, + tracer: OperateDeflections, + triangles: aa.AbstractTriangles, + source_plane_redshift, + shape: Shape, + ): + """ + Filter the triangles to keep only those that meet the solver condition + """ + source_plane_grid = self._source_plane_grid( + tracer=tracer, + grid=aa.Grid2DIrregular(triangles.vertices), + source_plane_redshift=source_plane_redshift, + ) + source_triangles = triangles.with_vertices(source_plane_grid.array) + + indexes = source_triangles.containing_indices(shape=shape) + + return triangles.for_indexes(indexes=indexes) + + def steps( + self, + tracer: OperateDeflections, + shape: Shape, + source_plane_redshift: Optional[float] = None, + ) -> Iterator[Step]: + """ + Iterate over the steps of the triangle solver algorithm. + + Parameters + ---------- + tracer + The tracer to use to trace the image plane coordinates to the source plane. + source_plane_redshift + The redshift of the source plane. + shape + The shape in the source plane for which we want to identify the image plane coordinates. + + Returns + ------- + An iterator over the steps of the triangle solver algorithm. + """ + initial_triangles = self.initial_triangles + for number in range(self.n_steps): + kept_triangles = self._filtered_triangles( + tracer=tracer, + triangles=initial_triangles, + source_plane_redshift=source_plane_redshift, + shape=shape, + ) + neighbourhood = kept_triangles.neighborhood() + up_sampled = neighbourhood.up_sample() + + yield Step( + number=number, + initial_triangles=initial_triangles, + filtered_triangles=kept_triangles, + neighbourhood=neighbourhood, + up_sampled=up_sampled, + ) + + initial_triangles = up_sampled + + def tree_flatten(self): + return (), ( + self.scale, + self.pixel_scale_precision, + self.magnification_threshold, + self.initial_triangles, + ) + + @classmethod + def tree_unflatten(cls, aux_data, children): + return cls( + scale=aux_data[0], + pixel_scale_precision=aux_data[1], + magnification_threshold=aux_data[2], + initial_triangles=aux_data[3], + ) + + +@register_pytree_node_class +class ShapeSolver(AbstractSolver): + def find_magnification( + self, + tracer: OperateDeflections, + shape: Shape, + source_plane_redshift: Optional[float] = None, + ) -> float: + """ + Find the magnification of the shape in the source plane. + + Parameters + ---------- + tracer + A tracer that traces the image plane to the source plane. + shape + The shape of an image plane pixel. + source_plane_redshift + The redshift of the source plane. + + Returns + ------- + The magnification of the shape in the source plane. + """ + kept_triangles = super().solve_triangles( + tracer=tracer, + shape=shape, + source_plane_redshift=source_plane_redshift, + ) + return kept_triangles.area / shape.area diff --git a/autolens/point/solver/step.py b/autolens/point/solver/step.py index 0f06aa568..5f734a404 100644 --- a/autolens/point/solver/step.py +++ b/autolens/point/solver/step.py @@ -1,53 +1,53 @@ -import logging -from dataclasses import dataclass - -import autoarray as aa -from autoarray.numpy_wrapper import register_pytree_node_class - -try: - from autoarray.structures.triangles.jax_array import ArrayTriangles -except ImportError: - from autoarray.structures.triangles.array import ArrayTriangles - - -logger = logging.getLogger(__name__) - - -@register_pytree_node_class -@dataclass -class Step: - """ - A step in the triangle solver algorithm. - - Attributes - ---------- - number - The number of the step. - initial_triangles - The triangles at the start of the step. - filtered_triangles - The triangles trace to triangles that contain the source plane coordinate. - neighbourhood - The neighbourhood of the filtered triangles. - up_sampled - The neighbourhood up-sampled to increase the resolution. - """ - - number: int - initial_triangles: aa.AbstractTriangles - filtered_triangles: aa.AbstractTriangles - neighbourhood: aa.AbstractTriangles - up_sampled: aa.AbstractTriangles - - def tree_flatten(self): - return ( - self.number, - self.initial_triangles, - self.filtered_triangles, - self.neighbourhood, - self.up_sampled, - ), () - - @classmethod - def tree_unflatten(cls, _, values): - return cls(*values) +import logging +from dataclasses import dataclass + +import autoarray as aa +from autoarray.numpy_wrapper import register_pytree_node_class + +try: + from autoarray.structures.triangles.jax_array import ArrayTriangles +except ImportError: + from autoarray.structures.triangles.array import ArrayTriangles + + +logger = logging.getLogger(__name__) + + +@register_pytree_node_class +@dataclass +class Step: + """ + A step in the triangle solver algorithm. + + Attributes + ---------- + number + The number of the step. + initial_triangles + The triangles at the start of the step. + filtered_triangles + The triangles trace to triangles that contain the source plane coordinate. + neighbourhood + The neighbourhood of the filtered triangles. + up_sampled + The neighbourhood up-sampled to increase the resolution. + """ + + number: int + initial_triangles: aa.AbstractTriangles + filtered_triangles: aa.AbstractTriangles + neighbourhood: aa.AbstractTriangles + up_sampled: aa.AbstractTriangles + + def tree_flatten(self): + return ( + self.number, + self.initial_triangles, + self.filtered_triangles, + self.neighbourhood, + self.up_sampled, + ), () + + @classmethod + def tree_unflatten(cls, _, values): + return cls(*values) diff --git a/autolens/point/visualise.py b/autolens/point/visualise.py index 26e2cd1f1..5bb6b7e10 100644 --- a/autolens/point/visualise.py +++ b/autolens/point/visualise.py @@ -1,24 +1,24 @@ -from matplotlib import pyplot as plt -import numpy as np - -from autolens.point.solver.step import Step - - -def add_triangles(triangles, color): - for triangle in triangles: - triangle = np.append(triangle, [triangle[0]], axis=0) - plt.plot(triangle[:, 0], triangle[:, 1], "o-", color=color) - - -def visualise(step: Step): - plt.figure(figsize=(8, 8)) - add_triangles(step.initial_triangles, color="black") - add_triangles(step.up_sampled, color="green") - add_triangles(step.neighbourhood, color="red") - add_triangles(step.filtered_triangles, color="blue") - - plt.xlabel("X") - plt.ylabel("Y") - plt.title(f"Step {step.number}") - plt.gca().set_aspect("equal", adjustable="box") - plt.show() +from matplotlib import pyplot as plt +import numpy as np + +from autolens.point.solver.step import Step + + +def add_triangles(triangles, color): + for triangle in triangles: + triangle = np.append(triangle, [triangle[0]], axis=0) + plt.plot(triangle[:, 0], triangle[:, 1], "o-", color=color) + + +def visualise(step: Step): + plt.figure(figsize=(8, 8)) + add_triangles(step.initial_triangles, color="black") + add_triangles(step.up_sampled, color="green") + add_triangles(step.neighbourhood, color="red") + add_triangles(step.filtered_triangles, color="blue") + + plt.xlabel("X") + plt.ylabel("Y") + plt.title(f"Step {step.number}") + plt.gca().set_aspect("equal", adjustable="box") + plt.show() diff --git a/eden.ini b/eden.ini index b800028e5..cedb5becb 100644 --- a/eden.ini +++ b/eden.ini @@ -1,3 +1,3 @@ -[eden] -name=autolens -prefix=al +[eden] +name=autolens +prefix=al diff --git a/optional_requirements.txt b/optional_requirements.txt index 524e88755..7f924b895 100644 --- a/optional_requirements.txt +++ b/optional_requirements.txt @@ -1,8 +1,8 @@ -numba -pylops>=1.10.0,<=2.3.1 -pynufft -zeus-mcmc==2.5.4 -getdist==1.4 -#jax>=0.4.13 -#jaxlib>=0.4.13 +numba +pylops>=1.10.0,<=2.3.1 +pynufft +zeus-mcmc==2.5.4 +getdist==1.4 +#jax>=0.4.13 +#jaxlib>=0.4.13 ultranest==4.3.2 \ No newline at end of file diff --git a/release.sh b/release.sh index fde2f648e..d5a6646d0 100755 --- a/release.sh +++ b/release.sh @@ -1,31 +1,31 @@ -#!/usr/bin/env bash - -export PACKAGE_NAME=autolens - -rm -rf $p/dist -rm -rf $p/build - -set -e - -export VERSION=$1 - -cat $PACKAGE_NAME/__init__.py | grep -v __version__ > temp - -cat temp > $PACKAGE_NAME/__init__.py -rm temp -echo "__version__ = '"$VERSION"'" >> $PACKAGE_NAME/__init__.py - -git add $PACKAGE_NAME/__init__.py - -set +e -git commit -m "Incremented version number" -set -e - -python3 setup.py sdist bdist_wheel -twine upload dist/* --skip-existing --username $PYPI_USERNAME --password $PYPI_PASSWORD - - -git push --tags - -rm -rf $p/dist -rm -rf $p/build +#!/usr/bin/env bash + +export PACKAGE_NAME=autolens + +rm -rf $p/dist +rm -rf $p/build + +set -e + +export VERSION=$1 + +cat $PACKAGE_NAME/__init__.py | grep -v __version__ > temp + +cat temp > $PACKAGE_NAME/__init__.py +rm temp +echo "__version__ = '"$VERSION"'" >> $PACKAGE_NAME/__init__.py + +git add $PACKAGE_NAME/__init__.py + +set +e +git commit -m "Incremented version number" +set -e + +python3 setup.py sdist bdist_wheel +twine upload dist/* --skip-existing --username $PYPI_USERNAME --password $PYPI_PASSWORD + + +git push --tags + +rm -rf $p/dist +rm -rf $p/build diff --git a/test_autolens/config/general.yaml b/test_autolens/config/general.yaml index 58138096d..032245c00 100644 --- a/test_autolens/config/general.yaml +++ b/test_autolens/config/general.yaml @@ -1,40 +1,40 @@ -analysis: - n_cores: 1 -fits: - flip_for_ds9: true -grid: - remove_projected_centre: false -hpc: - hpc_mode: false - iterations_per_update: 5000 -adapt: - adapt_minimum_percent: 0.01 - adapt_noise_limit: 100000000.0 -inversion: - check_reconstruction: false # If True, the inversion's reconstruction is checked to ensure the solution of a meshs's mapper is not an invalid solution where the values are all the same. - use_positive_only_solver: false # If True, inversion's use a positive-only linear algebra solver by default, which is slower but prevents unphysical negative values in the reconstructed solutuion. - no_regularization_add_to_curvature_diag_value: 1.0e-8 # The default value added to the curvature matrix's diagonal when regularization is not applied to a linear object, which prevents inversion's failing due to the matrix being singular. - positive_only_uses_p_initial: false # If True, the positive-only solver of an inversion's uses an initial guess of the reconstructed data's values as which values should be positive, speeding up the solver. -model: - ignore_prior_limits: true -numba: - cache: true - nopython: true - parallel: false - use_numba: true -output: - force_pickle_overwrite: false - info_whitespace_length: 80 - log_file: output.log - log_level: INFO - log_to_file: false - model_results_decimal_places: 3 - remove_files: false - samples_to_csv: false -profiling: - perform: true - repeats: 1 -test: - check_likelihood_function: false # if True, when a search is resumed the likelihood of a previous sample is recalculated to ensure it is consistent with the previous run. - exception_override: false - disable_positions_lh_inversion_check: false +analysis: + n_cores: 1 +fits: + flip_for_ds9: true +grid: + remove_projected_centre: false +hpc: + hpc_mode: false + iterations_per_update: 5000 +adapt: + adapt_minimum_percent: 0.01 + adapt_noise_limit: 100000000.0 +inversion: + check_reconstruction: false # If True, the inversion's reconstruction is checked to ensure the solution of a meshs's mapper is not an invalid solution where the values are all the same. + use_positive_only_solver: false # If True, inversion's use a positive-only linear algebra solver by default, which is slower but prevents unphysical negative values in the reconstructed solutuion. + no_regularization_add_to_curvature_diag_value: 1.0e-8 # The default value added to the curvature matrix's diagonal when regularization is not applied to a linear object, which prevents inversion's failing due to the matrix being singular. + positive_only_uses_p_initial: false # If True, the positive-only solver of an inversion's uses an initial guess of the reconstructed data's values as which values should be positive, speeding up the solver. +model: + ignore_prior_limits: true +numba: + cache: true + nopython: true + parallel: false + use_numba: true +output: + force_pickle_overwrite: false + info_whitespace_length: 80 + log_file: output.log + log_level: INFO + log_to_file: false + model_results_decimal_places: 3 + remove_files: false + samples_to_csv: false +profiling: + perform: true + repeats: 1 +test: + check_likelihood_function: false # if True, when a search is resumed the likelihood of a previous sample is recalculated to ensure it is consistent with the previous run. + exception_override: false + disable_positions_lh_inversion_check: false diff --git a/test_autolens/config/grids.yaml b/test_autolens/config/grids.yaml index 83db40ff5..74b4d9cbc 100644 --- a/test_autolens/config/grids.yaml +++ b/test_autolens/config/grids.yaml @@ -1,217 +1,217 @@ -interpolate: - convergence_2d_from: - Isothermal: false - IsothermalInitialize: false - IsothermalSph: true - deflections_yx_2d_from: - Isothermal: false - IsothermalInitialize: false - IsothermalSph: true - image_2d_from: - Sersic: false - SersicInitialize: false - SersicSph: true - potential_2d_from: - Isothermal: false - IsothermalInitialize: false - IsothermalSph: true -# Certain light and mass profile calculations become ill defined at (0.0, 0.0) or close to this value. This can lead -# to numerical issues in the calculation of the profile, for example a np.nan may arise, crashing the code. - -# To avoid this, we set a minimum value for the radial coordinate of the profile. If the radial coordinate is below -# this value, it is rounded up to this value. This ensures that the profile cannot receive a radial coordinate of 0.0. - -# For example, if an input grid coordinate has a radial coordinate of 1e-12, for most profiles this will be rounded up -# to radial_minimum=1e-08. This is a small enough value that it should not impact the results of the profile calculation. - -radial_minimum: - radial_minimum: - DevVaucouleurs: 1.0e-08 - DevVaucouleursSph: 1.0e-08 - EllMassProfile: 1.0e-08 - EllProfile: 1.0e-08 - Exponential: 1.0e-08 - ExponentialSph: 1.0e-08 - ExternalShear: 1.0e-08 - Gaussian: 1.0e-08 - GaussianGradient: 1.0e-08 - GaussianSph: 1.0e-08 - Isothermal: 1.0e-08 - IsothermalCore: 1.0e-08 - IsothermalCoreSph: 1.0e-08 - IsothermalInitialize: 1.0e-08 - IsothermalSph: 1.0e-08 - MassSheet: 1.0e-08 - MockGridRadialMinimum: 2.5 - NFW: 1.0e-08 - NFWSph: 1.0e-08 - NFWTruncatedSph: 1.0e-08 - PointMass: 0.0 - PowerLaw: 1.0e-08 - PowerLawBroken: 1.0e-08 - PowerLawBrokenSph: 1.0e-08 - PowerLawCore: 1.0e-08 - PowerLawCoreSph: 1.0e-08 - PowerLawSph: 1.0e-08 - Sersic: 1.0e-08 - SersicCore: 1.0e-08 - SersicCoreSph: 1.0e-08 - SersicGradient: 1.0e-08 - SersicGradientSph: 1.0e-08 - SersicSph: 1.0e-08 - SphNFWTruncatedMCR: 1.0e-08 - gNFW: 1.0e-08 - gNFWSph: 1.0e-08 - - -# Over sampling is an important numerical technique, whereby light profiles images are evaluated on a higher resolution -# grid than the image data to ensure the calculation is accurate. - -# By default, a user does not specify the over sampling factor, and a default over sampling scheme is used for each -# profile. This scheme first goes to the centre of the profile, and computes circles with certain radial values -# (e.g. radii). It then assigns an over sampling `sub_size` to each circle, where the central circles have the highest -# over sampling factor and the outer circles have the lowest. - -# The size of the circles that are appropriate for determining the over sampling factor are dependent on the resolution -# of the grid. For a high resolution grid (e.g. low pixel scale), a smaller circle central circle is necessary to -# over sample the profile accurately. The config file below therefore specifies the "radial factors" used for -# automatically determining the over sampling factors for each profile, which is the factor the pixel scale is multiplied -# by to determine the circle size. - -# The config entry below defines the default over sampling factor for each profile, where: - -# radial_factor_list: The factors that are multiplied by the pixel scale to determine the circle size that is used. -# sub_size_list: The over sampling factor that is used for each circle size. - -# For the default entries below, oversampling of degree 32 x 32 is used within a circle of radius 3.01 x pixel scale, -# 4 x 4 within a circle of radius 10.01 x pixel scale and 2 x 2 for all pixels outside of this radius. - -over_sampling: - radial_factor_list: - Chameleon: [1.0] - ChameleonSph: [1.0] - DevVaucouleurs: [1.0] - DevVaucouleursSph: [1.0] - dPIE: [1.0] - dPIESph: [1.0] - ExponentialGradient: [1.0] - ExponentialGradientSph: [1.0] - ElsonFreeFall: [1.0] - ElsonFreeFallSph: [1.0] - Exponential: [1.0] - ExponentialCore: [1.0] - ExponentialCoreSph: [1.0] - ExponentialSph: [1.0] - ExternalShear: [1.0] - Gaussian: [1.0] - GaussianSph: [1.0] - gNFW: [1.0] - gNFWMCRLudlow: [1.0] - gNFWVirialMassConcSph: [1.0] - gNFWSph: [1.0] - Isothermal: [1.0] - IsothermalCore: [1.0] - IsothermalCoreSph: [1.0] - IsothermalSph: [1.0] - MassSheet: [1.0] - Moffat: [1.0] - MoffatSph: [1.0] - PowerLawMultipole: [1.0] - NFW: [1.0] - NFWMCRDuffySph: [1.0] - NFWMCRLudlow: [1.0] - NFWMCRLudlowSph: [1.0] - NFWMCRScatterLudlow: [1.0] - NFWMCRScatterLudlowSph: [1.0] - NFWVirialMassConcSph: [1.0] - NFWSph: [1.0] - NFWTruncatedMCRDuffySph: [1.0] - NFWTruncatedMCRLudlowSph: [1.0] - NFWTruncatedMCRScatterLudlowSph: [1.0] - NFWTruncatedSph: [1.0] - PointMass: [1.0] - PowerLaw: [1.0] - PowerLawBroken: [1.0] - PowerLawBrokenSph: [1.0] - PowerLawCore: [1.0] - PowerLawCoreSph: [1.0] - PowerLawSph: [1.0] - Sersic: [1.0] - SersicCore: [1.0] - SersicCoreSph: [1.0] - SersicGradient: [1.0] - SersicSph: [1.0] - SersicGradientSph: [1.0] - ShapeletCartesianSph: [1.0] - ShapeletCartesian: [1.0] - ShapeletPolarSph: [1.0] - ShapeletPolar: [1.0] - ShapeletExponentialSph: [1.0] - ShapeletExponential: [1.0] - SMBH: [1.0] - SMBHBinary: [1.0] - EllProfile: [1.0] - sub_size_list: - Chameleon: [1, 1] - ChameleonSph: [1, 1] - DevVaucouleurs: [1, 1] - DevVaucouleursSph: [1, 1] - dPIE: [1, 1] - dPIESph: [1, 1] - ExponentialGradient: [1, 1] - ExponentialGradientSph: [1, 1] - ElsonFreeFall: [1, 1] - ElsonFreeFallSph: [1, 1] - Exponential: [1, 1] - ExponentialCore: [1, 1] - ExponentialCoreSph: [1, 1] - ExponentialSph: [1, 1] - ExternalShear: [1, 1] - Gaussian: [1, 1] - GaussianSph: [1, 1] - gNFW: [1, 1] - gNFWMCRLudlow: [1, 1] - gNFWVirialMassConcSph: [1, 1] - gNFWSph: [1, 1] - Isothermal: [1, 1] - IsothermalCore: [1, 1] - IsothermalCoreSph: [1, 1] - IsothermalSph: [1, 1] - MassSheet: [1, 1] - Moffat: [1, 1] - MoffatSph: [1, 1] - PowerLawMultipole: [1, 1] - NFW: [1, 1] - NFWMCRDuffySph: [1, 1] - NFWMCRLudlow: [1, 1] - NFWMCRLudlowSph: [1, 1] - NFWMCRScatterLudlow: [1, 1] - NFWMCRScatterLudlowSph: [1, 1] - NFWVirialMassConcSph : [1, 1] - NFWSph: [1, 1] - NFWTruncatedMCRDuffySph: [1, 1] - NFWTruncatedMCRLudlowSph: [1, 1] - NFWTruncatedMCRScatterLudlowSph: [1, 1] - NFWTruncatedSph: [1, 1] - PointMass: [1, 1] - PowerLaw: [1, 1] - PowerLawBroken: [1, 1] - PowerLawBrokenSph: [1, 1] - PowerLawCore: [1, 1] - PowerLawCoreSph: [1, 1] - PowerLawSph: [1, 1] - Sersic: [1, 1] - SersicCore: [1, 1] - SersicCoreSph: [1, 1] - SersicGradient: [1, 1] - SersicSph: [1, 1] - SersicGradientSph: [1, 1] - ShapeletCartesianSph: [1, 1] - ShapeletCartesian: [1, 1] - ShapeletPolarSph: [1, 1] - ShapeletPolar: [1, 1] - ShapeletExponentialSph: [1, 1] - ShapeletExponential: [1, 1] - SMBH: [1, 1] - SMBHBinary: [1, 1] +interpolate: + convergence_2d_from: + Isothermal: false + IsothermalInitialize: false + IsothermalSph: true + deflections_yx_2d_from: + Isothermal: false + IsothermalInitialize: false + IsothermalSph: true + image_2d_from: + Sersic: false + SersicInitialize: false + SersicSph: true + potential_2d_from: + Isothermal: false + IsothermalInitialize: false + IsothermalSph: true +# Certain light and mass profile calculations become ill defined at (0.0, 0.0) or close to this value. This can lead +# to numerical issues in the calculation of the profile, for example a np.nan may arise, crashing the code. + +# To avoid this, we set a minimum value for the radial coordinate of the profile. If the radial coordinate is below +# this value, it is rounded up to this value. This ensures that the profile cannot receive a radial coordinate of 0.0. + +# For example, if an input grid coordinate has a radial coordinate of 1e-12, for most profiles this will be rounded up +# to radial_minimum=1e-08. This is a small enough value that it should not impact the results of the profile calculation. + +radial_minimum: + radial_minimum: + DevVaucouleurs: 1.0e-08 + DevVaucouleursSph: 1.0e-08 + EllMassProfile: 1.0e-08 + EllProfile: 1.0e-08 + Exponential: 1.0e-08 + ExponentialSph: 1.0e-08 + ExternalShear: 1.0e-08 + Gaussian: 1.0e-08 + GaussianGradient: 1.0e-08 + GaussianSph: 1.0e-08 + Isothermal: 1.0e-08 + IsothermalCore: 1.0e-08 + IsothermalCoreSph: 1.0e-08 + IsothermalInitialize: 1.0e-08 + IsothermalSph: 1.0e-08 + MassSheet: 1.0e-08 + MockGridRadialMinimum: 2.5 + NFW: 1.0e-08 + NFWSph: 1.0e-08 + NFWTruncatedSph: 1.0e-08 + PointMass: 0.0 + PowerLaw: 1.0e-08 + PowerLawBroken: 1.0e-08 + PowerLawBrokenSph: 1.0e-08 + PowerLawCore: 1.0e-08 + PowerLawCoreSph: 1.0e-08 + PowerLawSph: 1.0e-08 + Sersic: 1.0e-08 + SersicCore: 1.0e-08 + SersicCoreSph: 1.0e-08 + SersicGradient: 1.0e-08 + SersicGradientSph: 1.0e-08 + SersicSph: 1.0e-08 + SphNFWTruncatedMCR: 1.0e-08 + gNFW: 1.0e-08 + gNFWSph: 1.0e-08 + + +# Over sampling is an important numerical technique, whereby light profiles images are evaluated on a higher resolution +# grid than the image data to ensure the calculation is accurate. + +# By default, a user does not specify the over sampling factor, and a default over sampling scheme is used for each +# profile. This scheme first goes to the centre of the profile, and computes circles with certain radial values +# (e.g. radii). It then assigns an over sampling `sub_size` to each circle, where the central circles have the highest +# over sampling factor and the outer circles have the lowest. + +# The size of the circles that are appropriate for determining the over sampling factor are dependent on the resolution +# of the grid. For a high resolution grid (e.g. low pixel scale), a smaller circle central circle is necessary to +# over sample the profile accurately. The config file below therefore specifies the "radial factors" used for +# automatically determining the over sampling factors for each profile, which is the factor the pixel scale is multiplied +# by to determine the circle size. + +# The config entry below defines the default over sampling factor for each profile, where: + +# radial_factor_list: The factors that are multiplied by the pixel scale to determine the circle size that is used. +# sub_size_list: The over sampling factor that is used for each circle size. + +# For the default entries below, oversampling of degree 32 x 32 is used within a circle of radius 3.01 x pixel scale, +# 4 x 4 within a circle of radius 10.01 x pixel scale and 2 x 2 for all pixels outside of this radius. + +over_sampling: + radial_factor_list: + Chameleon: [1.0] + ChameleonSph: [1.0] + DevVaucouleurs: [1.0] + DevVaucouleursSph: [1.0] + dPIE: [1.0] + dPIESph: [1.0] + ExponentialGradient: [1.0] + ExponentialGradientSph: [1.0] + ElsonFreeFall: [1.0] + ElsonFreeFallSph: [1.0] + Exponential: [1.0] + ExponentialCore: [1.0] + ExponentialCoreSph: [1.0] + ExponentialSph: [1.0] + ExternalShear: [1.0] + Gaussian: [1.0] + GaussianSph: [1.0] + gNFW: [1.0] + gNFWMCRLudlow: [1.0] + gNFWVirialMassConcSph: [1.0] + gNFWSph: [1.0] + Isothermal: [1.0] + IsothermalCore: [1.0] + IsothermalCoreSph: [1.0] + IsothermalSph: [1.0] + MassSheet: [1.0] + Moffat: [1.0] + MoffatSph: [1.0] + PowerLawMultipole: [1.0] + NFW: [1.0] + NFWMCRDuffySph: [1.0] + NFWMCRLudlow: [1.0] + NFWMCRLudlowSph: [1.0] + NFWMCRScatterLudlow: [1.0] + NFWMCRScatterLudlowSph: [1.0] + NFWVirialMassConcSph: [1.0] + NFWSph: [1.0] + NFWTruncatedMCRDuffySph: [1.0] + NFWTruncatedMCRLudlowSph: [1.0] + NFWTruncatedMCRScatterLudlowSph: [1.0] + NFWTruncatedSph: [1.0] + PointMass: [1.0] + PowerLaw: [1.0] + PowerLawBroken: [1.0] + PowerLawBrokenSph: [1.0] + PowerLawCore: [1.0] + PowerLawCoreSph: [1.0] + PowerLawSph: [1.0] + Sersic: [1.0] + SersicCore: [1.0] + SersicCoreSph: [1.0] + SersicGradient: [1.0] + SersicSph: [1.0] + SersicGradientSph: [1.0] + ShapeletCartesianSph: [1.0] + ShapeletCartesian: [1.0] + ShapeletPolarSph: [1.0] + ShapeletPolar: [1.0] + ShapeletExponentialSph: [1.0] + ShapeletExponential: [1.0] + SMBH: [1.0] + SMBHBinary: [1.0] + EllProfile: [1.0] + sub_size_list: + Chameleon: [1, 1] + ChameleonSph: [1, 1] + DevVaucouleurs: [1, 1] + DevVaucouleursSph: [1, 1] + dPIE: [1, 1] + dPIESph: [1, 1] + ExponentialGradient: [1, 1] + ExponentialGradientSph: [1, 1] + ElsonFreeFall: [1, 1] + ElsonFreeFallSph: [1, 1] + Exponential: [1, 1] + ExponentialCore: [1, 1] + ExponentialCoreSph: [1, 1] + ExponentialSph: [1, 1] + ExternalShear: [1, 1] + Gaussian: [1, 1] + GaussianSph: [1, 1] + gNFW: [1, 1] + gNFWMCRLudlow: [1, 1] + gNFWVirialMassConcSph: [1, 1] + gNFWSph: [1, 1] + Isothermal: [1, 1] + IsothermalCore: [1, 1] + IsothermalCoreSph: [1, 1] + IsothermalSph: [1, 1] + MassSheet: [1, 1] + Moffat: [1, 1] + MoffatSph: [1, 1] + PowerLawMultipole: [1, 1] + NFW: [1, 1] + NFWMCRDuffySph: [1, 1] + NFWMCRLudlow: [1, 1] + NFWMCRLudlowSph: [1, 1] + NFWMCRScatterLudlow: [1, 1] + NFWMCRScatterLudlowSph: [1, 1] + NFWVirialMassConcSph : [1, 1] + NFWSph: [1, 1] + NFWTruncatedMCRDuffySph: [1, 1] + NFWTruncatedMCRLudlowSph: [1, 1] + NFWTruncatedMCRScatterLudlowSph: [1, 1] + NFWTruncatedSph: [1, 1] + PointMass: [1, 1] + PowerLaw: [1, 1] + PowerLawBroken: [1, 1] + PowerLawBrokenSph: [1, 1] + PowerLawCore: [1, 1] + PowerLawCoreSph: [1, 1] + PowerLawSph: [1, 1] + Sersic: [1, 1] + SersicCore: [1, 1] + SersicCoreSph: [1, 1] + SersicGradient: [1, 1] + SersicSph: [1, 1] + SersicGradientSph: [1, 1] + ShapeletCartesianSph: [1, 1] + ShapeletCartesian: [1, 1] + ShapeletPolarSph: [1, 1] + ShapeletPolar: [1, 1] + ShapeletExponentialSph: [1, 1] + ShapeletExponential: [1, 1] + SMBH: [1, 1] + SMBHBinary: [1, 1] EllProfile: [1, 1] \ No newline at end of file diff --git a/test_autolens/config/non_linear.yaml b/test_autolens/config/non_linear.yaml index 2dcf909de..3fb607c33 100644 --- a/test_autolens/config/non_linear.yaml +++ b/test_autolens/config/non_linear.yaml @@ -1,83 +1,83 @@ -mock: - MockOptimizer: - initialize: - method: prior - printing: - silence: false - updates: - iterations_per_update: 2500 - remove_state_files_at_end: true - MockSearch: - initialize: - method: prior - printing: - silence: false - search: {} - updates: - iterations_per_update: 2500 - remove_state_files_at_end: true -nest: - DynestyDynamic: - general: - acceptance_ratio_threshold: 0.1 - bootstrap: null - bound: multi - enlarge: null - first_update: null - fmove: 0.9 - max_move: 100 - sample: auto - sampling_efficiency: 0.5 - slices: 5 - terminate_at_acceptance_ratio: false - update_interval: null - walks: 25 - initialize: - method: prior - parallel: - force_x1_cpu: false - number_of_cores: 1 - printing: - silence: false - updates: - iterations_per_update: 2500 - remove_state_files_at_end: true - DynestyStatic: - parallel: - number_of_cores: 1 - initialize: - method: prior - inversion: - acceptance_ratio_threshold: 0.05 - const_efficiency_mode: true - evidence_tolerance: 100.0 - multimodal: false - n_live_points: 50 - sampling_efficiency: 0.3 - terminate_at_acceptance_ratio: false - printing: - silence: false - search: - const_efficiency_mode: false - evidence_tolerance: 0.5 - importance_nested_sampling: false - max_iter: 0 - max_modes: 100 - mode_tolerance: -1.0e+90 - multimodal: false - n_live_points: 50 - sampling_efficiency: 0.5 - settings: - context: 0 - init_MPI: false - log_zero: -1.0e+100 - n_iter_before_update: 5 - null_log_evidence: -1.0e+90 - resume: true - seed: -1.0 - stagger_resampling_likelihood: true - verbose: false - write_output: true - updates: - iterations_per_update: 2500 - remove_state_files_at_end: true +mock: + MockOptimizer: + initialize: + method: prior + printing: + silence: false + updates: + iterations_per_update: 2500 + remove_state_files_at_end: true + MockSearch: + initialize: + method: prior + printing: + silence: false + search: {} + updates: + iterations_per_update: 2500 + remove_state_files_at_end: true +nest: + DynestyDynamic: + general: + acceptance_ratio_threshold: 0.1 + bootstrap: null + bound: multi + enlarge: null + first_update: null + fmove: 0.9 + max_move: 100 + sample: auto + sampling_efficiency: 0.5 + slices: 5 + terminate_at_acceptance_ratio: false + update_interval: null + walks: 25 + initialize: + method: prior + parallel: + force_x1_cpu: false + number_of_cores: 1 + printing: + silence: false + updates: + iterations_per_update: 2500 + remove_state_files_at_end: true + DynestyStatic: + parallel: + number_of_cores: 1 + initialize: + method: prior + inversion: + acceptance_ratio_threshold: 0.05 + const_efficiency_mode: true + evidence_tolerance: 100.0 + multimodal: false + n_live_points: 50 + sampling_efficiency: 0.3 + terminate_at_acceptance_ratio: false + printing: + silence: false + search: + const_efficiency_mode: false + evidence_tolerance: 0.5 + importance_nested_sampling: false + max_iter: 0 + max_modes: 100 + mode_tolerance: -1.0e+90 + multimodal: false + n_live_points: 50 + sampling_efficiency: 0.5 + settings: + context: 0 + init_MPI: false + log_zero: -1.0e+100 + n_iter_before_update: 5 + null_log_evidence: -1.0e+90 + resume: true + seed: -1.0 + stagger_resampling_likelihood: true + verbose: false + write_output: true + updates: + iterations_per_update: 2500 + remove_state_files_at_end: true diff --git a/test_autolens/config/notation.yaml b/test_autolens/config/notation.yaml index 8cc3102ef..2d19ca16d 100644 --- a/test_autolens/config/notation.yaml +++ b/test_autolens/config/notation.yaml @@ -1,84 +1,84 @@ -label: - label: - alpha: \alpha - angle_binary: \theta - beta: \beta - break_radius: \theta_{\rm B} - centre_0: y - centre_1: x - coefficient: \lambda - contribution_factor: \omega_{\rm 0} - core_radius: C_{\rm r} - core_radius_0: C_{rm r0} - core_radius_1: C_{\rm r1} - effective_radius: R_{\rm eff} - einstein_radius: \theta_{\rm Ein} - ell_comps_0: \epsilon_{\rm 1} - ell_comps_1: \epsilon_{\rm 2} - multipole_comps_0: M_{\rm 1} - multipole_comps_1: M_{\rm 2} - flux: F - gamma: \gamma - gamma_1: \gamma - gamma_2: \gamma - inner_coefficient: \lambda_{\rm 1} - inner_slope: t_{\rm 1} - intensity: I_{\rm b} - kappa: \kappa - kappa_s: \kappa_{\rm s} - log10m_vir: log_{\rm 10}(m_{vir}) - m: m - mass: M - mass_at_200: M_{\rm 200} - mass_ratio: M_{\rm ratio} - mass_to_light_gradient: \Gamma - mass_to_light_ratio: \Psi - mass_to_light_ratio_base: \Psi_{\rm base} - mass_to_light_radius: R_{\rm ref} - noise_factor: \omega_{\rm 1} - noise_power: \omega{\rm 2} - noise_scale: \sigma_{\rm 1} - normalization_scale: n - outer_coefficient: \lambda_{\rm 2} - outer_slope: t_{\rm 2} - overdens: \Delta_{\rm vir} - pixels: N_{\rm pix} - radius_break: R_{\rm b} - redshift: z - redshift_object: z_{\rm obj} - redshift_source: z_{\rm src} - scale_radius: R_{\rm s} - scatter: \sigma - separation: s - sersic_index: n - shape_0: y_{\rm pix} - shape_1: x_{\rm pix} - sigma: \sigma - signal_scale: V - sky_scale: \sigma_{\rm 0} - slope: \gamma - truncation_radius: R_{\rm t} - weight_floor: W_{\rm f} - weight_power: W_{\rm p} - superscript: - ExternalShear: ext - InputDeflections: defl - Pixelization: pix - Point: point - Redshift: '' - Regularization: reg -label_format: - format: - angular_diameter_distance_to_earth: '{:.2f}' - concentration: '{:.2f}' - einstein_mass: '{:.4e}' - einstein_radius: '{:.2f}' - kpc_per_arcsec: '{:.2f}' - luminosity: '{:.4e}' - m: '{:.1f}' - mass: '{:.4e}' - mass_at_truncation_radius: '{:.4e}' - radius: '{:.2f}' - redshift: '{:.2f}' - rho: '{:.2f}' - sersic_luminosity: '{:.4e}' +label: + label: + alpha: \alpha + angle_binary: \theta + beta: \beta + break_radius: \theta_{\rm B} + centre_0: y + centre_1: x + coefficient: \lambda + contribution_factor: \omega_{\rm 0} + core_radius: C_{\rm r} + core_radius_0: C_{rm r0} + core_radius_1: C_{\rm r1} + effective_radius: R_{\rm eff} + einstein_radius: \theta_{\rm Ein} + ell_comps_0: \epsilon_{\rm 1} + ell_comps_1: \epsilon_{\rm 2} + multipole_comps_0: M_{\rm 1} + multipole_comps_1: M_{\rm 2} + flux: F + gamma: \gamma + gamma_1: \gamma + gamma_2: \gamma + inner_coefficient: \lambda_{\rm 1} + inner_slope: t_{\rm 1} + intensity: I_{\rm b} + kappa: \kappa + kappa_s: \kappa_{\rm s} + log10m_vir: log_{\rm 10}(m_{vir}) + m: m + mass: M + mass_at_200: M_{\rm 200} + mass_ratio: M_{\rm ratio} + mass_to_light_gradient: \Gamma + mass_to_light_ratio: \Psi + mass_to_light_ratio_base: \Psi_{\rm base} + mass_to_light_radius: R_{\rm ref} + noise_factor: \omega_{\rm 1} + noise_power: \omega{\rm 2} + noise_scale: \sigma_{\rm 1} + normalization_scale: n + outer_coefficient: \lambda_{\rm 2} + outer_slope: t_{\rm 2} + overdens: \Delta_{\rm vir} + pixels: N_{\rm pix} + radius_break: R_{\rm b} + redshift: z + redshift_object: z_{\rm obj} + redshift_source: z_{\rm src} + scale_radius: R_{\rm s} + scatter: \sigma + separation: s + sersic_index: n + shape_0: y_{\rm pix} + shape_1: x_{\rm pix} + sigma: \sigma + signal_scale: V + sky_scale: \sigma_{\rm 0} + slope: \gamma + truncation_radius: R_{\rm t} + weight_floor: W_{\rm f} + weight_power: W_{\rm p} + superscript: + ExternalShear: ext + InputDeflections: defl + Pixelization: pix + Point: point + Redshift: '' + Regularization: reg +label_format: + format: + angular_diameter_distance_to_earth: '{:.2f}' + concentration: '{:.2f}' + einstein_mass: '{:.4e}' + einstein_radius: '{:.2f}' + kpc_per_arcsec: '{:.2f}' + luminosity: '{:.4e}' + m: '{:.1f}' + mass: '{:.4e}' + mass_at_truncation_radius: '{:.4e}' + radius: '{:.2f}' + redshift: '{:.2f}' + rho: '{:.2f}' + sersic_luminosity: '{:.4e}' diff --git a/test_autolens/config/output.yaml b/test_autolens/config/output.yaml index 5cb8812dc..4a44b384b 100644 --- a/test_autolens/config/output.yaml +++ b/test_autolens/config/output.yaml @@ -1,63 +1,63 @@ -# Determines whether files saved by the search are output to the hard-disk. This is true both when saving to the -# directory structure and when saving to database. - -# Files can be listed name: bool where the name is the name of the file without a suffix (e.g. model not model.json) -# and bool is true or false. - -# If a given file is not listed then the default value is used. - -default: true # If true then files which are not explicitly listed here are output anyway. If false then they are not. - -### Samples ### - -# The `samples.csv`file contains every sampled value of every free parameter with its log likelihood and weight. - -# This file is often large, therefore disabling it can significantly reduce hard-disk space use. - -# `samples.csv` is used to perform marginalization, infer model parameter errors and do other analysis of the search -# chains. Even if output of `samples.csv` is disabled, these tasks are still performed by the fit and output to -# the `samples_summary.json` file. However, without a `samples.csv` file these types of tasks cannot be performed -# after the fit is complete, for example via the database. - -samples: true - -# The `samples.csv` file contains every accepted sampled value of every free parameter with its log likelihood and -# weight. For certain searches, the majority of samples have a very low weight, which has no numerical impact on the -# results of the model-fit. However, these samples are still output to the `samples.csv` file, taking up hard-disk space -# and slowing down analysis of the samples (e.g. via the database). - -# The `samples_weight_threshold` below specifies the threshold value of the weight such that samples with a weight -# below this value are not output to the `samples.csv` file. This can be used to reduce the size of the `samples.csv` -# file and speed up analysis of the samples. - -# Note that for many searches (e.g. MCMC) all samples have equal weight, and thus this threshold has no impact and -# there is no simple way to save hard-disk space. However, for nested sampling, the majority of samples have a very -# low weight and this threshold can be used to save hard-disk space. - -# Set value to empty (e.g. delete 1.0e-10 below) to disable this feature. - -samples_weight_threshold: 1.0e-10 - -### Search Internal ### - -# The search internal folder which contains a saved state of the non-linear search, as a .pickle or .dill file. - -# If the entry below is false, the folder is still output during the model-fit, as it is required to resume the fit -# from where it left off. Therefore, settings `false` below does not impact model-fitting checkpointing and resumption. -# Instead, the search internal folder is deleted once the fit is completed. - -# The search internal folder file is often large, therefore deleting it after a fit is complete can significantly -# reduce hard-disk space use. - -# The search internal representation (e.g. what you can load from the output .pickle file) may have additional -# quantities specific to the non-linear search that you are interested in inspecting. Deleting the folder means this -# information is list. - -search_internal: false - -# Other Files: - -covariance: false # `covariance.csv`: The [free parameters x free parameters] covariance matrix. -data: true # `data.json`: The value of every data point in the data. -noise_map: true # `noise_map.json`: The value of every RMS noise map value. - +# Determines whether files saved by the search are output to the hard-disk. This is true both when saving to the +# directory structure and when saving to database. + +# Files can be listed name: bool where the name is the name of the file without a suffix (e.g. model not model.json) +# and bool is true or false. + +# If a given file is not listed then the default value is used. + +default: true # If true then files which are not explicitly listed here are output anyway. If false then they are not. + +### Samples ### + +# The `samples.csv`file contains every sampled value of every free parameter with its log likelihood and weight. + +# This file is often large, therefore disabling it can significantly reduce hard-disk space use. + +# `samples.csv` is used to perform marginalization, infer model parameter errors and do other analysis of the search +# chains. Even if output of `samples.csv` is disabled, these tasks are still performed by the fit and output to +# the `samples_summary.json` file. However, without a `samples.csv` file these types of tasks cannot be performed +# after the fit is complete, for example via the database. + +samples: true + +# The `samples.csv` file contains every accepted sampled value of every free parameter with its log likelihood and +# weight. For certain searches, the majority of samples have a very low weight, which has no numerical impact on the +# results of the model-fit. However, these samples are still output to the `samples.csv` file, taking up hard-disk space +# and slowing down analysis of the samples (e.g. via the database). + +# The `samples_weight_threshold` below specifies the threshold value of the weight such that samples with a weight +# below this value are not output to the `samples.csv` file. This can be used to reduce the size of the `samples.csv` +# file and speed up analysis of the samples. + +# Note that for many searches (e.g. MCMC) all samples have equal weight, and thus this threshold has no impact and +# there is no simple way to save hard-disk space. However, for nested sampling, the majority of samples have a very +# low weight and this threshold can be used to save hard-disk space. + +# Set value to empty (e.g. delete 1.0e-10 below) to disable this feature. + +samples_weight_threshold: 1.0e-10 + +### Search Internal ### + +# The search internal folder which contains a saved state of the non-linear search, as a .pickle or .dill file. + +# If the entry below is false, the folder is still output during the model-fit, as it is required to resume the fit +# from where it left off. Therefore, settings `false` below does not impact model-fitting checkpointing and resumption. +# Instead, the search internal folder is deleted once the fit is completed. + +# The search internal folder file is often large, therefore deleting it after a fit is complete can significantly +# reduce hard-disk space use. + +# The search internal representation (e.g. what you can load from the output .pickle file) may have additional +# quantities specific to the non-linear search that you are interested in inspecting. Deleting the folder means this +# information is list. + +search_internal: false + +# Other Files: + +covariance: false # `covariance.csv`: The [free parameters x free parameters] covariance matrix. +data: true # `data.json`: The value of every data point in the data. +noise_map: true # `noise_map.json`: The value of every RMS noise map value. + diff --git a/test_autolens/config/priors/dark_mass_profiles.yaml b/test_autolens/config/priors/dark_mass_profiles.yaml index 713a4856d..61480a243 100644 --- a/test_autolens/config/priors/dark_mass_profiles.yaml +++ b/test_autolens/config/priors/dark_mass_profiles.yaml @@ -1,338 +1,338 @@ -NFW: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - kappa_s: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - scale_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 -NFWSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - kappa_s: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - scale_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 -NFWTruncatedSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - kappa_s: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - scale_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 - truncation_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 -SphNFWTruncatedMCR: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - mass_at_200: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 100000000.0 - type: LogUniform - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 -gNFW: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - inner_slope: - gaussian_limits: - lower: -1.0 - upper: 3.0 - lower_limit: 0.0 - type: Uniform - upper_limit: 2.0 - width_modifier: - type: Absolute - value: 0.3 - kappa_s: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - scale_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 -gNFWSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - inner_slope: - gaussian_limits: - lower: -1.0 - upper: 3.0 - lower_limit: 0.0 - type: Uniform - upper_limit: 2.0 - width_modifier: - type: Absolute - value: 0.3 - kappa_s: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - scale_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 +NFW: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + kappa_s: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + scale_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 +NFWSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + kappa_s: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + scale_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 +NFWTruncatedSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + kappa_s: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + scale_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 + truncation_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 +SphNFWTruncatedMCR: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + mass_at_200: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 100000000.0 + type: LogUniform + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 +gNFW: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + inner_slope: + gaussian_limits: + lower: -1.0 + upper: 3.0 + lower_limit: 0.0 + type: Uniform + upper_limit: 2.0 + width_modifier: + type: Absolute + value: 0.3 + kappa_s: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + scale_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 +gNFWSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + inner_slope: + gaussian_limits: + lower: -1.0 + upper: 3.0 + lower_limit: 0.0 + type: Uniform + upper_limit: 2.0 + width_modifier: + type: Absolute + value: 0.3 + kappa_s: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + scale_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 diff --git a/test_autolens/config/priors/galaxy.yaml b/test_autolens/config/priors/galaxy.yaml index a0af83928..37d54b710 100644 --- a/test_autolens/config/priors/galaxy.yaml +++ b/test_autolens/config/priors/galaxy.yaml @@ -1,17 +1,17 @@ -Galaxy: - redshift: - lower_limit: 0.0 - type: Uniform - upper_limit: 3.0 - -Redshift: - redshift: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 1.0 +Galaxy: + redshift: + lower_limit: 0.0 + type: Uniform + upper_limit: 3.0 + +Redshift: + redshift: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 1.0 diff --git a/test_autolens/config/priors/geometry_profiles.yaml b/test_autolens/config/priors/geometry_profiles.yaml index b55820bc4..2cc1e251b 100644 --- a/test_autolens/config/priors/geometry_profiles.yaml +++ b/test_autolens/config/priors/geometry_profiles.yaml @@ -1,48 +1,48 @@ -AbstractSersic: - angle: - lower_limit: 0.0 - type: Uniform - upper_limit: 180.0 - axis_ratio: - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - centre_0: - lower_limit: -1.0 - type: Uniform - upper_limit: 1.0 - centre_1: - lower_limit: -1.0 - type: Uniform - upper_limit: 1.0 - effective_radius: - lower_limit: 0.0 - type: Uniform - upper_limit: 3.0 - intensity: - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - sersic_index: - lower_limit: 0.6 - type: Uniform - upper_limit: 8.0 -EllProfile: - angle: - lower_limit: 0.0 - type: Uniform - upper_limit: 2.0 - axis_ratio: - lower_limit: 0.0 - type: Uniform - upper_limit: 2.0 -GeometryProfile: - centre_0: - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - centre_1: - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 -SphlProfile: {} +AbstractSersic: + angle: + lower_limit: 0.0 + type: Uniform + upper_limit: 180.0 + axis_ratio: + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + centre_0: + lower_limit: -1.0 + type: Uniform + upper_limit: 1.0 + centre_1: + lower_limit: -1.0 + type: Uniform + upper_limit: 1.0 + effective_radius: + lower_limit: 0.0 + type: Uniform + upper_limit: 3.0 + intensity: + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + sersic_index: + lower_limit: 0.6 + type: Uniform + upper_limit: 8.0 +EllProfile: + angle: + lower_limit: 0.0 + type: Uniform + upper_limit: 2.0 + axis_ratio: + lower_limit: 0.0 + type: Uniform + upper_limit: 2.0 +GeometryProfile: + centre_0: + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + centre_1: + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 +SphlProfile: {} diff --git a/test_autolens/config/priors/light_profiles.yaml b/test_autolens/config/priors/light_profiles.yaml index ee1f07831..830e1fc8f 100644 --- a/test_autolens/config/priors/light_profiles.yaml +++ b/test_autolens/config/priors/light_profiles.yaml @@ -1,266 +1,266 @@ -EllLightProfile: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 0.5 - width_modifier: - type: Absolute - value: 0.05 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - intensity: - lower_limit: 0.0 - mean: 0.0 - sigma: 0.5 - type: Gaussian - upper_limit: inf - width_modifier: - type: Relative - value: 0.5 -Exponential: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 0.5 - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 2.0 - width_modifier: - type: Absolute - value: 2.0 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - intensity: - lower_limit: 0.0 - mean: 0.0 - sigma: 0.5 - type: Gaussian - upper_limit: inf - width_modifier: - type: Relative - value: 0.5 -Gaussian: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - sigma: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 25.0 - width_modifier: - type: Relative - value: 0.5 -Sersic: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - sersic_index: - gaussian_limits: - lower: 0.5 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 8.0 - width_modifier: - type: Absolute - value: 1.5 +EllLightProfile: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 0.5 + width_modifier: + type: Absolute + value: 0.05 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + intensity: + lower_limit: 0.0 + mean: 0.0 + sigma: 0.5 + type: Gaussian + upper_limit: inf + width_modifier: + type: Relative + value: 0.5 +Exponential: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 0.5 + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 2.0 + width_modifier: + type: Absolute + value: 2.0 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + intensity: + lower_limit: 0.0 + mean: 0.0 + sigma: 0.5 + type: Gaussian + upper_limit: inf + width_modifier: + type: Relative + value: 0.5 +Gaussian: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + sigma: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 25.0 + width_modifier: + type: Relative + value: 0.5 +Sersic: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + sersic_index: + gaussian_limits: + lower: 0.5 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 8.0 + width_modifier: + type: Absolute + value: 1.5 diff --git a/test_autolens/config/priors/mass_sheets.yaml b/test_autolens/config/priors/mass_sheets.yaml index 82551b7cb..6efda8397 100644 --- a/test_autolens/config/priors/mass_sheets.yaml +++ b/test_autolens/config/priors/mass_sheets.yaml @@ -1,21 +1,21 @@ -ExternalShear: - gamma_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -0.2 - type: Uniform - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.05 - gamma_2: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -0.2 - type: Uniform - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.05 +ExternalShear: + gamma_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -0.2 + type: Uniform + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.05 + gamma_2: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -0.2 + type: Uniform + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.05 diff --git a/test_autolens/config/priors/pixelizations.yaml b/test_autolens/config/priors/pixelizations.yaml index dde440f40..7d8084ed8 100644 --- a/test_autolens/config/priors/pixelizations.yaml +++ b/test_autolens/config/priors/pixelizations.yaml @@ -1,125 +1,125 @@ -delaunay.DelaunayBrightnessImage: - pixels: - gaussian_limits: - lower: 50.0 - upper: inf - lower_limit: 50.0 - type: Uniform - upper_limit: 2500.0 - width_modifier: - type: Absolute - value: 100.0 - weight_floor: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.1 - weight_power: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 20.0 - width_modifier: - type: Absolute - value: 5.0 -delaunay.DelaunayMagnification: - shape_0: - gaussian_limits: - lower: 3.0 - upper: inf - lower_limit: 20.0 - type: Uniform - upper_limit: 45.0 - width_modifier: - type: Absolute - value: 8.0 - shape_1: - gaussian_limits: - lower: 3.0 - upper: inf - lower_limit: 20.0 - type: Uniform - upper_limit: 45.0 - width_modifier: - type: Absolute - value: 8.0 -rectangular.Rectangular: - shape_0: - gaussian_limits: - lower: 3.0 - upper: inf - lower_limit: 20.0 - type: Uniform - upper_limit: 45.0 - width_modifier: - type: Absolute - value: 8.0 - shape_1: - gaussian_limits: - lower: 3.0 - upper: inf - lower_limit: 20.0 - type: Uniform - upper_limit: 45.0 - width_modifier: - type: Absolute - value: 8.0 -voronoi.VoronoiBrightnessImage: - pixels: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 50.0 - type: Uniform - upper_limit: 1500.0 - width_modifier: - type: Absolute - value: 400.0 - weight_floor: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.1 - weight_power: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 20.0 - width_modifier: - type: Absolute - value: 5.0 -voronoi.VoronoiMagnification: - shape_0: - gaussian_limits: - lower: 3.0 - upper: inf - lower_limit: 20.0 - type: Uniform - upper_limit: 45.0 - width_modifier: - type: Absolute - value: 8.0 - shape_1: - gaussian_limits: - lower: 3.0 - upper: inf - lower_limit: 20.0 - type: Uniform - upper_limit: 45.0 - width_modifier: - type: Absolute - value: 8.0 +delaunay.DelaunayBrightnessImage: + pixels: + gaussian_limits: + lower: 50.0 + upper: inf + lower_limit: 50.0 + type: Uniform + upper_limit: 2500.0 + width_modifier: + type: Absolute + value: 100.0 + weight_floor: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.1 + weight_power: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 20.0 + width_modifier: + type: Absolute + value: 5.0 +delaunay.DelaunayMagnification: + shape_0: + gaussian_limits: + lower: 3.0 + upper: inf + lower_limit: 20.0 + type: Uniform + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 + shape_1: + gaussian_limits: + lower: 3.0 + upper: inf + lower_limit: 20.0 + type: Uniform + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 +rectangular.Rectangular: + shape_0: + gaussian_limits: + lower: 3.0 + upper: inf + lower_limit: 20.0 + type: Uniform + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 + shape_1: + gaussian_limits: + lower: 3.0 + upper: inf + lower_limit: 20.0 + type: Uniform + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 +voronoi.VoronoiBrightnessImage: + pixels: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 50.0 + type: Uniform + upper_limit: 1500.0 + width_modifier: + type: Absolute + value: 400.0 + weight_floor: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.1 + weight_power: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 20.0 + width_modifier: + type: Absolute + value: 5.0 +voronoi.VoronoiMagnification: + shape_0: + gaussian_limits: + lower: 3.0 + upper: inf + lower_limit: 20.0 + type: Uniform + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 + shape_1: + gaussian_limits: + lower: 3.0 + upper: inf + lower_limit: 20.0 + type: Uniform + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 diff --git a/test_autolens/config/priors/regularization.yaml b/test_autolens/config/priors/regularization.yaml index c51693dc8..195ba9b2f 100644 --- a/test_autolens/config/priors/regularization.yaml +++ b/test_autolens/config/priors/regularization.yaml @@ -1,39 +1,39 @@ -adaptive_brightness.AdaptiveBrightness: - inner_coefficient: - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - outer_coefficient: - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 - signal_scale: - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 -constant.Constant: - coefficient: - lower_limit: 0.0 - type: Uniform - upper_limit: 1.0 -constant_zeorth.ConstantZeroth: - coefficient_neighbor: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - coefficient_zeroth: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 +adaptive_brightness.AdaptiveBrightness: + inner_coefficient: + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + outer_coefficient: + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 + signal_scale: + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 +constant.Constant: + coefficient: + lower_limit: 0.0 + type: Uniform + upper_limit: 1.0 +constant_zeorth.ConstantZeroth: + coefficient_neighbor: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + coefficient_zeroth: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 diff --git a/test_autolens/config/priors/stellar_mass_profiles.yaml b/test_autolens/config/priors/stellar_mass_profiles.yaml index ce1f7d9ed..cb68d765e 100644 --- a/test_autolens/config/priors/stellar_mass_profiles.yaml +++ b/test_autolens/config/priors/stellar_mass_profiles.yaml @@ -1,596 +1,596 @@ -DevVaucouleurs: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - mass_to_light_ratio: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.3 -DevVaucouleursSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - mass_to_light_ratio: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.3 -Exponential: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - mass_to_light_ratio: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.3 -ExponentialSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - mass_to_light_ratio: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.3 -Sersic: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - mass_to_light_ratio: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.3 - sersic_index: - gaussian_limits: - lower: 0.8 - upper: 5.0 - lower_limit: 0.8 - type: Uniform - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 -SersicGradient: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - mass_to_light_gradient: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: -1.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - mass_to_light_ratio: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.3 - sersic_index: - gaussian_limits: - lower: 0.8 - upper: 5.0 - lower_limit: 0.8 - type: Uniform - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 -SersicGradientSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - mass_to_light_gradient: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: -1.0 - type: Uniform - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - mass_to_light_ratio: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.3 - sersic_index: - gaussian_limits: - lower: 0.8 - upper: 5.0 - lower_limit: 0.8 - type: Uniform - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 -SersicSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - effective_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - intensity: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - mass_to_light_ratio: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 1.0e-06 - type: LogUniform - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.3 - sersic_index: - gaussian_limits: - lower: 0.8 - upper: 5.0 - lower_limit: 0.8 - type: Uniform - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 +DevVaucouleurs: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + mass_to_light_ratio: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.3 +DevVaucouleursSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + mass_to_light_ratio: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.3 +Exponential: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + mass_to_light_ratio: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.3 +ExponentialSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + mass_to_light_ratio: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.3 +Sersic: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + mass_to_light_ratio: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.3 + sersic_index: + gaussian_limits: + lower: 0.8 + upper: 5.0 + lower_limit: 0.8 + type: Uniform + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 +SersicGradient: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + mass_to_light_gradient: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: -1.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + mass_to_light_ratio: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.3 + sersic_index: + gaussian_limits: + lower: 0.8 + upper: 5.0 + lower_limit: 0.8 + type: Uniform + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 +SersicGradientSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + mass_to_light_gradient: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: -1.0 + type: Uniform + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + mass_to_light_ratio: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.3 + sersic_index: + gaussian_limits: + lower: 0.8 + upper: 5.0 + lower_limit: 0.8 + type: Uniform + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 +SersicSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + effective_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + intensity: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + mass_to_light_ratio: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 1.0e-06 + type: LogUniform + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.3 + sersic_index: + gaussian_limits: + lower: 0.8 + upper: 5.0 + lower_limit: 0.8 + type: Uniform + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 diff --git a/test_autolens/config/priors/total_mass_profiles.yaml b/test_autolens/config/priors/total_mass_profiles.yaml index 9fad7a6ee..c657bf654 100644 --- a/test_autolens/config/priors/total_mass_profiles.yaml +++ b/test_autolens/config/priors/total_mass_profiles.yaml @@ -1,491 +1,491 @@ -Isothermal: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - einstein_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 4.0 - width_modifier: - type: Relative - value: 0.05 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 -IsothermalCore: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - core_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.1 - einstein_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 4.0 - width_modifier: - type: Relative - value: 0.05 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 -IsothermalCoreSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - core_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.1 - einstein_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 4.0 - width_modifier: - type: Relative - value: 0.05 -IsothermalSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - einstein_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 4.0 - width_modifier: - type: Relative - value: 0.05 -PointMass: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - einstein_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 -PowerLaw: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - einstein_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 4.0 - width_modifier: - type: Relative - value: 0.05 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - slope: - gaussian_limits: - lower: 1.0 - upper: 3.0 - lower_limit: 1.5 - type: Uniform - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 -PowerLawCore: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - core_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.1 - einstein_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 4.0 - width_modifier: - type: Relative - value: 0.05 - ell_comps_0: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - ell_comps_1: - gaussian_limits: - lower: -1.0 - upper: 1.0 - lower_limit: -1.0 - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - slope: - gaussian_limits: - lower: 1.0 - upper: 3.0 - lower_limit: 1.5 - type: Uniform - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 -PowerLawCoreSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - core_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.1 - einstein_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 4.0 - width_modifier: - type: Relative - value: 0.05 - slope: - gaussian_limits: - lower: 1.0 - upper: 3.0 - lower_limit: 1.5 - type: Uniform - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 -PowerLawSph: - centre_0: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - centre_1: - gaussian_limits: - lower: -inf - upper: inf - lower_limit: -inf - mean: 0.0 - sigma: 0.3 - type: Gaussian - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - einstein_radius: - gaussian_limits: - lower: 0.0 - upper: inf - lower_limit: 0.0 - type: Uniform - upper_limit: 4.0 - width_modifier: - type: Relative - value: 0.05 - slope: - gaussian_limits: - lower: 1.0 - upper: 3.0 - lower_limit: 1.5 - type: Uniform - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 +Isothermal: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + einstein_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 4.0 + width_modifier: + type: Relative + value: 0.05 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 +IsothermalCore: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + core_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.1 + einstein_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 4.0 + width_modifier: + type: Relative + value: 0.05 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 +IsothermalCoreSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + core_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.1 + einstein_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 4.0 + width_modifier: + type: Relative + value: 0.05 +IsothermalSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + einstein_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 4.0 + width_modifier: + type: Relative + value: 0.05 +PointMass: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + einstein_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 +PowerLaw: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + einstein_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 4.0 + width_modifier: + type: Relative + value: 0.05 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + slope: + gaussian_limits: + lower: 1.0 + upper: 3.0 + lower_limit: 1.5 + type: Uniform + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 +PowerLawCore: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + core_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.1 + einstein_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 4.0 + width_modifier: + type: Relative + value: 0.05 + ell_comps_0: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + gaussian_limits: + lower: -1.0 + upper: 1.0 + lower_limit: -1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + slope: + gaussian_limits: + lower: 1.0 + upper: 3.0 + lower_limit: 1.5 + type: Uniform + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 +PowerLawCoreSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + core_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.1 + einstein_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 4.0 + width_modifier: + type: Relative + value: 0.05 + slope: + gaussian_limits: + lower: 1.0 + upper: 3.0 + lower_limit: 1.5 + type: Uniform + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 +PowerLawSph: + centre_0: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + centre_1: + gaussian_limits: + lower: -inf + upper: inf + lower_limit: -inf + mean: 0.0 + sigma: 0.3 + type: Gaussian + upper_limit: inf + width_modifier: + type: Absolute + value: 0.05 + einstein_radius: + gaussian_limits: + lower: 0.0 + upper: inf + lower_limit: 0.0 + type: Uniform + upper_limit: 4.0 + width_modifier: + type: Relative + value: 0.05 + slope: + gaussian_limits: + lower: 1.0 + upper: 3.0 + lower_limit: 1.5 + type: Uniform + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 diff --git a/test_autolens/config/visualize.yaml b/test_autolens/config/visualize.yaml index 9405d0ced..763343667 100644 --- a/test_autolens/config/visualize.yaml +++ b/test_autolens/config/visualize.yaml @@ -1,154 +1,154 @@ -general: - general: - backend: default - imshow_origin: upper - zoom_around_mask: true -include: - include_2d: - border: false - tangential_caustics: false - radial_caustics: false - tangential_critical_curves: false - radial_critical_curves: false - grid: true - inversion_grid: true - light_profile_centres: true - mapper_image_plane_mesh_grid: false - mapper_source_plane_mesh_grid: true - mask: true - mass_profile_centres: true - multiple_images: false - origin: true - parallel_overscan: true - positions: true - serial_overscan: true - serial_prescan: true -mat_wrap_2d: - CausticsLine: - figure: - c: w,g - linestyle: -- - linewidth: 5 - subplot: - c: g - linestyle: -- - linewidth: 7 - CriticalCurvesLine: - figure: - c: w,k - linestyle: '-' - linewidth: 4 - subplot: - c: b - linestyle: '-' - linewidth: 6 - LightProfileCentreScatter: - figure: - c: k,r - marker: + - s: 1 - subplot: - c: b - marker: . - s: 15 - MassProfileCentreScatter: - figure: - c: r,k - marker: x - s: 2 - subplot: - c: k - marker: o - s: 16 - MultipleImagesScatter: - figure: - c: k,w - marker: o - s: 3 - subplot: - c: g - marker: . - s: 17 -plots: - dataset: - data: true - noise_map: false - signal_to_noise_map: false - subplot_dataset: true - uv_wavelengths: false - fit: - all_at_end_fits: true - all_at_end_png: false - chi_squared_map: true - data: true - model_data: true - model_images_of_planes: false - noise_map: false - normalized_residual_map: true - plane_images_of_planes: true - residual_map: false - signal_to_noise_map: false - subplot_fit: true - subplots_of_planes: false - subtracted_images_of_planes: true - fit_imaging: {} - fit_interferometer: - subplot_fit_real_space: true - subplot_fit_dirty_images: true - amplitudes_vs_uv_distances: false - dirty_chi_squared_map: false - dirty_image: false - dirty_noise_map: false - dirty_normalized_residual_map: false - dirty_residual_map: false - dirty_signal_to_noise_map: false - phases_vs_uv_distances: false - uv_wavelengths: false - fit_quantity: - all_at_end_fits: true - all_at_end_png: true - chi_squared_map: false - image: true - model_image: false - noise_map: false - residual_map: false - subplot_fit: true - galaxies: - convergence: false - image: false - potential: false - adapt: - images_of_galaxies: true - model_image: true - imaging: - psf: true - interferometer: - amplitudes_vs_uv_distances: false - dirty_image: false - dirty_noise_map: false - dirty_signal_to_noise_map: false - phases_vs_uv_distances: false - uv_wavelengths: false - inversion: - all_at_end_png: false - chi_squared_map: true - errors: false - normalized_residual_map: false - reconstructed_image: true - reconstruction: true - regularization_weights: false - residual_map: false - subplot_inversion: true - positions: - image_with_positions: true - tracer: - all_at_end_fits: true - all_at_end_png: false - convergence: true - deflections: false - image: true - magnification: true - potential: false - source_plane_image: true - subplot_tracer: true +general: + general: + backend: default + imshow_origin: upper + zoom_around_mask: true +include: + include_2d: + border: false + tangential_caustics: false + radial_caustics: false + tangential_critical_curves: false + radial_critical_curves: false + grid: true + inversion_grid: true + light_profile_centres: true + mapper_image_plane_mesh_grid: false + mapper_source_plane_mesh_grid: true + mask: true + mass_profile_centres: true + multiple_images: false + origin: true + parallel_overscan: true + positions: true + serial_overscan: true + serial_prescan: true +mat_wrap_2d: + CausticsLine: + figure: + c: w,g + linestyle: -- + linewidth: 5 + subplot: + c: g + linestyle: -- + linewidth: 7 + CriticalCurvesLine: + figure: + c: w,k + linestyle: '-' + linewidth: 4 + subplot: + c: b + linestyle: '-' + linewidth: 6 + LightProfileCentreScatter: + figure: + c: k,r + marker: + + s: 1 + subplot: + c: b + marker: . + s: 15 + MassProfileCentreScatter: + figure: + c: r,k + marker: x + s: 2 + subplot: + c: k + marker: o + s: 16 + MultipleImagesScatter: + figure: + c: k,w + marker: o + s: 3 + subplot: + c: g + marker: . + s: 17 +plots: + dataset: + data: true + noise_map: false + signal_to_noise_map: false + subplot_dataset: true + uv_wavelengths: false + fit: + all_at_end_fits: true + all_at_end_png: false + chi_squared_map: true + data: true + model_data: true + model_images_of_planes: false + noise_map: false + normalized_residual_map: true + plane_images_of_planes: true + residual_map: false + signal_to_noise_map: false + subplot_fit: true + subplots_of_planes: false + subtracted_images_of_planes: true + fit_imaging: {} + fit_interferometer: + subplot_fit_real_space: true + subplot_fit_dirty_images: true + amplitudes_vs_uv_distances: false + dirty_chi_squared_map: false + dirty_image: false + dirty_noise_map: false + dirty_normalized_residual_map: false + dirty_residual_map: false + dirty_signal_to_noise_map: false + phases_vs_uv_distances: false + uv_wavelengths: false + fit_quantity: + all_at_end_fits: true + all_at_end_png: true + chi_squared_map: false + image: true + model_image: false + noise_map: false + residual_map: false + subplot_fit: true + galaxies: + convergence: false + image: false + potential: false + adapt: + images_of_galaxies: true + model_image: true + imaging: + psf: true + interferometer: + amplitudes_vs_uv_distances: false + dirty_image: false + dirty_noise_map: false + dirty_signal_to_noise_map: false + phases_vs_uv_distances: false + uv_wavelengths: false + inversion: + all_at_end_png: false + chi_squared_map: true + errors: false + normalized_residual_map: false + reconstructed_image: true + reconstruction: true + regularization_weights: false + residual_map: false + subplot_inversion: true + positions: + image_with_positions: true + tracer: + all_at_end_fits: true + all_at_end_png: false + convergence: true + deflections: false + image: true + magnification: true + potential: false + source_plane_image: true + subplot_tracer: true subplot_galaxies_images: true \ No newline at end of file diff --git a/test_autolens/point/files/point_dict.json b/test_autolens/point/files/point_dict.json index ab232721d..6f3bd0e8e 100644 --- a/test_autolens/point/files/point_dict.json +++ b/test_autolens/point/files/point_dict.json @@ -1,36 +1,36 @@ -[ - { - "name": "source_1", - "positions": [ - [ - 1.0, - 1.0 - ] - ], - "positions_noise_map": [ - 1.0 - ], - "fluxes": null, - "fluxes_noise_map": null - }, - { - "name": "source_2", - "positions": [ - [ - 1.0, - 1.0 - ] - ], - "positions_noise_map": [ - 1.0 - ], - "fluxes": [ - 2.0, - 3.0 - ], - "fluxes_noise_map": [ - 4.0, - 5.0 - ] - } +[ + { + "name": "source_1", + "positions": [ + [ + 1.0, + 1.0 + ] + ], + "positions_noise_map": [ + 1.0 + ], + "fluxes": null, + "fluxes_noise_map": null + }, + { + "name": "source_2", + "positions": [ + [ + 1.0, + 1.0 + ] + ], + "positions_noise_map": [ + 1.0 + ], + "fluxes": [ + 2.0, + 3.0 + ], + "fluxes_noise_map": [ + 4.0, + 5.0 + ] + } ] \ No newline at end of file diff --git a/test_autolens/point/test_point_source_dataset.py b/test_autolens/point/test_point_source_dataset.py index d0a53325c..2e10fd722 100644 --- a/test_autolens/point/test_point_source_dataset.py +++ b/test_autolens/point/test_point_source_dataset.py @@ -1,14 +1,14 @@ -import autolens as al - - -def test__info(): - dataset = al.PointDataset( - "name", - positions=al.Grid2DIrregular([(1, 2)]), - positions_noise_map=al.ArrayIrregular([1]), - fluxes=al.ArrayIrregular([2]), - fluxes_noise_map=al.ArrayIrregular([3]), - ) - - assert "name" in dataset.info - assert "positions : Grid2DIrregular" in dataset.info +import autolens as al + + +def test__info(): + dataset = al.PointDataset( + "name", + positions=al.Grid2DIrregular([(1, 2)]), + positions_noise_map=al.ArrayIrregular([1]), + fluxes=al.ArrayIrregular([2]), + fluxes_noise_map=al.ArrayIrregular([3]), + ) + + assert "name" in dataset.info + assert "positions : Grid2DIrregular" in dataset.info diff --git a/test_autolens/point/triangles/conftest.py b/test_autolens/point/triangles/conftest.py index 3c3620630..1aec734ea 100644 --- a/test_autolens/point/triangles/conftest.py +++ b/test_autolens/point/triangles/conftest.py @@ -1,30 +1,30 @@ -import pytest -import autolens as al - - -@pytest.fixture -def grid(): - return al.Grid2D.uniform( - shape_native=(10, 10), - pixel_scales=1.0, - ) - - -@pytest.fixture -def tracer(): - isothermal_mass_profile = al.mp.Isothermal( - centre=(0.0, 0.0), - einstein_radius=1.6, - ell_comps=al.convert.ell_comps_from(axis_ratio=0.9, angle=45.0), - ) - - lens_galaxy = al.Galaxy( - redshift=0.5, - mass=isothermal_mass_profile, - ) - - point_source = al.ps.Point(centre=(0.07, 0.07)) - - source_galaxy = al.Galaxy(redshift=1.0, point_0=point_source) - - return al.Tracer(galaxies=[lens_galaxy, source_galaxy]) +import pytest +import autolens as al + + +@pytest.fixture +def grid(): + return al.Grid2D.uniform( + shape_native=(10, 10), + pixel_scales=1.0, + ) + + +@pytest.fixture +def tracer(): + isothermal_mass_profile = al.mp.Isothermal( + centre=(0.0, 0.0), + einstein_radius=1.6, + ell_comps=al.convert.ell_comps_from(axis_ratio=0.9, angle=45.0), + ) + + lens_galaxy = al.Galaxy( + redshift=0.5, + mass=isothermal_mass_profile, + ) + + point_source = al.ps.Point(centre=(0.07, 0.07)) + + source_galaxy = al.Galaxy(redshift=1.0, point_0=point_source) + + return al.Tracer(galaxies=[lens_galaxy, source_galaxy]) diff --git a/test_autolens/point/triangles/test_extended.py b/test_autolens/point/triangles/test_extended.py index 1c07b0772..08a1061b6 100644 --- a/test_autolens/point/triangles/test_extended.py +++ b/test_autolens/point/triangles/test_extended.py @@ -1,24 +1,24 @@ -import pytest - -from autoarray.structures.triangles.shape import Circle -from autolens.mock import NullTracer -from autolens.point.solver.shape_solver import ShapeSolver - - -@pytest.fixture -def solver(grid): - return ShapeSolver.for_grid( - grid=grid, - pixel_scale_precision=0.01, - ) - - -def test_solver_basic(solver): - assert solver.find_magnification( - tracer=NullTracer(), - shape=Circle( - 0.0, - 0.0, - radius=0.01, - ), - ) == pytest.approx(1.0, abs=0.01) +import pytest + +from autoarray.structures.triangles.shape import Circle +from autolens.mock import NullTracer +from autolens.point.solver.shape_solver import ShapeSolver + + +@pytest.fixture +def solver(grid): + return ShapeSolver.for_grid( + grid=grid, + pixel_scale_precision=0.01, + ) + + +def test_solver_basic(solver): + assert solver.find_magnification( + tracer=NullTracer(), + shape=Circle( + 0.0, + 0.0, + radius=0.01, + ), + ) == pytest.approx(1.0, abs=0.01) diff --git a/test_autolens/point/triangles/test_jax.py b/test_autolens/point/triangles/test_jax.py index aac41330b..6f3b30e31 100644 --- a/test_autolens/point/triangles/test_jax.py +++ b/test_autolens/point/triangles/test_jax.py @@ -1,12 +1,12 @@ -import autofit as af -from autogalaxy.profiles.mass import Isothermal - - -def test_isothermal_pytree(): - model = af.Model(Isothermal) - - children, aux = model.instance_flatten(Isothermal()) - instance = model.instance_unflatten(aux, children) - - assert isinstance(instance, Isothermal) - assert instance.centre == (0.0, 0.0) +import autofit as af +from autogalaxy.profiles.mass import Isothermal + + +def test_isothermal_pytree(): + model = af.Model(Isothermal) + + children, aux = model.instance_flatten(Isothermal()) + instance = model.instance_unflatten(aux, children) + + assert isinstance(instance, Isothermal) + assert instance.centre == (0.0, 0.0) diff --git a/test_autolens/point/triangles/test_regressions.py b/test_autolens/point/triangles/test_regressions.py index f4aa1dbab..c1fc9d5db 100644 --- a/test_autolens/point/triangles/test_regressions.py +++ b/test_autolens/point/triangles/test_regressions.py @@ -1,76 +1,76 @@ -from autoconf.dictable import from_dict -import autolens as al -from autolens.point.solver import PointSolver - - -instance_dict = { - "type": "instance", - "class_path": "autofit.mapper.model.ModelInstance", - "arguments": { - "child_items": { - "type": "dict", - "arguments": { - "source_galaxy": { - "type": "instance", - "class_path": "autogalaxy.galaxy.galaxy.Galaxy", - "arguments": { - "redshift": 1.0, - "label": "cls6", - "light": { - "type": "instance", - "class_path": "autogalaxy.profiles.light.standard.exponential.Exponential", - "arguments": { - "effective_radius": 0.1, - "ell_comps": [0.4731722153284571, -0.27306667016189645], - "centre": [-0.04829335038475, 0.02350935356045], - "intensity": 0.1, - }, - }, - "point_0": { - "type": "instance", - "class_path": "autogalaxy.profiles.point_source.Point", - "arguments": { - "centre": [-0.04829335038475, 0.02350935356045] - }, - }, - }, - }, - "lens_galaxy": { - "type": "instance", - "class_path": "autogalaxy.galaxy.galaxy.Galaxy", - "arguments": { - "redshift": 0.5, - "label": "cls6", - "mass": { - "type": "instance", - "class_path": "autogalaxy.profiles.mass.total.isothermal.Isothermal", - "arguments": { - "ell_comps": [ - 0.05263157894736841, - 3.2227547345982974e-18, - ], - "einstein_radius": 1.6, - "centre": [0.0, 0.0], - }, - }, - }, - }, - }, - } - }, -} - - -def test_missing_multiple_image(grid): - instance = from_dict(instance_dict) - - tracer = al.Tracer(galaxies=[instance.lens_galaxy, instance.source_galaxy]) - - solver = PointSolver.for_grid( - grid=grid, - pixel_scale_precision=0.001, - ) - - triangle_positions = solver.solve( - tracer=tracer, source_plane_coordinate=instance.source_galaxy.point_0.centre - ) +from autoconf.dictable import from_dict +import autolens as al +from autolens.point.solver import PointSolver + + +instance_dict = { + "type": "instance", + "class_path": "autofit.mapper.model.ModelInstance", + "arguments": { + "child_items": { + "type": "dict", + "arguments": { + "source_galaxy": { + "type": "instance", + "class_path": "autogalaxy.galaxy.galaxy.Galaxy", + "arguments": { + "redshift": 1.0, + "label": "cls6", + "light": { + "type": "instance", + "class_path": "autogalaxy.profiles.light.standard.exponential.Exponential", + "arguments": { + "effective_radius": 0.1, + "ell_comps": [0.4731722153284571, -0.27306667016189645], + "centre": [-0.04829335038475, 0.02350935356045], + "intensity": 0.1, + }, + }, + "point_0": { + "type": "instance", + "class_path": "autogalaxy.profiles.point_source.Point", + "arguments": { + "centre": [-0.04829335038475, 0.02350935356045] + }, + }, + }, + }, + "lens_galaxy": { + "type": "instance", + "class_path": "autogalaxy.galaxy.galaxy.Galaxy", + "arguments": { + "redshift": 0.5, + "label": "cls6", + "mass": { + "type": "instance", + "class_path": "autogalaxy.profiles.mass.total.isothermal.Isothermal", + "arguments": { + "ell_comps": [ + 0.05263157894736841, + 3.2227547345982974e-18, + ], + "einstein_radius": 1.6, + "centre": [0.0, 0.0], + }, + }, + }, + }, + }, + } + }, +} + + +def test_missing_multiple_image(grid): + instance = from_dict(instance_dict) + + tracer = al.Tracer(galaxies=[instance.lens_galaxy, instance.source_galaxy]) + + solver = PointSolver.for_grid( + grid=grid, + pixel_scale_precision=0.001, + ) + + triangle_positions = solver.solve( + tracer=tracer, source_plane_coordinate=instance.source_galaxy.point_0.centre + ) diff --git a/test_autolens/point/triangles/test_solver.py b/test_autolens/point/triangles/test_solver.py index 6a5334bbe..a6661bcdf 100644 --- a/test_autolens/point/triangles/test_solver.py +++ b/test_autolens/point/triangles/test_solver.py @@ -1,82 +1,82 @@ -from typing import Tuple - -import pytest - -import autolens as al -import autogalaxy as ag -from autoarray.structures.triangles.jax_coordinate_array import ArrayTriangles -from autolens.mock import NullTracer -from autolens.point.solver import PointSolver - - -@pytest.fixture -def solver(grid): - return PointSolver.for_grid( - grid=grid, - pixel_scale_precision=0.01, - ) - - -def test_solver_basic(solver): - tracer = al.Tracer( - galaxies=[ - al.Galaxy( - redshift=0.5, - mass=ag.mp.Isothermal( - centre=(0.0, 0.0), - einstein_radius=1.0, - ), - ), - al.Galaxy( - redshift=1.0, - ), - ] - ) - - assert solver.solve( - tracer=tracer, - source_plane_coordinate=(0.0, 0.0), - ) - - -def test_steps(solver): - assert solver.n_steps == 7 - - -@pytest.mark.parametrize( - "source_plane_coordinate", - [ - (0.0, 0.0), - (0.0, 1.0), - (1.0, 0.0), - (1.0, 1.0), - (0.5, 0.5), - (0.1, 0.1), - (-1.0, -1.0), - ], -) -def test_trivial( - source_plane_coordinate: Tuple[float, float], - grid, -): - solver = PointSolver.for_grid( - grid=grid, - pixel_scale_precision=0.01, - array_triangles_cls=ArrayTriangles, - ) - (coordinates,) = solver.solve( - tracer=NullTracer(), - source_plane_coordinate=source_plane_coordinate, - ) - assert coordinates == pytest.approx(source_plane_coordinate, abs=1.0e-1) - - -def test_real_example(grid, tracer): - solver = PointSolver.for_grid( - grid=grid, - pixel_scale_precision=0.001, - array_triangles_cls=ArrayTriangles, - ) - result = solver.solve(tracer=tracer, source_plane_coordinate=(0.07, 0.07)) - - assert len(result) == 5 +from typing import Tuple + +import pytest + +import autolens as al +import autogalaxy as ag +from autoarray.structures.triangles.jax_coordinate_array import ArrayTriangles +from autolens.mock import NullTracer +from autolens.point.solver import PointSolver + + +@pytest.fixture +def solver(grid): + return PointSolver.for_grid( + grid=grid, + pixel_scale_precision=0.01, + ) + + +def test_solver_basic(solver): + tracer = al.Tracer( + galaxies=[ + al.Galaxy( + redshift=0.5, + mass=ag.mp.Isothermal( + centre=(0.0, 0.0), + einstein_radius=1.0, + ), + ), + al.Galaxy( + redshift=1.0, + ), + ] + ) + + assert solver.solve( + tracer=tracer, + source_plane_coordinate=(0.0, 0.0), + ) + + +def test_steps(solver): + assert solver.n_steps == 7 + + +@pytest.mark.parametrize( + "source_plane_coordinate", + [ + (0.0, 0.0), + (0.0, 1.0), + (1.0, 0.0), + (1.0, 1.0), + (0.5, 0.5), + (0.1, 0.1), + (-1.0, -1.0), + ], +) +def test_trivial( + source_plane_coordinate: Tuple[float, float], + grid, +): + solver = PointSolver.for_grid( + grid=grid, + pixel_scale_precision=0.01, + array_triangles_cls=ArrayTriangles, + ) + (coordinates,) = solver.solve( + tracer=NullTracer(), + source_plane_coordinate=source_plane_coordinate, + ) + assert coordinates == pytest.approx(source_plane_coordinate, abs=1.0e-1) + + +def test_real_example(grid, tracer): + solver = PointSolver.for_grid( + grid=grid, + pixel_scale_precision=0.001, + array_triangles_cls=ArrayTriangles, + ) + result = solver.solve(tracer=tracer, source_plane_coordinate=(0.07, 0.07)) + + assert len(result) == 5 diff --git a/test_autolens/point/triangles/test_solver_jax.py b/test_autolens/point/triangles/test_solver_jax.py index ff01ae9a7..9be3cf4a8 100644 --- a/test_autolens/point/triangles/test_solver_jax.py +++ b/test_autolens/point/triangles/test_solver_jax.py @@ -1,119 +1,119 @@ -import time -from typing import Tuple - -import pytest - -import autogalaxy as ag -import autofit as af -import numpy as np -from autolens import PointSolver - -try: - from autoarray.structures.triangles.coordinate_array import CoordinateArrayTriangles -except ImportError: - from autoarray.structures.triangles.jax_coordinate_array import ( - CoordinateArrayTriangles, - ) - -from autolens.mock import NullTracer - -pytest.importorskip("jax") - - -@pytest.fixture(autouse=True) -def register(tracer): - af.Model.from_instance(tracer) - - -@pytest.fixture -def solver(grid): - return PointSolver.for_grid( - grid=grid, - pixel_scale_precision=0.01, - array_triangles_cls=CoordinateArrayTriangles, - ) - - -def test_solver(solver): - tracer = ag.mp.Isothermal( - centre=(0.0, 0.0), - einstein_radius=1.0, - ) - assert solver.solve( - tracer, - source_plane_coordinate=(0.0, 0.0), - ) - - -@pytest.mark.parametrize( - "source_plane_coordinate", - [ - (0.0, 0.0), - (0.0, 1.0), - (1.0, 0.0), - (1.0, 1.0), - (0.5, 0.5), - (0.1, 0.1), - (-1.0, -1.0), - ], -) -def test_trivial( - source_plane_coordinate: Tuple[float, float], - grid, - solver, -): - coordinates = solver.solve( - NullTracer(), - source_plane_coordinate=source_plane_coordinate, - ) - coordinates = coordinates.array[~np.isnan(coordinates.array).any(axis=1)] - assert coordinates[0] == pytest.approx(source_plane_coordinate, abs=1.0e-1) - - -def test_real_example(grid, tracer): - solver = PointSolver.for_grid( - grid=grid, - pixel_scale_precision=0.001, - array_triangles_cls=CoordinateArrayTriangles, - ) - - result = solver.solve(tracer, (0.07, 0.07)) - assert len(result) == 5 - - -def _test_jax(grid): - sizes = (5, 10, 15, 20, 25, 30, 35, 40, 45, 50) - run_times = [] - init_times = [] - - for size in sizes: - start = time.time() - solver = PointSolver.for_grid( - grid=grid, - pixel_scale_precision=0.001, - array_triangles_cls=CoordinateArrayTriangles, - max_containing_size=size, - ) - - solver.solve(NullTracer(), (0.07, 0.07)) - - repeats = 100 - - done_init_time = time.time() - init_time = done_init_time - start - for _ in range(repeats): - _ = solver.solve(NullTracer(), (0.07, 0.07)) - - # print(result) - - init_times.append(init_time) - - run_time = (time.time() - done_init_time) / repeats - run_times.append(run_time) - - print(f"Time taken for {size}: {run_time} ({init_time} to init)") - - from matplotlib import pyplot as plt - - plt.plot(sizes, run_times) - plt.show() +import time +from typing import Tuple + +import pytest + +import autogalaxy as ag +import autofit as af +import numpy as np +from autolens import PointSolver + +try: + from autoarray.structures.triangles.coordinate_array import CoordinateArrayTriangles +except ImportError: + from autoarray.structures.triangles.jax_coordinate_array import ( + CoordinateArrayTriangles, + ) + +from autolens.mock import NullTracer + +pytest.importorskip("jax") + + +@pytest.fixture(autouse=True) +def register(tracer): + af.Model.from_instance(tracer) + + +@pytest.fixture +def solver(grid): + return PointSolver.for_grid( + grid=grid, + pixel_scale_precision=0.01, + array_triangles_cls=CoordinateArrayTriangles, + ) + + +def test_solver(solver): + tracer = ag.mp.Isothermal( + centre=(0.0, 0.0), + einstein_radius=1.0, + ) + assert solver.solve( + tracer, + source_plane_coordinate=(0.0, 0.0), + ) + + +@pytest.mark.parametrize( + "source_plane_coordinate", + [ + (0.0, 0.0), + (0.0, 1.0), + (1.0, 0.0), + (1.0, 1.0), + (0.5, 0.5), + (0.1, 0.1), + (-1.0, -1.0), + ], +) +def test_trivial( + source_plane_coordinate: Tuple[float, float], + grid, + solver, +): + coordinates = solver.solve( + NullTracer(), + source_plane_coordinate=source_plane_coordinate, + ) + coordinates = coordinates.array[~np.isnan(coordinates.array).any(axis=1)] + assert coordinates[0] == pytest.approx(source_plane_coordinate, abs=1.0e-1) + + +def test_real_example(grid, tracer): + solver = PointSolver.for_grid( + grid=grid, + pixel_scale_precision=0.001, + array_triangles_cls=CoordinateArrayTriangles, + ) + + result = solver.solve(tracer, (0.07, 0.07)) + assert len(result) == 5 + + +def _test_jax(grid): + sizes = (5, 10, 15, 20, 25, 30, 35, 40, 45, 50) + run_times = [] + init_times = [] + + for size in sizes: + start = time.time() + solver = PointSolver.for_grid( + grid=grid, + pixel_scale_precision=0.001, + array_triangles_cls=CoordinateArrayTriangles, + max_containing_size=size, + ) + + solver.solve(NullTracer(), (0.07, 0.07)) + + repeats = 100 + + done_init_time = time.time() + init_time = done_init_time - start + for _ in range(repeats): + _ = solver.solve(NullTracer(), (0.07, 0.07)) + + # print(result) + + init_times.append(init_time) + + run_time = (time.time() - done_init_time) / repeats + run_times.append(run_time) + + print(f"Time taken for {size}: {run_time} ({init_time} to init)") + + from matplotlib import pyplot as plt + + plt.plot(sizes, run_times) + plt.show()