diff --git a/README.rst b/README.rst index c1bf2bd50..29449b180 100644 --- a/README.rst +++ b/README.rst @@ -20,6 +20,18 @@ PyAutoGalaxy: Open-Source Multi Wavelength Galaxy Structure & Morphology .. image:: https://joss.theoj.org/papers/10.21105/joss.04475/status.svg :target: https://doi.org/10.21105/joss.04475 +.. image:: https://www.repostatus.org/badges/latest/active.svg + :target: https://www.repostatus.org/#active + :alt: Project Status: Active + +.. image:: https://img.shields.io/pypi/pyversions/autogalaxy + :target: https://pypi.org/project/autogalaxy/ + :alt: Python Versions + +.. image:: https://img.shields.io/pypi/v/autogalaxy.svg + :target: https://pypi.org/project/autogalaxy/ + :alt: PyPI Version + `Installation Guide `_ | `readthedocs `_ | `Introduction on Binder `_ | diff --git a/autogalaxy/__init__.py b/autogalaxy/__init__.py index 738c55b86..5c0477e0d 100644 --- a/autogalaxy/__init__.py +++ b/autogalaxy/__init__.py @@ -1,3 +1,8 @@ +from autoconf.dictable import register_parser +from autofit import conf + +conf.instance.register(__file__) + from autoconf.dictable import from_dict, from_json, output_to_json, to_dict from autoarray.dataset import preprocess # noqa from autoarray.dataset.imaging.dataset import Imaging # noqa @@ -23,8 +28,6 @@ from autoarray.mask.mask_1d import Mask1D # noqa from autoarray.mask.mask_2d import Mask2D # noqa from autoarray.mask.derive.zoom_2d import Zoom2D -from autoarray.operators.convolver import Convolver # noqa -from autoarray.operators.convolver import Convolver # noqa from autoarray.operators.transformer import TransformerDFT # noqa from autoarray.operators.transformer import TransformerNUFFT # noqa from autoarray.layout.layout import Layout2D # noqa @@ -50,8 +53,6 @@ from .analysis.adapt_images.adapt_images import AdaptImages from .analysis.adapt_images.adapt_image_maker import AdaptImageMaker -from .analysis.maker import FitMaker -from .analysis.preloads import Preloads from . import aggregator as agg from . import exc from . import plot @@ -115,6 +116,4 @@ from autoconf.fitsable import output_to_fits from autoconf.fitsable import hdu_list_for_output_from -conf.instance.register(__file__) - __version__ = "2025.5.10.1" diff --git a/autogalaxy/abstract_fit.py b/autogalaxy/abstract_fit.py index 0682901de..654f0ec31 100644 --- a/autogalaxy/abstract_fit.py +++ b/autogalaxy/abstract_fit.py @@ -110,9 +110,7 @@ def linear_light_profile_intensity_dict( reconstruction = self.inversion.reconstruction_dict[linear_obj_func] for i, light_profile in enumerate(linear_obj_func.light_profile_list): - linear_light_profile_intensity_dict[light_profile] = float( - reconstruction[i] - ) + linear_light_profile_intensity_dict[light_profile] = reconstruction[i] return linear_light_profile_intensity_dict diff --git a/autogalaxy/aggregator/agg_util.py b/autogalaxy/aggregator/agg_util.py index 78b88eec6..de6e641a4 100644 --- a/autogalaxy/aggregator/agg_util.py +++ b/autogalaxy/aggregator/agg_util.py @@ -140,7 +140,7 @@ def adapt_images_from( galaxy_name_image_dict[value.header["EXTNAME"].lower()] = adapt_image - instance = fit.model.instance_from_prior_medians(ignore_prior_limits=True) + instance = fit.model.instance_from_prior_medians(ignore_assertions=True) adapt_images = AdaptImages(galaxy_name_image_dict=galaxy_name_image_dict) diff --git a/autogalaxy/aggregator/imaging/fit_imaging.py b/autogalaxy/aggregator/imaging/fit_imaging.py index d10494fc1..ef22525a3 100644 --- a/autogalaxy/aggregator/imaging/fit_imaging.py +++ b/autogalaxy/aggregator/imaging/fit_imaging.py @@ -7,8 +7,6 @@ import autofit as af import autoarray as aa -from autogalaxy.analysis.preloads import Preloads - from autogalaxy.aggregator.imaging.imaging import _imaging_from from autogalaxy.aggregator.galaxies import _galaxies_from from autogalaxy.aggregator.dataset_model import _dataset_model_from @@ -19,7 +17,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` objects from a `PyAutoFit` loaded directory `Fit` or sqlite database `Fit` object. @@ -53,10 +50,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. """ from autogalaxy.imaging.fit_imaging import FitImaging @@ -71,25 +64,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, galaxies, dataset_model, adapt_images, mesh_grids_of_planes in zip( + for dataset, galaxies, dataset_model, adapt_images in zip( dataset_list, galaxies_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( @@ -98,7 +80,6 @@ def _fit_imaging_from( dataset_model=dataset_model, adapt_images=adapt_images, settings_inversion=settings_inversion, - preloads=preloads, ) ) @@ -110,7 +91,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 @@ -145,15 +125,17 @@ def __init__( A `PyAutoFit` aggregator object which can load the results of model-fits. 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. + + Parameters + ---------- + aggregator + A `PyAutoFit` aggregator object which can load the results of model-fits. + settings_inversion + Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit. """ 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 @@ -167,7 +149,7 @@ def object_via_gen_from( ---------- fit A `PyAutoFit` `Fit` object which contains the results of a model-fit as an entry which has been loaded from - an output directory or from an sqlite database.. + an output directory or from an sqlite database.. instance A manual instance that overwrites the max log likelihood instance in fit (e.g. for drawing the instance randomly from the PDF). @@ -176,5 +158,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/autogalaxy/aggregator/interferometer/fit_interferometer.py b/autogalaxy/aggregator/interferometer/fit_interferometer.py index f2f802396..4f4034c4b 100644 --- a/autogalaxy/aggregator/interferometer/fit_interferometer.py +++ b/autogalaxy/aggregator/interferometer/fit_interferometer.py @@ -7,8 +7,6 @@ import autofit as af import autoarray as aa -from autogalaxy.analysis.preloads import Preloads - from autogalaxy.aggregator import agg_util from autogalaxy.aggregator.interferometer.interferometer import _interferometer_from from autogalaxy.aggregator.dataset_model import _dataset_model_from @@ -19,7 +17,6 @@ def _fit_interferometer_from( fit: af.Fit, instance: Optional[af.ModelInstance] = None, settings_inversion: aa.SettingsInversion = None, - use_preloaded_grid: bool = True, ) -> List[FitInterferometer]: """ Returns a list of `FitInterferometer` objects from a `PyAutoFit` loaded directory `Fit` or sqlite database `Fit` object. @@ -54,10 +51,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. """ from autogalaxy.interferometer.fit_interferometer import FitInterferometer @@ -73,25 +66,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, galaxies, dataset_model, adapt_images, mesh_grids_of_planes in zip( + for dataset, galaxies, dataset_model, adapt_images in zip( dataset_list, galaxies_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( @@ -100,7 +82,6 @@ def _fit_interferometer_from( dataset_model=dataset_model, adapt_images=adapt_images, settings_inversion=settings_inversion, - preloads=preloads, ) ) @@ -112,50 +93,51 @@ 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 `FitInterferometer` objects from the - results of a model-fit. + Interfaces with an `PyAutoFit` aggregator object to create instances of `FitInterferometer` objects from the + results of a model-fit. - The results of a model-fit can be loaded from hard-disk or stored in a sqlite database, including the following + The results of a model-fit can be loaded from hard-disk or stored in a sqlite database, including the following attributes of the fit: - - The interferometer data, noise-map, uv-wavelengths and settings as .fits files (e.g. `dataset/data.fits`). - - The real space mask defining the grid of the interferometer for the FFT (`dataset/real_space_mask.fits`). - - The settings of inversions used by the fit (`dataset/settings_inversion.json`). + - The interferometer data, noise-map, uv-wavelengths and settings as .fits files (e.g. `dataset/data.fits`). + - The real space mask defining the grid of the interferometer for the FFT (`dataset/real_space_mask.fits`). + - The settings of inversions used by the fit (`dataset/settings_inversion.json`). + + The `aggregator` contains the path to each of these files, and they can be loaded individually. This class + can load them all at once and create an `FitInterferometer` object via the `_fit_interferometer_from` method. - The `aggregator` contains the path to each of these files, and they can be loaded individually. This class - can load them all at once and create an `FitInterferometer` object via the `_fit_interferometer_from` method. + This class's methods returns generators which create the instances of the `FitInterferometer` objects. This ensures + that large sets of results can be efficiently loaded from the hard-disk and do not require storing all + `FitInterferometer` instances in the memory at once. - This class's methods returns generators which create the instances of the `FitInterferometer` objects. This ensures - that large sets of results can be efficiently loaded from the hard-disk and do not require storing all - `FitInterferometer` instances in the memory at once. + For example, if the `aggregator` contains 3 model-fits, this class can be used to create a generator which + creates instances of the corresponding 3 `FitInterferometer` objects. - For example, if the `aggregator` contains 3 model-fits, this class can be used to create a generator which - creates instances of the corresponding 3 `FitInterferometer` objects. + If multiple `Imaging` objects were fitted simultaneously via analysis summing, the `fit.child_values()` method + is instead used to load lists of the data, noise-map, PSF and mask and combine them into a list of + `FitImaging` objects. - If multiple `Imaging` objects were fitted simultaneously via analysis summing, the `fit.child_values()` method - is instead used to load lists of the data, noise-map, PSF and mask and combine them into a list of - `FitImaging` objects. + This can be done manually, but this object provides a more concise API. - This can be done manually, but this object provides a more concise API. + Parameters + ---------- + aggregator + A `PyAutoFit` aggregator object which can load the results of model-fits. + settings_inversion + Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit. - Parameters - ---------- - aggregator - A `PyAutoFit` aggregator object which can load the results of model-fits. - 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. + Parameters + ---------- + aggregator + A `PyAutoFit` aggregator object which can load the results of model-fits. + settings_inversion + Optionally overwrite the `SettingsInversion` of the `Inversion` object that is created from the fit. """ 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 @@ -169,7 +151,7 @@ def object_via_gen_from( ---------- fit A `PyAutoFit` `Fit` object which contains the results of a model-fit as an entry which has been loaded from - an output directory or from an sqlite database.. + an output directory or from an sqlite database.. instance A manual instance that overwrites the max log likelihood instance in fit (e.g. for drawing the instance randomly from the PDF). @@ -178,5 +160,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/autogalaxy/analysis/analysis/analysis.py b/autogalaxy/analysis/analysis/analysis.py index 7b87a910e..345b218db 100644 --- a/autogalaxy/analysis/analysis/analysis.py +++ b/autogalaxy/analysis/analysis/analysis.py @@ -1,18 +1,12 @@ -import json import logging -from typing import Dict, List, Optional, Tuple, Union -from os import path -import os -import time +from typing import List, Optional -from autoconf import conf import autofit as af import autoarray as aa from autogalaxy.galaxy.galaxy import Galaxy from autogalaxy.galaxy.galaxies import Galaxies from autogalaxy.cosmology.lensing import LensingCosmology -from autogalaxy.cosmology.wrap import Planck15 logger = logging.getLogger(__name__) @@ -20,7 +14,9 @@ class Analysis(af.Analysis): - def __init__(self, cosmology: LensingCosmology = Planck15): + def __init__( + self, cosmology: LensingCosmology = None, preloads: aa.Preloads = None, **kwargs + ): """ Fits a model to a dataset via a non-linear search. @@ -34,10 +30,16 @@ def __init__(self, cosmology: LensingCosmology = Planck15): cosmology The Cosmology assumed for this analysis. """ - self.cosmology = cosmology + + from autogalaxy.cosmology.wrap import Planck15 + + self.cosmology = cosmology or Planck15() + self.preloads = preloads + self.kwargs = kwargs def galaxies_via_instance_from( - self, instance: af.ModelInstance, run_time_dict: Optional[Dict] = None + self, + instance: af.ModelInstance, ) -> List[Galaxy]: """ Create a list of galaxies from a model instance, which is used to fit the dataset. @@ -60,10 +62,9 @@ def galaxies_via_instance_from( if getattr(instance, "extra_galaxies", None) is not None: return Galaxies( galaxies=instance.galaxies + instance.extra_galaxies, - run_time_dict=run_time_dict, ) - return Galaxies(galaxies=instance.galaxies, run_time_dict=run_time_dict) + return Galaxies(galaxies=instance.galaxies) def dataset_model_via_instance_from( self, instance: af.ModelInstance @@ -126,135 +127,3 @@ def make_result( search_internal=search_internal, analysis=self, ) - - def profile_log_likelihood_function( - self, instance: af.ModelInstance, paths: Optional[af.DirectoryPaths] = None - ) -> Tuple[Dict, Dict]: - """ - This function is optionally called throughout a model-fit to profile the log likelihood function. - - All function calls inside the `log_likelihood_function` that are decorated with the `profile_func` are timed - with their times stored in a dictionary called the `run_time_dict`. - - 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, - which they can be inspected to ensure run-times are as expected. - - Parameters - ---------- - 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). - paths - The paths object which manages all paths, e.g. where the non-linear search outputs are stored, - visualization and the pickled objects used by the aggregator output by this function. - - Returns - ------- - Two dictionaries, the profiling dictionary and info dictionary, which contain the profiling times of the - `log_likelihood_function` and information on the model and dataset used to perform the profiling. - """ - - if isinstance(paths, af.DatabasePaths): - return - - run_time_dict = {} - info_dict = {} - - repeats = conf.instance["general"]["profiling"]["repeats"] - info_dict["repeats"] = repeats - - # Ensure numba functions are compiled before profiling begins. - - fit = self.fit_from(instance=instance) - fit.figure_of_merit - - start = time.time() - - for _ in range(repeats): - try: - fit = self.fit_from(instance=instance) - fit.figure_of_merit - except Exception: - logger.info( - "Profiling failed. Returning without outputting information." - ) - return - - fit_time = (time.time() - start) / repeats - - run_time_dict["fit_time"] = fit_time - - fit = self.fit_from(instance=instance, run_time_dict=run_time_dict) - fit.figure_of_merit - - try: - info_dict["image_pixels"] = self.dataset.grids.lp.shape_slim - info_dict["sub_total_light_profiles"] = ( - self.dataset.grids.lp.over_sampler.sub_total - ) - except AttributeError: - pass - - if fit.model_obj.has(cls=aa.Pixelization): - info_dict["use_w_tilde"] = fit.inversion.settings.use_w_tilde - try: - info_dict["sub_total_pixelization"] = ( - self.dataset.grids.pixelization.over_sampler.sub_total - ) - except AttributeError: - pass - info_dict["use_positive_only_solver"] = ( - fit.inversion.settings.use_positive_only_solver - ) - info_dict["force_edge_pixels_to_zeros"] = ( - fit.inversion.settings.force_edge_pixels_to_zeros - ) - info_dict["use_w_tilde_numpy"] = fit.inversion.settings.use_w_tilde_numpy - info_dict["source_pixels"] = len(fit.inversion.reconstruction) - - if hasattr(fit.inversion, "w_tilde"): - info_dict["w_tilde_curvature_preload_size"] = ( - fit.inversion.w_tilde.curvature_preload.shape[0] - ) - - self.output_profiling_info( - paths=paths, run_time_dict=run_time_dict, info_dict=info_dict - ) - - return run_time_dict, info_dict - - def output_profiling_info( - self, paths: Optional[af.DirectoryPaths], run_time_dict: Dict, info_dict: Dict - ): - """ - Output the log likelihood function profiling information to hard-disk as a json file. - - This function is separate from the `profile_log_likelihood_function` function above such that it can be - called by children `Analysis` classes that profile additional aspects of the model-fit and therefore add - extra information to the `run_time_dict` and `info_dict`. - - Parameters - ---------- - paths - The paths object which manages all paths, e.g. where the non-linear search outputs are stored, - visualization and the pickled objects used by the aggregator output by this function. - run_time_dict - A dictionary containing the profiling times of the functions called by the `log_likelihood_function`. - info_dict - A dictionary containing information on the model and dataset used to perform the profiling, where these - settings typically control the overall run-time. - """ - - if paths is None: - return - - os.makedirs(paths.profile_path, exist_ok=True) - - with open(path.join(paths.profile_path, "run_time_dict.json"), "w+") as f: - json.dump(run_time_dict, f, indent=4) - - with open(path.join(paths.profile_path, "info_dict.json"), "w+") as f: - json.dump(info_dict, f, indent=4) diff --git a/autogalaxy/analysis/analysis/dataset.py b/autogalaxy/analysis/analysis/dataset.py index 012731639..f9e73c3bf 100644 --- a/autogalaxy/analysis/analysis/dataset.py +++ b/autogalaxy/analysis/analysis/dataset.py @@ -1,9 +1,6 @@ -import copy import logging from typing import Optional, Union -import os -from autoconf import conf from autoconf.dictable import to_dict, output_to_json import autofit as af @@ -11,10 +8,7 @@ from autogalaxy.analysis.adapt_images.adapt_image_maker import AdaptImageMaker from autogalaxy.analysis.adapt_images.adapt_images import AdaptImages -from autogalaxy.analysis.maker import FitMaker -from autogalaxy.analysis.preloads import Preloads from autogalaxy.cosmology.lensing import LensingCosmology -from autogalaxy.cosmology.wrap import Planck15 from autogalaxy.analysis.analysis.analysis import Analysis from autogalaxy.analysis.result import ResultDataset @@ -28,9 +22,11 @@ def __init__( self, dataset: Union[aa.Imaging, aa.Interferometer], adapt_image_maker: Optional[AdaptImageMaker] = None, - cosmology: LensingCosmology = Planck15(), + cosmology: LensingCosmology = None, settings_inversion: aa.SettingsInversion = None, + preloads: aa.Preloads = None, title_prefix: str = None, + **kwargs, ): """ Abstract Analysis class for all model-fits which fit galaxies to a dataset, like imaging or interferometer data. @@ -55,7 +51,11 @@ def __init__( A string that is added before the title of all figures output by visualization, for example to put the name of the dataset and galaxy in the title. """ - super().__init__(cosmology=cosmology) + super().__init__( + cosmology=cosmology, + preloads=preloads, + **kwargs, + ) self.dataset = dataset self.adapt_image_maker = adapt_image_maker @@ -63,18 +63,8 @@ def __init__( self.settings_inversion = settings_inversion or aa.SettingsInversion() - self.preloads = self.preloads_cls() - self.title_prefix = title_prefix - @property - def preloads_cls(self): - return Preloads - - @property - def fit_maker_cls(self): - return FitMaker - @property def adapt_images(self): if self._adapt_images is not None: @@ -83,67 +73,6 @@ def adapt_images(self): if self.adapt_image_maker is not None: return self.adapt_image_maker.adapt_images - def set_preloads(self, paths: af.DirectoryPaths, model: af.Collection): - """ - It is common for the model to have components whose parameters are all fixed, and thus the way that component - fits the data does not change. For example, if all parameter associated with the light profiles of galaxies - in the model are fixed, the image generated from these galaxies will not change irrespective of the model - parameters chosen by the non-linear search. - - Preloading exploits this to speed up the log likelihood function, by inspecting the model and storing in memory - quantities that do not change. For the example above, the image of all galaxies would be stored in memory and - to perform every fit in the `log_likelihood_funtion`. - - This function sets up all preload quantities, which are described fully in the `preloads` modules. This - occurs directly before the non-linear search begins, to ensure the model parameterization is fixed. - - Parameters - ---------- - paths - The paths object which manages all paths, e.g. where the non-linear search outputs are stored, - visualization and the pickled objects used by the aggregator output by this function. - model - The model object, which includes model components representing the galaxies that are fitted to - the imaging data. - """ - - logger.info( - "PRELOADS - Setting up preloads, may take a few minutes for fits using an inversion." - ) - - self.preloads = self.preloads_cls() - - settings_inversion_original = copy.copy(self.settings_inversion) - - self.settings_inversion.image_mesh_min_mesh_pixels_per_pixel = None - self.settings_inversion.image_mesh_adapt_background_percent_threshold = None - - fit_maker = self.fit_maker_cls(model=model, fit_from=self.fit_from) - - fit_0 = fit_maker.fit_via_model_from(unit_value=0.45) - fit_1 = fit_maker.fit_via_model_from(unit_value=0.55) - - if fit_0 is None or fit_1 is None: - self.preloads = self.preloads_cls(failed=True) - - self.settings_inversion = settings_inversion_original - - else: - self.preloads = self.preloads_cls.setup_all_via_fits( - fit_0=fit_0, fit_1=fit_1 - ) - - if conf.instance["general"]["test"]["check_preloads"]: - self.preloads.check_via_fit(fit=fit_0) - - self.settings_inversion = settings_inversion_original - - if isinstance(paths, af.DatabasePaths): - return - - os.makedirs(paths.profile_path, exist_ok=True) - self.preloads.output_info_to_summary(file_path=paths.profile_path) - def save_attributes(self, paths: af.DirectoryPaths): """ Before the model-fit via the non-linear search begins, this routine saves attributes of the `Analysis` object diff --git a/autogalaxy/analysis/maker.py b/autogalaxy/analysis/maker.py deleted file mode 100644 index 154042ee9..000000000 --- a/autogalaxy/analysis/maker.py +++ /dev/null @@ -1,128 +0,0 @@ -import logging -from typing import Callable, Union - -import autoarray as aa -import autofit as af -from autoconf import conf -from autofit.exc import PriorLimitException -from autogalaxy.analysis.preloads import Preloads - -logger = logging.getLogger(__name__) - -logger.setLevel(level="INFO") - - -class FitMaker: - def __init__(self, model: af.Collection, fit_from: Callable): - """ - Makes fits using an input PyAutoFit `model`, where the parameters of the model are drawn from its prior. This - uses an input `fit_from`, which given an `instance` of the model creates the fit object. - - This is used for implicit preloading in the `Analysis` classes, whereby the created fits are compared against - one another to determine whether certain components of the analysis can be preloaded. - - This includes functionality for creating the fit via the model in different ways, so that if certain - models are ill-defined another is used instead. - - Parameters - ---------- - model - A **PyAutoFit** model object which via its parameters and their priors can created instances of the model. - fit_from - A function which given the instance of the model creates a `Fit` object. - """ - - self.model = model - self.fit_from = fit_from - - @property - def preloads_cls(self): - return Preloads - - def fit_via_model_from( - self, unit_value: float - ) -> Union[aa.FitImaging, aa.FitInterferometer]: - """ - Create a fit via the model. - - This first tries to compute the fit from the input `unit_value`, where the `unit_value` defines unit hyper - cube values of each parameter's prior in the model, used to map each value to physical values for the fit. - - If this model fit produces an `Exception` because the parameter combination does not fit the data accurately, - a sequence of random fits are instead used into an exception is not returned. However, if the number - of `preload_attempts` defined in the configuration files is exceeded a None is returned. - - Parameters - ---------- - unit_value - The unit hyper cube values of each parameter's prior in the model, used to map each value to physical - values for the fit. - - Returns - ------- - fit - A fit object where an instance of the model has been fitted to the data. - """ - try: - try: - return self.fit_unit_instance_from(unit_value=unit_value) - except IndexError as e: - raise Exception from e - except (Exception, PriorLimitException): - return self.fit_random_instance_from() - - def fit_unit_instance_from( - self, unit_value: float - ) -> Union[aa.FitImaging, aa.FitInterferometer]: - """ - Create a fit via the model using an input `unit_value`, where the `unit_value` defines unit hyper - cube values of each parameter's prior in the model, used to map each value to physical values for the fit. - - Parameters - ---------- - unit_value - The unit hyper cube values of each parameter's prior in the model, used to map each value to physical - values for the fit. - - Returns - ------- - fit - A fit object where an instance of the model has been fitted to the data. - """ - instance = self.model.instance_from_unit_vector( - unit_vector=[unit_value] * self.model.prior_count, ignore_prior_limits=True - ) - - fit = self.fit_from( - instance=instance, - ) - fit.figure_of_merit - return fit - - def fit_random_instance_from(self) -> Union[aa.FitImaging, aa.FitInterferometer]: - """ - Create a fit via the model by guessing a sequence of random fits until an exception is not returned. If - the number of `preload_attempts` defined in the configuration files is exceeded a None is returned. - - Returns - ------- - fit - A fit object where an instance of the model has been fitted to the data. - """ - - preload_attempts = conf.instance["general"]["analysis"]["preload_attempts"] - - for i in range(preload_attempts): - try: - instance = self.model.random_instance(ignore_prior_limits=True) - - fit = self.fit_from( - instance=instance, - ) - - fit.figure_of_merit - - return fit - - except Exception as e: - continue diff --git a/autogalaxy/analysis/plotter_interface.py b/autogalaxy/analysis/plotter_interface.py index 35763e5f0..b49e492d8 100644 --- a/autogalaxy/analysis/plotter_interface.py +++ b/autogalaxy/analysis/plotter_interface.py @@ -1,7 +1,10 @@ +from __future__ import annotations import csv import os -from pathlib import Path -from typing import List, Union +from typing import List, Union, TYPE_CHECKING + +if TYPE_CHECKING: + from pathlib import Path from autoconf import conf from autoconf.fitsable import hdu_list_for_output_from @@ -15,7 +18,6 @@ from autogalaxy.galaxy.plot.galaxies_plotters import GalaxiesPlotter from autogalaxy.galaxy.plot.adapt_plotters import AdaptPlotter -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.mat_plot.one_d import MatPlot1D from autogalaxy.plot.mat_plot.two_d import MatPlot2D @@ -62,11 +64,11 @@ def __init__(self, image_path: Union[Path, str], title_prefix: str = None): A string that is added before the title of all figures output by visualization, for example to put the name of the dataset and galaxy in the title. """ + from pathlib import Path + self.image_path = Path(image_path) self.title_prefix = title_prefix - self.include_2d = Include2D() - os.makedirs(image_path, exist_ok=True) @property @@ -141,7 +143,6 @@ def should_plot(name): galaxies=galaxies, grid=grid, mat_plot_2d=mat_plot_2d, - include_2d=self.include_2d, ) if should_plot("subplot_galaxy_images"): @@ -153,7 +154,6 @@ def should_plot(name): galaxies=galaxies, grid=grid, mat_plot_2d=mat_plot_2d, - include_2d=self.include_2d, ) if should_plot("subplot_galaxies"): @@ -219,7 +219,8 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() inversion_plotter = aplt.InversionPlotter( - inversion=inversion, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + inversion=inversion, + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_inversion"): @@ -250,7 +251,14 @@ def should_plot(name): writer.writerow(["y", "x", "reconstruction", "noise_map"]) # header for i in range(len(x)): - writer.writerow([y[i], x[i], reconstruction[i], noise_map[i]]) + writer.writerow( + [ + float(y[i]), + float(x[i]), + float(reconstruction[i]), + float(noise_map[i]), + ] + ) def adapt_images( self, @@ -279,7 +287,7 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() adapt_plotter = AdaptPlotter( - mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_adapt_images"): diff --git a/autogalaxy/analysis/preloads.py b/autogalaxy/analysis/preloads.py deleted file mode 100644 index b1d513e86..000000000 --- a/autogalaxy/analysis/preloads.py +++ /dev/null @@ -1,213 +0,0 @@ -import logging -import numpy as np -from os import path -from typing import Dict, Optional, List - -import autofit as af -import autoarray as aa - -logger = logging.getLogger(__name__) - -logger.setLevel(level="INFO") - - -class Preloads(aa.Preloads): - def __init__( - self, - w_tilde: Optional[aa.WTildeImaging] = None, - use_w_tilde: Optional[bool] = None, - blurred_image: Optional[aa.Array2D] = 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, "Galaxy"]] = None, - linear_func_operated_mapping_matrix_dict=None, - data_linear_func_matrix_dict=None, - mapper_operated_mapping_matrix_dict=None, - operated_mapping_matrix: Optional[np.ndarray] = None, - curvature_matrix: Optional[np.ndarray] = 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 thoughout 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 - ------- - 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, - relocated_grid=relocated_grid, - image_plane_mesh_grid_pg_list=image_plane_mesh_grid_pg_list, - mapper_list=mapper_list, - 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, - operated_mapping_matrix=operated_mapping_matrix, - curvature_matrix=curvature_matrix, - 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.mapper_galaxy_dict = mapper_galaxy_dict - self.blurred_image = blurred_image - 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_mapper_list(fit_0=fit_0, fit_1=fit_1) - - if preloads.mapper_list is not None: - preloads.mapper_galaxy_dict = fit_0.galaxies_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_blurred_image(self, fit_0, fit_1): - """ - If the `LightProfile`'s in a model are all fixed parameters their corresponding image and therefore PSF blurred - image do not change during the model fit and can therefore be preloaded. - - This function compares the blurred image of two fit's corresponding to two model instances, and preloads - the blurred image if the blurred image of both fits are the same. - - The preload is typically used though out search chaining pipelines, as it is common to fix the lens light for - the majority of model-fits. - - 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.blurred_image = None - - precision = 1e-8 - - if (np.max(abs(fit_0.blurred_image - fit_1.blurred_image)) < precision) and ( - np.sum(fit_0.blurred_image) > precision - ): - self.blurred_image = fit_0.blurred_image - - logger.info( - "PRELOADS - Blurred image (e.g. the image of all light profiles) is preloaded for this model-fit." - ) - - def output_info_to_summary(self, file_path): - file_preloads = path.join(file_path, "preloads.summary") - - if self.failed: - logger.info( - "PRELOADS - Preloading failed as models gave too many exceptions, preloading therefore " - "not used." - ) - - af.formatter.output_list_of_strings_to_file( - file=file_preloads, list_of_strings=["FAILED"] - ) - - else: - af.formatter.output_list_of_strings_to_file( - file=file_preloads, list_of_strings=self.info - ) - - @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"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/autogalaxy/config/general.yaml b/autogalaxy/config/general.yaml index 2701b2df7..fa2fecc9f 100644 --- a/autogalaxy/config/general.yaml +++ b/autogalaxy/config/general.yaml @@ -1,9 +1,8 @@ -analysis: - preload_attempts: 250 +jax: + use_jax: true # If True, uses JAX internally, whereas False uses normal Numpy. fits: flip_for_ds9: true grid: - remove_projected_centre: false # Whether 1D plots of a light profile should remove the central point to avoid the large numerical central value skewing the y axis. max_evaluation_grid_size: 1000 # An evaluation grid whose shape is adaptive chosen is used to compute quantities like critical curves, this integer is the max size of the grid ensuring faster run times. adapt: adapt_minimum_percent: 0.01 @@ -12,6 +11,4 @@ inversion: use_border_relocator: true # If True, by default a pixelization's border is used to relocate all pixels outside its border to the border. test: check_likelihood_function: true # 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. + exception_override: false \ No newline at end of file diff --git a/autogalaxy/config/grids.yaml b/autogalaxy/config/grids.yaml deleted file mode 100644 index e77427ee3..000000000 --- a/autogalaxy/config/grids.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# 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: - Chameleon: 1.0e-08 - ChameleonSph: 1.0e-08 - DevVaucouleurs: 1.0e-06 - DevVaucouleursSph: 1.0e-06 - dPIE: 1.0e-08 - dPIESph: 1.0e-08 - ExponentialGradient: 1.0e-06 - ExponentialGradientSph: 1.0e-06 - ElsonFreeFall: 1.0e-08 - ElsonFreeFallSph: 1.0e-08 - Exponential: 1.0e-06 - ExponentialCore: 1.0e-06 - ExponentialCoreSph: 1.0e-06 - ExponentialSph: 1.0e-06 - ExternalShear: 1.0e-08 - Gaussian: 1.0e-08 - GaussianGradient: 1.0e-08 - GaussianSph: 1.0e-08 - gNFW: 1.0e-06 - gNFWMCRLudlow: 1.0e-06 - gNFWVirialMassConcSph: 1.0e-06 - gNFWVirialMassgNFWConcSph: 1.0e-06 - gNFWSph: 1.0e-06 - Isothermal: 1.0e-08 - IsothermalCore: 1.0e-08 - IsothermalCoreSph: 1.0e-08 - IsothermalSph: 1.0e-08 - MassSheet: 1.0e-08 - Moffat: 1.0e-08 - MoffatSph: 1.0e-08 - PowerLawMultipole: 1.0e-08 - NFW: 1.0e-06 - NFWMCRDuffySph: 1.0e-06 - NFWMCRLudlow: 1.0e-06 - NFWMCRLudlowSph: 1.0e-06 - NFWMCRScatterLudlow: 1.0e-06 - NFWMCRScatterLudlowSph: 1.0e-06 - NFWVirialMassConcSph : 1.0e-06 - NFWSph: 1.0e-06 - NFWTruncatedMCRDuffySph: 1.0e-06 - NFWTruncatedMCRLudlowSph: 1.0e-06 - NFWTruncatedMCRScatterLudlowSph: 1.0e-06 - NFWTruncatedSph: 1.0e-06 - PointMass: 1.0e-08 - 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-06 - SersicCore: 1.0e-06 - SersicCoreSph: 1.0e-06 - SersicGradient: 1.0e-06 - SersicSph: 1.0e-06 - SersicGradientSph: 1.0e-06 - ShapeletCartesianSph: 1.0e-8 - ShapeletCartesian: 1.0e-8 - ShapeletPolarSph: 1.0e-8 - ShapeletPolar: 1.0e-8 - ShapeletExponentialSph: 1.0e-8 - ShapeletExponential: 1.0e-8 - SMBH: 1.0e-8 - SMBHBinary: 1.0e-8 - EllProfile: 1.0e-08 diff --git a/autogalaxy/config/notation.yaml b/autogalaxy/config/notation.yaml index 264a3c8de..593c44555 100644 --- a/autogalaxy/config/notation.yaml +++ b/autogalaxy/config/notation.yaml @@ -9,7 +9,6 @@ label: centre_1: x coefficient: \lambda c_2: c_{\rm 2} - c_gNFW: c_{\rm gNFW} concentration: conc core_radius: C_{\rm r} core_radius_0: C_{rm r0} @@ -73,7 +72,6 @@ label: SMBH: smbh Redshift: z Regularization: reg - InputDeflections: defl label_format: format: sigma: '{:.4f}' @@ -141,4 +139,4 @@ label_format: virial_mass: '{:.4f}' virial_overdens: '{:.4f}' weight_floor: '{:.4f}' - weight_power: '{:.4f}' + weight_power: '{:.4f}' \ No newline at end of file diff --git a/autogalaxy/config/output.yaml b/autogalaxy/config/output.yaml index b25c335c6..88f7d01c4 100644 --- a/autogalaxy/config/output.yaml +++ b/autogalaxy/config/output.yaml @@ -86,8 +86,10 @@ start_point: true # manually after completing a successful model-fit. This will save computational run time by not computing latent # variables during a any model-fit which is unsuccessful. -latent_during_fit: true # Whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files during the fit when it performs on-the-fly output. +latent_during_fit: false # Whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files during the fit when it performs on-the-fly output. latent_after_fit: true # If `latent_during_fit` is False, whether to output the `latent.csv`, `latent.results` and `latent_summary.json` files after the fit is complete. +latent_draw_via_pdf : true # Whether to draw latent variable values via the PDF of every sample, which uses fewer samples to estimate latent variable errors. If False, latent variable values are drawn from every sample. +latent_draw_via_pdf_size : 100 # The number of samples drawn to estimate latent variable errors if `latent_draw_via_pdf` is True. latent_csv: true # Whether to ouptut the `latent.csv` file. latent_results: true # Whether to output the `latent.results` file. diff --git a/autogalaxy/config/priors/README.rst b/autogalaxy/config/priors/README.rst index 27bd5ebd9..0b492084a 100644 --- a/autogalaxy/config/priors/README.rst +++ b/autogalaxy/config/priors/README.rst @@ -13,7 +13,7 @@ They appear as follows: width_modifier: type: Absolute value: 20.0 - gaussian_limits: + limits: lower: -inf upper: inf @@ -27,9 +27,9 @@ The sections of this example config set the following: width_modifier When the results of a search are passed to a subsequent search to set up the priors of its non-linear search, this entry describes how the Prior is passed. - gaussian_limits + limits When the results of a search are passed to a subsequent search, they are passed using a GaussianPrior. The - gaussian_limits set the physical lower and upper limits of this GaussianPrior, such that parameter samples + limits set the physical lower and upper limits of this GaussianPrior, such that parameter samples can not go beyond these limits. The files ``template_module.yaml`` and ``TemplateObject.yaml`` give templates one can use to set up prior default diff --git a/autogalaxy/config/priors/basis.yaml b/autogalaxy/config/priors/basis.yaml index d4b4187f1..a208ccb42 100644 --- a/autogalaxy/config/priors/basis.yaml +++ b/autogalaxy/config/priors/basis.yaml @@ -1 +1 @@ -Basis: {} +Basis: {} diff --git a/autogalaxy/config/priors/cosmology.yaml b/autogalaxy/config/priors/cosmology.yaml index 1efc5d637..656941bba 100644 --- a/autogalaxy/config/priors/cosmology.yaml +++ b/autogalaxy/config/priors/cosmology.yaml @@ -1,63 +1,63 @@ -model.LambdaCDMWrap: - H0: - type: Constant - value: 67.66 - Om0: - type: Constant - value: 0.30966 - Ode0: - type: Constant - value: 0.69034 - Tcmb0: - type: Constant - value: 2.7255 - Neff: - type: Constant - value: 3.046 - m_nu: - type: Constant - value: 0.06 - Ob0: - type: Constant - value: 0.04897 -model.FlatLambdaCDMWrap: - H0: - type: Constant - value: 67.66 - Om0: - type: Constant - value: 0.30966 - Tcmb0: - type: Constant - value: 2.7255 - Neff: - type: Constant - value: 3.046 - m_nu: - type: Constant - value: 0.06 - Ob0: - type: Constant - value: 0.04897 -model.FlatwCDMWrap: - H0: - type: Constant - value: 67.66 - Om0: - type: Constant - value: 0.30966 - w0: - type: Constant - value: -1.0 - Tcmb0: - type: Constant - value: 2.7255 - Neff: - type: Constant - value: 3.046 - m_nu: - type: Constant - value: 0.06 - Ob0: - type: Constant +model.LambdaCDMWrap: + H0: + type: Constant + value: 67.66 + Om0: + type: Constant + value: 0.30966 + Ode0: + type: Constant + value: 0.69034 + Tcmb0: + type: Constant + value: 2.7255 + Neff: + type: Constant + value: 3.046 + m_nu: + type: Constant + value: 0.06 + Ob0: + type: Constant + value: 0.04897 +model.FlatLambdaCDMWrap: + H0: + type: Constant + value: 67.66 + Om0: + type: Constant + value: 0.30966 + Tcmb0: + type: Constant + value: 2.7255 + Neff: + type: Constant + value: 3.046 + m_nu: + type: Constant + value: 0.06 + Ob0: + type: Constant + value: 0.04897 +model.FlatwCDMWrap: + H0: + type: Constant + value: 67.66 + Om0: + type: Constant + value: 0.30966 + w0: + type: Constant + value: -1.0 + Tcmb0: + type: Constant + value: 2.7255 + Neff: + type: Constant + value: 3.046 + m_nu: + type: Constant + value: 0.06 + Ob0: + type: Constant value: 0.04897 \ No newline at end of file diff --git a/autogalaxy/config/priors/ellipse/ellipse.yaml b/autogalaxy/config/priors/ellipse/ellipse.yaml index 631c14b93..471d2ca98 100644 --- a/autogalaxy/config/priors/ellipse/ellipse.yaml +++ b/autogalaxy/config/priors/ellipse/ellipse.yaml @@ -3,47 +3,39 @@ Ellipse: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf centre_1: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf ell_comps_0: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 width_modifier: type: Absolute value: 0.2 - gaussian_limits: + limits: lower: -1.0 upper: 1.0 ell_comps_1: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 width_modifier: type: Absolute value: 0.2 - gaussian_limits: + limits: lower: -1.0 upper: 1.0 diff --git a/autogalaxy/config/priors/ellipse/ellipse_multipole.yaml b/autogalaxy/config/priors/ellipse/ellipse_multipole.yaml index 232ea447e..3f5d34739 100644 --- a/autogalaxy/config/priors/ellipse/ellipse_multipole.yaml +++ b/autogalaxy/config/priors/ellipse/ellipse_multipole.yaml @@ -6,7 +6,7 @@ EllipseMultipole: width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf multipole_comps_1: @@ -16,6 +16,6 @@ EllipseMultipole: width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf diff --git a/autogalaxy/config/priors/galaxy/redshift.yaml b/autogalaxy/config/priors/galaxy/redshift.yaml index 7fac1b0e7..1938e8a22 100644 --- a/autogalaxy/config/priors/galaxy/redshift.yaml +++ b/autogalaxy/config/priors/galaxy/redshift.yaml @@ -6,6 +6,6 @@ Redshift: width_modifier: type: Absolute value: 1.0 - gaussian_limits: + limits: lower: 0.0 upper: inf \ No newline at end of file diff --git a/autogalaxy/config/priors/image_mesh/hilbert.yaml b/autogalaxy/config/priors/image_mesh/hilbert.yaml index 8f773ecb3..038fc4d85 100644 --- a/autogalaxy/config/priors/image_mesh/hilbert.yaml +++ b/autogalaxy/config/priors/image_mesh/hilbert.yaml @@ -6,7 +6,7 @@ Hilbert: width_modifier: type: Absolute value: 100.0 - gaussian_limits: + limits: lower: 50.0 upper: inf weight_floor: @@ -16,7 +16,7 @@ Hilbert: width_modifier: type: Absolute value: 0.1 - gaussian_limits: + limits: lower: 0.0 upper: inf weight_power: @@ -26,6 +26,6 @@ Hilbert: width_modifier: type: Absolute value: 5.0 - gaussian_limits: + limits: lower: 0.0 upper: inf \ No newline at end of file diff --git a/autogalaxy/config/priors/image_mesh/kmeans.yaml b/autogalaxy/config/priors/image_mesh/kmeans.yaml index 31bb2ee4a..ece8c704e 100644 --- a/autogalaxy/config/priors/image_mesh/kmeans.yaml +++ b/autogalaxy/config/priors/image_mesh/kmeans.yaml @@ -6,7 +6,7 @@ KMeans: width_modifier: type: Absolute value: 100.0 - gaussian_limits: + limits: lower: 50.0 upper: inf weight_floor: @@ -16,7 +16,7 @@ KMeans: width_modifier: type: Absolute value: 0.1 - gaussian_limits: + limits: lower: 0.0 upper: inf weight_power: @@ -26,6 +26,6 @@ KMeans: width_modifier: type: Absolute value: 5.0 - gaussian_limits: + limits: lower: 0.0 upper: inf \ No newline at end of file diff --git a/autogalaxy/config/priors/image_mesh/overlay.yaml b/autogalaxy/config/priors/image_mesh/overlay.yaml index ac4e334bf..17c283ab0 100644 --- a/autogalaxy/config/priors/image_mesh/overlay.yaml +++ b/autogalaxy/config/priors/image_mesh/overlay.yaml @@ -6,7 +6,7 @@ Overlay: width_modifier: type: Absolute value: 8.0 - gaussian_limits: + limits: lower: 3.0 upper: inf shape_1: @@ -16,6 +16,6 @@ Overlay: width_modifier: type: Absolute value: 8.0 - gaussian_limits: + limits: lower: 3.0 upper: inf \ No newline at end of file diff --git a/autogalaxy/config/priors/light/linear/chameleon.yaml b/autogalaxy/config/priors/light/linear/chameleon.yaml index 212701531..972e029d6 100644 --- a/autogalaxy/config/priors/light/linear/chameleon.yaml +++ b/autogalaxy/config/priors/light/linear/chameleon.yaml @@ -1,114 +1,106 @@ -Chameleon: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius_0: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - core_radius_1: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 -ChameleonSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius_0: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - core_radius_1: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf +Chameleon: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius_0: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + core_radius_1: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 +ChameleonSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius_0: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + core_radius_1: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/linear/dev_vaucouleurs.yaml b/autogalaxy/config/priors/light/linear/dev_vaucouleurs.yaml index 1c4bd5220..8283aea4c 100644 --- a/autogalaxy/config/priors/light/linear/dev_vaucouleurs.yaml +++ b/autogalaxy/config/priors/light/linear/dev_vaucouleurs.yaml @@ -1,94 +1,86 @@ -DevVaucouleurs: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 -DevVaucouleursSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf +DevVaucouleurs: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 +DevVaucouleursSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/linear/eff.yaml b/autogalaxy/config/priors/light/linear/eff.yaml index 548249856..a3664c44c 100644 --- a/autogalaxy/config/priors/light/linear/eff.yaml +++ b/autogalaxy/config/priors/light/linear/eff.yaml @@ -1,114 +1,106 @@ -ElsonFreeFall: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - eta: - type: Uniform - lower_limit: 0.5 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.0 - upper: 5.0 -ElsonFreeFallSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - eta: - type: Uniform - lower_limit: 0.5 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.0 - upper: 5.0 +ElsonFreeFall: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + eta: + type: Uniform + lower_limit: 0.5 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.0 + upper: 5.0 +ElsonFreeFallSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + eta: + type: Uniform + lower_limit: 0.5 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.0 + upper: 5.0 diff --git a/autogalaxy/config/priors/light/linear/exponential.yaml b/autogalaxy/config/priors/light/linear/exponential.yaml index 5bc79c66b..c75a8aea7 100644 --- a/autogalaxy/config/priors/light/linear/exponential.yaml +++ b/autogalaxy/config/priors/light/linear/exponential.yaml @@ -1,94 +1,86 @@ -Exponential: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 -ExponentialSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf +Exponential: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 +ExponentialSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/linear/exponential_core.yaml b/autogalaxy/config/priors/light/linear/exponential_core.yaml index 041d297d3..8591d4e35 100644 --- a/autogalaxy/config/priors/light/linear/exponential_core.yaml +++ b/autogalaxy/config/priors/light/linear/exponential_core.yaml @@ -1,112 +1,104 @@ -ExponentialCore: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - alpha: - type: Constant - value: 3.0 - gamma: - type: Constant - value: 0.25 - radius_break: - type: Constant - value: 0.025 -ExponentialCoreSph: - alpha: - type: Constant - value: 3.0 - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - gamma: - type: Constant - value: 0.25 - radius_break: - type: Constant - value: 0.025 +ExponentialCore: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + alpha: + type: Constant + value: 3.0 + gamma: + type: Constant + value: 0.25 + radius_break: + type: Constant + value: 0.025 +ExponentialCoreSph: + alpha: + type: Constant + value: 3.0 + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + gamma: + type: Constant + value: 0.25 + radius_break: + type: Constant + value: 0.025 diff --git a/autogalaxy/config/priors/light/linear/gaussian.yaml b/autogalaxy/config/priors/light/linear/gaussian.yaml index 6ded43381..a2a46cdbf 100644 --- a/autogalaxy/config/priors/light/linear/gaussian.yaml +++ b/autogalaxy/config/priors/light/linear/gaussian.yaml @@ -1,94 +1,86 @@ -Gaussian: - sigma: - type: Uniform - lower_limit: 0.0 - upper_limit: 25.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 -GaussianSph: - sigma: - type: Uniform - lower_limit: 0.0 - upper_limit: 25.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf +Gaussian: + sigma: + type: Uniform + lower_limit: 0.0 + upper_limit: 25.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 +GaussianSph: + sigma: + type: Uniform + lower_limit: 0.0 + upper_limit: 25.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf diff --git a/autogalaxy/config/priors/light/linear/moffat.yaml b/autogalaxy/config/priors/light/linear/moffat.yaml index a8a484a54..1df948f58 100644 --- a/autogalaxy/config/priors/light/linear/moffat.yaml +++ b/autogalaxy/config/priors/light/linear/moffat.yaml @@ -1,114 +1,106 @@ -Moffat: - alpha: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - beta: - type: Uniform - lower_limit: 1.0 - upper_limit: 5.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 -MoffatSph: - alpha: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - beta: - type: Uniform - lower_limit: 1.0 - upper_limit: 5.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf +Moffat: + alpha: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + beta: + type: Uniform + lower_limit: 1.0 + upper_limit: 5.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 +MoffatSph: + alpha: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + beta: + type: Uniform + lower_limit: 1.0 + upper_limit: 5.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf diff --git a/autogalaxy/config/priors/light/linear/sersic.yaml b/autogalaxy/config/priors/light/linear/sersic.yaml index 277bad262..5d8ce0645 100644 --- a/autogalaxy/config/priors/light/linear/sersic.yaml +++ b/autogalaxy/config/priors/light/linear/sersic.yaml @@ -1,114 +1,106 @@ -Sersic: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 -SersicSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 +Sersic: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 +SersicSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 diff --git a/autogalaxy/config/priors/light/linear/sersic_core.yaml b/autogalaxy/config/priors/light/linear/sersic_core.yaml index 0b36998e7..fc85243d6 100644 --- a/autogalaxy/config/priors/light/linear/sersic_core.yaml +++ b/autogalaxy/config/priors/light/linear/sersic_core.yaml @@ -1,132 +1,124 @@ -SersicCore: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 - alpha: - type: Constant - value: 3.0 - gamma: - type: Constant - value: 0.25 - radius_break: - type: Constant - value: 0.025 -SersicCoreSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 - alpha: - type: Constant - value: 3.0 - gamma: - type: Constant - value: 0.25 - radius_break: - type: Constant +SersicCore: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 + alpha: + type: Constant + value: 3.0 + gamma: + type: Constant + value: 0.25 + radius_break: + type: Constant + value: 0.025 +SersicCoreSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 + alpha: + type: Constant + value: 3.0 + gamma: + type: Constant + value: 0.25 + radius_break: + type: Constant value: 0.025 \ No newline at end of file diff --git a/autogalaxy/config/priors/light/linear/shapelets/cartesian.yaml b/autogalaxy/config/priors/light/linear/shapelets/cartesian.yaml index 4ac1c996b..2894442dd 100644 --- a/autogalaxy/config/priors/light/linear/shapelets/cartesian.yaml +++ b/autogalaxy/config/priors/light/linear/shapelets/cartesian.yaml @@ -3,24 +3,20 @@ ShapeletCartesianSph: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf centre_1: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf beta: @@ -30,7 +26,7 @@ ShapeletCartesianSph: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf ShapeletCartesian: @@ -38,28 +34,24 @@ ShapeletCartesian: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf centre_1: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf ell_comps_0: - type: Gaussian + type: TruncatedGaussian mean: 0.0 sigma: 0.3 lower_limit: -1.0 @@ -67,11 +59,11 @@ ShapeletCartesian: width_modifier: type: Absolute value: 0.2 - gaussian_limits: + limits: lower: -1.0 upper: 1.0 ell_comps_1: - type: Gaussian + type: TruncatedGaussian mean: 0.0 sigma: 0.3 lower_limit: -1.0 @@ -79,7 +71,7 @@ ShapeletCartesian: width_modifier: type: Absolute value: 0.2 - gaussian_limits: + limits: lower: -1.0 upper: 1.0 beta: @@ -89,6 +81,6 @@ ShapeletCartesian: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf diff --git a/autogalaxy/config/priors/light/linear/shapelets/exponential.yaml b/autogalaxy/config/priors/light/linear/shapelets/exponential.yaml index ffec6b5bb..5c6b8ad24 100644 --- a/autogalaxy/config/priors/light/linear/shapelets/exponential.yaml +++ b/autogalaxy/config/priors/light/linear/shapelets/exponential.yaml @@ -3,24 +3,20 @@ ShapeletExponentialSph: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf centre_1: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf beta: @@ -30,7 +26,7 @@ ShapeletExponentialSph: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf ShapeletExponential: @@ -38,28 +34,24 @@ ShapeletExponential: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf centre_1: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf ell_comps_0: - type: Gaussian + type: TruncatedGaussian mean: 0.0 sigma: 0.3 lower_limit: -1.0 @@ -67,11 +59,11 @@ ShapeletExponential: width_modifier: type: Absolute value: 0.2 - gaussian_limits: + limits: lower: -1.0 upper: 1.0 ell_comps_1: - type: Gaussian + type: TruncatedGaussian mean: 0.0 sigma: 0.3 lower_limit: -1.0 @@ -79,7 +71,7 @@ ShapeletExponential: width_modifier: type: Absolute value: 0.2 - gaussian_limits: + limits: lower: -1.0 upper: 1.0 beta: @@ -89,6 +81,6 @@ ShapeletExponential: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf diff --git a/autogalaxy/config/priors/light/linear/shapelets/polar.yaml b/autogalaxy/config/priors/light/linear/shapelets/polar.yaml index f8c93e235..fb32f83f0 100644 --- a/autogalaxy/config/priors/light/linear/shapelets/polar.yaml +++ b/autogalaxy/config/priors/light/linear/shapelets/polar.yaml @@ -3,24 +3,20 @@ ShapeletPolarSph: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf centre_1: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf beta: @@ -30,7 +26,7 @@ ShapeletPolarSph: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf ShapeletPolar: @@ -38,28 +34,24 @@ ShapeletPolar: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf centre_1: type: Gaussian mean: 0.0 sigma: 0.3 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf ell_comps_0: - type: Gaussian + type: TruncatedGaussian mean: 0.0 sigma: 0.3 lower_limit: -1.0 @@ -67,11 +59,11 @@ ShapeletPolar: width_modifier: type: Absolute value: 0.2 - gaussian_limits: + limits: lower: -1.0 upper: 1.0 ell_comps_1: - type: Gaussian + type: TruncatedGaussian mean: 0.0 sigma: 0.3 lower_limit: -1.0 @@ -79,7 +71,7 @@ ShapeletPolar: width_modifier: type: Absolute value: 0.2 - gaussian_limits: + limits: lower: -1.0 upper: 1.0 beta: @@ -89,6 +81,6 @@ ShapeletPolar: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf diff --git a/autogalaxy/config/priors/light/linear_operated/gaussian.yaml b/autogalaxy/config/priors/light/linear_operated/gaussian.yaml index 3d6a67991..edc467704 100644 --- a/autogalaxy/config/priors/light/linear_operated/gaussian.yaml +++ b/autogalaxy/config/priors/light/linear_operated/gaussian.yaml @@ -1,69 +1,65 @@ -Gaussian: - sigma: - type: Uniform - lower_limit: 0.0 - upper_limit: 5.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +Gaussian: + sigma: + type: Uniform + lower_limit: 0.0 + upper_limit: 5.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/linear_operated/moffat.yaml b/autogalaxy/config/priors/light/linear_operated/moffat.yaml index 8d3a97a23..725f85416 100644 --- a/autogalaxy/config/priors/light/linear_operated/moffat.yaml +++ b/autogalaxy/config/priors/light/linear_operated/moffat.yaml @@ -1,69 +1,65 @@ -Moffat: - alpha: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - beta: - type: Uniform - lower_limit: 1.0 - upper_limit: 5.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 +Moffat: + alpha: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + beta: + type: Uniform + lower_limit: 1.0 + upper_limit: 5.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 diff --git a/autogalaxy/config/priors/light/operated/gaussian.yaml b/autogalaxy/config/priors/light/operated/gaussian.yaml index 3d6a67991..edc467704 100644 --- a/autogalaxy/config/priors/light/operated/gaussian.yaml +++ b/autogalaxy/config/priors/light/operated/gaussian.yaml @@ -1,69 +1,65 @@ -Gaussian: - sigma: - type: Uniform - lower_limit: 0.0 - upper_limit: 5.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +Gaussian: + sigma: + type: Uniform + lower_limit: 0.0 + upper_limit: 5.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/operated/moffat.yaml b/autogalaxy/config/priors/light/operated/moffat.yaml index 40addc1d9..54c71c06a 100644 --- a/autogalaxy/config/priors/light/operated/moffat.yaml +++ b/autogalaxy/config/priors/light/operated/moffat.yaml @@ -1,79 +1,75 @@ -Moffat: - alpha: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - beta: - type: Uniform - lower_limit: 1.0 - upper_limit: 5.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +Moffat: + alpha: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + beta: + type: Uniform + lower_limit: 1.0 + upper_limit: 5.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/operated/sersic.yaml b/autogalaxy/config/priors/light/operated/sersic.yaml index 4db2ca6b1..6506de47b 100644 --- a/autogalaxy/config/priors/light/operated/sersic.yaml +++ b/autogalaxy/config/priors/light/operated/sersic.yaml @@ -1,79 +1,75 @@ -ersic: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 +ersic: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 diff --git a/autogalaxy/config/priors/light/standard/chameleon.yaml b/autogalaxy/config/priors/light/standard/chameleon.yaml index 971679724..0e2abcaec 100644 --- a/autogalaxy/config/priors/light/standard/chameleon.yaml +++ b/autogalaxy/config/priors/light/standard/chameleon.yaml @@ -1,134 +1,126 @@ -Chameleon: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius_0: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - core_radius_1: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -ChameleonSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius_0: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - core_radius_1: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +Chameleon: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius_0: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + core_radius_1: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +ChameleonSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius_0: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + core_radius_1: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/standard/dev_vaucouleurs.yaml b/autogalaxy/config/priors/light/standard/dev_vaucouleurs.yaml index 02b23e42f..957965594 100644 --- a/autogalaxy/config/priors/light/standard/dev_vaucouleurs.yaml +++ b/autogalaxy/config/priors/light/standard/dev_vaucouleurs.yaml @@ -1,114 +1,106 @@ -DevVaucouleurs: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -DevVaucouleursSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +DevVaucouleurs: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +DevVaucouleursSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/standard/eff.yaml b/autogalaxy/config/priors/light/standard/eff.yaml index 3c36e9b99..591e2211e 100644 --- a/autogalaxy/config/priors/light/standard/eff.yaml +++ b/autogalaxy/config/priors/light/standard/eff.yaml @@ -1,134 +1,126 @@ -ElsonFreeFall: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - eta: - type: Uniform - lower_limit: 0.5 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.0 - upper: 5.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -ElsonFreeFallSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - eta: - type: Uniform - lower_limit: 0.5 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.0 - upper: 5.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +ElsonFreeFall: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + eta: + type: Uniform + lower_limit: 0.5 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.0 + upper: 5.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +ElsonFreeFallSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + eta: + type: Uniform + lower_limit: 0.5 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.0 + upper: 5.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/standard/exponential.yaml b/autogalaxy/config/priors/light/standard/exponential.yaml index c34c6e927..3048fb01b 100644 --- a/autogalaxy/config/priors/light/standard/exponential.yaml +++ b/autogalaxy/config/priors/light/standard/exponential.yaml @@ -1,114 +1,106 @@ -Exponential: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -ExponentialSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +Exponential: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +ExponentialSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/standard/exponential_core.yaml b/autogalaxy/config/priors/light/standard/exponential_core.yaml index df091ff31..3f5ea7cf4 100644 --- a/autogalaxy/config/priors/light/standard/exponential_core.yaml +++ b/autogalaxy/config/priors/light/standard/exponential_core.yaml @@ -1,132 +1,124 @@ -ExponentialCore: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-05 - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - alpha: - type: Constant - value: 3.0 - gamma: - type: Constant - value: 0.25 - radius_break: - type: Constant - value: 0.025 -ExponentialCoreSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-05 - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - alpha: - type: Constant - value: 3.0 - gamma: - type: Constant - value: 0.25 - radius_break: - type: Constant - value: 0.025 +ExponentialCore: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-05 + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + alpha: + type: Constant + value: 3.0 + gamma: + type: Constant + value: 0.25 + radius_break: + type: Constant + value: 0.025 +ExponentialCoreSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-05 + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + alpha: + type: Constant + value: 3.0 + gamma: + type: Constant + value: 0.25 + radius_break: + type: Constant + value: 0.025 diff --git a/autogalaxy/config/priors/light/standard/gaussian.yaml b/autogalaxy/config/priors/light/standard/gaussian.yaml index ac712a116..d19093815 100644 --- a/autogalaxy/config/priors/light/standard/gaussian.yaml +++ b/autogalaxy/config/priors/light/standard/gaussian.yaml @@ -1,114 +1,106 @@ -Gaussian: - sigma: - type: Uniform - lower_limit: 0.0 - upper_limit: 25.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -GaussianSph: - sigma: - type: Uniform - lower_limit: 0.0 - upper_limit: 25.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +Gaussian: + sigma: + type: Uniform + lower_limit: 0.0 + upper_limit: 25.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +GaussianSph: + sigma: + type: Uniform + lower_limit: 0.0 + upper_limit: 25.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/standard/moffat.yaml b/autogalaxy/config/priors/light/standard/moffat.yaml index 4894fb419..dd13d3e69 100644 --- a/autogalaxy/config/priors/light/standard/moffat.yaml +++ b/autogalaxy/config/priors/light/standard/moffat.yaml @@ -1,134 +1,126 @@ -Moffat: - alpha: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - beta: - type: Uniform - lower_limit: 1.0 - upper_limit: 5.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -MoffatSph: - alpha: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - beta: - type: Uniform - lower_limit: 1.0 - upper_limit: 5.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +Moffat: + alpha: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + beta: + type: Uniform + lower_limit: 1.0 + upper_limit: 5.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +MoffatSph: + alpha: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + beta: + type: Uniform + lower_limit: 1.0 + upper_limit: 5.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/light/standard/sersic.yaml b/autogalaxy/config/priors/light/standard/sersic.yaml index 5593b9562..78263470d 100644 --- a/autogalaxy/config/priors/light/standard/sersic.yaml +++ b/autogalaxy/config/priors/light/standard/sersic.yaml @@ -1,134 +1,122 @@ -Sersic: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 -SersicSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 +Sersic: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + limits: + lower: -1.0 + upper: 1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + width_modifier: + type: Absolute + value: 0.2 + ell_comps_1: + limits: + lower: -1.0 + upper: 1.0 + mean: 0.0 + sigma: 0.3 + type: Gaussian + width_modifier: + type: Absolute + value: 0.2 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 +SersicSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 diff --git a/autogalaxy/config/priors/light/standard/sersic_core.yaml b/autogalaxy/config/priors/light/standard/sersic_core.yaml index 19a894c9c..0ff7a733a 100644 --- a/autogalaxy/config/priors/light/standard/sersic_core.yaml +++ b/autogalaxy/config/priors/light/standard/sersic_core.yaml @@ -1,152 +1,144 @@ -SersicCore: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-05 - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 - alpha: - type: Constant - value: 3.0 - gamma: - type: Constant - value: 0.25 - radius_break: - type: Constant - value: 0.025 -SersicCoreSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-05 - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 - alpha: - type: Constant - value: 3.0 - gamma: - type: Constant - value: 0.25 - radius_break: - type: Constant - value: 0.025 +SersicCore: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-05 + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 + alpha: + type: Constant + value: 3.0 + gamma: + type: Constant + value: 0.25 + radius_break: + type: Constant + value: 0.025 +SersicCoreSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-05 + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 + alpha: + type: Constant + value: 3.0 + gamma: + type: Constant + value: 0.25 + radius_break: + type: Constant + value: 0.025 diff --git a/autogalaxy/config/priors/mass/dark/gnfw.yaml b/autogalaxy/config/priors/mass/dark/gnfw.yaml index e7438167a..44630a34c 100644 --- a/autogalaxy/config/priors/mass/dark/gnfw.yaml +++ b/autogalaxy/config/priors/mass/dark/gnfw.yaml @@ -1,134 +1,126 @@ -gNFW: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - inner_slope: - type: Uniform - lower_limit: 0.0 - upper_limit: 2.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: -1.0 - upper: 3.0 - kappa_s: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - scale_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf -gNFWSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - inner_slope: - type: Uniform - lower_limit: 0.0 - upper_limit: 2.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: -1.0 - upper: 3.0 - kappa_s: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - scale_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf +gNFW: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + inner_slope: + type: Uniform + lower_limit: 0.0 + upper_limit: 2.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: -1.0 + upper: 3.0 + kappa_s: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + scale_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf +gNFWSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + inner_slope: + type: Uniform + lower_limit: 0.0 + upper_limit: 2.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: -1.0 + upper: 3.0 + kappa_s: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + scale_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/dark/gnfw_mcr.yaml b/autogalaxy/config/priors/mass/dark/gnfw_mcr.yaml index 4e2a7ad3a..2c2da24f6 100644 --- a/autogalaxy/config/priors/mass/dark/gnfw_mcr.yaml +++ b/autogalaxy/config/priors/mass/dark/gnfw_mcr.yaml @@ -1,89 +1,85 @@ -gNFWMCRLudlow: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - inner_slope: - type: Uniform - lower_limit: 0.0 - upper_limit: 2.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: -1.0 - upper: 3.0 - mass_at_200: - type: LogUniform - lower_limit: 100000000.0 - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +gNFWMCRLudlow: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + inner_slope: + type: Uniform + lower_limit: 0.0 + upper_limit: 2.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: -1.0 + upper: 3.0 + mass_at_200: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/dark/gnfw_virial_mass_conc.yaml b/autogalaxy/config/priors/mass/dark/gnfw_virial_mass_conc.yaml index f3f8ba6bf..a59654dd6 100644 --- a/autogalaxy/config/priors/mass/dark/gnfw_virial_mass_conc.yaml +++ b/autogalaxy/config/priors/mass/dark/gnfw_virial_mass_conc.yaml @@ -1,85 +1,81 @@ -gNFWVirialMassConcSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - log10m_vir: - type: Uniform - lower_limit: 7.0 - upper_limit: 12.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - c_2: - type: LogUniform - lower_limit: 1.0 - upper_limit: 100.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - overdens: - type: Uniform - lower_limit: 100.0 - upper_limit: 250.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - inner_slope: - type: Uniform - lower_limit: 0.0 - upper_limit: 2.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: -1.0 +gNFWVirialMassConcSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + log10m_vir: + type: Uniform + lower_limit: 7.0 + upper_limit: 12.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + c_2: + type: LogUniform + lower_limit: 1.0 + upper_limit: 100.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + overdens: + type: Uniform + lower_limit: 100.0 + upper_limit: 250.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + inner_slope: + type: Uniform + lower_limit: 0.0 + upper_limit: 2.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: -1.0 upper: 3.0 \ No newline at end of file diff --git a/autogalaxy/config/priors/mass/dark/nfw.yaml b/autogalaxy/config/priors/mass/dark/nfw.yaml index 0345d21ab..b351b0743 100644 --- a/autogalaxy/config/priors/mass/dark/nfw.yaml +++ b/autogalaxy/config/priors/mass/dark/nfw.yaml @@ -1,114 +1,106 @@ -NFW: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - kappa_s: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - scale_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf -NFWSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - kappa_s: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - scale_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf +NFW: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + kappa_s: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + scale_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf +NFWSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + kappa_s: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + scale_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/dark/nfw_mcr.yaml b/autogalaxy/config/priors/mass/dark/nfw_mcr.yaml index 305a2285f..3e2a381ca 100644 --- a/autogalaxy/config/priors/mass/dark/nfw_mcr.yaml +++ b/autogalaxy/config/priors/mass/dark/nfw_mcr.yaml @@ -1,189 +1,177 @@ -NFWMCRDuffySph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - mass_at_200: - type: LogUniform - lower_limit: 100000000.0 - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -NFWMCRLudlow: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - mass_at_200: - type: LogUniform - lower_limit: 100000000.0 - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -NFWMCRLudlowSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - mass_at_200: - type: LogUniform - lower_limit: 100000000.0 - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +NFWMCRDuffySph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + mass_at_200: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +NFWMCRLudlow: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + mass_at_200: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +NFWMCRLudlowSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + mass_at_200: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/dark/nfw_mcr_scatter.yaml b/autogalaxy/config/priors/mass/dark/nfw_mcr_scatter.yaml index 660f0802f..d01feb8ff 100644 --- a/autogalaxy/config/priors/mass/dark/nfw_mcr_scatter.yaml +++ b/autogalaxy/config/priors/mass/dark/nfw_mcr_scatter.yaml @@ -1,67 +1,61 @@ -NFWMCRScatterLudlowSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - mass_at_200: - type: LogUniform - lower_limit: 100000000.0 - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - scatter: - type: Gaussian - mean: 0.0 - sigma: 3.0 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 1.0 - gaussian_limits: - lower: -inf - upper: inf +NFWMCRScatterLudlowSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + mass_at_200: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + scatter: + type: Gaussian + mean: 0.0 + sigma: 3.0 + width_modifier: + type: Absolute + value: 1.0 + limits: + lower: -inf + upper: inf diff --git a/autogalaxy/config/priors/mass/dark/nfw_truncated.yaml b/autogalaxy/config/priors/mass/dark/nfw_truncated.yaml index c6fab741c..f123940e2 100644 --- a/autogalaxy/config/priors/mass/dark/nfw_truncated.yaml +++ b/autogalaxy/config/priors/mass/dark/nfw_truncated.yaml @@ -1,55 +1,51 @@ -NFWTruncatedSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - kappa_s: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - scale_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - truncation_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf +NFWTruncatedSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + kappa_s: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + scale_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + truncation_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/dark/nfw_truncated_mcr.yaml b/autogalaxy/config/priors/mass/dark/nfw_truncated_mcr.yaml index 30829067b..13c1a813f 100644 --- a/autogalaxy/config/priors/mass/dark/nfw_truncated_mcr.yaml +++ b/autogalaxy/config/priors/mass/dark/nfw_truncated_mcr.yaml @@ -1,177 +1,163 @@ -NFWTruncatedMCRDuffySph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - mass_at_200: - type: LogUniform - lower_limit: 100000000.0 - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -NFWTruncatedMCRLudlowSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - mass_at_200: - type: LogUniform - lower_limit: 100000000.0 - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -NFWTruncatedMCRScatterLudlowSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - mass_at_200: - type: LogUniform - lower_limit: 100000000.0 - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - scatter: - type: Gaussian - mean: 0.0 - sigma: 3.0 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 1.0 - gaussian_limits: - lower: -inf - upper: inf +NFWTruncatedMCRDuffySph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + mass_at_200: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +NFWTruncatedMCRLudlowSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + mass_at_200: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +NFWTruncatedMCRScatterLudlowSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + mass_at_200: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + scatter: + type: Gaussian + mean: 0.0 + sigma: 3.0 + width_modifier: + type: Absolute + value: 1.0 + limits: + lower: -inf + upper: inf diff --git a/autogalaxy/config/priors/mass/dark/nfw_virial_mass_conc.yaml b/autogalaxy/config/priors/mass/dark/nfw_virial_mass_conc.yaml index cfc064a4f..cff238db0 100644 --- a/autogalaxy/config/priors/mass/dark/nfw_virial_mass_conc.yaml +++ b/autogalaxy/config/priors/mass/dark/nfw_virial_mass_conc.yaml @@ -1,75 +1,71 @@ -NFWVirialMassConcSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - virial_mass: - type: LogUniform - lower_limit: 100000000.0 - upper_limit: 1000000000000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - concentration: - type: Uniform - lower_limit: 0.0 - upper_limit: 12.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - virial_overdens: - type: Uniform - lower_limit: 100.0 - upper_limit: 250.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +NFWVirialMassConcSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + virial_mass: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + concentration: + type: Uniform + lower_limit: 0.0 + upper_limit: 12.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + virial_overdens: + type: Uniform + lower_limit: 100.0 + upper_limit: 250.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/point/point.yaml b/autogalaxy/config/priors/mass/point/point.yaml index cf40f0ac9..328a5a465 100644 --- a/autogalaxy/config/priors/mass/point/point.yaml +++ b/autogalaxy/config/priors/mass/point/point.yaml @@ -1,35 +1,31 @@ -PointMass: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf +PointMass: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/point/smbh.yaml b/autogalaxy/config/priors/mass/point/smbh.yaml index 8d871d0eb..ef3c231ad 100644 --- a/autogalaxy/config/priors/mass/point/smbh.yaml +++ b/autogalaxy/config/priors/mass/point/smbh.yaml @@ -1,55 +1,51 @@ -SMBH: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - mass: - type: LogUniform - lower_limit: 1000000.0 - upper_limit: 10000000000000.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 +SMBH: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + mass: + type: LogUniform + lower_limit: 1000000.0 + upper_limit: 10000000000000.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 upper: inf \ No newline at end of file diff --git a/autogalaxy/config/priors/mass/point/smbh_binary.yaml b/autogalaxy/config/priors/mass/point/smbh_binary.yaml index 50b95a91f..9e3f73668 100644 --- a/autogalaxy/config/priors/mass/point/smbh_binary.yaml +++ b/autogalaxy/config/priors/mass/point/smbh_binary.yaml @@ -1,85 +1,81 @@ -SMBHBinary: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 1.0 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 1.0 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - separation: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - angle_binary: - type: Uniform - lower_limit: 0.0 - upper_limit: 360.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - mass: - type: LogUniform - lower_limit: 1000000.0 - upper_limit: 10000000000000.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - mass_ratio: - type: Uniform - lower_limit: 1.0 - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_object: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - redshift_source: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 +SMBHBinary: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 1.0 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 1.0 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + separation: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + angle_binary: + type: Uniform + lower_limit: 0.0 + upper_limit: 360.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + mass: + type: LogUniform + lower_limit: 1000000.0 + upper_limit: 10000000000000.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + mass_ratio: + type: Uniform + lower_limit: 1.0 + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 upper: inf \ No newline at end of file diff --git a/autogalaxy/config/priors/mass/sheets/external_shear.yaml b/autogalaxy/config/priors/mass/sheets/external_shear.yaml index ab46432e7..b77dd285d 100644 --- a/autogalaxy/config/priors/mass/sheets/external_shear.yaml +++ b/autogalaxy/config/priors/mass/sheets/external_shear.yaml @@ -1,21 +1,21 @@ -ExternalShear: - gamma_1: - type: Uniform - lower_limit: -0.2 - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - gamma_2: - type: Uniform - lower_limit: -0.2 - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf +ExternalShear: + gamma_1: + type: Uniform + lower_limit: -0.2 + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + gamma_2: + type: Uniform + lower_limit: -0.2 + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf diff --git a/autogalaxy/config/priors/mass/sheets/mass_sheet.yaml b/autogalaxy/config/priors/mass/sheets/mass_sheet.yaml index 4494af32c..9e8aae636 100644 --- a/autogalaxy/config/priors/mass/sheets/mass_sheet.yaml +++ b/autogalaxy/config/priors/mass/sheets/mass_sheet.yaml @@ -1,35 +1,31 @@ -MassSheet: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - kappa: - type: Uniform - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf +MassSheet: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + kappa: + type: Uniform + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf diff --git a/autogalaxy/config/priors/mass/stellar/chameleon.yaml b/autogalaxy/config/priors/mass/stellar/chameleon.yaml index fe09daafd..41d6a32eb 100644 --- a/autogalaxy/config/priors/mass/stellar/chameleon.yaml +++ b/autogalaxy/config/priors/mass/stellar/chameleon.yaml @@ -1,154 +1,146 @@ -Chameleon: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius_0: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - core_radius_1: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf -ChameleonSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius_0: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - core_radius_1: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Absolute - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf +Chameleon: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius_0: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + core_radius_1: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf +ChameleonSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius_0: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + core_radius_1: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Absolute + value: 0.3 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/stellar/dev_vaucouleurs.yaml b/autogalaxy/config/priors/mass/stellar/dev_vaucouleurs.yaml index 692270371..42052ca08 100644 --- a/autogalaxy/config/priors/mass/stellar/dev_vaucouleurs.yaml +++ b/autogalaxy/config/priors/mass/stellar/dev_vaucouleurs.yaml @@ -1,134 +1,126 @@ -DevVaucouleurs: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf -DevVaucouleursSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf +DevVaucouleurs: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf +DevVaucouleursSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/stellar/exponential.yaml b/autogalaxy/config/priors/mass/stellar/exponential.yaml index deb9631da..36724d2fc 100644 --- a/autogalaxy/config/priors/mass/stellar/exponential.yaml +++ b/autogalaxy/config/priors/mass/stellar/exponential.yaml @@ -1,134 +1,126 @@ -Exponential: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf -ExponentialSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf +Exponential: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf +ExponentialSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/stellar/gaussian.yaml b/autogalaxy/config/priors/mass/stellar/gaussian.yaml index 1a593535a..b2d09ce7a 100644 --- a/autogalaxy/config/priors/mass/stellar/gaussian.yaml +++ b/autogalaxy/config/priors/mass/stellar/gaussian.yaml @@ -1,79 +1,75 @@ -Gaussian: - sigma: - type: Uniform - lower_limit: 0.0 - upper_limit: 25.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf +Gaussian: + sigma: + type: Uniform + lower_limit: 0.0 + upper_limit: 25.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/stellar/gaussian_gradient.yaml b/autogalaxy/config/priors/mass/stellar/gaussian_gradient.yaml index 8bcb2340d..a1f6c906c 100644 --- a/autogalaxy/config/priors/mass/stellar/gaussian_gradient.yaml +++ b/autogalaxy/config/priors/mass/stellar/gaussian_gradient.yaml @@ -1,92 +1,88 @@ -GaussianGradient: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - sigma: - type: Uniform - lower_limit: 0.0 - upper_limit: 25.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio_base: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_gradient: - type: Uniform - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_radius: - type: Constant +GaussianGradient: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + sigma: + type: Uniform + lower_limit: 0.0 + upper_limit: 25.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio_base: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf + mass_to_light_gradient: + type: Uniform + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf + mass_to_light_radius: + type: Constant value: 1.0 \ No newline at end of file diff --git a/autogalaxy/config/priors/mass/stellar/sersic.yaml b/autogalaxy/config/priors/mass/stellar/sersic.yaml index 37c18f926..86c5317fc 100644 --- a/autogalaxy/config/priors/mass/stellar/sersic.yaml +++ b/autogalaxy/config/priors/mass/stellar/sersic.yaml @@ -1,154 +1,146 @@ -Sersic: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 -SersicSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 +Sersic: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 +SersicSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 diff --git a/autogalaxy/config/priors/mass/stellar/sersic_core.yaml b/autogalaxy/config/priors/mass/stellar/sersic_core.yaml index b05ebecf5..e6a8a5112 100644 --- a/autogalaxy/config/priors/mass/stellar/sersic_core.yaml +++ b/autogalaxy/config/priors/mass/stellar/sersic_core.yaml @@ -1,172 +1,164 @@ -SersicCore: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-05 - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - alpha: - type: Constant - value: 3.0 - gamma: - type: Constant - value: 0.25 - radius_break: - type: Constant - value: 0.025 - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 -SersicCoreSph: - alpha: - type: Constant - value: 3.0 - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - gamma: - type: Constant - value: 0.25 - intensity: - type: LogUniform - lower_limit: 1.0e-05 - upper_limit: 1000.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - radius_break: - type: Constant - value: 0.025 - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 +SersicCore: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-05 + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + alpha: + type: Constant + value: 3.0 + gamma: + type: Constant + value: 0.25 + radius_break: + type: Constant + value: 0.025 + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 +SersicCoreSph: + alpha: + type: Constant + value: 3.0 + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + gamma: + type: Constant + value: 0.25 + intensity: + type: LogUniform + lower_limit: 1.0e-05 + upper_limit: 1000.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf + radius_break: + type: Constant + value: 0.025 + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 diff --git a/autogalaxy/config/priors/mass/stellar/sersic_gradient.yaml b/autogalaxy/config/priors/mass/stellar/sersic_gradient.yaml index 47e0a4a30..2391ec01c 100644 --- a/autogalaxy/config/priors/mass/stellar/sersic_gradient.yaml +++ b/autogalaxy/config/priors/mass/stellar/sersic_gradient.yaml @@ -1,174 +1,166 @@ -SersicGradient: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_gradient: - type: Uniform - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -inf - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 -SersicGradientSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - effective_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 30.0 - width_modifier: - type: Relative - value: 1.0 - gaussian_limits: - lower: 0.0 - upper: inf - intensity: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 10.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - mass_to_light_gradient: - type: Uniform - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -inf - upper: inf - mass_to_light_ratio: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.3 - gaussian_limits: - lower: 0.0 - upper: inf - sersic_index: - type: Uniform - lower_limit: 0.8 - upper_limit: 5.0 - width_modifier: - type: Absolute - value: 1.5 - gaussian_limits: - lower: 0.8 - upper: 5.0 +SersicGradient: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_gradient: + type: Uniform + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -inf + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 +SersicGradientSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + effective_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 30.0 + width_modifier: + type: Relative + value: 1.0 + limits: + lower: 0.0 + upper: inf + intensity: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 10.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + mass_to_light_gradient: + type: Uniform + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -inf + upper: inf + mass_to_light_ratio: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.3 + limits: + lower: 0.0 + upper: inf + sersic_index: + type: Uniform + lower_limit: 0.8 + upper_limit: 5.0 + width_modifier: + type: Absolute + value: 1.5 + limits: + lower: 0.8 + upper: 5.0 diff --git a/autogalaxy/config/priors/mass/total/isothermal.yaml b/autogalaxy/config/priors/mass/total/isothermal.yaml index 2be7aeb3b..142a0b415 100644 --- a/autogalaxy/config/priors/mass/total/isothermal.yaml +++ b/autogalaxy/config/priors/mass/total/isothermal.yaml @@ -1,94 +1,86 @@ -Isothermal: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 -IsothermalSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf +Isothermal: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 +IsothermalSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/total/isothermal_core.yaml b/autogalaxy/config/priors/mass/total/isothermal_core.yaml index c5d7989f1..358281709 100644 --- a/autogalaxy/config/priors/mass/total/isothermal_core.yaml +++ b/autogalaxy/config/priors/mass/total/isothermal_core.yaml @@ -1,114 +1,106 @@ -IsothermalCore: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.1 - gaussian_limits: - lower: 0.0 - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 -IsothermalCoreSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.1 - gaussian_limits: - lower: 0.0 - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf +IsothermalCore: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.1 + limits: + lower: 0.0 + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 +IsothermalCoreSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.1 + limits: + lower: 0.0 + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/mass/total/power_law.yaml b/autogalaxy/config/priors/mass/total/power_law.yaml index 6d902237f..d0b73133f 100644 --- a/autogalaxy/config/priors/mass/total/power_law.yaml +++ b/autogalaxy/config/priors/mass/total/power_law.yaml @@ -1,114 +1,106 @@ -PowerLaw: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - slope: - type: Uniform - lower_limit: 1.5 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: 1.0 - upper: 3.0 -PowerLawSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - slope: - type: Uniform - lower_limit: 1.5 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: 1.0 - upper: 3.0 +PowerLaw: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + slope: + type: Uniform + lower_limit: 1.5 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: 1.0 + upper: 3.0 +PowerLawSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + slope: + type: Uniform + lower_limit: 1.5 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: 1.0 + upper: 3.0 diff --git a/autogalaxy/config/priors/mass/total/power_law_broken.yaml b/autogalaxy/config/priors/mass/total/power_law_broken.yaml index d882e8a53..40e52deeb 100644 --- a/autogalaxy/config/priors/mass/total/power_law_broken.yaml +++ b/autogalaxy/config/priors/mass/total/power_law_broken.yaml @@ -1,154 +1,146 @@ -PowerLawBroken: - break_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - inner_slope: - type: Uniform - lower_limit: 0.0 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: 3.0 - outer_slope: - type: Uniform - lower_limit: 0.0 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: 3.0 -PowerLawBrokenSph: - break_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.1 - gaussian_limits: - lower: 0.0 - upper: inf - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - inner_slope: - type: Uniform - lower_limit: 0.0 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: 3.0 - outer_slope: - type: Uniform - lower_limit: 0.0 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: 3.0 +PowerLawBroken: + break_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + inner_slope: + type: Uniform + lower_limit: 0.0 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: 0.0 + upper: 3.0 + outer_slope: + type: Uniform + lower_limit: 0.0 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: 0.0 + upper: 3.0 +PowerLawBrokenSph: + break_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.1 + limits: + lower: 0.0 + upper: inf + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + inner_slope: + type: Uniform + lower_limit: 0.0 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: 0.0 + upper: 3.0 + outer_slope: + type: Uniform + lower_limit: 0.0 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: 0.0 + upper: 3.0 diff --git a/autogalaxy/config/priors/mass/total/power_law_core.yaml b/autogalaxy/config/priors/mass/total/power_law_core.yaml index bad6ee493..c5b2ab6cb 100644 --- a/autogalaxy/config/priors/mass/total/power_law_core.yaml +++ b/autogalaxy/config/priors/mass/total/power_law_core.yaml @@ -1,134 +1,126 @@ -PowerLawCore: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.1 - gaussian_limits: - lower: 0.0 - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - ell_comps_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - ell_comps_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -1.0 - upper_limit: 1.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: -1.0 - upper: 1.0 - slope: - type: Uniform - lower_limit: 1.5 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: 1.0 - upper: 3.0 -PowerLawCoreSph: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.1 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - core_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 0.2 - width_modifier: - type: Absolute - value: 0.1 - gaussian_limits: - lower: 0.0 - upper: inf - einstein_radius: - type: Uniform - lower_limit: 0.0 - upper_limit: 8.0 - width_modifier: - type: Relative - value: 0.25 - gaussian_limits: - lower: 0.0 - upper: inf - slope: - type: Uniform - lower_limit: 1.5 - upper_limit: 3.0 - width_modifier: - type: Absolute - value: 0.2 - gaussian_limits: - lower: 1.0 - upper: 3.0 +PowerLawCore: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.1 + limits: + lower: 0.0 + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + ell_comps_0: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + ell_comps_1: + type: TruncatedGaussian + mean: 0.0 + sigma: 0.3 + lower_limit: -1.0 + upper_limit: 1.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: -1.0 + upper: 1.0 + slope: + type: Uniform + lower_limit: 1.5 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: 1.0 + upper: 3.0 +PowerLawCoreSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + core_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 0.2 + width_modifier: + type: Absolute + value: 0.1 + limits: + lower: 0.0 + upper: inf + einstein_radius: + type: Uniform + lower_limit: 0.0 + upper_limit: 8.0 + width_modifier: + type: Relative + value: 0.25 + limits: + lower: 0.0 + upper: inf + slope: + type: Uniform + lower_limit: 1.5 + upper_limit: 3.0 + width_modifier: + type: Absolute + value: 0.2 + limits: + lower: 1.0 + upper: 3.0 diff --git a/autogalaxy/config/priors/mass/total/power_law_multipole.yaml b/autogalaxy/config/priors/mass/total/power_law_multipole.yaml index 66f96df5d..9ad385680 100644 --- a/autogalaxy/config/priors/mass/total/power_law_multipole.yaml +++ b/autogalaxy/config/priors/mass/total/power_law_multipole.yaml @@ -6,24 +6,20 @@ PowerLawMultipole: type: Gaussian mean: 0.0 sigma: 0.1 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf centre_1: type: Gaussian mean: 0.0 sigma: 0.1 - lower_limit: -inf - upper_limit: inf width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf einstein_radius: @@ -33,7 +29,7 @@ PowerLawMultipole: width_modifier: type: Relative value: 0.25 - gaussian_limits: + limits: lower: 0.0 upper: inf slope: @@ -43,7 +39,7 @@ PowerLawMultipole: width_modifier: type: Absolute value: 0.2 - gaussian_limits: + limits: lower: 1.0 upper: 3.0 multipole_comps_0: @@ -53,7 +49,7 @@ PowerLawMultipole: width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf multipole_comps_1: @@ -63,6 +59,6 @@ PowerLawMultipole: width_modifier: type: Absolute value: 0.05 - gaussian_limits: + limits: lower: -inf upper: inf \ No newline at end of file diff --git a/autogalaxy/config/priors/mesh/delaunay.yaml b/autogalaxy/config/priors/mesh/delaunay.yaml index 604de83de..783f4b746 100644 --- a/autogalaxy/config/priors/mesh/delaunay.yaml +++ b/autogalaxy/config/priors/mesh/delaunay.yaml @@ -1 +1 @@ -Delaunay: +Delaunay: diff --git a/autogalaxy/config/priors/mesh/rectangular.yaml b/autogalaxy/config/priors/mesh/rectangular.yaml index 26a1c354c..1c3e6a4fa 100644 --- a/autogalaxy/config/priors/mesh/rectangular.yaml +++ b/autogalaxy/config/priors/mesh/rectangular.yaml @@ -1,21 +1,21 @@ -Rectangular: - shape_0: - type: Uniform - lower_limit: 20.0 - upper_limit: 45.0 - width_modifier: - type: Absolute - value: 8.0 - gaussian_limits: - lower: 3.0 - upper: inf - shape_1: - type: Uniform - lower_limit: 20.0 - upper_limit: 45.0 - width_modifier: - type: Absolute - value: 8.0 - gaussian_limits: - lower: 3.0 - upper: inf +Rectangular: + shape_0: + type: Uniform + lower_limit: 20.0 + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 + limits: + lower: 3.0 + upper: inf + shape_1: + type: Uniform + lower_limit: 20.0 + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 + limits: + lower: 3.0 + upper: inf diff --git a/autogalaxy/config/priors/mesh/rectangular_uniform.yaml b/autogalaxy/config/priors/mesh/rectangular_uniform.yaml new file mode 100644 index 000000000..cfa7cb83b --- /dev/null +++ b/autogalaxy/config/priors/mesh/rectangular_uniform.yaml @@ -0,0 +1,21 @@ +RectangularUniform: + shape_0: + type: Uniform + lower_limit: 20.0 + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 + limits: + lower: 3.0 + upper: inf + shape_1: + type: Uniform + lower_limit: 20.0 + upper_limit: 45.0 + width_modifier: + type: Absolute + value: 8.0 + limits: + lower: 3.0 + upper: inf diff --git a/autogalaxy/config/priors/point_sources.yaml b/autogalaxy/config/priors/point_sources.yaml index 67adf1f37..ce44f3f6a 100644 --- a/autogalaxy/config/priors/point_sources.yaml +++ b/autogalaxy/config/priors/point_sources.yaml @@ -1,85 +1,73 @@ -Point: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf -PointFlux: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - flux: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf -PointSourceChi: - centre_0: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf - centre_1: - type: Gaussian - mean: 0.0 - sigma: 0.3 - lower_limit: -inf - upper_limit: inf - width_modifier: - type: Absolute - value: 0.05 - gaussian_limits: - lower: -inf - upper: inf +Point: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf +PointFlux: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + flux: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf +PointSourceChi: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.3 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf diff --git a/autogalaxy/config/priors/regularization/adaptive_brightness.yaml b/autogalaxy/config/priors/regularization/adaptive_brightness.yaml index 1697df3bd..0d69dcddd 100644 --- a/autogalaxy/config/priors/regularization/adaptive_brightness.yaml +++ b/autogalaxy/config/priors/regularization/adaptive_brightness.yaml @@ -1,62 +1,62 @@ -AdaptiveBrightness: - inner_coefficient: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - outer_coefficient: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - signal_scale: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf -AdaptiveBrightnessSplit: - inner_coefficient: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - outer_coefficient: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - signal_scale: - type: Uniform - lower_limit: 0.0 - upper_limit: 1.0 - width_modifier: - type: Relative - value: 0.2 - gaussian_limits: - lower: 0.0 - upper: inf +AdaptiveBrightness: + inner_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + outer_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + signal_scale: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf +AdaptiveBrightnessSplit: + inner_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + outer_coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + signal_scale: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/regularization/adaptive_brightness_split_zeroth.yaml b/autogalaxy/config/priors/regularization/adaptive_brightness_split_zeroth.yaml index 812cd282e..6fd086a67 100644 --- a/autogalaxy/config/priors/regularization/adaptive_brightness_split_zeroth.yaml +++ b/autogalaxy/config/priors/regularization/adaptive_brightness_split_zeroth.yaml @@ -6,7 +6,7 @@ AdaptiveBrightnessSplitZeroth: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf zeroth_signal_scale: @@ -16,7 +16,7 @@ AdaptiveBrightnessSplitZeroth: width_modifier: type: Relative value: 0.2 - gaussian_limits: + limits: lower: 0.0 upper: inf inner_coefficient: @@ -26,7 +26,7 @@ AdaptiveBrightnessSplitZeroth: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf outer_coefficient: @@ -36,7 +36,7 @@ AdaptiveBrightnessSplitZeroth: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf signal_scale: @@ -46,6 +46,6 @@ AdaptiveBrightnessSplitZeroth: width_modifier: type: Relative value: 0.2 - gaussian_limits: + limits: lower: 0.0 upper: inf \ No newline at end of file diff --git a/autogalaxy/config/priors/regularization/constant.yaml b/autogalaxy/config/priors/regularization/constant.yaml index f54978b5a..d21d98f91 100644 --- a/autogalaxy/config/priors/regularization/constant.yaml +++ b/autogalaxy/config/priors/regularization/constant.yaml @@ -1,11 +1,11 @@ -Constant: - coefficient: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +Constant: + coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/regularization/constant_split.yaml b/autogalaxy/config/priors/regularization/constant_split.yaml index 106692048..036651ed2 100644 --- a/autogalaxy/config/priors/regularization/constant_split.yaml +++ b/autogalaxy/config/priors/regularization/constant_split.yaml @@ -1,11 +1,11 @@ -ConstantSplit: - coefficient: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +ConstantSplit: + coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/regularization/constant_zeroth.yaml b/autogalaxy/config/priors/regularization/constant_zeroth.yaml index 9122df418..ef47c14c3 100644 --- a/autogalaxy/config/priors/regularization/constant_zeroth.yaml +++ b/autogalaxy/config/priors/regularization/constant_zeroth.yaml @@ -1,21 +1,21 @@ -ConstantZeroth: - coefficient_neighbor: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf - coefficient_zeroth: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +ConstantZeroth: + coefficient_neighbor: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + coefficient_zeroth: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/priors/regularization/exponential_kernel.yaml b/autogalaxy/config/priors/regularization/exponential_kernel.yaml index 8618c8d98..add53a05d 100644 --- a/autogalaxy/config/priors/regularization/exponential_kernel.yaml +++ b/autogalaxy/config/priors/regularization/exponential_kernel.yaml @@ -6,7 +6,7 @@ ExponentialKernel: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf scale: @@ -16,6 +16,6 @@ ExponentialKernel: width_modifier: type: Relative value: 0.2 - gaussian_limits: + limits: lower: 0.0 upper: inf diff --git a/autogalaxy/config/priors/regularization/gaussian_kernel.yaml b/autogalaxy/config/priors/regularization/gaussian_kernel.yaml index 9aec65be7..48f050ee2 100644 --- a/autogalaxy/config/priors/regularization/gaussian_kernel.yaml +++ b/autogalaxy/config/priors/regularization/gaussian_kernel.yaml @@ -6,7 +6,7 @@ GaussianKernel: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf scale: @@ -16,6 +16,6 @@ GaussianKernel: width_modifier: type: Relative value: 0.2 - gaussian_limits: + limits: lower: 0.0 upper: inf diff --git a/autogalaxy/config/priors/regularization/matern_kernel.yaml b/autogalaxy/config/priors/regularization/matern_kernel.yaml index 60b7cd02d..f2fed72e4 100644 --- a/autogalaxy/config/priors/regularization/matern_kernel.yaml +++ b/autogalaxy/config/priors/regularization/matern_kernel.yaml @@ -6,7 +6,7 @@ MaternKernel: width_modifier: type: Relative value: 0.5 - gaussian_limits: + limits: lower: 0.0 upper: inf scale: @@ -16,7 +16,7 @@ MaternKernel: width_modifier: type: Relative value: 0.2 - gaussian_limits: + limits: lower: 0.0 upper: inf nu: @@ -26,6 +26,6 @@ MaternKernel: width_modifier: type: Relative value: 0.2 - gaussian_limits: + limits: lower: 0.0 upper: inf diff --git a/autogalaxy/config/priors/regularization/zeroth.yaml b/autogalaxy/config/priors/regularization/zeroth.yaml index 7ad61a7ff..92b358f0f 100644 --- a/autogalaxy/config/priors/regularization/zeroth.yaml +++ b/autogalaxy/config/priors/regularization/zeroth.yaml @@ -1,11 +1,11 @@ -Zeroth: - coefficient: - type: LogUniform - lower_limit: 1.0e-06 - upper_limit: 1000000.0 - width_modifier: - type: Relative - value: 0.5 - gaussian_limits: - lower: 0.0 - upper: inf +Zeroth: + coefficient: + type: LogUniform + lower_limit: 1.0e-06 + upper_limit: 1000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf diff --git a/autogalaxy/config/visualize/general.yaml b/autogalaxy/config/visualize/general.yaml index 4a6fd0ebc..e022ac819 100644 --- a/autogalaxy/config/visualize/general.yaml +++ b/autogalaxy/config/visualize/general.yaml @@ -1,9 +1,9 @@ -general: - backend: default - imshow_origin: upper - zoom_around_mask: true -inversion: - reconstruction_vmax_factor: 0.5 -zoom: - plane_percent: 0.01 +general: + backend: default + imshow_origin: upper + zoom_around_mask: true +inversion: + reconstruction_vmax_factor: 0.5 +zoom: + plane_percent: 0.01 inversion_percent: 0.01 \ No newline at end of file diff --git a/autogalaxy/config/visualize/include.yaml b/autogalaxy/config/visualize/include.yaml deleted file mode 100644 index 0c9a25708..000000000 --- a/autogalaxy/config/visualize/include.yaml +++ /dev/null @@ -1,11 +0,0 @@ -include_1d: - einstein_radius: true - half_light_radius: true -include_2d: - tangential_critical_curves: true - tangential_caustics: true - radial_critical_curves: true - radial_caustics: true - light_profile_centres: true - mass_profile_centres: true - multiple_images: true diff --git a/autogalaxy/config/visualize/mat_wrap_1d.yaml b/autogalaxy/config/visualize/mat_wrap_1d.yaml index 2eca68f71..590cf0b5b 100644 --- a/autogalaxy/config/visualize/mat_wrap_1d.yaml +++ b/autogalaxy/config/visualize/mat_wrap_1d.yaml @@ -1,19 +1,19 @@ -EinsteinRadiusAXVLine: - figure: - c: b - linestyle: -- - subplot: - c: b - linestyle: -- -HalfLightRadiusAXVLine: - figure: - c: g - linestyle: -. - subplot: - c: kg - linestyle: -. -ModelFluxesYXScatter: - figure: - c: c - subplot: - c: c +EinsteinRadiusAXVLine: + figure: + c: b + linestyle: -- + subplot: + c: b + linestyle: -- +HalfLightRadiusAXVLine: + figure: + c: g + linestyle: -. + subplot: + c: kg + linestyle: -. +ModelFluxesYXScatter: + figure: + c: c + subplot: + c: c diff --git a/autogalaxy/config/visualize/mat_wrap_2d.yaml b/autogalaxy/config/visualize/mat_wrap_2d.yaml index 74d23f1db..3d8be5b01 100644 --- a/autogalaxy/config/visualize/mat_wrap_2d.yaml +++ b/autogalaxy/config/visualize/mat_wrap_2d.yaml @@ -1,63 +1,63 @@ -TangentialCriticalCurvesPlot: - figure: - c: w - linestyle: '-' - linewidth: 2 - subplot: - c: w - linestyle: '-' - linewidth: 2 -TangentialCausticsPlot: - figure: - c: w - linestyle: '-' - linewidth: 2 - subplot: - c: w - linestyle: '-' - linewidth: 2 -RadialCriticalCurvesPlot: - figure: - c: y - linestyle: '-' - linewidth: 2 - subplot: - c: y - linestyle: '-' - linewidth: 2 -RadialCausticsPlot: - figure: - c: y - linestyle: '-' - linewidth: 2 - subplot: - c: y - linestyle: '-' - linewidth: 2 -LightProfileCentresScatter: - figure: - c: k,r,g,b,m,y - marker: + - s: 20 - subplot: - c: r,g,b,m,y,k - marker: + - s: 26 -MassProfileCentresScatter: - figure: - c: k,r,g,b,m,y - marker: x - s: 20 - subplot: - c: r,g,b,m,y,k - marker: x - s: 26 -MultipleImagesScatter: - figure: - c: k,r,g,b,m,y - marker: o - s: 16 - subplot: - c: r,g,b,m,y,k - marker: o - s: 16 +TangentialCriticalCurvesPlot: + figure: + c: w + linestyle: '-' + linewidth: 2 + subplot: + c: w + linestyle: '-' + linewidth: 2 +TangentialCausticsPlot: + figure: + c: w + linestyle: '-' + linewidth: 2 + subplot: + c: w + linestyle: '-' + linewidth: 2 +RadialCriticalCurvesPlot: + figure: + c: y + linestyle: '-' + linewidth: 2 + subplot: + c: y + linestyle: '-' + linewidth: 2 +RadialCausticsPlot: + figure: + c: y + linestyle: '-' + linewidth: 2 + subplot: + c: y + linestyle: '-' + linewidth: 2 +LightProfileCentresScatter: + figure: + c: k,r,g,b,m,y + marker: + + s: 20 + subplot: + c: r,g,b,m,y,k + marker: + + s: 26 +MassProfileCentresScatter: + figure: + c: k,r,g,b,m,y + marker: x + s: 20 + subplot: + c: r,g,b,m,y,k + marker: x + s: 26 +MultipleImagesScatter: + figure: + c: k,r,g,b,m,y + marker: o + s: 16 + subplot: + c: r,g,b,m,y,k + marker: o + s: 16 diff --git a/autogalaxy/convert.py b/autogalaxy/convert.py index 127d7d4ea..3a199d220 100644 --- a/autogalaxy/convert.py +++ b/autogalaxy/convert.py @@ -1,7 +1,8 @@ -from astropy import units -import numpy as np from typing import Tuple +import jax +import jax.numpy as jnp + def ell_comps_from(axis_ratio: float, angle: float) -> Tuple[float, float]: """ @@ -22,10 +23,10 @@ def ell_comps_from(axis_ratio: float, angle: float) -> Tuple[float, float]: angle Rotation angle of light profile counter-clockwise from positive x-axis. """ - angle *= np.pi / 180.0 + angle *= jnp.pi / 180.0 fac = (1 - axis_ratio) / (1 + axis_ratio) - ellip_y = fac * np.sin(2 * angle) - ellip_x = fac * np.cos(2 * angle) + ellip_y = fac * jnp.sin(2 * angle) + ellip_x = fac * jnp.cos(2 * angle) return (ellip_y, ellip_x) @@ -59,16 +60,14 @@ def axis_ratio_and_angle_from(ell_comps: Tuple[float, float]) -> Tuple[float, fl ell_comps The elliptical components of the light or mass profile which are converted to an angle. """ - angle = np.arctan2(ell_comps[0], ell_comps[1]) / 2 - angle *= 180.0 / np.pi + angle = jnp.arctan2(ell_comps[0], ell_comps[1]) / 2 + angle *= 180.0 / jnp.pi + + angle = jax.lax.select(angle < -45, angle + 180, angle) - if abs(angle) > 45 and angle < 0: - angle += 180 + fac = jnp.sqrt(ell_comps[1] ** 2 + ell_comps[0] ** 2) + fac = jax.lax.min(fac, 0.999) - fac = np.sqrt(ell_comps[1] ** 2 + ell_comps[0] ** 2) - if fac > 0.999: - fac = 0.999 # avoid unphysical solution - # if fac > 1: print('unphysical e1,e2') axis_ratio = (1 - fac) / (1 + fac) return axis_ratio, angle @@ -140,15 +139,15 @@ def shear_gamma_1_2_from(magnitude: float, angle: float) -> Tuple[float, float]: The gamma 1 and gamma 2 components of a shear are given by: - gamma_1 = magnitude * np.cos(2 * angle * np.pi / 180.0) - gamma_2 = magnitude * np.sin(2 * angle * np.pi / 180.0) + gamma_1 = magnitude * jnp.cos(2 * angle * jnp.pi / 180.0) + gamma_2 = magnitude * jnp.sin(2 * angle * jnp.pi / 180.0) Which are the values this function returns. Converting from gamma 1 and gamma 2 to magnitude and angle is given by: - magnitude = np.sqrt(gamma_1**2 + gamma_2**2) - angle = np.arctan2(gamma_2, gamma_1) / 2 * 180.0 / np.pi + magnitude = jnp.sqrt(gamma_1**2 + gamma_2**2) + angle = jnp.arctan2(gamma_2, gamma_1) / 2 * 180.0 / jnp.pi Parameters ---------- @@ -157,8 +156,8 @@ def shear_gamma_1_2_from(magnitude: float, angle: float) -> Tuple[float, float]: angle Rotation angle of light profile counter-clockwise from positive x-axis. """ - gamma_1 = magnitude * np.cos(2 * angle * np.pi / 180.0) - gamma_2 = magnitude * np.sin(2 * angle * np.pi / 180.0) + gamma_1 = magnitude * jnp.cos(2 * angle * jnp.pi / 180.0) + gamma_2 = magnitude * jnp.sin(2 * angle * jnp.pi / 180.0) return (gamma_1, gamma_2) @@ -170,13 +169,13 @@ def shear_magnitude_and_angle_from( The gamma 1 and gamma 2 components of a shear are given by: - gamma_1 = magnitude * np.cos(2 * angle * np.pi / 180.0) - gamma_2 = magnitude * np.sin(2 * angle * np.pi / 180.0) + gamma_1 = magnitude * jnp.cos(2 * angle * jnp.pi / 180.0) + gamma_2 = magnitude * jnp.sin(2 * angle * jnp.pi / 180.0) Converting from gamma 1 and gamma 2 to magnitude and angle is given by: - magnitude = np.sqrt(gamma_1**2 + gamma_2**2) - angle = np.arctan2(gamma_2, gamma_1) / 2 * 180.0 / np.pi + magnitude = jnp.sqrt(gamma_1**2 + gamma_2**2) + angle = jnp.arctan2(gamma_2, gamma_1) / 2 * 180.0 / jnp.pi Which are the values this function returns. @@ -194,14 +193,13 @@ def shear_magnitude_and_angle_from( gamma_2 The gamma 2 component of the shear. """ - angle = np.arctan2(gamma_2, gamma_1) / 2 * 180.0 / np.pi - magnitude = np.sqrt(gamma_1**2 + gamma_2**2) - - if angle < 0: - angle += 180.0 + angle = jnp.arctan2(gamma_2, gamma_1) / 2 * 180.0 / jnp.pi + magnitude = jnp.sqrt(gamma_1**2 + gamma_2**2) - if abs(angle - 90) > 45 and angle > 90: - angle -= 180 + angle = jnp.where(angle < 0, angle + 180.0, angle) + angle = jnp.where( + (jnp.abs(angle - 90.0) > 45.0) & (angle > 90.0), angle - 180.0, angle + ) return magnitude, angle @@ -212,13 +210,13 @@ def shear_magnitude_from(gamma_1: float, gamma_2: float) -> float: The gamma 1 and gamma 2 components of a shear are given by: - gamma_1 = magnitude * np.cos(2 * angle * np.pi / 180.0) - gamma_2 = magnitude * np.sin(2 * angle * np.pi / 180.0) + gamma_1 = magnitude * jnp.cos(2 * angle * jnp.pi / 180.0) + gamma_2 = magnitude * jnp.sin(2 * angle * jnp.pi / 180.0) Converting from gamma 1 and gamma 2 to magnitude and angle is given by: - magnitude = np.sqrt(gamma_1**2 + gamma_2**2) - angle = np.arctan2(gamma_2, gamma_1) / 2 * 180.0 / np.pi + magnitude = jnp.sqrt(gamma_1**2 + gamma_2**2) + angle = jnp.arctan2(gamma_2, gamma_1) / 2 * 180.0 / jnp.pi The magnitude value is what this function returns. @@ -239,13 +237,13 @@ def shear_angle_from(gamma_1: float, gamma_2: float) -> float: The gamma 1 and gamma 2 components of a shear are given by: - gamma_1 = magnitude * np.cos(2 * angle * np.pi / 180.0) - gamma_2 = magnitude * np.sin(2 * angle * np.pi / 180.0) + gamma_1 = magnitude * jnp.cos(2 * angle * jnp.pi / 180.0) + gamma_2 = magnitude * jnp.sin(2 * angle * jnp.pi / 180.0) Converting from gamma 1 and gamma 2 to magnitude and angle is given by: - magnitude = np.sqrt(gamma_1**2 + gamma_2**2) - angle = np.arctan2(gamma_2, gamma_1) / 2 * 180.0 / np.pi + magnitude = jnp.sqrt(gamma_1**2 + gamma_2**2) + angle = jnp.arctan2(gamma_2, gamma_1) / 2 * 180.0 / jnp.pi The angle value is what this function returns. @@ -292,12 +290,11 @@ def multipole_k_m_and_phi_m_from( The normalization and angle parameters of the multipole. """ phi_m = ( - np.arctan2(multipole_comps[0], multipole_comps[1]) * 180.0 / np.pi / float(m) + jnp.arctan2(multipole_comps[0], multipole_comps[1]) * 180.0 / jnp.pi / float(m) ) - k_m = np.sqrt(multipole_comps[1] ** 2 + multipole_comps[0] ** 2) + k_m = jnp.sqrt(multipole_comps[1] ** 2 + multipole_comps[0] ** 2) - if phi_m < -90.0 / m: - phi_m += 360.0 / m + phi_m = jnp.where(phi_m < -90.0 / m, phi_m + 360.0 / m, phi_m) return k_m, phi_m @@ -324,7 +321,9 @@ def multipole_comps_from(k_m: float, phi_m: float, m: int) -> Tuple[float, float ------- The multipole component parameters. """ - multipole_comp_0 = k_m * np.sin(phi_m * float(m) * units.deg.to(units.rad)) - multipole_comp_1 = k_m * np.cos(phi_m * float(m) * units.deg.to(units.rad)) + from astropy import units + + multipole_comp_0 = k_m * jnp.sin(phi_m * float(m) * units.deg.to(units.rad)) + multipole_comp_1 = k_m * jnp.cos(phi_m * float(m) * units.deg.to(units.rad)) return (multipole_comp_0, multipole_comp_1) diff --git a/autogalaxy/cosmology/__init__.py b/autogalaxy/cosmology/__init__.py index c711bd2a7..5923b9c27 100644 --- a/autogalaxy/cosmology/__init__.py +++ b/autogalaxy/cosmology/__init__.py @@ -1,5 +1,2 @@ from .lensing import LensingCosmology from .wrap import Planck15 -from .model import LambdaCDMWrap -from .model import FlatwCDMWrap -from .model import FlatLambdaCDMWrap diff --git a/autogalaxy/cosmology/lensing.py b/autogalaxy/cosmology/lensing.py index 818504c6e..5823c6d9d 100644 --- a/autogalaxy/cosmology/lensing.py +++ b/autogalaxy/cosmology/lensing.py @@ -1,10 +1,8 @@ -from astropy import constants -from astropy import cosmology as cosmo import math import numpy as np -class LensingCosmology(cosmo.FLRW): +class LensingCosmology: """ Class containing specific functions for performing gravitational lensing cosmology calculations. @@ -12,6 +10,12 @@ class LensingCosmology(cosmo.FLRW): calculations. """ + def __init__(self): + + from astropy.cosmology import FLRW + + self._cosmo = FLRW() + def arcsec_per_kpc_from(self, redshift: float) -> float: """ Angular separation in arcsec corresponding to a proper kpc at redshift `z`. @@ -189,6 +193,8 @@ def critical_surface_density_between_redshifts_solar_mass_per_kpc2_from( The redshift of the second strong lens galaxy (E.g. the lens galaxy) for which the critical surface density is calculated. """ + from astropy import constants + const = constants.c.to("kpc / s") ** 2.0 / ( 4 * math.pi * constants.G.to("kpc3 / (solMass s2)") ) @@ -305,6 +311,8 @@ def velocity_dispersion_from( redshift_1 The redshift of the second strong lens galaxy (the source). """ + from astropy import constants + const = constants.c.to("kpc / s") angular_diameter_distance_to_redshift_0_kpc = ( diff --git a/autogalaxy/cosmology/wrap.py b/autogalaxy/cosmology/wrap.py index 2728b545b..9adbf6bd9 100644 --- a/autogalaxy/cosmology/wrap.py +++ b/autogalaxy/cosmology/wrap.py @@ -1,25 +1,17 @@ from astropy import cosmology as cosmo - from autogalaxy.cosmology.lensing import LensingCosmology class Planck15(cosmo.FlatLambdaCDM, LensingCosmology): def __init__(self): - """ - A wrapper for the astropy `Planck15` cosmology class. - - The only role of this class is to instantiate the `Planck15` cosmology class from astropy, but to additionally - inherit from `LensingCosmology`, which is a class that provides additional functionality for calculating lensing - specific quantities in the cosmology. - """ - Planck15 = cosmo.Planck15 + Planck15_astropy = cosmo.Planck15 super().__init__( - H0=Planck15.H0, - Om0=Planck15.Om0, - Tcmb0=Planck15.Tcmb0, - Neff=Planck15.Neff, - m_nu=Planck15.m_nu, - Ob0=Planck15.Ob0, - name=Planck15.name, + H0=Planck15_astropy.H0, + Om0=Planck15_astropy.Om0, + Tcmb0=Planck15_astropy.Tcmb0, + Neff=Planck15_astropy.Neff, + m_nu=Planck15_astropy.m_nu, + Ob0=Planck15_astropy.Ob0, + name=Planck15_astropy.name, ) diff --git a/autogalaxy/ellipse/dataset_interp.py b/autogalaxy/ellipse/dataset_interp.py index ea165c5bc..a1b801b10 100644 --- a/autogalaxy/ellipse/dataset_interp.py +++ b/autogalaxy/ellipse/dataset_interp.py @@ -1,5 +1,4 @@ import numpy as np -from scipy import interpolate from typing import Tuple from autoconf import cached_property @@ -45,11 +44,13 @@ def points_interp(self) -> Tuple[np.ndarray, np.ndarray]: return (x, y) @cached_property - def mask_interp(self) -> interpolate.RegularGridInterpolator: + def mask_interp(self) -> "interpolate.RegularGridInterpolator": """ Returns a 2D interpolation of the mask, which is used to determine whether inteprolated values use a masked pixel for the interpolation and thus should not be included in a fit. """ + from scipy import interpolate + return interpolate.RegularGridInterpolator( points=self.points_interp, values=np.float64(self.dataset.data.mask), @@ -58,10 +59,12 @@ def mask_interp(self) -> interpolate.RegularGridInterpolator: ) @cached_property - def data_interp(self) -> interpolate.RegularGridInterpolator: + def data_interp(self) -> "interpolate.RegularGridInterpolator": """ Returns a 2D interpolation of the data, which is used to evaluate the data at any point in 2D space. """ + from scipy import interpolate + return interpolate.RegularGridInterpolator( points=self.points_interp, values=np.float64(self.dataset.data.native), @@ -70,10 +73,11 @@ def data_interp(self) -> interpolate.RegularGridInterpolator: ) @cached_property - def noise_map_interp(self) -> interpolate.RegularGridInterpolator: + def noise_map_interp(self) -> "interpolate.RegularGridInterpolator": """ Returns a 2D interpolation of the noise-map, which is used to evaluate the noise-map at any point in 2D space. """ + from scipy import interpolate return interpolate.RegularGridInterpolator( points=self.points_interp, diff --git a/autogalaxy/ellipse/model/analysis.py b/autogalaxy/ellipse/model/analysis.py index b833e8c86..80046e6b9 100644 --- a/autogalaxy/ellipse/model/analysis.py +++ b/autogalaxy/ellipse/model/analysis.py @@ -75,11 +75,8 @@ def log_likelihood_function(self, instance: af.ModelInstance) -> float: float The log likelihood indicating how well this model instance fitted the imaging data. """ - try: - fit_list = self.fit_list_from(instance=instance) - return sum(fit.log_likelihood for fit in fit_list) - except ValueError as e: - raise exc.FitException from e + fit_list = self.fit_list_from(instance=instance) + return sum(fit.log_likelihood for fit in fit_list) def fit_list_from(self, instance: af.ModelInstance) -> List[FitEllipse]: """ @@ -189,60 +186,3 @@ def save_attributes(self, paths: af.DirectoryPaths): visualization, and the pickled objects used by the aggregator output by this function. """ pass - - def profile_log_likelihood_function( - self, instance: af.ModelInstance, paths: Optional[af.DirectoryPaths] = None - ) -> Tuple[Dict, Dict]: - """ - This function is optionally called throughout a model-fit to profile the log likelihood function. - - All function calls inside the `log_likelihood_function` that are decorated with the `profile_func` are timed - with their times stored in a dictionary called the `run_time_dict`. - - 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, - which they can be inspected to ensure run-times are as expected. - - Parameters - ---------- - 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). - paths - The paths object which manages all paths, e.g. where the non-linear search outputs are stored, - visualization and the pickled objects used by the aggregator output by this function. - - Returns - ------- - Two dictionaries, the profiling dictionary and info dictionary, which contain the profiling times of the - `log_likelihood_function` and information on the model and dataset used to perform the profiling. - """ - repeats = 1 - - if isinstance(paths, af.DatabasePaths): - return - - run_time_dict = {} - - # Ensure numba functions are compiled before profiling begins. - - self.log_likelihood_function(instance=instance) - - start = time.time() - - for _ in range(repeats): - try: - self.log_likelihood_function(instance=instance) - except Exception: - logger.info( - "Profiling failed. Returning without outputting information." - ) - return - - fit_time = (time.time() - start) / repeats - - run_time_dict["fit_time"] = fit_time - - return run_time_dict, {} diff --git a/autogalaxy/ellipse/model/plotter_interface.py b/autogalaxy/ellipse/model/plotter_interface.py index 3e5f6a1a9..1f5590fdc 100644 --- a/autogalaxy/ellipse/model/plotter_interface.py +++ b/autogalaxy/ellipse/model/plotter_interface.py @@ -38,15 +38,16 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() dataset_plotter = aplt.ImagingPlotter( - dataset=dataset, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + dataset=dataset, + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_dataset"): dataset_plotter.subplot_dataset() image_list = [ - dataset.data.native_for_fits, - dataset.noise_map.native_for_fits, + dataset.data.native, + dataset.noise_map.native, ] hdu_list = hdu_list_for_output_from( @@ -90,7 +91,8 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() fit_plotter = FitEllipsePlotter( - fit_list=fit_list, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + fit_list=fit_list, + mat_plot_2d=mat_plot_2d, ) try: diff --git a/autogalaxy/ellipse/plot/fit_ellipse_plot_util.py b/autogalaxy/ellipse/plot/fit_ellipse_plot_util.py deleted file mode 100644 index 43bf81b5d..000000000 --- a/autogalaxy/ellipse/plot/fit_ellipse_plot_util.py +++ /dev/null @@ -1,236 +0,0 @@ -import copy, matplotlib -import numpy as np -import matplotlib.pyplot as plt - -from astropy import units -from matplotlib.colors import LinearSegmentedColormap - - -def subplot_fit(fit_list): - # NOTE: - logscale = False - - # NOTE: - figure, axes = plt.subplots(nrows=1, ncols=2, figsize=(16, 8)) - - image = fit.data.native - image_temp = image - - # NOTE: - # image = copy.copy(sample.image) - # if sample.mask is not None: - # image[sample.mask.astype(bool)] = np.nan - # - # image_temp = copy.copy(sample.image) - # image_temp[~sample.mask.astype(bool)] = np.nan - # else: - # image_temp = None - - # NOTE: - def custom_colormap(): - # Define the colors - # colors = ['white', 'black', 'red'] - # positions = [0.0, 0.5, 1.0] - colors = ["grey", "white", "red", "darkred", "black"] - positions = [0.0, 0.25, 0.5, 0.75, 1.0] - - # Create the colormap - cmap = LinearSegmentedColormap.from_list( - "custom_colormap", list(zip(positions, colors)) - ) - - return cmap - - vmin = None - vmax = None - - if vmin is None: - vmin = 0.025 - if vmax is None: - vmax = 5.0 - - norm = matplotlib.colors.LogNorm(vmin=vmin, vmax=vmax) - - im = axes[0].imshow( - np.log10(image) if logscale else image, - cmap="jet", - aspect="auto", - norm=norm, - ) - if image_temp is not None: - axes[0].imshow( - np.log10(image_temp) if logscale else image_temp, - cmap="jet", - aspect="auto", - alpha=0.5, - ) - - ellipse_list = [fit.ellipse for fit in fit_list] - - list_of_angles = [] - list_of_y_fit = [] - list_of_y_errors_fit = [] - y_means = [] - y_stds = [] - - radii - - for i, (a, parameters) in enumerate(zip(array, list_of_parameters)): - if i == 0: - m = sum(1 for value in parameters.values() if value is not None) - - y_fit, y_errors_fit, (x, y), angles = sample.extract( - a=a, parameters=parameters, condition=extract_condition - ) - list_of_angles.append(angles) - list_of_y_fit.append(y_fit) - list_of_y_errors_fit.append(y_errors_fit) - - if y_errors_fit is None: - # y_errors_fit = 0.05 * y_fit - raise NotImplementedError() - - # NOTE: - y_mean = np.nanmean(y_fit) - y_means.append(y_mean) - - # NOTE: - y_std = np.nanstd(y_fit) - y_stds.append(y_std) - - # NOTE: - axes[0].plot(x, y, marker="o", markersize=2.5, color="w") - - # NOTE: - axes[1].errorbar( - angles * units.rad.to(units.deg), - y_fit, - yerr=y_errors_fit, - linestyle="None", - marker="o", - markersize=2.5, - color="black", - ) - axes[1].axhline(y_mean, linestyle=":", color="black") - - levels = np.sort(np.log10(y_means)) if logscale else np.sort(y_means) - axes[0].contour( - np.log10(image) if logscale else image, - # levels=y_means[::-1], - levels=levels, - colors="black", - ) - colors = [im.cmap(im.norm(level)) for level in levels][::-1] - - for i, (angles, y_fit, y_errors_fit) in enumerate( - zip(list_of_angles, list_of_y_fit, list_of_y_errors_fit) - ): - axes[1].errorbar( - angles * units.rad.to(units.deg), - y_fit, - yerr=y_errors_fit, - linestyle="None", - marker="o", - markersize=2.5, - color=colors[i], - ) - # axes[0].plot( - # [247], - # [250], - # marker="o" - # ) - xticks = np.linspace(0, image.shape[1], 11) - yticks = np.linspace(0, image.shape[0], 11) - axes[0].set_xticks(xticks) - axes[0].set_yticks(xticks) - axes[1].set_xticks([0, 90, 180, 270, 360]) - axes[1].set_xlabel(r"$\phi$ (deg)", fontsize=15) - axes[1].set_ylabel(r"$\rm I(\phi)$ [E/s]", fontsize=15) - axes[1].tick_params(axis="y", labelsize=12.5) - axes[1].yaxis.tick_right() - axes[1].yaxis.set_label_position("right") - for i, ax in enumerate(axes): - ax.minorticks_on() - ax.tick_params( - axis="both", - which="major", - length=6, - right=True, - top=True, - direction="in", - colors="w" if i == 0 else "black", - ) - ax.tick_params( - axis="both", - which="minor", - length=3, - right=True, - top=True, - direction="in", - colors="w" if i == 0 else "black", - ) - - axes[1].set_yscale("log") - - # text = axes[0].text( - # 0.05, - # 0.95, - # "model 1", - # horizontalalignment='left', - # verticalalignment='center', - # transform=axes[0].transAxes, - # fontsize=25, - # weight="bold", - # color="w" - # ) - # text.set_path_effects([patheffects.withStroke(linewidth=3, foreground='black')]) - - # text = axes[0].text( - # 0.7, - # 0.95, - # "NGC 2274", - # horizontalalignment='left', - # verticalalignment='center', - # transform=axes[0].transAxes, - # fontsize=25, - # weight="bold", - # color="w" - # ) - # text.set_path_effects([patheffects.withStroke(linewidth=3, foreground='black')]) - - if a_max is None: - axes[0].set_xlim(0, image.shape[1]) - axes[0].set_ylim(0, image.shape[0]) - else: - x0 = list_of_parameters[0]["x0"] - y0 = list_of_parameters[0]["y0"] - axes[0].set_xlim(x0 - a_max, x0 + a_max) - axes[0].set_ylim(y0 - a_max, y0 + a_max) - - # NOTE: - figure.subplots_adjust(left=0.05, right=0.95, bottom=0.075, top=0.95, wspace=0.0) - - y = [] - for i, (a, chi_squares_i) in enumerate(zip(array, chi_squares)): - n = len(chi_squares_i) - 1 - - # NOTE: - y_i = np.nansum(chi_squares_i[:-1]) / (n - m) - y.append(y_i) - - figure_stats, axes_stats = plt.subplots() - axes_stats.plot(array, y, linestyle="None", marker="o", color="black") - axes_stats.set_xscale("log") - axes_stats.set_yscale("log") - # directory = "./MASSIVE/metadata" - # filename = "{}/xy_model_default.numpy".format(directory) - # with open(filename, 'wb') as f: - # np.save(f, [x, y]) - # plt.show() - # exit() - - # NOTE: - # chi_squares_flattened = list(itertools.chain(*chi_squares)) - # plt.hist(chi_squares_flattened, bins=100, alpha=0.75) - - # plt.show();exit() diff --git a/autogalaxy/ellipse/plot/fit_ellipse_plotters.py b/autogalaxy/ellipse/plot/fit_ellipse_plotters.py index b6d99eeb7..d65d9bcd3 100644 --- a/autogalaxy/ellipse/plot/fit_ellipse_plotters.py +++ b/autogalaxy/ellipse/plot/fit_ellipse_plotters.py @@ -1,52 +1,35 @@ -import matplotlib.pyplot as plt import numpy as np from typing import List -from autoconf import conf - import autoarray as aa from autoarray import plot as aplt -from autoarray.plot.auto_labels import AutoLabels - from autogalaxy.ellipse.fit_ellipse import FitEllipse from autogalaxy.plot.abstract_plotters import Plotter from autogalaxy.plot.mat_plot.one_d import MatPlot1D from autogalaxy.plot.visuals.one_d import Visuals1D -from autogalaxy.plot.include.one_d import Include1D from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D class FitEllipsePlotter(Plotter): def __init__( self, fit_list: List[FitEllipse], - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, ): super().__init__( mat_plot_1d=mat_plot_1d, visuals_1d=visuals_1d, - include_1d=include_1d, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, - include_2d=include_2d, ) self.fit_list = fit_list - def get_visuals_1d(self) -> Visuals1D: - return self.visuals_1d - - def get_visuals_2d(self): - return self.get_2d.via_mask_from(mask=self.fit_list[0].dataset.mask) - def figures_2d( self, data: bool = False, @@ -92,7 +75,7 @@ def figures_2d( ellipse_list.append(aa.Grid2DIrregular.from_yx_1d(y=y, x=x)) - visuals_2d = self.get_visuals_2d() + Visuals2D( + visuals_2d = self.visuals_2d + Visuals2D( positions=ellipse_list, lines=ellipse_list ) diff --git a/autogalaxy/fixtures.py b/autogalaxy/fixtures.py index 5ead16f63..970631c4a 100644 --- a/autogalaxy/fixtures.py +++ b/autogalaxy/fixtures.py @@ -133,7 +133,7 @@ def make_galaxies_x2_7x7(): def make_galaxies_x2_inversion_7x7(): source_gal_inversion = ag.Galaxy( redshift=1.0, - pixelization=ag.mesh.Rectangular(), + pixelization=ag.mesh.RectangularUniform(), regularization=ag.reg.Constant(), ) @@ -282,25 +282,3 @@ def make_analysis_ellipse_7x7(): dataset=make_masked_imaging_7x7(), ) return analysis - - -def make_include_1d_all(): - return aplt.Include1D(half_light_radius=True) - - -def make_include_2d_all(): - return aplt.Include2D( - origin=True, - mask=True, - border=True, - positions=True, - light_profile_centres=True, - mass_profile_centres=True, - tangential_critical_curves=False, - radial_critical_curves=False, - tangential_caustics=False, - radial_caustics=False, - multiple_images=False, - mapper_source_plane_mesh_grid=True, - mapper_image_plane_mesh_grid=True, - ) diff --git a/autogalaxy/galaxy/galaxies.py b/autogalaxy/galaxy/galaxies.py index 71a406ee1..8b172f51a 100644 --- a/autogalaxy/galaxy/galaxies.py +++ b/autogalaxy/galaxy/galaxies.py @@ -15,7 +15,6 @@ class Galaxies(List, OperateImageGalaxies, OperateDeflections): def __init__( self, galaxies: List[Galaxy], - run_time_dict: Optional[Dict] = None, ): """ A collection of galaxies, used to perform operations on the galaxies as a group. @@ -42,13 +41,9 @@ def __init__( ---------- galaxies The list of galaxies whose calculations are performed by this class. - run_time_dict - A dictionary of information on the run-times of function calls, including the total time and time spent on - different calculations. """ super().__init__(galaxies) - self.run_time_dict = run_time_dict @property def redshift(self): @@ -177,9 +172,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarr grid The 2D (y, x) coordinates where values of the deflections are evaluated. """ - if self: - return sum(map(lambda g: g.deflections_yx_2d_from(grid=grid), self)) - return np.zeros(shape=(grid.shape[0], 2)) + return sum(map(lambda g: g.deflections_yx_2d_from(grid=grid), self)) @aa.grid_dec.to_grid def traced_grid_2d_from(self, grid: aa.type.Grid2DLike) -> aa.type.Grid2DLike: @@ -210,9 +203,7 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: grid The 2D (y, x) coordinates where values of the convergence are evaluated. """ - if self: - return sum(map(lambda g: g.convergence_2d_from(grid=grid), self)) - return np.zeros((grid.shape[0],)) + return sum(map(lambda g: g.convergence_2d_from(grid=grid), self)) @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: @@ -236,9 +227,7 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: grid The 2D (y, x) coordinates where values of the potential are evaluated. """ - if self: - return sum(map(lambda g: g.potential_2d_from(grid=grid), self)) - return np.zeros((grid.shape[0],)) + return sum(map(lambda g: g.potential_2d_from(grid=grid), self)) def has(self, cls: Union[Type, Tuple[Type]]) -> bool: """ diff --git a/autogalaxy/galaxy/galaxy.py b/autogalaxy/galaxy/galaxy.py index 08b89a787..0a924c496 100644 --- a/autogalaxy/galaxy/galaxy.py +++ b/autogalaxy/galaxy/galaxy.py @@ -1,10 +1,12 @@ from typing import Dict, List, Optional, Type, Union +import jax.numpy as jnp import numpy as np +from autoconf.dictable import instance_as_dict, to_dict + import autoarray as aa import autofit as af -from autoconf.dictable import instance_as_dict, to_dict from autogalaxy import exc from autogalaxy.operate.deflections import OperateDeflections @@ -227,8 +229,7 @@ def image_2d_from( > 0 ): return sum(self.image_2d_list_from(grid=grid, operated_only=operated_only)) - - return np.zeros((grid.shape[0],)) + return jnp.zeros((grid.shape[0],)) @aa.grid_dec.to_projected def image_1d_from(self, grid: aa.type.Grid2DLike) -> np.ndarray: @@ -261,7 +262,7 @@ def image_1d_from(self, grid: aa.type.Grid2DLike) -> np.ndarray: return sum(image_1d_list) - return np.zeros((grid.shape[0],)) + return jnp.zeros((grid.shape[0],)) @aa.grid_dec.to_vector_yx def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: @@ -289,7 +290,8 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarr self.cls_list_from(cls=MassProfile), ) ) - return np.zeros((grid.shape[0], 2)) + + return jnp.zeros((grid.shape[0], 2)) @aa.grid_dec.to_array def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: @@ -316,7 +318,8 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: self.cls_list_from(cls=MassProfile), ) ) - return np.zeros((grid.shape[0],)) + + return jnp.zeros((grid.shape[0],)) @aa.grid_dec.to_grid def traced_grid_2d_from(self, grid: aa.type.Grid2DLike) -> aa.type.Grid2DLike: @@ -355,6 +358,7 @@ def convergence_1d_from(self, grid: aa.type.Grid1D2DLike) -> np.ndarray: convergence_1d_list = [] for mass_profile in self.cls_list_from(cls=MassProfile): + grid_radial = self.grid_radial_from( grid=grid, centre=mass_profile.centre, angle=mass_profile.angle ) @@ -365,7 +369,7 @@ def convergence_1d_from(self, grid: aa.type.Grid1D2DLike) -> np.ndarray: return sum(convergence_1d_list) - return np.zeros((grid.shape[0],)) + return jnp.zeros((grid.shape[0],)) @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: @@ -392,7 +396,7 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: self.cls_list_from(cls=MassProfile), ) ) - return np.zeros((grid.shape[0],)) + return jnp.zeros((grid.shape[0],)) @aa.grid_dec.to_projected def potential_1d_from(self, grid: aa.type.Grid2DLike) -> np.ndarray: @@ -425,7 +429,7 @@ def potential_1d_from(self, grid: aa.type.Grid2DLike) -> np.ndarray: return sum(potential_1d_list) - return np.zeros((grid.shape[0],)) + return jnp.zeros((grid.shape[0],)) @property def half_light_radius(self): diff --git a/autogalaxy/galaxy/plot/adapt_plotters.py b/autogalaxy/galaxy/plot/adapt_plotters.py index 933242c65..a2b07e2ef 100644 --- a/autogalaxy/galaxy/plot/adapt_plotters.py +++ b/autogalaxy/galaxy/plot/adapt_plotters.py @@ -7,22 +7,15 @@ from autogalaxy.plot.abstract_plotters import Plotter from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D class AdaptPlotter(Plotter): def __init__( self, - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, ): - super().__init__( - mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d - ) - - def get_visuals_2d(self) -> Visuals2D: - return self.visuals_2d + super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d) def figure_model_image(self, model_image: aa.Array2D): """ @@ -36,7 +29,7 @@ def figure_model_image(self, model_image: aa.Array2D): self.mat_plot_2d.plot_array( array=model_image, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title="adapt image", filename="adapt_model_image" ), @@ -53,7 +46,7 @@ def figure_galaxy_image(self, galaxy_image: aa.Array2D): """ self.mat_plot_2d.plot_array( array=galaxy_image, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title="galaxy Image", filename="adapt_galaxy_image" ), diff --git a/autogalaxy/galaxy/plot/galaxies_plotters.py b/autogalaxy/galaxy/plot/galaxies_plotters.py index 14573cd4b..56522360f 100644 --- a/autogalaxy/galaxy/plot/galaxies_plotters.py +++ b/autogalaxy/galaxy/plot/galaxies_plotters.py @@ -8,8 +8,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.mass_plotter import MassPlotter from autogalaxy.galaxy.galaxy import Galaxy from autogalaxy.galaxy.galaxies import Galaxies @@ -23,12 +21,10 @@ def __init__( self, galaxies: List[Galaxy], grid: aa.type.Grid1D2DLike, - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, ): """ Plots the attributes of a list of galaxies using the matplotlib methods `plot()` and `imshow()` and many @@ -40,8 +36,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `MassProfile` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `MassProfile` and plotted via the visuals object. Parameters ---------- @@ -53,14 +48,10 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. - include_1d - Specifies which attributes of the `MassProfile` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `MassProfile` are extracted and plotted as visuals for 2D plots. """ self.galaxies = Galaxies(galaxies=galaxies) @@ -76,10 +67,8 @@ def __init__( super().__init__( mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -88,22 +77,10 @@ def __init__( self._mass_plotter = MassPlotter( mass_obj=self.galaxies, grid=self.grid, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_light_mass_obj_from( - light_mass_obj=self.galaxies, grid=self.grid - ) - - def get_visuals_2d_of_galaxy(self, galaxy_index: int) -> aplt.Visuals2D: - return self.get_2d.via_galaxies_from( - galaxies=self.galaxies, grid=self.grid, galaxy_index=galaxy_index - ) - def galaxy_plotter_from(self, galaxy_index: int) -> GalaxyPlotter: """ Returns an `GalaxyPlotter` corresponding to a `Galaxy` in the `Tracer`. @@ -118,8 +95,7 @@ def galaxy_plotter_from(self, galaxy_index: int) -> GalaxyPlotter: galaxy=self.galaxies[galaxy_index], grid=self.grid, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_visuals_2d_of_galaxy(galaxy_index=galaxy_index), - include_2d=self.include_2d, + visuals_2d=self._mass_plotter.visuals_2d_with_critical_curves, ) def figures_2d( @@ -172,7 +148,7 @@ def figures_2d( if image: self.mat_plot_2d.plot_array( array=self.galaxies.image_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=f"Image{title_suffix}", filename=f"image_2d{filename_suffix}" ), @@ -188,7 +164,7 @@ def figures_2d( array=self.galaxies.plane_image_2d_from( grid=self.grid, zoom_to_brightest=zoom_to_brightest ), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=title, filename=f"plane_image{filename_suffix}", @@ -203,7 +179,7 @@ def figures_2d( self.mat_plot_2d.plot_grid( grid=self.grid, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=title, filename=f"plane_grid{filename_suffix}", diff --git a/autogalaxy/galaxy/plot/galaxy_plotters.py b/autogalaxy/galaxy/plot/galaxy_plotters.py index 003f6767f..f03fbe83d 100644 --- a/autogalaxy/galaxy/plot/galaxy_plotters.py +++ b/autogalaxy/galaxy/plot/galaxy_plotters.py @@ -10,8 +10,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.mass_plotter import MassPlotter from autogalaxy.profiles.light.abstract import LightProfile @@ -33,12 +31,10 @@ def __init__( self, galaxy: Galaxy, grid: aa.type.Grid1D2DLike, - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, ): """ Plots the attributes of `Galaxy` objects using the matplotlib methods `plot()` and `imshow()` and many @@ -50,8 +46,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `MassProfile` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `MassProfile` and plotted via the visuals object. Parameters ---------- @@ -63,14 +58,10 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. - include_1d - Specifies which attributes of the `MassProfile` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `MassProfile` are extracted and plotted as visuals for 2D plots. """ from autogalaxy.profiles.light.linear import ( @@ -85,10 +76,8 @@ def __init__( super().__init__( mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -98,23 +87,10 @@ def __init__( self._mass_plotter = MassPlotter( mass_obj=self.galaxy, grid=self.grid, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) - def get_visuals_1d_light(self) -> Visuals1D: - return self.get_1d.via_light_obj_from(light_obj=self.galaxy) - - def get_visuals_1d_mass(self) -> Visuals1D: - return self.get_1d.via_mass_obj_from(mass_obj=self.galaxy, grid=self.grid) - - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_light_mass_obj_from( - light_mass_obj=self.galaxy, grid=self.grid - ) - def light_profile_plotter_from( self, light_profile: LightProfile, one_d_only: bool = False ) -> LightProfilePlotter: @@ -136,25 +112,23 @@ def light_profile_plotter_from( from autogalaxy.profiles.plot.light_profile_plotters import LightProfilePlotter if not one_d_only: + return LightProfilePlotter( light_profile=light_profile, grid=self.grid, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_2d.via_light_obj_from( - light_obj=light_profile, grid=self.grid - ), - include_2d=self.include_2d, + visuals_2d=self.visuals_2d, mat_plot_1d=self.mat_plot_1d, - visuals_1d=self.get_1d.via_light_obj_from(light_obj=light_profile), - include_1d=self.include_1d, + visuals_1d=self.visuals_1d + + Visuals1D().add_half_light_radius(light_obj=light_profile), ) return LightProfilePlotter( light_profile=light_profile, grid=self.grid, mat_plot_1d=self.mat_plot_1d, - visuals_1d=self.get_1d.via_light_obj_from(light_obj=light_profile), - include_1d=self.include_1d, + visuals_1d=self.visuals_1d + + Visuals1D().add_half_light_radius(light_obj=light_profile), ) def mass_profile_plotter_from( @@ -180,25 +154,20 @@ def mass_profile_plotter_from( mass_profile=mass_profile, grid=self.grid, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_2d.via_mass_obj_from( - mass_obj=mass_profile, grid=self.grid - ), - include_2d=self.include_2d, + visuals_2d=self._mass_plotter.visuals_2d_with_critical_curves, mat_plot_1d=self.mat_plot_1d, - visuals_1d=self.get_1d.via_mass_obj_from( + visuals_1d=self.visuals_1d + + Visuals1D().add_einstein_radius( mass_obj=mass_profile, grid=self.grid ), - include_1d=self.include_1d, ) return MassProfilePlotter( mass_profile=mass_profile, grid=self.grid, mat_plot_1d=self.mat_plot_1d, - visuals_1d=self.get_1d.via_mass_obj_from( - mass_obj=mass_profile, grid=self.grid - ), - include_1d=self.include_1d, + visuals_1d=self.visuals_1d + + Visuals1D().add_einstein_radius(mass_obj=mass_profile, grid=self.grid), ) @property @@ -264,7 +233,8 @@ def figures_1d( self.mat_plot_1d.plot_yx( y=image_1d, x=image_1d.grid_radial, - visuals_1d=self.get_visuals_1d_light(), + visuals_1d=self.visuals_1d + + Visuals1D().add_half_light_radius(self.galaxy), auto_labels=aplt.AutoLabels( title="Image vs Radius", ylabel="Image ", @@ -281,7 +251,8 @@ def figures_1d( self.mat_plot_1d.plot_yx( y=convergence_1d, x=convergence_1d.grid_radial, - visuals_1d=self.get_visuals_1d_mass(), + visuals_1d=self.visuals_1d + + Visuals1D().add_einstein_radius(mass_obj=self.galaxy, grid=self.grid), auto_labels=aplt.AutoLabels( title="Convergence vs Radius", ylabel="Convergence ", @@ -298,7 +269,7 @@ def figures_1d( self.mat_plot_1d.plot_yx( y=potential_1d, x=potential_1d.grid_radial, - visuals_1d=self.get_visuals_1d_mass(), + visuals_1d=self.visuals_1d, auto_labels=aplt.AutoLabels( title="Potential vs Radius", ylabel="Potential ", @@ -438,7 +409,7 @@ def figures_2d( if image: self.mat_plot_2d.plot_array( array=self.galaxy.image_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=f"Image{title_suffix}", filename=f"image_2d{filename_suffix}" ), @@ -535,12 +506,10 @@ def __init__( self, galaxy_pdf_list: List[Galaxy], grid: aa.Grid2D, - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, sigma: Optional[float] = 3.0, ): """ @@ -558,8 +527,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `GalaxyProfile` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `GalaxyProfile` and plotted via the visuals object. Parameters ---------- @@ -571,14 +539,10 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. - include_1d - Specifies which attributes of the `GalaxyProfile` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `GalaxyProfile` are extracted and plotted as visuals for 2D plots. sigma The confidence interval in terms of a sigma value at which the errors are computed (e.g. a value of sigma=3.0 uses confidence intevals at ~0.01 and 0.99 the PDF). @@ -587,10 +551,8 @@ def __init__( galaxy=None, grid=grid, mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -645,10 +607,8 @@ def light_profile_pdf_plotter_from(self, index) -> LightProfilePDFPlotter: grid=self.grid, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, - include_2d=self.include_2d, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.visuals_1d, - include_1d=self.include_1d, ) @property @@ -693,10 +653,8 @@ def mass_profile_pdf_plotter_from(self, index) -> MassProfilePDFPlotter: grid=self.grid, mat_plot_2d=self.mat_plot_2d, visuals_2d=self.visuals_2d, - include_2d=self.include_2d, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.visuals_1d, - include_1d=self.include_1d, ) def figures_1d( @@ -749,7 +707,7 @@ def figures_1d( profile_1d_list=image_1d_list, low_limit=self.low_limit ) - visuals_1d_via_light_obj_list = self.get_1d.via_light_obj_list_from( + visuals_1d_via_light_obj_list = Visuals1D().add_half_light_radius_errors( light_obj_list=self.galaxy_pdf_list, low_limit=self.low_limit ) visuals_1d_with_shaded_region = self.visuals_1d.__class__( @@ -796,7 +754,7 @@ def figures_1d( profile_1d_list=convergence_1d_list, low_limit=self.low_limit ) - visuals_1d_via_lensing_obj_list = self.get_1d.via_mass_obj_list_from( + visuals_1d_via_lensing_obj_list = Visuals1D().add_einstein_radius_errors( mass_obj_list=self.galaxy_pdf_list, grid=self.grid, low_limit=self.low_limit, @@ -845,7 +803,7 @@ def figures_1d( profile_1d_list=potential_1d_list, low_limit=self.low_limit ) - visuals_1d_via_lensing_obj_list = self.get_1d.via_mass_obj_list_from( + visuals_1d_via_lensing_obj_list = Visuals1D().add_einstein_radius_errors( mass_obj_list=self.galaxy_pdf_list, grid=self.grid, low_limit=self.low_limit, diff --git a/autogalaxy/galaxy/to_inversion.py b/autogalaxy/galaxy/to_inversion.py index 23660ad6c..353e09b66 100644 --- a/autogalaxy/galaxy/to_inversion.py +++ b/autogalaxy/galaxy/to_inversion.py @@ -15,7 +15,6 @@ from autogalaxy.profiles.light.linear import LightProfileLinear from autogalaxy.galaxy.galaxy import Galaxy from autogalaxy.galaxy.galaxies import Galaxies -from autogalaxy.analysis.preloads import Preloads class AbstractToInversion: @@ -24,8 +23,6 @@ def __init__( dataset: Optional[Union[aa.Imaging, aa.Interferometer, aa.DatasetInterface]], adapt_images: Optional[AdaptImages] = None, settings_inversion: aa.SettingsInversion = aa.SettingsInversion(), - preloads=Preloads(), - run_time_dict: Optional[Dict] = None, ): """ Abstract class which interfaces a dataset and input modeling object (e.g. galaxies, a tracer) with the @@ -59,10 +56,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. """ if dataset is not None: if dataset.noise_covariance_matrix is not None: @@ -82,24 +75,21 @@ def __init__( self.settings_inversion = settings_inversion - self.preloads = preloads - self.run_time_dict = run_time_dict - @property - def convolver(self) -> Optional[aa.Convolver]: + def psf(self) -> Optional[aa.Kernel2D]: """ - Returns the convolver of the imaging dataset, if the inversion is performed on an imaging dataset. + Returns the PSF of the imaging dataset, if the inversion is performed on an imaging dataset. The `GalaxiesToInversion` class acts as an interface between the dataset and inversion module for - both imaging and interferometer datasets. Only imaging datasets have a convolver, thus this property - ensures that for an interferometer dataset code which references a convolver does not raise an error. + both imaging and interferometer datasets. Only imaging datasets have a PSF, thus this property + ensures that for an interferometer dataset code which references a PSF does not raise an error. Returns ------- - The convolver of the imaging dataset, if it is an imaging dataset. + The psf of the imaging dataset, if it is an imaging dataset. """ try: - return self.dataset.convolver + return self.dataset.psf except AttributeError: return None @@ -198,8 +188,6 @@ def __init__( galaxies: List[Galaxy], adapt_images: Optional[AdaptImages] = None, settings_inversion: aa.SettingsInversion = aa.SettingsInversion(), - preloads=aa.Preloads(), - run_time_dict: Optional[Dict] = None, ): """ Interfaces a dataset and input list of galaxies with the inversion module. to setup a @@ -234,10 +222,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. """ self.galaxies = Galaxies(galaxies) @@ -245,8 +229,6 @@ def __init__( dataset=dataset, adapt_images=adapt_images, settings_inversion=settings_inversion, - preloads=preloads, - run_time_dict=run_time_dict, ) @property @@ -319,7 +301,7 @@ def cls_light_profile_func_list_galaxy_dict_from( lp_linear_func = LightProfileLinearObjFuncList( grid=self.dataset.grids.lp, blurring_grid=self.dataset.grids.blurring, - convolver=self.dataset.convolver, + psf=self.dataset.psf, light_profile_list=light_profile_list, regularization=light_profile.regularization, ) @@ -500,14 +482,11 @@ def mapper_from( source_plane_mesh_grid=source_plane_mesh_grid, image_plane_mesh_grid=image_plane_mesh_grid, adapt_data=adapt_galaxy_image, - preloads=self.preloads, - run_time_dict=self.run_time_dict, ) return mapper_from( mapper_grids=mapper_grids, regularization=regularization, - run_time_dict=self.run_time_dict, ) @cached_property @@ -589,8 +568,6 @@ def inversion(self) -> aa.AbstractInversion: dataset=self.dataset, linear_obj_list=self.linear_obj_list, settings=self.settings_inversion, - preloads=self.preloads, - run_time_dict=self.run_time_dict, ) inversion.linear_obj_galaxy_dict = self.linear_obj_galaxy_dict diff --git a/autogalaxy/gui/scribbler.py b/autogalaxy/gui/scribbler.py index 8362a0fee..74385a73d 100644 --- a/autogalaxy/gui/scribbler.py +++ b/autogalaxy/gui/scribbler.py @@ -1,7 +1,5 @@ from collections import OrderedDict import numpy as np -import matplotlib -import matplotlib.pyplot as plt from typing import Tuple @@ -58,6 +56,7 @@ def __init__( extent = (x0_pix, x1_pix, y0_pix, y1_pix) + import matplotlib import matplotlib.pyplot as plt matplotlib.use(backend) @@ -129,6 +128,9 @@ def on_mouse_down(self, event): self.add_circle_to_scribble(center) def on_mouse_motion(self, event): + + import matplotlib + center = (event.xdata, event.ydata) # draw the bush circle @@ -166,6 +168,9 @@ def on_keypress(self, event): self.active_scribble_color = self.scribble_colors[num] def add_circle_to_scribble(self, center): + + import matplotlib + circle = matplotlib.patches.Circle( center, radius=self.brush_radius, @@ -198,10 +203,14 @@ def shrink_brush(self): self.figure.canvas.draw() def quit_(self): + import matplotlib.pyplot as plt + plt.close() self.figure.canvas.stop_event_loop() def show_mask(self): + import matplotlib.pyplot as plt + masks = self.get_scribble_masks() junk_mask = masks["1"] feature_mask = masks["2"] diff --git a/autogalaxy/imaging/fit_imaging.py b/autogalaxy/imaging/fit_imaging.py index 08819dfe1..9fda04b32 100644 --- a/autogalaxy/imaging/fit_imaging.py +++ b/autogalaxy/imaging/fit_imaging.py @@ -7,7 +7,6 @@ from autogalaxy.abstract_fit import AbstractFitInversion from autogalaxy.analysis.adapt_images.adapt_images import AdaptImages -from autogalaxy.analysis.preloads import Preloads from autogalaxy.galaxy.galaxy import Galaxy from autogalaxy.galaxy.galaxies import Galaxies from autogalaxy.galaxy.to_inversion import GalaxiesToInversion @@ -26,8 +25,6 @@ def __init__( dataset_model: Optional[aa.DatasetModel] = None, adapt_images: Optional[AdaptImages] = None, settings_inversion: aa.SettingsInversion = aa.SettingsInversion(), - preloads: aa.Preloads = Preloads(), - run_time_dict: Optional[Dict] = None, ): """ Fits an imaging dataset using a list of galaxies. @@ -66,21 +63,13 @@ 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 fucntion calls which have the `profile_func` - decorator take to run. """ - self.galaxies = Galaxies(galaxies=galaxies, run_time_dict=run_time_dict) - self.preloads = preloads + self.galaxies = Galaxies(galaxies=galaxies) super().__init__( dataset=dataset, dataset_model=dataset_model, - run_time_dict=run_time_dict, ) AbstractFitInversion.__init__( self=self, @@ -109,7 +98,7 @@ def blurred_image(self) -> aa.Array2D: return self.galaxies.blurred_image_2d_from( grid=self.grids.lp, - convolver=self.dataset.convolver, + psf=self.dataset.psf, blurring_grid=self.grids.blurring, ) @@ -126,7 +115,7 @@ def galaxies_to_inversion(self) -> GalaxiesToInversion: data=self.profile_subtracted_image, noise_map=self.noise_map, grids=self.grids, - convolver=self.dataset.convolver, + psf=self.dataset.psf, w_tilde=self.w_tilde, ) @@ -135,8 +124,6 @@ def galaxies_to_inversion(self) -> GalaxiesToInversion: galaxies=self.galaxies, adapt_images=self.adapt_images, settings_inversion=self.settings_inversion, - preloads=self.preloads, - run_time_dict=self.run_time_dict, ) @cached_property @@ -186,7 +173,7 @@ def galaxy_model_image_dict(self) -> Dict[Galaxy, np.ndarray]: galaxy_blurred_image_2d_dict = self.galaxies.galaxy_blurred_image_2d_dict_from( grid=self.grids.lp, - convolver=self.dataset.convolver, + psf=self.dataset.psf, blurring_grid=self.grids.blurring, ) @@ -285,44 +272,3 @@ def galaxies_linear_light_profiles_to_light_profiles(self) -> List[Galaxy]: 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, galaxies 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, galaxies 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, - galaxies=self.galaxies, - 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/autogalaxy/imaging/model/analysis.py b/autogalaxy/imaging/model/analysis.py index 6f6b2f21e..90e3c3e47 100644 --- a/autogalaxy/imaging/model/analysis.py +++ b/autogalaxy/imaging/model/analysis.py @@ -1,24 +1,15 @@ -import numpy as np -from typing import Dict, Optional, Tuple - -from autoconf.fitsable import hdu_list_for_output_from +from typing import Optional import autofit as af import autoarray as aa -from autoarray.exc import PixelizationException - from autogalaxy.analysis.adapt_images.adapt_image_maker import AdaptImageMaker from autogalaxy.analysis.analysis.dataset import AnalysisDataset -from autogalaxy.analysis.preloads import Preloads from autogalaxy.cosmology.lensing import LensingCosmology -from autogalaxy.cosmology.wrap import Planck15 from autogalaxy.imaging.model.result import ResultImaging from autogalaxy.imaging.model.visualizer import VisualizerImaging from autogalaxy.imaging.fit_imaging import FitImaging -from autogalaxy import exc - class AnalysisImaging(AnalysisDataset): Result = ResultImaging @@ -28,7 +19,7 @@ def __init__( self, dataset: aa.Imaging, adapt_image_maker: Optional[AdaptImageMaker] = None, - cosmology: LensingCosmology = Planck15(), + cosmology: LensingCosmology = None, settings_inversion: aa.SettingsInversion = None, title_prefix: str = None, ): @@ -95,9 +86,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: @@ -137,25 +125,11 @@ def log_likelihood_function(self, instance: af.ModelInstance) -> float: float The log likelihood indicating how well this model instance fitted the imaging data. """ - - try: - return self.fit_from(instance=instance).figure_of_merit - except ( - PixelizationException, - exc.PixelizationException, - exc.InversionException, - exc.GridException, - ValueError, - np.linalg.LinAlgError, - OverflowError, - ) as e: - raise exc.FitException from e + return self.fit_from(instance=instance).figure_of_merit def fit_from( self, instance: af.ModelInstance, - preload_overwrite: Optional[Preloads] = None, - run_time_dict: Optional[Dict] = None, ) -> FitImaging: """ Given a model instance create a `FitImaging` object. @@ -170,8 +144,6 @@ def fit_from( 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. - run_time_dict - A dictionary which times functions called to fit the model to data, for profiling. Returns ------- @@ -180,23 +152,19 @@ def fit_from( """ galaxies = self.galaxies_via_instance_from( - instance=instance, run_time_dict=run_time_dict + instance=instance, ) dataset_model = self.dataset_model_via_instance_from(instance=instance) adapt_images = self.adapt_images_via_instance_from(instance=instance) - preloads = self.preloads if preload_overwrite is None else preload_overwrite - return FitImaging( dataset=self.dataset, galaxies=galaxies, dataset_model=dataset_model, adapt_images=adapt_images, settings_inversion=self.settings_inversion, - preloads=preloads, - run_time_dict=run_time_dict, ) def save_attributes(self, paths: af.DirectoryPaths): @@ -228,44 +196,3 @@ def save_attributes(self, paths: af.DirectoryPaths): visualization, and the pickled objects used by the aggregator output by this function. """ super().save_attributes(paths=paths) - - def profile_log_likelihood_function( - self, instance: af.ModelInstance, paths: Optional[af.DirectoryPaths] = None - ) -> Tuple[Dict, Dict]: - """ - This function is optionally called throughout a model-fit to profile the log likelihood function. - - All function calls inside the `log_likelihood_function` that are decorated with the `profile_func` are timed - with their times stored in a dictionary called the `run_time_dict`. - - 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, - which they can be inspected to ensure run-times are as expected. - - Parameters - ---------- - 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). - paths - The paths object which manages all paths, e.g. where the non-linear search outputs are stored, - visualization and the pickled objects used by the aggregator output by this function. - - Returns - ------- - Two dictionaries, the profiling dictionary and info dictionary, which contain the profiling times of the - `log_likelihood_function` and information on the model and dataset used to perform the profiling. - """ - run_time_dict, info_dict = super().profile_log_likelihood_function( - instance=instance, - ) - - info_dict["psf_shape_2d"] = self.dataset.psf.shape_native - - self.output_profiling_info( - paths=paths, run_time_dict=run_time_dict, info_dict=info_dict - ) - - return run_time_dict, info_dict diff --git a/autogalaxy/imaging/model/plotter_interface.py b/autogalaxy/imaging/model/plotter_interface.py index 97b91c42e..00fece1d9 100644 --- a/autogalaxy/imaging/model/plotter_interface.py +++ b/autogalaxy/imaging/model/plotter_interface.py @@ -105,7 +105,8 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() dataset_plotter = aplt.ImagingPlotter( - dataset=dataset, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + dataset=dataset, + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_dataset"): @@ -164,7 +165,8 @@ def should_plot(name): mat_plot_2d = self.mat_plot_2d_from() fit_plotter = FitImagingPlotter( - fit=fit, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + fit=fit, + mat_plot_2d=mat_plot_2d, ) if should_plot("subplot_fit"): @@ -206,7 +208,8 @@ def should_plot(name): dataset_plotter_list = [ aplt.ImagingPlotter( - dataset=dataset, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + dataset=dataset, + mat_plot_2d=mat_plot_2d, ) for dataset in dataset_list ] @@ -260,7 +263,8 @@ def should_plot(name): fit_plotter_list = [ FitImagingPlotter( - fit=fit, mat_plot_2d=mat_plot_2d, include_2d=self.include_2d + fit=fit, + mat_plot_2d=mat_plot_2d, ) for fit in fit_list ] diff --git a/autogalaxy/imaging/plot/fit_imaging_plotters.py b/autogalaxy/imaging/plot/fit_imaging_plotters.py index 439d3e9aa..a5b1cc3e5 100644 --- a/autogalaxy/imaging/plot/fit_imaging_plotters.py +++ b/autogalaxy/imaging/plot/fit_imaging_plotters.py @@ -11,16 +11,14 @@ from autogalaxy.plot.abstract_plotters import Plotter from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D class FitImagingPlotter(Plotter): def __init__( self, fit: FitImaging, - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, residuals_symmetric_cmap: bool = True, ): """ @@ -32,8 +30,7 @@ def __init__( but a user can manually input values into `MatPlot2d` to customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals2D` object. Attributes may be extracted from - the `FitImaging` and plotted via the visuals object, if the corresponding entry is `True` in the `Include2D` - object or the `config/visualize/include.ini` file. + the `FitImaging` and plotted via the visuals object. Parameters ---------- @@ -43,23 +40,17 @@ def __init__( Contains objects which wrap the matplotlib function calls that make the plot. visuals_2d Contains visuals that can be overlaid on the plot. - include_2d - Specifies which attributes of the `FitImaging` are extracted and plotted as visuals. residuals_symmetric_cmap If true, the `residual_map` and `normalized_residual_map` are plotted with a symmetric color map such that `abs(vmin) = abs(vmax)`. """ - super().__init__( - mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d - ) + super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d) self.fit = fit self._fit_imaging_meta_plotter = FitImagingPlotterMeta( fit=self.fit, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, residuals_symmetric_cmap=residuals_symmetric_cmap, ) @@ -67,9 +58,6 @@ def __init__( self.figures_2d = self._fit_imaging_meta_plotter.figures_2d self.subplot = self._fit_imaging_meta_plotter.subplot - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_fit_imaging_from(fit=self.fit) - @property def inversion_plotter(self) -> aplt.InversionPlotter: """ @@ -83,8 +71,7 @@ def inversion_plotter(self) -> aplt.InversionPlotter: return aplt.InversionPlotter( inversion=self.fit.inversion, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_visuals_2d(), - include_2d=self.include_2d, + visuals_2d=self.visuals_2d, ) @property @@ -153,7 +140,7 @@ def figures_2d_of_galaxies( self.mat_plot_2d.plot_array( array=self.fit.subtracted_images_of_galaxies_list[galaxy_index], - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=f"Subtracted Image of Galaxy {galaxy_index}", filename=f"subtracted_image_of_galaxy_{galaxy_index}", @@ -163,7 +150,7 @@ def figures_2d_of_galaxies( if model_image: self.mat_plot_2d.plot_array( array=self.fit.model_images_of_galaxies_list[galaxy_index], - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels( title=f"Model Image of Galaxy {galaxy_index}", filename=f"model_image_of_galaxy_{galaxy_index}", diff --git a/autogalaxy/interferometer/fit_interferometer.py b/autogalaxy/interferometer/fit_interferometer.py index 634382c1a..282151050 100644 --- a/autogalaxy/interferometer/fit_interferometer.py +++ b/autogalaxy/interferometer/fit_interferometer.py @@ -7,7 +7,6 @@ from autogalaxy.abstract_fit import AbstractFitInversion from autogalaxy.analysis.adapt_images.adapt_images import AdaptImages -from autogalaxy.analysis.preloads import Preloads from autogalaxy.galaxy.galaxy import Galaxy from autogalaxy.galaxy.galaxies import Galaxies from autogalaxy.galaxy.to_inversion import GalaxiesToInversion @@ -21,8 +20,6 @@ def __init__( dataset_model: Optional[aa.DatasetModel] = None, adapt_images: Optional[AdaptImages] = None, settings_inversion: aa.SettingsInversion = aa.SettingsInversion(), - preloads: aa.Preloads = Preloads(), - run_time_dict: Optional[Dict] = None, ): """ Fits an interferometer dataset using a list of galaxies. @@ -62,12 +59,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 fucntion calls which have the `profile_func` - decorator take to run. """ try: @@ -75,13 +66,12 @@ def __init__( except ImportError: settings_inversion.use_w_tilde = False - self.galaxies = Galaxies(galaxies=galaxies, run_time_dict=run_time_dict) + self.galaxies = Galaxies(galaxies=galaxies) super().__init__( dataset=dataset, dataset_model=dataset_model, use_mask_in_fit=False, - run_time_dict=run_time_dict, ) AbstractFitInversion.__init__( self=self, @@ -92,8 +82,6 @@ def __init__( self.adapt_images = adapt_images self.settings_inversion = settings_inversion - self.preloads = preloads - @property def profile_visibilities(self) -> aa.Visibilities: """ @@ -126,8 +114,6 @@ def galaxies_to_inversion(self) -> GalaxiesToInversion: galaxies=self.galaxies, adapt_images=self.adapt_images, settings_inversion=self.settings_inversion, - preloads=self.preloads, - run_time_dict=self.run_time_dict, ) @cached_property @@ -223,44 +209,3 @@ def galaxies_linear_light_profiles_to_light_profiles(self) -> List[Galaxy]: 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, galaxies 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, galaxies 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, - galaxies=self.galaxies, - 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/autogalaxy/interferometer/model/analysis.py b/autogalaxy/interferometer/model/analysis.py index 1dce6801f..9abffdb33 100644 --- a/autogalaxy/interferometer/model/analysis.py +++ b/autogalaxy/interferometer/model/analysis.py @@ -1,24 +1,17 @@ import logging -import numpy as np -from typing import Dict, Optional, Tuple +from typing import Optional from autoconf.dictable import to_dict -from autoconf.fitsable import hdu_list_for_output_from import autofit as af import autoarray as aa -from autoarray.exc import PixelizationException - from autogalaxy.analysis.adapt_images.adapt_image_maker import AdaptImageMaker from autogalaxy.analysis.analysis.dataset import AnalysisDataset -from autogalaxy.analysis.preloads import Preloads from autogalaxy.cosmology.lensing import LensingCosmology -from autogalaxy.cosmology.wrap import Planck15 from autogalaxy.interferometer.model.result import ResultInterferometer from autogalaxy.interferometer.fit_interferometer import FitInterferometer from autogalaxy.interferometer.model.visualizer import VisualizerInterferometer -from autogalaxy import exc logger = logging.getLogger(__name__) @@ -33,7 +26,7 @@ def __init__( self, dataset: aa.Interferometer, adapt_image_maker: Optional[AdaptImageMaker] = None, - cosmology: LensingCosmology = Planck15(), + cosmology: LensingCosmology = None, settings_inversion: aa.SettingsInversion = None, title_prefix: str = None, ): @@ -100,13 +93,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: af.ModelInstance) -> float: @@ -145,25 +131,11 @@ def log_likelihood_function(self, instance: af.ModelInstance) -> float: float The log likelihood indicating how well this model instance fitted the interferometer data. """ - - try: - return self.fit_from(instance=instance).figure_of_merit - except ( - PixelizationException, - exc.PixelizationException, - exc.InversionException, - exc.GridException, - ValueError, - np.linalg.LinAlgError, - OverflowError, - ) as e: - raise exc.FitException from e + return self.fit_from(instance=instance).figure_of_merit def fit_from( self, instance: af.ModelInstance, - preload_overwrite: Optional[Preloads] = None, - run_time_dict: Optional[Dict] = None, ) -> FitInterferometer: """ Given a model instance create a `FitInterferometer` object. @@ -178,8 +150,6 @@ def fit_from( 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. - run_time_dict - A dictionary which times functions called to fit the model to data, for profiling. Returns ------- @@ -187,20 +157,16 @@ def fit_from( The fit of the galaxies to the interferometer dataset, which includes the log likelihood. """ galaxies = self.galaxies_via_instance_from( - instance=instance, run_time_dict=run_time_dict + instance=instance, ) 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, galaxies=galaxies, adapt_images=adapt_images, settings_inversion=self.settings_inversion, - preloads=preloads, - run_time_dict=run_time_dict, ) def save_attributes(self, paths: af.DirectoryPaths): @@ -240,45 +206,3 @@ def save_attributes(self, paths: af.DirectoryPaths): paths.save_json( "transformer_class", to_dict(self.dataset.transformer.__class__), "dataset" ) - - def profile_log_likelihood_function( - self, instance: af.ModelInstance, paths: Optional[af.DirectoryPaths] = None - ) -> Tuple[Dict, Dict]: - """ - This function is optionally called throughout a model-fit to profile the log likelihood function. - - All function calls inside the `log_likelihood_function` that are decorated with the `profile_func` are timed - with their times stored in a dictionary called the `run_time_dict`. - - 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, - which they can be inspected to ensure run-times are as expected. - - Parameters - ---------- - 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). - paths - The paths object which manages all paths, e.g. where the non-linear search outputs are stored, - visualization and the pickled objects used by the aggregator output by this function. - - Returns - ------- - Two dictionaries, the profiling dictionary and info dictionary, which contain the profiling times of the - `log_likelihood_function` and information on the model and dataset used to perform the profiling. - """ - run_time_dict, info_dict = super().profile_log_likelihood_function( - instance=instance, - ) - - info_dict["number_of_visibilities"] = self.dataset.data.shape[0] - info_dict["transformer_cls"] = self.dataset.transformer.__class__.__name__ - - self.output_profiling_info( - paths=paths, run_time_dict=run_time_dict, info_dict=info_dict - ) - - return run_time_dict, info_dict diff --git a/autogalaxy/interferometer/model/plotter_interface.py b/autogalaxy/interferometer/model/plotter_interface.py index a37096fbc..f27237b31 100644 --- a/autogalaxy/interferometer/model/plotter_interface.py +++ b/autogalaxy/interferometer/model/plotter_interface.py @@ -106,7 +106,6 @@ def should_plot(name): dataset_plotter = aplt.InterferometerPlotter( dataset=dataset, - include_2d=self.include_2d, mat_plot_1d=mat_plot_1d, mat_plot_2d=mat_plot_2d, ) @@ -160,7 +159,6 @@ def should_plot(name): fit_plotter = FitInterferometerPlotter( fit=fit, - include_2d=self.include_2d, mat_plot_1d=mat_plot_1d, mat_plot_2d=mat_plot_2d, ) diff --git a/autogalaxy/interferometer/plot/fit_interferometer_plotters.py b/autogalaxy/interferometer/plot/fit_interferometer_plotters.py index 8fd3995ab..1dbddd50d 100644 --- a/autogalaxy/interferometer/plot/fit_interferometer_plotters.py +++ b/autogalaxy/interferometer/plot/fit_interferometer_plotters.py @@ -12,8 +12,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.galaxy.plot.galaxies_plotters import GalaxiesPlotter @@ -22,12 +20,10 @@ class FitInterferometerPlotter(Plotter): def __init__( self, fit: FitInterferometer, - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, residuals_symmetric_cmap: bool = True, ): """ @@ -40,8 +36,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `FitInterferometer` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `FitInterferometer` and plotted via the visuals object. Parameters ---------- @@ -51,24 +46,18 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. - include_1d - Specifies which attributes of the `FitInterferometer` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `FitInterferometer` are extracted and plotted as visuals for 2D plots. residuals_symmetric_cmap If true, the `residual_map` and `normalized_residual_map` are plotted with a symmetric color map such that `abs(vmin) = abs(vmax)`. """ super().__init__( mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, ) @@ -76,12 +65,9 @@ def __init__( self._fit_interferometer_meta_plotter = FitInterferometerPlotterMeta( fit=self.fit, - get_visuals_2d_real_space=self.get_visuals_2d_real_space, mat_plot_1d=self.mat_plot_1d, - include_1d=self.include_1d, visuals_1d=self.visuals_1d, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, residuals_symmetric_cmap=residuals_symmetric_cmap, ) @@ -93,9 +79,6 @@ def __init__( self._fit_interferometer_meta_plotter.subplot_fit_dirty_images ) - def get_visuals_2d_real_space(self) -> Visuals2D: - return self.get_2d.via_mask_from(mask=self.fit.dataset.real_space_mask) - @property def galaxies(self) -> List[Galaxy]: return self.fit.galaxies_linear_light_profiles_to_light_profiles @@ -113,8 +96,7 @@ def galaxies_plotter_from(self, galaxies: List[Galaxy]) -> GalaxiesPlotter: galaxies=galaxies, grid=self.fit.grids.lp, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_visuals_2d_real_space(), - include_2d=self.include_2d, + visuals_2d=self.visuals_2d, ) @property @@ -130,8 +112,7 @@ def inversion_plotter(self) -> aplt.InversionPlotter: return aplt.InversionPlotter( inversion=self.fit.inversion, mat_plot_2d=self.mat_plot_2d, - visuals_2d=self.get_visuals_2d_real_space(), - include_2d=self.include_2d, + visuals_2d=self.visuals_2d, ) def subplot_fit(self): diff --git a/autogalaxy/operate/deflections.py b/autogalaxy/operate/deflections.py index be4ef24b1..27286bcae 100644 --- a/autogalaxy/operate/deflections.py +++ b/autogalaxy/operate/deflections.py @@ -1,9 +1,10 @@ -from functools import wraps +import jax +from jax import jit +import jax.numpy as jnp +from functools import wraps, partial import logging -import numpy as np from typing import List, Tuple, Union -from autoconf import conf import autoarray as aa @@ -45,49 +46,18 @@ def wrapper(lensing_obj, grid, jacobian=None): return wrapper -def evaluation_grid(func): - @wraps(func) - def wrapper( - lensing_obj, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 - ): - if hasattr(grid, "is_evaluation_grid"): - if grid.is_evaluation_grid: - return func(lensing_obj, grid, pixel_scale) - - pixel_scale_ratio = grid.pixel_scale / pixel_scale - - zoom = aa.Zoom2D(mask=grid.mask) - - zoom_shape_native = zoom.shape_native - shape_native = ( - int(pixel_scale_ratio * zoom_shape_native[0]), - int(pixel_scale_ratio * zoom_shape_native[1]), - ) - - max_evaluation_grid_size = conf.instance["general"]["grid"][ - "max_evaluation_grid_size" - ] +def one_step(r, _, theta, fun, fun_dr): + r = jnp.abs(r - fun(r, theta) / fun_dr(r, theta)) + return r, None - # This is a hack to prevent the evaluation gird going beyond 1000 x 1000 pixels, which slows the code - # down a lot. Need a better moe robust way to set this up for any general lens. - - if shape_native[0] > max_evaluation_grid_size: - pixel_scale = pixel_scale_ratio / ( - shape_native[0] / float(max_evaluation_grid_size) - ) - shape_native = (max_evaluation_grid_size, max_evaluation_grid_size) - grid = aa.Grid2D.uniform( - shape_native=shape_native, - pixel_scales=(pixel_scale, pixel_scale), - origin=zoom.offset_scaled, - ) - - grid.is_evaluation_grid = True - - return func(lensing_obj, grid, pixel_scale) - - return wrapper +@partial(jit, static_argnums=(4,)) +def step_r(r, theta, fun, fun_dr, N=20): + one_step_partial = jax.tree_util.Partial( + one_step, theta=theta, fun=fun, fun_dr=fun_dr + ) + new_r = jax.lax.scan(one_step_partial, r, xs=jnp.arange(N))[0] + return jnp.stack([new_r * jnp.sin(theta), new_r * jnp.cos(theta)]).T class OperateDeflections: @@ -109,6 +79,22 @@ class OperateDeflections: def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): raise NotImplementedError + def deflections_yx_scalar(self, y, x, pixel_scales): + + # A version of the deflection function that takes in two scalars + # and outputs a 2D vector. Needed for JAX auto differentiation. + + mask = aa.Mask2D.all_false( + shape_native=(1, 1), + pixel_scales=pixel_scales, + ) + + g = aa.Grid2D( + values=jnp.stack((y.reshape(1), x.reshape(1)), axis=-1), mask=mask + ) + + return self.deflections_yx_2d_from(g).squeeze() + def __eq__(self, other): return self.__dict__ == other.__dict__ and self.__class__ is other.__class__ @@ -199,6 +185,9 @@ def time_delays_from(self, grid) -> aa.Array2D: mask=grid.mask, ) + def __hash__(self): + return hash(repr(self)) + @precompute_jacobian def tangential_eigen_value_from(self, grid, jacobian=None) -> aa.Array2D: """ @@ -288,21 +277,21 @@ def hessian_from(self, grid, buffer: float = 0.01, deflections_func=None) -> Tup if deflections_func is None: deflections_func = self.deflections_yx_2d_from - grid_shift_y_up = aa.Grid2DIrregular(values=np.zeros(grid.shape)) - grid_shift_y_up[:, 0] = grid[:, 0] + buffer - grid_shift_y_up[:, 1] = grid[:, 1] + grid_shift_y_up = aa.Grid2DIrregular( + values=jnp.stack([grid[:, 0] + buffer, grid[:, 1]], axis=1) + ) - grid_shift_y_down = aa.Grid2DIrregular(values=np.zeros(grid.shape)) - grid_shift_y_down[:, 0] = grid[:, 0] - buffer - grid_shift_y_down[:, 1] = grid[:, 1] + grid_shift_y_down = aa.Grid2DIrregular( + values=jnp.stack([grid[:, 0] - buffer, grid[:, 1]], axis=1) + ) - grid_shift_x_left = aa.Grid2DIrregular(values=np.zeros(grid.shape)) - grid_shift_x_left[:, 0] = grid[:, 0] - grid_shift_x_left[:, 1] = grid[:, 1] - buffer + grid_shift_x_left = aa.Grid2DIrregular( + values=jnp.stack([grid[:, 0], grid[:, 1] - buffer], axis=1) + ) - grid_shift_x_right = aa.Grid2DIrregular(values=np.zeros(grid.shape)) - grid_shift_x_right[:, 0] = grid[:, 0] - grid_shift_x_right[:, 1] = grid[:, 1] + buffer + grid_shift_x_right = aa.Grid2DIrregular( + values=jnp.stack([grid[:, 0], grid[:, 1] + buffer], axis=1) + ) deflections_up = deflections_func(grid=grid_shift_y_up) deflections_down = deflections_func(grid=grid_shift_y_down) @@ -383,7 +372,7 @@ def shear_yx_2d_via_hessian_from( gamma_1 = 0.5 * (hessian_xx - hessian_yy) gamma_2 = hessian_xy - shear_yx_2d = np.zeros(shape=(grid.shape_slim, 2)) + shear_yx_2d = jnp.zeros(shape=(grid.shape_slim, 2)) shear_yx_2d[:, 0] = gamma_2 shear_yx_2d[:, 1] = gamma_1 @@ -430,9 +419,9 @@ def contour_list_from(self, grid, contour_array): return grid_contour.contour_list - @evaluation_grid def tangential_critical_curve_list_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 + self, + grid, ) -> List[aa.Grid2DIrregular]: """ Returns all tangential critical curves of the lensing system, which are computed as follows: @@ -456,9 +445,9 @@ def tangential_critical_curve_list_from( return self.contour_list_from(grid=grid, contour_array=tangential_eigen_values) - @evaluation_grid def radial_critical_curve_list_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 + self, + grid, ) -> List[aa.Grid2DIrregular]: """ Returns all radial critical curves of the lensing system, which are computed as follows: @@ -482,9 +471,9 @@ def radial_critical_curve_list_from( return self.contour_list_from(grid=grid, contour_array=radial_eigen_values) - @evaluation_grid def tangential_caustic_list_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 + self, + grid, ) -> List[aa.Grid2DIrregular]: """ Returns all tangential caustics of the lensing system, which are computed as follows: @@ -508,7 +497,7 @@ def tangential_caustic_list_from( """ tangential_critical_curve_list = self.tangential_critical_curve_list_from( - grid=grid, pixel_scale=pixel_scale + grid=grid ) tangential_caustic_list = [] @@ -524,9 +513,9 @@ def tangential_caustic_list_from( return tangential_caustic_list - @evaluation_grid def radial_caustic_list_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 + self, + grid, ) -> List[aa.Grid2DIrregular]: """ Returns all radial caustics of the lensing system, which are computed as follows: @@ -549,9 +538,7 @@ def radial_caustic_list_from( caustic to be computed more accurately using a higher resolution grid. """ - radial_critical_curve_list = self.radial_critical_curve_list_from( - grid=grid, pixel_scale=pixel_scale - ) + radial_critical_curve_list = self.radial_critical_curve_list_from(grid=grid) radial_caustic_list = [] @@ -566,10 +553,7 @@ def radial_caustic_list_from( return radial_caustic_list - @evaluation_grid - def radial_critical_curve_area_list_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] - ) -> List[float]: + def radial_critical_curve_area_list_from(self, grid) -> List[float]: """ Returns the surface area within each radial critical curve as a list, the calculation of which is described in the function `radial_critical_curve_list_from()`. @@ -589,15 +573,13 @@ def radial_critical_curve_area_list_from( If input, the `evaluation_grid` decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid. """ - radial_critical_curve_list = self.radial_critical_curve_list_from( - grid=grid, pixel_scale=pixel_scale - ) + radial_critical_curve_list = self.radial_critical_curve_list_from(grid=grid) return self.area_within_curve_list_from(curve_list=radial_critical_curve_list) - @evaluation_grid def tangential_critical_curve_area_list_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 + self, + grid, ) -> List[float]: """ Returns the surface area within each tangential critical curve as a list, the calculation of which is @@ -618,7 +600,7 @@ def tangential_critical_curve_area_list_from( caustic to be computed more accurately using a higher resolution grid. """ tangential_critical_curve_list = self.tangential_critical_curve_list_from( - grid=grid, pixel_scale=pixel_scale + grid=grid ) return self.area_within_curve_list_from( @@ -632,14 +614,14 @@ def area_within_curve_list_from( for curve in curve_list: x, y = curve[:, 0], curve[:, 1] - area = np.abs(0.5 * np.sum(y[:-1] * np.diff(x) - x[:-1] * np.diff(y))) + area = jnp.abs(0.5 * jnp.sum(y[:-1] * jnp.diff(x) - x[:-1] * jnp.diff(y))) area_within_each_curve_list.append(area) return area_within_each_curve_list - @evaluation_grid def einstein_radius_list_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 + self, + grid, ): """ Returns a list of the Einstein radii corresponding to the area within each tangential critical curve. @@ -666,16 +648,14 @@ def einstein_radius_list_from( caustic to be computed more accurately using a higher resolution grid. """ try: - area_list = self.tangential_critical_curve_area_list_from( - grid=grid, pixel_scale=pixel_scale - ) - return [np.sqrt(area / np.pi) for area in area_list] + area_list = self.tangential_critical_curve_area_list_from(grid=grid) + return [jnp.sqrt(area / jnp.pi) for area in area_list] except TypeError: raise TypeError("The grid input was unable to estimate the Einstein Radius") - @evaluation_grid def einstein_radius_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 + self, + grid, ): """ Returns the Einstein radius corresponding to the area within the tangential critical curve. @@ -717,9 +697,9 @@ def einstein_radius_from( return sum(einstein_radii_list) - @evaluation_grid def einstein_mass_angular_list_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 + self, + grid, ) -> List[float]: """ Returns a list of the angular Einstein massses corresponding to the area within each tangential critical curve. @@ -748,14 +728,12 @@ def einstein_mass_angular_list_from( If input, the `evaluation_grid` decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid. """ - einstein_radius_list = self.einstein_radius_list_from( - grid=grid, pixel_scale=pixel_scale - ) - return [np.pi * einstein_radius**2 for einstein_radius in einstein_radius_list] + einstein_radius_list = self.einstein_radius_list_from(grid=grid) + return [jnp.pi * einstein_radius**2 for einstein_radius in einstein_radius_list] - @evaluation_grid def einstein_mass_angular_from( - self, grid, pixel_scale: Union[Tuple[float, float], float] = 0.05 + self, + grid, ) -> float: """ Returns the Einstein radius corresponding to the area within the tangential critical curve. @@ -784,9 +762,7 @@ def einstein_mass_angular_from( If input, the `evaluation_grid` decorator creates the 2D grid at this resolution, therefore enabling the caustic to be computed more accurately using a higher resolution grid. """ - einstein_mass_angular_list = self.einstein_mass_angular_list_from( - grid=grid, pixel_scale=pixel_scale - ) + einstein_mass_angular_list = self.einstein_mass_angular_list_from(grid=grid) if len(einstein_mass_angular_list) > 1: logger.info( @@ -798,6 +774,167 @@ def einstein_mass_angular_from( return einstein_mass_angular_list[0] + def jacobian_stack(self, y, x, pixel_scales): + return jnp.stack( + jax.jacfwd(self.deflections_yx_scalar, argnums=(0, 1))(y, x, pixel_scales) + ) + + def jacobian_stack_vector(self, y, x, pixel_scales): + return jnp.vectorize( + jax.tree_util.Partial(self.jacobian_stack, pixel_scales=pixel_scales), + signature="(),()->(i,i)", + )(y, x) + + def convergence_mag_shear_yx(self, y, x): + J = self.jacobian_stack_vector(y, x, 0.05) + K = 0.5 * (J[..., 0, 0] + J[..., 1, 1]) + mag_shear = 0.5 * jnp.sqrt( + (J[..., 0, 1] + J[..., 1, 0]) ** 2 + (J[..., 0, 0] - J[..., 1, 1]) ** 2 + ) + return K, mag_shear + + @partial(jit, static_argnums=(0,)) + def tangential_eigen_value_yx(self, y, x): + K, mag_shear = self.convergence_mag_shear_yx(y, x) + return 1 - K - mag_shear + + @partial(jit, static_argnums=(0, 3)) + def tangential_eigen_value_rt(self, r, theta, centre=(0.0, 0.0)): + y = r * jnp.sin(theta) + centre[0] + x = r * jnp.cos(theta) + centre[1] + return self.tangential_eigen_value_yx(y, x) + + @partial(jit, static_argnums=(0, 3)) + def grad_r_tangential_eigen_value(self, r, theta, centre=(0.0, 0.0)): + # ignore `self` with the `argnums` below + tangential_eigen_part = partial(self.tangential_eigen_value_rt, centre=centre) + return jnp.vectorize( + jax.jacfwd(tangential_eigen_part, argnums=(0,)), signature="(),()->()" + )(r, theta)[0] + + @partial(jit, static_argnums=(0,)) + def radial_eigen_value_yx(self, y, x): + K, mag_shear = self.convergence_mag_shear_yx(y, x) + return 1 - K + mag_shear + + @partial(jit, static_argnums=(0, 3)) + def radial_eigen_value_rt(self, r, theta, centre=(0.0, 0.0)): + y = r * jnp.sin(theta) + centre[0] + x = r * jnp.cos(theta) + centre[1] + return self.radial_eigen_value_yx(y, x) + + @partial(jit, static_argnums=(0, 3)) + def grad_r_radial_eigen_value(self, r, theta, centre=(0.0, 0.0)): + # ignore `self` with the `argnums` below + radial_eigen_part = partial(self.radial_eigen_value_rt, centre=centre) + return jnp.vectorize( + jax.jacfwd(radial_eigen_part, argnums=(0,)), signature="(),()->()" + )(r, theta)[0] + + def tangential_critical_curve_jax( + self, + init_r=0.1, + init_centre=(0.0, 0.0), + n_points=300, + n_steps=20, + threshold=1e-5, + ): + """ + Returns all tangential critical curves of the lensing system, which are computed as follows: + + 1) Create a set of `n_points` initial points in a circle of radius `init_r` and centred on `init_centre` + 2) Apply `n_steps` of Newton's method to these points in the "radial" direction only (i.e. keeping angle fixed). + Jax's auto differentiation is used to find the radial derivatives of the tangential eigen value function for + this step. + 3) Filter the results and only keep point that have their tangential eigen value `threshold` of 0 + + No underlying grid is needed for the method, but the quality of the results are dependent on the initial + circle of points. + + Parameters + ---------- + init_r : float + Radius of the circle of initial guess points + init_centre : tuple + centre of the circle of initial guess points as `(y, x)` + n_points : Int + Number of initial guess points to create (evenly spaced in angle around `init_centre`) + n_steps : Int + Number of iterations of Newton's method to apply + threshold : float + Only keep points whose tangential eigen value is within this value of zero (inclusive) + """ + r = jnp.ones(n_points) * init_r + theta = jnp.linspace(0, 2 * jnp.pi, n_points + 1)[:-1] + new_yx = step_r( + r, + theta, + jax.tree_util.Partial(self.tangential_eigen_value_rt, centre=init_centre), + jax.tree_util.Partial( + self.grad_r_tangential_eigen_value, centre=init_centre + ), + n_steps, + ) + new_yx = new_yx + jnp.array(init_centre) + # filter out nan values + fdx = jnp.isfinite(new_yx).all(axis=1) + new_yx = new_yx[fdx] + # filter out failed points + value = jnp.abs(self.tangential_eigen_value_yx(new_yx[:, 0], new_yx[:, 1])) + gdx = value <= threshold + return aa.structures.grids.irregular_2d.Grid2DIrregular(values=new_yx[gdx]) + + def radial_critical_curve_jax( + self, + init_r=0.01, + init_centre=(0.0, 0.0), + n_points=300, + n_steps=20, + threshold=1e-5, + ): + """ + Returns all radial critical curves of the lensing system, which are computed as follows: + + 1) Create a set of `n_points` initial points in a circle of radius `init_r` and centred on `init_centre` + 2) Apply `n_steps` of Newton's method to these points in the "radial" direction only (i.e. keeping angle fixed). + Jax's auto differentiation is used to find the radial derivatives of the radial eigen value function for + this step. + 3) Filter the results and only keep point that have their radial eigen value `threshold` of 0 + + No underlying grid is needed for the method, but the quality of the results are dependent on the initial + circle of points. + + Parameters + ---------- + init_r : float + Radius of the circle of initial guess points + init_centre : tuple + centre of the circle of initial guess points as `(y, x)` + n_points : Int + Number of initial guess points to create (evenly spaced in angle around `init_centre`) + n_steps : Int + Number of iterations of Newton's method to apply + threshold : float + Only keep points whose radial eigen value is within this value of zero (inclusive) + """ + r = jnp.ones(n_points) * init_r + theta = jnp.linspace(0, 2 * jnp.pi, n_points + 1)[:-1] + new_yx = step_r( + r, + theta, + jax.tree_util.Partial(self.radial_eigen_value_rt, centre=init_centre), + jax.tree_util.Partial(self.grad_r_radial_eigen_value, centre=init_centre), + n_steps, + ) + new_yx = new_yx + jnp.array(init_centre) + # filter out nan values + fdx = jnp.isfinite(new_yx).all(axis=1) + new_yx = new_yx[fdx] + # filter out failed points + value = jnp.abs(self.radial_eigen_value_yx(new_yx[:, 0], new_yx[:, 1])) + gdx = value <= threshold + return aa.structures.grids.irregular_2d.Grid2DIrregular(values=new_yx[gdx]) + def jacobian_from(self, grid): """ Returns the Jacobian of the lensing object, which is computed by taking the gradient of the 2D deflection @@ -815,36 +952,24 @@ def jacobian_from(self, grid): grid The 2D grid of (y,x) arc-second coordinates the deflection angles and Jacobian are computed on. """ - - deflections = self.deflections_yx_2d_from(grid=grid) - - # TODO : Can probably make this work on irregular grid? Is there any point? - - a11 = aa.Array2D( - values=1.0 - - np.gradient(deflections.native[:, :, 1], grid.native[0, :, 1], axis=1), - mask=grid.mask, - ) - - a12 = aa.Array2D( - values=-1.0 - * np.gradient(deflections.native[:, :, 1], grid.native[:, 0, 0], axis=0), - mask=grid.mask, - ) - - a21 = aa.Array2D( - values=-1.0 - * np.gradient(deflections.native[:, :, 0], grid.native[0, :, 1], axis=1), - mask=grid.mask, - ) - - a22 = aa.Array2D( - values=1 - - np.gradient(deflections.native[:, :, 0], grid.native[:, 0, 0], axis=0), - mask=grid.mask, + A = self.jacobian_stack_vector( + grid.array[:, 0], grid.array[:, 1], grid.pixel_scales ) + a = jnp.eye(2).reshape(1, 2, 2) - A + return [ + [ + aa.Array2D(values=a[..., 1, 1], mask=grid.mask), + aa.Array2D(values=a[..., 1, 0], mask=grid.mask), + ], + [ + aa.Array2D(values=a[..., 0, 1], mask=grid.mask), + aa.Array2D(values=a[..., 0, 0], mask=grid.mask), + ], + ] - return [[a11, a12], [a21, a22]] + # transpose the result + # use `moveaxis` as grid might not be nx2 + # return jnp.moveaxis(jnp.moveaxis(a, -1, 0), -1, 0) @precompute_jacobian def convergence_2d_via_jacobian_from(self, grid, jacobian=None) -> aa.Array2D: @@ -893,10 +1018,9 @@ def shear_yx_2d_via_jacobian_from( jacobian A precomputed lensing jacobian, which is passed throughout the `CalcLens` functions for efficiency. """ - - shear_yx_2d = np.zeros(shape=(grid.shape_slim, 2)) - shear_yx_2d[:, 0] = -0.5 * (jacobian[0][1] + jacobian[1][0]) - shear_yx_2d[:, 1] = 0.5 * (jacobian[1][1] - jacobian[0][0]) + shear_y = -0.5 * (jacobian[0][1] + jacobian[1][0]).array + shear_x = 0.5 * (jacobian[1][1] - jacobian[0][0]).array + shear_yx_2d = jnp.stack([shear_y, shear_x]).T if isinstance(grid, aa.Grid2DIrregular): return ShearYX2DIrregular(values=shear_yx_2d, grid=grid) diff --git a/autogalaxy/operate/image.py b/autogalaxy/operate/image.py index bc639e421..2170e1f01 100644 --- a/autogalaxy/operate/image.py +++ b/autogalaxy/operate/image.py @@ -1,14 +1,15 @@ from __future__ import annotations -import numpy as np +import jax +import jax.numpy as jnp from typing import TYPE_CHECKING, Dict, List, Optional +from autoarray import Array2D + if TYPE_CHECKING: from autogalaxy.galaxy.galaxy import Galaxy import autoarray as aa -from autogalaxy import exc - class OperateImage: """ @@ -29,36 +30,24 @@ def image_2d_from( def has(self, cls) -> bool: raise NotImplementedError - @aa.profile_func def _blurred_image_2d_from( self, image_2d: aa.Array2D, blurring_image_2d: aa.Array2D, - psf: Optional[aa.Kernel2D], - convolver: aa.Convolver, + psf: aa.Kernel2D, ) -> aa.Array2D: - if psf is not None: - return psf.convolved_array_with_mask_from( - array=image_2d.native + blurring_image_2d.native, - mask=image_2d.mask, - ) - - elif convolver is not None: - return convolver.convolve_image( - image=image_2d, blurring_image=blurring_image_2d - ) - else: - raise exc.OperateException( - "A PSF or Convolver was not passed to the `blurred_image_2d_list_from()` function." - ) + values = psf.convolve_image( + image=image_2d, + blurring_image=blurring_image_2d, + ) + return Array2D(values=values, mask=image_2d.mask) def blurred_image_2d_from( self, grid: aa.Grid2D, blurring_grid: aa.Grid2D, - psf: Optional[aa.Kernel2D] = None, - convolver: aa.Convolver = None, + psf: aa.Kernel2D = None, ) -> aa.Array2D: """ Evaluate the light object's 2D image from a input 2D grid of coordinates and convolve it with a PSF. @@ -92,7 +81,6 @@ def blurred_image_2d_from( image_2d=image_2d_not_operated, blurring_image_2d=blurring_image_2d_not_operated, psf=psf, - convolver=convolver, ) if self.has(cls=LightProfileOperated): @@ -169,7 +157,6 @@ def unmasked_blurred_image_2d_from(self, grid, psf): return padded_image_2d + padded_image_2d_operated - @aa.profile_func def visibilities_from( self, grid: aa.Grid2D, transformer: aa.type.Transformer ) -> aa.Visibilities: @@ -198,12 +185,14 @@ def visibilities_from( image_2d = self.image_2d_from(grid=grid) - if not np.any(image_2d): - return aa.Visibilities.zeros( + return jax.lax.cond( + jnp.any(image_2d.array), + lambda _: transformer.visibilities_from(image=image_2d), + lambda _: aa.Visibilities.zeros( shape_slim=(transformer.uv_wavelengths.shape[0],) - ) - - return transformer.visibilities_from(image=image_2d) + ), + operand=None, + ) class OperateImageList(OperateImage): @@ -224,8 +213,7 @@ def blurred_image_2d_list_from( self, grid: aa.Grid2D, blurring_grid: aa.Grid2D, - psf: Optional[aa.Kernel2D] = None, - convolver: aa.Convolver = None, + psf: aa.Kernel2D = None, ) -> List[aa.Array2D]: """ Evaluate the light object's list of 2D images from a input 2D grid of coordinates and convolve each image with @@ -267,7 +255,6 @@ def blurred_image_2d_list_from( image_2d=image_2d_not_operated, blurring_image_2d=blurring_image_2d_not_operated, psf=psf, - convolver=convolver, ) image_2d_operated = image_2d_operated_list[i] @@ -302,13 +289,13 @@ def unmasked_blurred_image_2d_list_from( """ padded_grid = grid.padded_grid_from(kernel_shape_native=psf.shape_native) - padded_image_1d_list = self.image_2d_list_from(grid=padded_grid) + padded_image_2d_list = self.image_2d_list_from(grid=padded_grid) unmasked_blurred_image_list = [] - for padded_image_1d in padded_image_1d_list: + for padded_image_2d in padded_image_2d_list: unmasked_blurred_array_2d = padded_grid.mask.unmasked_blurred_array_from( - padded_array=padded_image_1d, psf=psf, image_shape=grid.mask.shape + padded_array=padded_image_2d, psf=psf, image_shape=grid.mask.shape ) unmasked_blurred_image_list.append(unmasked_blurred_array_2d) @@ -346,7 +333,7 @@ def visibilities_list_from( visibilities_list = [] for image_2d in image_2d_list: - if not np.any(image_2d): + if not jnp.any(image_2d.array): visibilities = aa.Visibilities.zeros( shape_slim=(transformer.uv_wavelengths.shape[0],) ) @@ -375,7 +362,7 @@ def galaxy_image_2d_dict_from( raise NotImplementedError def galaxy_blurred_image_2d_dict_from( - self, grid, convolver, blurring_grid + self, grid, psf, blurring_grid ) -> Dict[Galaxy, aa.Array2D]: """ Evaluate the light object's dictionary mapping galaixes to their corresponding 2D images and convolve each @@ -418,7 +405,7 @@ def galaxy_blurred_image_2d_dict_from( galaxy_key ] - blurred_image_2d = convolver.convolve_image( + blurred_image_2d = psf.convolve_image( image=image_2d_not_operated, blurring_image=blurring_image_2d_not_operated, ) @@ -465,7 +452,7 @@ def galaxy_visibilities_dict_from( for galaxy_key in galaxy_image_2d_dict.keys(): image_2d = galaxy_image_2d_dict[galaxy_key] - if not np.any(image_2d): + if not jnp.any(image_2d.array): visibilities = aa.Visibilities.zeros( shape_slim=(transformer.uv_wavelengths.shape[0],) ) diff --git a/autogalaxy/plot/__init__.py b/autogalaxy/plot/__init__.py index 81623d62f..0a0564b52 100644 --- a/autogalaxy/plot/__init__.py +++ b/autogalaxy/plot/__init__.py @@ -72,8 +72,6 @@ from autogalaxy.plot.mat_plot.one_d import MatPlot1D from autogalaxy.plot.mat_plot.two_d import MatPlot2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D diff --git a/autogalaxy/plot/abstract_plotters.py b/autogalaxy/plot/abstract_plotters.py index 2816e7a94..3acd36679 100644 --- a/autogalaxy/plot/abstract_plotters.py +++ b/autogalaxy/plot/abstract_plotters.py @@ -4,16 +4,31 @@ from autoarray.plot.abstract_plotters import AbstractPlotter +from autogalaxy.plot.mat_plot.one_d import MatPlot1D +from autogalaxy.plot.mat_plot.two_d import MatPlot2D +from autogalaxy.plot.visuals.one_d import Visuals1D +from autogalaxy.plot.visuals.two_d import Visuals2D + class Plotter(AbstractPlotter): - @property - def get_1d(self): - from autogalaxy.plot.get_visuals.one_d import GetVisuals1D - return GetVisuals1D(visuals=self.visuals_1d, include=self.include_1d) + def __init__( + self, + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, + ): + + super().__init__( + mat_plot_1d=mat_plot_1d, + visuals_1d=visuals_1d, + mat_plot_2d=mat_plot_2d, + visuals_2d=visuals_2d, + ) - @property - def get_2d(self): - from autogalaxy.plot.get_visuals.two_d import GetVisuals2D + self.visuals_1d = visuals_1d or Visuals1D() + self.mat_plot_1d = mat_plot_1d or MatPlot1D() - return GetVisuals2D(visuals=self.visuals_2d, include=self.include_2d) + self.visuals_2d = visuals_2d or Visuals2D() + self.mat_plot_2d = mat_plot_2d or MatPlot2D() diff --git a/autogalaxy/plot/get_visuals/__init__.py b/autogalaxy/plot/get_visuals/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/autogalaxy/plot/get_visuals/one_d.py b/autogalaxy/plot/get_visuals/one_d.py deleted file mode 100644 index 7f5c8ddc9..000000000 --- a/autogalaxy/plot/get_visuals/one_d.py +++ /dev/null @@ -1,244 +0,0 @@ -import logging -from typing import List, Union - -import autoarray as aa -import autoarray.plot as aplt - -from autogalaxy.galaxy.galaxy import Galaxy -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.visuals.one_d import Visuals1D -from autogalaxy.profiles.light.abstract import LightProfile -from autogalaxy.profiles.mass.abstract.abstract import MassProfile - -from autogalaxy import exc -from autogalaxy.util import error_util - -logger = logging.getLogger(__name__) - - -class GetVisuals1D(aplt.GetVisuals1D): - def __init__(self, include: Include1D, visuals: Visuals1D): - """ - Class which gets 1D attributes and adds them to a `Visuals1D` objects, such that they are plotted on 1D figures. - - For a visual to be extracted and added for plotting, it must have a `True` value in its corresponding entry in - the `Include1D` object. If this entry is `False`, the `GetVisuals1D.get` method returns a None and the attribute - is omitted from the plot. - - The `GetVisuals1D` class adds new visuals to a pre-existing `Visuals1D` object that is passed to its `__init__` - method. This only adds a new entry if the visual are not already in this object. - - Parameters - ---------- - include - Sets which 1D visuals are included on the figure that is to be plotted (only entries which are `True` - are extracted via the `GetVisuals1D` object). - visuals - The pre-existing visuals of the plotter which new visuals are added too via the `GetVisuals1D` class. - """ - super().__init__(include=include, visuals=visuals) - - def via_light_obj_from(self, light_obj: Union[LightProfile, Galaxy]) -> Visuals1D: - """ - From an object with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be plotted - and return them in a `Visuals1D` object. - - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. - - From a light object the following 1D attributes can be extracted for plotting: - - - half_light_radius: the radius containing 50% of the light objects total integrated luminosity. - - Parameters - ---------- - light_obj - The light object (e.g. a `LightProfile`, `Galaxy`) whose attributes are extracted for plotting. - - Returns - ------- - Visuals1D - The collection of attributes that can be plotted by a `Plotter` object. - """ - - half_light_radius = self.get( - "half_light_radius", value=light_obj.half_light_radius - ) - - return self.visuals + self.visuals.__class__( - half_light_radius=half_light_radius - ) - - def via_light_obj_list_from( - self, light_obj_list: Union[List[LightProfile], List[Galaxy]], low_limit: float - ) -> Visuals1D: - """ - From a list of objects with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be - plotted and return them in a `Visuals1D` object. - - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. - - This function iterates over all light objects in the list and averages over each attribute's values to estimate - the mean value of the attribute and its error, both of which can then be plotted. This is typically used - to plot 1D errors on a quantity that are estimated via a Probability Density Function. - - From a light object lust the following 1D attributes can be extracted for plotting: - - - half_light_radius: the radius containing 50% of the light objects total integrated luminosity. - - Parameters - ---------- - light_obj_list - The list of light objects (e.g. a `LightProfile`, `Galaxy`) whose mean attributes and error estimates are - extracted for plotting. - low_limit - The value of sigma to which errors are estimated (e.g. 1.0 will estimate errors at the ~0.32 and ~0.68 - intervals of the probability distribution. - - Returns - ------- - Visuals1D - The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. - """ - - if self.include.half_light_radius: - half_light_radius_list = [ - light_profile.half_light_radius for light_profile in light_obj_list - ] - - if None in half_light_radius_list: - half_light_radius = None - half_light_radius_errors = None - - else: - ( - half_light_radius, - half_light_radius_errors, - ) = error_util.value_median_and_error_region_via_quantile( - value_list=half_light_radius_list, low_limit=low_limit - ) - - else: - half_light_radius = None - half_light_radius_errors = None - - half_light_radius = self.get("half_light_radius", value=half_light_radius) - half_light_radius_errors = self.get( - "half_light_radius", value=half_light_radius_errors - ) - - return self.visuals + self.visuals.__class__( - half_light_radius=half_light_radius, - half_light_radius_errors=half_light_radius_errors, - ) - - def via_mass_obj_from( - self, mass_obj: Union[MassProfile, Galaxy], grid: aa.type.Grid2DLike - ) -> Visuals1D: - """ - From an object with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be plotted - and return them in a `Visuals1D` object. - - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. - - From a mass object the following 1D attributes can be extracted for plotting: - - - einstein_radius: the einstein radius (e.g. area within critical curve) of the mass object. - - Mass profiles can be too shallow to do lensing and therefore an Einstein radius cannot be computed. This - raises a TypeError which is accounted for below. - - Parameters - ---------- - mass_obj - The mass object (e.g. a `MassProfile`, `Galaxy`) whose attributes are extracted for plotting. - - Returns - ------- - Visuals1D - The collection of attributes that can be plotted by a `Plotter` object. - """ - - einstein_radius = None - - if self.include.einstein_radius: - try: - einstein_radius = mass_obj.einstein_radius_from(grid=grid) - except (TypeError, AttributeError): - pass - - einstein_radius = self.get("einstein_radius", value=einstein_radius) - - return self.visuals + self.visuals.__class__(einstein_radius=einstein_radius) - - def via_mass_obj_list_from( - self, - mass_obj_list: Union[List[MassProfile], List[Galaxy]], - grid: aa.type.Grid2DLike, - low_limit: float, - ) -> Visuals1D: - """ - From a list of objects with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be - plotted and return them in a `Visuals1D` object. - - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. - - This function iterates over all mass objects in the list and averages over each attribute's values to estimate - the mean value of the attribute and its error, both of which can then be plotted. This is typically used - to plot 1D errors on a quantity that are estimated via a Probability Density Function. - - From a mass object lust the following 1D attributes can be extracted for plotting: - - - half_mass_radius: the radius containing 50% of the mass objects total integrated luminosity. - - Parameters - ---------- - mass_obj_list - The list of mass objects (e.g. a `MassProfile`, `Galaxy`) whose mean attributes and error estimates are - extracted for plotting. - low_limit - The value of sigma to which errors are estimated (e.g. 1.0 will estimate errors at the ~0.32 and ~0.68 - intervals of the probability distribution. - - Returns - ------- - Visuals1D - The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. - """ - - if self.include.einstein_radius: - einstein_radius_list = [] - - for mass_obj in mass_obj_list: - try: - einstein_radius_list.append( - mass_obj.einstein_radius_from(grid=grid) - ) - except TypeError: - einstein_radius_list.append(None) - - einstein_radius_list = list(filter(None, einstein_radius_list)) - - ( - einstein_radius, - einstein_radius_errors, - ) = error_util.value_median_and_error_region_via_quantile( - value_list=einstein_radius_list, low_limit=low_limit - ) - - else: - einstein_radius = None - einstein_radius_errors = None - - einstein_radius = self.get("einstein_radius", value=einstein_radius) - einstein_radius_errors = self.get( - "einstein_radius", value=einstein_radius_errors - ) - - return self.visuals + self.visuals.__class__( - einstein_radius=einstein_radius, - einstein_radius_errors=einstein_radius_errors, - ) diff --git a/autogalaxy/plot/get_visuals/two_d.py b/autogalaxy/plot/get_visuals/two_d.py deleted file mode 100644 index 73f0efc04..000000000 --- a/autogalaxy/plot/get_visuals/two_d.py +++ /dev/null @@ -1,286 +0,0 @@ -from typing import List, Union - -import autoarray as aa -import autoarray.plot as aplt - -from autogalaxy.imaging.fit_imaging import FitImaging -from autogalaxy.plot.include.two_d import Include2D -from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.profiles.light.abstract import LightProfile -from autogalaxy.profiles.mass.abstract.abstract import MassProfile -from autogalaxy.galaxy.galaxy import Galaxy - - -class GetVisuals2D(aplt.GetVisuals2D): - def __init__(self, include: Include2D, visuals: Visuals2D): - """ - Class which gets 2D attributes and adds them to a `Visuals2D` objects, such that they are plotted on 2D figures. - - For a visual to be extracted and added for plotting, it must have a `True` value in its corresponding entry in - the `Include2D` object. If this entry is `False`, the `GetVisuals2D.get` method returns a None and the - attribute is omitted from the plot. - - The `GetVisuals2D` class adds new visuals to a pre-existing `Visuals2D` object that is passed to - its `__init__` method. This only adds a new entry if the visual are not already in this object. - - Parameters - ---------- - include - Sets which 2D visuals are included on the figure that is to be plotted (only entries which are `True` - are extracted via the `GetVisuals2D` object). - visuals - The pre-existing visuals of the plotter which new visuals are added too via the `GetVisuals2D` class. - """ - super().__init__(include=include, visuals=visuals) - - def via_light_obj_from( - self, light_obj: Union[LightProfile, Galaxy], grid - ) -> Visuals2D: - """ - From an object with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be - plotted and return them in a `Visuals2D` object. - - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. - - From a light object the following 2D attributes can be extracted for plotting: - - - origin: the (y,x) origin of the coordinate system used to plot the light object's quantities in 2D. - - mask: the mask of the grid used to plot the light object's quantities in 2D. - - border: the border of this mask. - - light profile centres: the (y,x) centre of every `LightProfile` in the object. - - Parameters - ---------- - light_obj - The light object (e.g. a `LightProfile`, `Galaxy`) whose attributes are extracted for plotting. - grid - The 2D grid of (y,x) coordinates used to plot the light object's quantities in 2D. - - Returns - ------- - vis.Visuals2D - The collection of attributes that can be plotted by a `Plotter` object. - """ - - visuals_via_mask = self.via_mask_from(mask=grid.mask) - - if isinstance(light_obj, LightProfile): - light_profile_centres = self.get( - "light_profile_centres", aa.Grid2DIrregular(values=[light_obj.centre]) - ) - - else: - light_profile_centres = self.get( - "light_profile_centres", - light_obj.extract_attribute(cls=LightProfile, attr_name="centre"), - ) - - return ( - self.visuals - + visuals_via_mask - + self.visuals.__class__(light_profile_centres=light_profile_centres) - ) - - def via_mass_obj_from( - self, mass_obj: Union[MassProfile, Galaxy], grid: aa.type.Grid2DLike - ) -> Visuals2D: - """ - From an object with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be - plotted and return them in a `Visuals2D` object. - - Only attributes not already in `self.visuals` and with `True` entries in the `Include1D` object are extracted - for plotting. - - From a mass object the following 2D attributes can be extracted for plotting: - - - origin: the (y,x) origin of the coordinate system used to plot the mass object's quantities in 2D. - - mask: the mask of the grid used to plot the mass object's quantities in 2D. - - border: the border of this mask. - - mass profile centres: the (y,x) centre of every `MassProfile` in the mass object. - - critical curves: the critical curves of the mass object. - - Parameters - ---------- - mass_obj - The mass object (e.g. a `MassProfile`, `Galaxy`) whose attributes are extracted for plotting. - grid - The 2D grid of (y,x) coordinates used to plot the mass object's quantities in 2D. - - Returns - ------- - vis.Visuals2D - The collection of attributes that can be plotted by a `Plotter` object. - """ - - visuals_via_mask = self.via_mask_from(mask=grid.mask) - - if isinstance(mass_obj, MassProfile): - mass_profile_centres = self.get( - "mass_profile_centres", aa.Grid2DIrregular(values=[mass_obj.centre]) - ) - - else: - mass_profile_centres = self.get( - "mass_profile_centres", - mass_obj.extract_attribute(cls=MassProfile, attr_name="centre"), - ) - - tangential_critical_curves = self.get( - "tangential_critical_curves", - mass_obj.tangential_critical_curve_list_from(grid=grid), - "tangential_critical_curves", - ) - - radial_critical_curves = None - - radial_critical_curve_area_list = mass_obj.radial_critical_curve_area_list_from( - grid=grid - ) - - if any([area > grid.pixel_scale for area in radial_critical_curve_area_list]): - radial_critical_curves = self.get( - "radial_critical_curves", - mass_obj.radial_critical_curve_list_from(grid=grid), - "radial_critical_curves", - ) - - return ( - self.visuals - + visuals_via_mask - + self.visuals.__class__( - mass_profile_centres=mass_profile_centres, - tangential_critical_curves=tangential_critical_curves, - radial_critical_curves=radial_critical_curves, - ) - ) - - def via_light_mass_obj_from(self, light_mass_obj: Union[Galaxy], grid) -> Visuals2D: - """ - From an object that contains both light profiles and / or mass profiles (e.g. a `Galaxy`), get the - attributes that can be plotted and returns them in a `Visuals2D` object. - - Only attributes with `True` entries in the `Include` object are extracted. - - From a light and lensing object the following attributes can be extracted for plotting: - - - origin: the (y,x) origin of the coordinate system used to plot the light object's quantities in 2D. - - light profile centres: the (y,x) centre of every `LightProfile` in the object. - - mass profile centres: the (y,x) centre of every `MassProfile` in the object. - - critical curves: the critical curves of all mass profile combined. - - Parameters - ---------- - light_mass_obj - The light and mass object (e.g. a `Galaxy`) whose attributes are extracted for plotting. - grid - The 2D grid of (y,x) coordinates used to plot the light and mass object's quantities in 2D. - - Returns - ------- - vis.Visuals2D - A collection of attributes that can be plotted by a `Plotter` object. - """ - - visuals_2d = self.via_mass_obj_from(mass_obj=light_mass_obj, grid=grid) - visuals_2d.mask = None - - visuals_with_grid = self.visuals.__class__(grid=self.get("grid", grid)) - - return ( - visuals_2d - + visuals_with_grid - + self.via_light_obj_from(light_obj=light_mass_obj, grid=grid) - ) - - def via_galaxies_from( - self, galaxies: List[Galaxy], grid: aa.type.Grid2DLike, galaxy_index: int - ) -> Visuals2D: - """ - From a list of galaxies get the attributes that can be plotted and returns them in a `Visuals2D` object. - - Only attributes with `True` entries in the `Include` object are extracted. - - From a list of galaxie the following attributes can be extracted for plotting: - - - origin: the (y,x) origin of the coordinate system used to plot the light object's quantities in 2D. - - border: the border of the mask of the grid used to plot the light object's quantities in 2D. - - light profile centres: the (y,x) centre of every `LightProfile` in the object. - - mass profile centres: the (y,x) centre of every `MassProfile` in the object. - - critical curves: the critical curves of all of the galaxy's mass profiles combined. - - caustics: the caustics of all of the galaxy's mass profiles combined. - - When plotting galaxies it is common for plots to only display quantities corresponding to one galaxy at a time - (e.g. the image of each galaxy). Therefore, quantities are only extracted from one galaxy, specified by the - input `galaxy_index`. - - Parameters - ---------- - galaxies - The galaxies which have attributes extracted for plotting. - grid - The 2D grid of (y,x) coordinates used to plot the galaxies quantities in 2D. - galaxy_index - The index of the galaxy in the galaxies which is used to extract quantities, as only one galaxy is plotted - at a time. - - Returns - ------- - vis.Visuals2D - A collection of attributes that can be plotted by a `Plotter` object. - """ - origin = self.get("origin", value=aa.Grid2DIrregular(values=[grid.origin])) - - light_profile_centres = self.get( - "light_profile_centres", - galaxies[galaxy_index].extract_attribute( - cls=LightProfile, attr_name="centre" - ), - ) - - mass_profile_centres = self.get( - "mass_profile_centres", - galaxies[galaxy_index].extract_attribute( - cls=MassProfile, attr_name="centre" - ), - ) - - return self.visuals + self.visuals.__class__( - origin=origin, - light_profile_centres=light_profile_centres, - mass_profile_centres=mass_profile_centres, - ) - - def via_fit_imaging_from(self, fit: FitImaging) -> Visuals2D: - """ - From a `FitImaging` get its attributes that can be plotted and return them in a `Visuals2D` object. - - Only attributes not already in `self.visuals` and with `True` entries in the `Include2D` object are extracted - for plotting. - - From a `FitImaging` the following attributes can be extracted for plotting: - - - origin: the (y,x) origin of the 2D coordinate system. - - mask: the 2D mask. - - border: the border of the 2D mask, which are all of the mask's exterior edge pixels. - - light profile centres: the (y,x) centre of every `LightProfile` in the object. - - mass profile centres: the (y,x) centre of every `MassProfile` in the object. - - critical curves: the critical curves of all mass profile combined. - - Parameters - ---------- - fit - The fit imaging object whose attributes are extracted for plotting. - - Returns - ------- - Visuals2D - The collection of attributes that are plotted by a `Plotter` object. - """ - visuals_2d_via_fit = super().via_fit_imaging_from(fit=fit) - - visuals_2d_via_light_mass_obj = self.via_light_mass_obj_from( - light_mass_obj=fit.galaxies, grid=fit.grids.lp - ) - - return visuals_2d_via_fit + visuals_2d_via_light_mass_obj diff --git a/autogalaxy/plot/include/__init__.py b/autogalaxy/plot/include/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/autogalaxy/plot/include/one_d.py b/autogalaxy/plot/include/one_d.py deleted file mode 100644 index a74ae0f4a..000000000 --- a/autogalaxy/plot/include/one_d.py +++ /dev/null @@ -1,34 +0,0 @@ -import autoarray.plot as aplt - - -class Include1D(aplt.Include1D): - def __init__(self, half_light_radius=None, einstein_radius=None): - """ - Sets which `Visuals1D` are included on a figure plotting 1D data that is plotted using a `Plotter1D`. - - The `Include` object is used to extract the visuals of the plotted 1D data structures so they can be used in - plot functions. Only visuals with a `True` entry in the `Include` object are extracted and plotted. - - If an entry is not input into the class (e.g. it retains its default entry of `None`) then the bool is - loaded from the `config/visualize/include.ini` config file. This means the default visuals of a project - can be specified in a config file. - - Parameters - ---------- - half_light_radius - If `True`, the `half_light_radius` of the plotted light profile is included on the figure. - einstein_radius - If `True`, the `einstein_radius` of the plotted mass profile is included on the figure. - """ - super().__init__() - - self._half_light_radius = half_light_radius - self._einstein_radius = einstein_radius - - @property - def half_light_radius(self): - return self.load(value=self._half_light_radius, name="half_light_radius") - - @property - def einstein_radius(self): - return self.load(value=self._einstein_radius, name="einstein_radius") diff --git a/autogalaxy/plot/include/two_d.py b/autogalaxy/plot/include/two_d.py deleted file mode 100644 index c8ba69b90..000000000 --- a/autogalaxy/plot/include/two_d.py +++ /dev/null @@ -1,80 +0,0 @@ -from typing import Optional - -import autoarray.plot as aplt - - -class Include2D(aplt.Include2D): - def __init__( - self, - origin=None, - mask=None, - border=None, - grid=None, - positions=None, - light_profile_centres=None, - mass_profile_centres=None, - tangential_critical_curves=None, - radial_critical_curves=None, - tangential_caustics=None, - radial_caustics=None, - multiple_images=None, - mapper_source_plane_mesh_grid: Optional[bool] = None, - mapper_source_plane_data_grid: Optional[bool] = None, - mapper_image_plane_mesh_grid=None, - ): - super().__init__( - origin=origin, - mask=mask, - border=border, - grid=grid, - mapper_source_plane_mesh_grid=mapper_source_plane_mesh_grid, - mapper_source_plane_data_grid=mapper_source_plane_data_grid, - mapper_image_plane_mesh_grid=mapper_image_plane_mesh_grid, - ) - - self._positions = positions - self._light_profile_centres = light_profile_centres - self._mass_profile_centres = mass_profile_centres - self._tangential_critical_curves = tangential_critical_curves - self._radial_critical_curves = radial_critical_curves - self._tangential_caustics = tangential_caustics - self._radial_caustics = radial_caustics - self._multiple_images = multiple_images - - @property - def positions(self): - return self.load(value=self._positions, name="positions") - - @property - def light_profile_centres(self): - return self.load( - value=self._light_profile_centres, name="light_profile_centres" - ) - - @property - def mass_profile_centres(self): - return self.load(value=self._mass_profile_centres, name="mass_profile_centres") - - @property - def tangential_critical_curves(self): - return self.load( - value=self._tangential_critical_curves, name="tangential_critical_curves" - ) - - @property - def radial_critical_curves(self): - return self.load( - value=self._radial_critical_curves, name="radial_critical_curves" - ) - - @property - def tangential_caustics(self): - return self.load(value=self._tangential_caustics, name="tangential_caustics") - - @property - def radial_caustics(self): - return self.load(value=self._radial_caustics, name="radial_caustics") - - @property - def multiple_images(self): - return self.load(value=self._multiple_images, name="multiple_images") diff --git a/autogalaxy/plot/mass_plotter.py b/autogalaxy/plot/mass_plotter.py index ca8f2577c..c6bb69268 100644 --- a/autogalaxy/plot/mass_plotter.py +++ b/autogalaxy/plot/mass_plotter.py @@ -1,13 +1,10 @@ -from typing import Callable +from autoconf import cached_property import autoarray as aa import autoarray.plot as aplt -from autogalaxy.operate.deflections import OperateDeflections - from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.plot.abstract_plotters import Plotter @@ -17,21 +14,23 @@ def __init__( self, mass_obj, grid: aa.type.Grid2DLike, - get_visuals_2d: Callable, - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, ): - super().__init__( - mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d - ) + super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d) self.mass_obj = mass_obj self.grid = grid - self._get_visuals_2d = get_visuals_2d - def get_visuals_2d(self) -> Visuals2D: - return self._get_visuals_2d() + @cached_property + def visuals_2d_with_critical_curves(self) -> aplt.Visuals2D: + """ + Returns the `Visuals2D` of the plotter with critical curves and caustics added, which are used to plot + the critical curves and caustics of the `Tracer` object. + """ + return self.visuals_2d.add_critical_curves_or_caustics( + mass_obj=self.mass_obj, grid=self.grid, plane_index=0 + ) def figures_2d( self, @@ -63,10 +62,11 @@ def figures_2d( magnification Whether to make a 2D plot (via `imshow`) of the magnification. """ + if convergence: self.mat_plot_2d.plot_array( array=self.mass_obj.convergence_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Convergence{title_suffix}", filename=f"convergence_2d{filename_suffix}", @@ -77,7 +77,7 @@ def figures_2d( if potential: self.mat_plot_2d.plot_array( array=self.mass_obj.potential_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Potential{title_suffix}", filename=f"potential_2d{filename_suffix}", @@ -93,7 +93,7 @@ def figures_2d( self.mat_plot_2d.plot_array( array=deflections_y, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Deflections Y{title_suffix}", filename=f"deflections_y_2d{filename_suffix}", @@ -109,7 +109,7 @@ def figures_2d( self.mat_plot_2d.plot_array( array=deflections_x, - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Deflections X{title_suffix}", filename=f"deflections_x_2d{filename_suffix}", @@ -120,7 +120,7 @@ def figures_2d( if magnification: self.mat_plot_2d.plot_array( array=self.mass_obj.magnification_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d_with_critical_curves, auto_labels=aplt.AutoLabels( title=f"Magnification{title_suffix}", filename=f"magnification_2d{filename_suffix}", diff --git a/autogalaxy/plot/mat_plot/two_d.py b/autogalaxy/plot/mat_plot/two_d.py index eebc44048..060547d4f 100644 --- a/autogalaxy/plot/mat_plot/two_d.py +++ b/autogalaxy/plot/mat_plot/two_d.py @@ -25,6 +25,7 @@ def __init__( output: Optional[aplt.Output] = None, array_overlay: Optional[aplt.ArrayOverlay] = None, contour: Optional[aplt.Contour] = None, + fill: Optional[aplt.Fill] = None, grid_scatter: Optional[aplt.GridScatter] = None, grid_plot: Optional[aplt.GridPlot] = None, vector_yx_quiver: Optional[aplt.VectorYXQuiver] = None, @@ -110,6 +111,8 @@ def __init__( Overlays an input `Array2D` over the figure using `plt.imshow`. contour Overlays contours of an input `Array2D` over the figure using `plt.contour`. + fill + Sets the fill of the figure using `plt.fill` and customizes its appearance, such as the color and alpha. grid_scatter Scatters a `Grid2D` of (y,x) coordinates over the figure using `plt.scatter`. grid_plot @@ -204,6 +207,7 @@ def __init__( patch_overlay=patch_overlay, array_overlay=array_overlay, contour=contour, + fill=fill, grid_plot=grid_plot, interpolated_reconstruction=interpolated_reconstruction, delaunay_drawer=delaunay_drawer, diff --git a/autogalaxy/plot/visuals/one_d.py b/autogalaxy/plot/visuals/one_d.py index f25203137..7d69d112a 100644 --- a/autogalaxy/plot/visuals/one_d.py +++ b/autogalaxy/plot/visuals/one_d.py @@ -1,9 +1,19 @@ +from __future__ import annotations + import numpy as np -from typing import List, Union, Optional +from typing import List, Union, Optional, TYPE_CHECKING import autoarray as aa import autoarray.plot as aplt +if TYPE_CHECKING: + + from autogalaxy.galaxy.galaxy import Galaxy + from autogalaxy.profiles.light.abstract import LightProfile + from autogalaxy.profiles.mass.abstract.abstract import MassProfile + +from autogalaxy.util import error_util + class Visuals1D(aplt.Visuals1D): def __init__( @@ -54,3 +64,174 @@ def plot_via_plotter(self, plotter, grid_indexes=None, mapper=None): plotter.model_fluxes_yx_scatter.scatter_yx( y=self.model_fluxes, x=np.arange(len(self.model_fluxes)) ) + + def add_half_light_radius( + self, light_obj: Union[LightProfile, Galaxy] + ) -> "Visuals1D": + """ + From an object with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be plotted + and return them in a `Visuals1D` object. + + Only attributes not already in `self` are extracted for plotting. + + From a light object the following 1D attributes can be extracted for plotting: + + - half_light_radius: the radius containing 50% of the light objects total integrated luminosity. + + Parameters + ---------- + light_obj + The light object (e.g. a `LightProfile`, `Galaxy`) whose attributes are extracted for plotting. + + Returns + ------- + Visuals1D + The collection of attributes that can be plotted by a `Plotter` object. + """ + return self + self.__class__(half_light_radius=light_obj.half_light_radius) + + def add_half_light_radius_errors( + self, light_obj_list: Union[List[LightProfile], List[Galaxy]], low_limit: float + ) -> "Visuals1D": + """ + From a list of objects with light profiles (e.g. a `LightProfile`, `Galaxy`) get its attributes that can be + plotted and return them in a `Visuals1D` object. + + Only attributes not already in `self` are extracted for plotting. + + This function iterates over all light objects in the list and averages over each attribute's values to estimate + the mean value of the attribute and its error, both of which can then be plotted. This is typically used + to plot 1D errors on a quantity that are estimated via a Probability Density Function. + + From a light object lust the following 1D attributes can be extracted for plotting: + + - half_light_radius: the radius containing 50% of the light objects total integrated luminosity. + + Parameters + ---------- + light_obj_list + The list of light objects (e.g. a `LightProfile`, `Galaxy`) whose mean attributes and error estimates are + extracted for plotting. + low_limit + The value of sigma to which errors are estimated (e.g. 1.0 will estimate errors at the ~0.32 and ~0.68 + intervals of the probability distribution. + + Returns + ------- + Visuals1D + The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. + """ + + half_light_radius_list = [ + light_profile.half_light_radius for light_profile in light_obj_list + ] + + if None in half_light_radius_list: + half_light_radius = None + half_light_radius_errors = None + + else: + ( + half_light_radius, + half_light_radius_errors, + ) = error_util.value_median_and_error_region_via_quantile( + value_list=half_light_radius_list, low_limit=low_limit + ) + + return self + self.__class__( + half_light_radius=half_light_radius, + half_light_radius_errors=half_light_radius_errors, + ) + + def add_einstein_radius( + self, mass_obj: Union[MassProfile, Galaxy], grid: aa.type.Grid2DLike + ) -> "Visuals1D": + """ + From an object with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be plotted + and return them in a `Visuals1D` object. + + Only attributes not already in `self` are extracted for plotting. + + From a mass object the following 1D attributes can be extracted for plotting: + + - einstein_radius: the einstein radius (e.g. area within critical curve) of the mass object. + + Mass profiles can be too shallow to do lensing and therefore an Einstein radius cannot be computed. This + raises a TypeError which is accounted for below. + + Parameters + ---------- + mass_obj + The mass object (e.g. a `MassProfile`, `Galaxy`) whose attributes are extracted for plotting. + + Returns + ------- + Visuals1D + The collection of attributes that can be plotted by a `Plotter` object. + """ + + einstein_radius = None + + try: + einstein_radius = mass_obj.einstein_radius_from(grid=grid) + except (TypeError, AttributeError): + pass + + return self + self.__class__(einstein_radius=einstein_radius) + + def add_einstein_radius_errors( + self, + mass_obj_list: Union[List[MassProfile], List[Galaxy]], + grid: aa.type.Grid2DLike, + low_limit: float, + ) -> "Visuals1D": + """ + From a list of objects with mass profiles (e.g. a `MassProfile`, `Galaxy`) get its attributes that can be + plotted and return them in a `Visuals1D` object. + + Only attributes not already in `self` are extracted for plotting. + + This function iterates over all mass objects in the list and averages over each attribute's values to estimate + the mean value of the attribute and its error, both of which can then be plotted. This is typically used + to plot 1D errors on a quantity that are estimated via a Probability Density Function. + + From a mass object lust the following 1D attributes can be extracted for plotting: + + - half_mass_radius: the radius containing 50% of the mass objects total integrated luminosity. + + Parameters + ---------- + mass_obj_list + The list of mass objects (e.g. a `MassProfile`, `Galaxy`) whose mean attributes and error estimates are + extracted for plotting. + low_limit + The value of sigma to which errors are estimated (e.g. 1.0 will estimate errors at the ~0.32 and ~0.68 + intervals of the probability distribution. + + Returns + ------- + Visuals1D + The mean value and errors of each attribute that are plotted in 1D by a `Plotter` object. + """ + + einstein_radius_list = [] + + for mass_obj in mass_obj_list: + try: + einstein_radius_list.append(mass_obj.einstein_radius_from(grid=grid)) + except TypeError: + einstein_radius_list.append(None) + + einstein_radius_list = list(filter(None, einstein_radius_list)) + + ( + einstein_radius, + einstein_radius_errors, + ) = error_util.value_median_and_error_region_via_quantile( + value_list=einstein_radius_list, low_limit=low_limit + ) + + return self + self.__class__( + einstein_radius=einstein_radius, + einstein_radius_errors=einstein_radius_errors, + ) diff --git a/autogalaxy/plot/visuals/two_d.py b/autogalaxy/plot/visuals/two_d.py index 49f422979..1c33e86bf 100644 --- a/autogalaxy/plot/visuals/two_d.py +++ b/autogalaxy/plot/visuals/two_d.py @@ -1,114 +1,230 @@ -from matplotlib import patches as ptch -from typing import List, Union, Optional - -import autoarray as aa -import autoarray.plot as aplt - - -class Visuals2D(aplt.Visuals2D): - def __init__( - self, - origin: aa.Grid2D = None, - border: aa.Grid2D = None, - mask: aa.Mask2D = None, - lines: Optional[Union[List[aa.Array1D], aa.Grid2DIrregular]] = None, - positions: Optional[Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]]] = None, - grid: Union[aa.Grid2D] = None, - mesh_grid: aa.Grid2D = None, - vectors: aa.VectorYX2DIrregular = None, - patches: Union[ptch.Patch] = None, - array_overlay: aa.Array2D = None, - light_profile_centres: aa.Grid2DIrregular = None, - mass_profile_centres: aa.Grid2DIrregular = None, - multiple_images: aa.Grid2DIrregular = None, - tangential_critical_curves: Optional[ - Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] - ] = None, - radial_critical_curves: Optional[ - Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] - ] = None, - tangential_caustics: Optional[ - Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] - ] = None, - radial_caustics: Optional[ - Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] - ] = None, - parallel_overscan=None, - serial_prescan=None, - serial_overscan=None, - indexes: Union[List[int], List[List[int]]] = None, - pix_indexes: Union[List[int], List[List[int]]] = None, - ): - super().__init__( - mask=mask, - positions=positions, - grid=grid, - lines=lines, - mesh_grid=mesh_grid, - vectors=vectors, - patches=patches, - array_overlay=array_overlay, - origin=origin, - border=border, - parallel_overscan=parallel_overscan, - serial_prescan=serial_prescan, - serial_overscan=serial_overscan, - indexes=indexes, - pix_indexes=pix_indexes, - ) - - self.light_profile_centres = light_profile_centres - self.mass_profile_centres = mass_profile_centres - self.multiple_images = multiple_images - self.tangential_critical_curves = tangential_critical_curves - self.radial_critical_curves = radial_critical_curves - self.tangential_caustics = tangential_caustics - self.radial_caustics = radial_caustics - - def plot_via_plotter(self, plotter, grid_indexes=None, mapper=None, geometry=None): - super().plot_via_plotter( - plotter=plotter, grid_indexes=grid_indexes, mapper=mapper, geometry=geometry - ) - - if self.light_profile_centres is not None: - plotter.light_profile_centres_scatter.scatter_grid( - grid=self.light_profile_centres - ) - - if self.mass_profile_centres is not None: - plotter.mass_profile_centres_scatter.scatter_grid( - grid=self.mass_profile_centres - ) - - if self.multiple_images is not None: - plotter.multiple_images_scatter.scatter_grid(grid=self.multiple_images) - - if self.tangential_critical_curves is not None: - try: - plotter.tangential_critical_curves_plot.plot_grid( - grid=self.tangential_critical_curves - ) - except TypeError: - pass - - if self.radial_critical_curves is not None: - try: - plotter.radial_critical_curves_plot.plot_grid( - grid=self.radial_critical_curves - ) - except TypeError: - pass - - if self.tangential_caustics is not None: - try: - plotter.tangential_caustics_plot.plot_grid( - grid=self.tangential_caustics - ) - except TypeError: - pass - - if self.radial_caustics is not None: - try: - plotter.radial_caustics_plot.plot_grid(grid=self.radial_caustics) - except TypeError: - pass +from typing import List, Union, Optional + +import autoarray as aa +import autoarray.plot as aplt + + +class Visuals2D(aplt.Visuals2D): + def __init__( + self, + origin: aa.Grid2D = None, + border: aa.Grid2D = None, + mask: aa.Mask2D = None, + lines: Optional[Union[List[aa.Array1D], aa.Grid2DIrregular]] = None, + positions: Optional[Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]]] = None, + grid: Union[aa.Grid2D] = None, + mesh_grid: aa.Grid2D = None, + vectors: aa.VectorYX2DIrregular = None, + patches: "Union[ptch.Patch]" = None, + fill_region: Optional[List] = None, + array_overlay: aa.Array2D = None, + light_profile_centres: aa.Grid2DIrregular = None, + mass_profile_centres: aa.Grid2DIrregular = None, + multiple_images: aa.Grid2DIrregular = None, + tangential_critical_curves: Optional[ + Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] + ] = None, + radial_critical_curves: Optional[ + Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] + ] = None, + tangential_caustics: Optional[ + Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] + ] = None, + radial_caustics: Optional[ + Union[aa.Grid2DIrregular, List[aa.Grid2DIrregular]] + ] = None, + parallel_overscan=None, + serial_prescan=None, + serial_overscan=None, + indexes: Union[List[int], List[List[int]]] = None, + ): + super().__init__( + mask=mask, + positions=positions, + grid=grid, + lines=lines, + mesh_grid=mesh_grid, + vectors=vectors, + patches=patches, + fill_region=fill_region, + array_overlay=array_overlay, + origin=origin, + border=border, + parallel_overscan=parallel_overscan, + serial_prescan=serial_prescan, + serial_overscan=serial_overscan, + indexes=indexes, + ) + + self.light_profile_centres = light_profile_centres + self.mass_profile_centres = mass_profile_centres + self.multiple_images = multiple_images + self.tangential_critical_curves = tangential_critical_curves + self.radial_critical_curves = radial_critical_curves + self.tangential_caustics = tangential_caustics + self.radial_caustics = radial_caustics + + def plot_via_plotter(self, plotter, grid_indexes=None): + super().plot_via_plotter( + plotter=plotter, + grid_indexes=grid_indexes, + ) + + if self.light_profile_centres is not None: + plotter.light_profile_centres_scatter.scatter_grid( + grid=self.light_profile_centres + ) + + if self.mass_profile_centres is not None: + plotter.mass_profile_centres_scatter.scatter_grid( + grid=self.mass_profile_centres + ) + + if self.multiple_images is not None: + plotter.multiple_images_scatter.scatter_grid( + grid=self.multiple_images.array + ) + + if self.tangential_critical_curves is not None: + try: + plotter.tangential_critical_curves_plot.plot_grid( + grid=self.tangential_critical_curves + ) + except TypeError: + pass + + if self.radial_critical_curves is not None: + try: + plotter.radial_critical_curves_plot.plot_grid( + grid=self.radial_critical_curves + ) + except TypeError: + pass + + if self.tangential_caustics is not None: + try: + try: + plotter.tangential_caustics_plot.plot_grid( + grid=self.tangential_caustics + ) + except (AttributeError, ValueError): + plotter.tangential_caustics_plot.plot_grid( + grid=self.tangential_caustics.array + ) + except TypeError: + pass + + if self.radial_caustics is not None: + try: + plotter.radial_caustics_plot.plot_grid(grid=self.radial_caustics) + except TypeError: + pass + + def add_critical_curves_or_caustics( + self, mass_obj, grid: aa.type.Grid2DLike, plane_index: int + ): + """ + From a object with mass profiles (e.g. mass profile, galaxy) extract the critical curves or caustics and + returns them in a `Visuals2D` object. + + This includes support for a `plane_index`, which specifies the index of the plane in the tracer, which is + an object used in PyAutoLens to represent a lensing system with multiple planes (e.g. an image plane and a + source plane). The `plane_index` allows for the extraction of quantities from a specific plane in the tracer. + + When plotting a `Tracer` it is common for plots to only display quantities corresponding to one plane at a time + (e.g. the convergence in the image plane, the source in the source plane). Therefore, quantities are only + extracted from one plane, specified by the input `plane_index`. + + Parameters + ---------- + mass_obj + The mass object (e.g. mass profile, galaxy, tracer) object which has attributes extracted for plotting. + grid + The 2D grid of (y,x) coordinates used to plot the tracer's quantities in 2D. + plane_index + The index of the plane in the tracer which is used to extract quantities, as only one plane is plotted + at a time. + + Returns + ------- + vis.Visuals2D + A collection of attributes that can be plotted by a `Plotter` object. + """ + if plane_index == 0: + return self.add_critical_curves(mass_obj=mass_obj, grid=grid) + return self.add_caustics(mass_obj=mass_obj, grid=grid) + + def add_critical_curves(self, mass_obj, grid: aa.type.Grid2DLike): + """ + From a object with mass profiles (e.g. mass profile, galaxy) extract the critical curves and + returns them in a `Visuals2D` object. + + When plotting a `Tracer` it is common for plots to only display quantities corresponding to one plane at a time + (e.g. the convergence in the image plane, the source in the source plane). Therefore, quantities are only + extracted from one plane, specified by the input `plane_index`. + + Parameters + ---------- + mass_obj + The mass object (e.g. mass profile, galaxy, tracer) object which has attributes extracted for plotting. + grid + The 2D grid of (y,x) coordinates used to plot the tracer's quantities in 2D. + plane_index + The index of the plane in the tracer which is used to extract quantities, as only one plane is plotted + at a time. + + Returns + ------- + vis.Visuals2D + A collection of attributes that can be plotted by a `Plotter` object. + """ + + tangential_critical_curves = mass_obj.tangential_critical_curve_list_from( + grid=grid + ) + + radial_critical_curves = None + radial_critical_curve_area_list = mass_obj.radial_critical_curve_area_list_from( + grid=grid + ) + + if any([area > grid.pixel_scale for area in radial_critical_curve_area_list]): + radial_critical_curves = mass_obj.radial_critical_curve_list_from(grid=grid) + + return self + self.__class__( + tangential_critical_curves=tangential_critical_curves, + radial_critical_curves=radial_critical_curves, + ) + + def add_caustics(self, mass_obj, grid: aa.type.Grid2DLike): + """ + From a object with mass profiles (e.g. mass profile, galaxy) extract the caustics and + returns them in a `Visuals2D` object. + + When plotting a `Tracer` it is common for plots to only display quantities corresponding to one plane at a time + (e.g. the convergence in the image plane, the source in the source plane). Therefore, quantities are only + extracted from one plane, specified by the input `plane_index`. + + Parameters + ---------- + mass_obj + The mass object (e.g. mass profile, galaxy, tracer) object which has attributes extracted for plotting. + grid + The 2D grid of (y,x) coordinates used to plot the tracer's quantities in 2D. + plane_index + The index of the plane in the tracer which is used to extract quantities, as only one plane is plotted + at a time. + + Returns + ------- + vis.Visuals2D + A collection of attributes that can be plotted by a `Plotter` object. + """ + + tangential_caustics = mass_obj.tangential_caustic_list_from(grid=grid) + radial_caustics = mass_obj.radial_caustic_list_from(grid=grid) + + return self + self.__class__( + tangential_caustics=tangential_caustics, + radial_caustics=radial_caustics, + ) diff --git a/autogalaxy/profiles/basis.py b/autogalaxy/profiles/basis.py index f71777a00..3fc08b3ee 100644 --- a/autogalaxy/profiles/basis.py +++ b/autogalaxy/profiles/basis.py @@ -1,3 +1,4 @@ +import jax.numpy as jnp import numpy as np from typing import Dict, List, Optional, Union @@ -128,7 +129,7 @@ def image_2d_list_from( ( light_profile.image_2d_from(grid=grid, operated_only=operated_only) if not isinstance(light_profile, lp_linear.LightProfileLinear) - else np.zeros((grid.shape[0],)) + else jnp.zeros((grid.shape[0],)) ) for light_profile in self.light_profile_list ] @@ -152,9 +153,9 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> aa.Array2D: """ if len(self.mass_profile_list) > 0: return sum( - [mass.convergence_2d_from(grid=grid) for mass in self.mass_profile_list] + [mass.convergence_2d_from(grid=grid) for mass in self.profile_list] ) - return np.zeros((grid.shape[0],)) + return jnp.zeros((grid.shape[0],)) def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> aa.Array2D: """ @@ -177,7 +178,7 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> aa.Array2D: return sum( [mass.potential_2d_from(grid=grid) for mass in self.profile_list] ) - return np.zeros((grid.shape[0],)) + return jnp.zeros((grid.shape[0],)) def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> aa.Array2D: """ @@ -200,7 +201,7 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> aa.Array return sum( [mass.deflections_yx_2d_from(grid=grid) for mass in self.profile_list] ) - return np.zeros((grid.shape[0], 2)) + return jnp.zeros((grid.shape[0], 2)) def lp_instance_from(self, linear_light_profile_intensity_dict: Dict): light_profile_list = [] diff --git a/autogalaxy/profiles/geometry_profiles.py b/autogalaxy/profiles/geometry_profiles.py index c75b8cdbf..4d340dc1c 100644 --- a/autogalaxy/profiles/geometry_profiles.py +++ b/autogalaxy/profiles/geometry_profiles.py @@ -1,7 +1,8 @@ -from typing import Optional, Tuple, Type - +import jax.numpy as jnp import numpy as np +from typing import Optional, Tuple, Type + import autoarray as aa from autogalaxy import convert @@ -86,14 +87,16 @@ def __init__(self, centre: Tuple[float, float] = (0.0, 0.0)): def radial_grid_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: """ Convert a grid of (y, x) coordinates, to their radial distances from the profile - centre (e.g. :math: r = x**2 + y**2). + centre (e.g. :math: r = sqrt(x**2 + y**2)). Parameters ---------- grid The grid of (y, x) coordinates which are converted to radial distances. """ - return np.sqrt(np.add(np.square(grid[:, 0]), np.square(grid[:, 1]))) + return jnp.sqrt( + jnp.add(jnp.square(grid.array[:, 0]), jnp.square(grid.array[:, 1])) + ) def angle_to_profile_grid_from( self, grid_angles: np.ndarray, **kwargs @@ -107,11 +110,11 @@ def angle_to_profile_grid_from( grid_angles The angle theta counter-clockwise from the positive x-axis to each coordinate in radians. """ - return np.cos(grid_angles), np.sin(grid_angles) + return jnp.cos(grid_angles), jnp.sin(grid_angles) @aa.grid_dec.to_grid def _cartesian_grid_via_radial_from( - self, grid: aa.type.Grid2DLike, radius: np.ndarray, **kwargs + self, grid: aa.type.Grid2DLike, radius: jnp.ndarray, **kwargs ) -> aa.type.Grid2DLike: """ Convert a grid of (y,x) coordinates with their specified radial distances (e.g. :math: r = x**2 + y**2) to @@ -124,9 +127,15 @@ def _cartesian_grid_via_radial_from( radius The circular radius of each coordinate from the profile center. """ - grid_angles = np.arctan2(grid[:, 0], grid[:, 1]) + grid_angles = jnp.arctan2(grid.array[:, 0], grid.array[:, 1]) cos_theta, sin_theta = self.angle_to_profile_grid_from(grid_angles=grid_angles) - return np.multiply(radius[:, None], np.vstack((sin_theta, cos_theta)).T) + + if isinstance(radius, jnp.ndarray): + return jnp.multiply(radius[:, None], jnp.vstack((sin_theta, cos_theta)).T) + elif isinstance(radius, np.ndarray): + return np.multiply(radius[:, None], np.vstack((sin_theta, cos_theta)).T) + + return jnp.multiply(radius.array[:, None], jnp.vstack((sin_theta, cos_theta)).T) @aa.grid_dec.to_grid def transformed_to_reference_frame_grid_from(self, grid, **kwargs): @@ -140,7 +149,7 @@ def transformed_to_reference_frame_grid_from(self, grid, **kwargs): grid The (y, x) coordinates in the original reference frame of the grid. """ - return np.subtract(grid, self.centre) + return jnp.subtract(grid.array, jnp.array(self.centre)) @aa.grid_dec.to_grid def transformed_from_reference_frame_grid_from(self, grid, **kwargs): @@ -155,7 +164,7 @@ def transformed_from_reference_frame_grid_from(self, grid, **kwargs): grid The (y, x) coordinates in the reference frame of the profile. """ - return np.add(grid, self.centre) + return jnp.add(grid.array, jnp.array(self.centre)) class EllProfile(SphProfile): @@ -230,7 +239,7 @@ def angle_radians(self) -> float: The position angle in radians of the major-axis of the ellipse defined by profile, defined counter clockwise from the positive x-axis (0.0 > angle > 2pi). """ - return np.radians(self.angle) + return jnp.radians(self.angle) @property def _cos_angle(self) -> float: @@ -245,8 +254,8 @@ def _cos_and_sin_to_x_axis(self, **kwargs): Determine the sin and cosine of the angle between the profile's ellipse and the positive x-axis, counter-clockwise. """ - angle_radians = np.radians(self.angle) - return np.cos(angle_radians), np.sin(angle_radians) + angle_radians = jnp.radians(self.angle) + return jnp.cos(angle_radians), jnp.sin(angle_radians) def angle_to_profile_grid_from(self, grid_angles, **kwargs): """ @@ -257,8 +266,10 @@ def angle_to_profile_grid_from(self, grid_angles, **kwargs): grid_angles The angle theta counter-clockwise from the positive x-axis to each coordinate in radians. """ - theta_coordinate_to_profile = np.add(grid_angles, -self.angle_radians) - return np.cos(theta_coordinate_to_profile), np.sin(theta_coordinate_to_profile) + theta_coordinate_to_profile = jnp.add(grid_angles, -self.angle_radians) + return jnp.cos(theta_coordinate_to_profile), jnp.sin( + theta_coordinate_to_profile + ) @aa.grid_dec.to_grid def rotated_grid_from_reference_frame_from( @@ -292,10 +303,9 @@ def rotated_grid_from_reference_frame_from( ) @aa.grid_dec.to_array - @aa.grid_dec.relocate_to_radial_minimum def elliptical_radii_grid_from( self, grid: aa.type.Grid2DLike, **kwargs - ) -> np.ndarray: + ) -> jnp.ndarray: """ Convert a grid of (y,x) coordinates to their elliptical radii values: :math: (x^2 + (y^2/q))^0.5 @@ -304,17 +314,17 @@ def elliptical_radii_grid_from( grid The (y, x) coordinates in the reference frame of the elliptical profile. """ - return np.sqrt( - np.add( - np.square(grid[:, 1]), np.square(np.divide(grid[:, 0], self.axis_ratio)) + return jnp.sqrt( + jnp.add( + jnp.square(grid.array[:, 1]), + jnp.square(jnp.divide(grid.array[:, 0], self.axis_ratio)), ) ) @aa.grid_dec.to_array - @aa.grid_dec.relocate_to_radial_minimum def eccentric_radii_grid_from( self, grid: aa.type.Grid2DLike, **kwargs - ) -> np.ndarray: + ) -> jnp.ndarray: """ Convert a grid of (y,x) coordinates to an eccentric radius: :math: axis_ratio^0.5 (x^2 + (y^2/q))^0.5 @@ -331,12 +341,12 @@ def eccentric_radii_grid_from( grid_radii = self.elliptical_radii_grid_from(grid=grid, **kwargs) - return np.multiply(np.sqrt(self.axis_ratio), grid_radii).view(np.ndarray) + return jnp.multiply(jnp.sqrt(self.axis_ratio), grid_radii.array) @aa.grid_dec.to_grid def transformed_to_reference_frame_grid_from( self, grid: aa.type.Grid2DLike, **kwargs - ) -> np.ndarray: + ) -> jnp.ndarray: """ Transform a grid of (y,x) coordinates to the reference frame of the profile. @@ -372,7 +382,7 @@ def transformed_from_reference_frame_grid_from( return super().transformed_from_reference_frame_grid_from(grid=grid) return aa.util.geometry.transform_grid_2d_from_reference_frame( - grid_2d=grid, centre=self.centre, angle=self.angle + grid_2d=grid.array, centre=self.centre, angle=self.angle ) def _eta_u(self, u, coordinates): diff --git a/autogalaxy/profiles/light/abstract.py b/autogalaxy/profiles/light/abstract.py index 928f99011..da88cbcc4 100644 --- a/autogalaxy/profiles/light/abstract.py +++ b/autogalaxy/profiles/light/abstract.py @@ -1,5 +1,4 @@ import numpy as np -from scipy.integrate import quad from typing import Optional, Tuple import autoarray as aa @@ -117,6 +116,7 @@ def luminosity_within_circle_from(self, radius: float) -> float: radius The radius of the circle to compute the dimensionless luminosity within. """ + from scipy.integrate import quad return quad(func=self.luminosity_integral, a=0.0, b=radius)[0] @@ -131,7 +131,9 @@ def luminosity_integral(self, x: np.ndarray) -> np.ndarray: x The 1D (x) radial coordinates where the luminosity integral is evaluated. """ - return 2 * np.pi * x * self.image_2d_via_radii_from(x) + from autoarray.structures.arrays.irregular import ArrayIrregular + + return 2 * np.pi * x * self.image_2d_via_radii_from(ArrayIrregular(x)) @property def half_light_radius(self) -> float: diff --git a/autogalaxy/profiles/light/linear/abstract.py b/autogalaxy/profiles/light/linear/abstract.py index a44194e3b..68fdf2bac 100644 --- a/autogalaxy/profiles/light/linear/abstract.py +++ b/autogalaxy/profiles/light/linear/abstract.py @@ -1,10 +1,10 @@ import inspect +import jax.numpy as jnp import numpy as np -from typing import ClassVar, Dict, List, Optional +from typing import Dict, List, Optional from autoconf import cached_property import autoarray as aa -import autofit as af from autogalaxy.profiles.light.operated.abstract import ( LightProfileOperated, @@ -143,10 +143,9 @@ def __init__( self, grid: aa.type.Grid1D2DLike, blurring_grid: aa.type.Grid1D2DLike, - convolver: Optional[aa.Convolver], + psf: Optional[aa.Kernel2D], light_profile_list: List[LightProfileLinear], regularization=Optional[aa.reg.Regularization], - run_time_dict: Optional[Dict] = None, ): """ A list of linear light profiles which fits a dataset via linear algebra using the images of each linear light @@ -184,15 +183,13 @@ def __init__( blurring_grid The blurring grid is all points whose light is outside the data's mask but close enough to the mask that it may be blurred into the mask. This is also used when evaluating the image of each light profile. - convolver - The convolver used to blur the light profile images of each light profile, the output of which + psf + The psf used to blur the light profile images of each light profile, the output of which makes up the columns of the `operated_mapping matrix`. light_profile_list A list of the linear light profiles that are used to fit the data via linear algebra. regularization The regularization scheme which may be applied to this linear object in order to smooth its solution. - run_time_dict - A dictionary which contains timing of certain functions calls which is used for profiling. """ for light_profile in light_profile_list: if not isinstance(light_profile, LightProfileLinear): @@ -206,11 +203,12 @@ def __init__( ) super().__init__( - grid=grid, regularization=regularization, run_time_dict=run_time_dict + grid=grid, + regularization=regularization, ) self.blurring_grid = blurring_grid - self.convolver = convolver + self.psf = psf self.light_profile_list = light_profile_list @property @@ -255,23 +253,30 @@ def mapping_matrix(self) -> np.ndarray: This function iterates over each light profile in the list and evaluates its image on the grid, storing this image in the `mapping_matrix`. + The standard behaviour is that this is only used for linear light profiles computed when fitting interferometer + data, where the `mapping_matrix` is used to compute the `operated_mapping_matrix` via a fast Fourier transform. + This is because the FFT does not require light outside the masked region to computed, unlike for imaging + data which omits this function and uses `operated_mapping_matrix_override` instead. + Returns ------- The `mapping_matrix` of the linear light profiles. """ - mapping_matrix = np.zeros(shape=(self.pixels_in_mask, self.params)) + + image_2d_list = [] for pixel, light_profile in enumerate(self.light_profile_list): + image_2d = light_profile.image_2d_from(grid=self.grid).slim - mapping_matrix[:, pixel] = image_2d + image_2d_list.append(image_2d.array) - return mapping_matrix + return jnp.stack(image_2d_list, axis=1) @cached_property def operated_mapping_matrix_override(self) -> Optional[np.ndarray]: """ - The inversion object takes the `mapping_matrix` of each linear object and combines it with the `Convolver` + The inversion object takes the `mapping_matrix` of each linear object and combines it with the PSF operator to perform a 2D convolution and compute the `operated_mapping_matrix`. If this property is overwritten this operation is not performed, with the `operated_mapping_matrix` output this @@ -291,17 +296,17 @@ def operated_mapping_matrix_override(self) -> Optional[np.ndarray]: if isinstance(self.light_profile_list[0], LightProfileOperated): return self.mapping_matrix - operated_mapping_matrix = np.zeros(shape=(self.pixels_in_mask, self.params)) + blurred_image_2d_list = [] for pixel, light_profile in enumerate(self.light_profile_list): image_2d = light_profile.image_2d_from(grid=self.grid) blurring_image_2d = light_profile.image_2d_from(grid=self.blurring_grid) - blurred_image_2d = self.convolver.convolve_image( + blurred_image_2d = self.psf.convolve_image( image=image_2d, blurring_image=blurring_image_2d ) - operated_mapping_matrix[:, pixel] = blurred_image_2d + blurred_image_2d_list.append(blurred_image_2d.array) - return operated_mapping_matrix + return jnp.stack(blurred_image_2d_list, axis=1) diff --git a/autogalaxy/profiles/light/linear/shapelets/cartesian.py b/autogalaxy/profiles/light/linear/shapelets/cartesian.py index f6363a093..b6849d4a7 100644 --- a/autogalaxy/profiles/light/linear/shapelets/cartesian.py +++ b/autogalaxy/profiles/light/linear/shapelets/cartesian.py @@ -1,14 +1,8 @@ -import numpy as np -from scipy.special import hermite, factorial -from typing import Optional, Tuple +from typing import Tuple -import autoarray as aa from autogalaxy.profiles.light import standard as lp -from autogalaxy.profiles.light.decorators import ( - check_operated_only, -) from autogalaxy.profiles.light.linear.abstract import LightProfileLinear @@ -50,55 +44,6 @@ def __init__( n_y=n_y, n_x=n_x, centre=centre, ell_comps=ell_comps, beta=beta ) - @aa.over_sample - @aa.grid_dec.to_array - @check_operated_only - @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum - def image_2d_from( - self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs - ) -> np.ndarray: - """ - Returns the Cartesian Shapelet light profile's 2D image from a 2D grid of Cartesian (y,x) coordinates. - - If the coordinates have not been transformed to the profile's geometry (e.g. translated to the - profile `centre`), this is performed automatically. - - Parameters - ---------- - grid - The 2D (y, x) coordinates in the original reference frame of the grid. - - Returns - ------- - image - The image of the Cartesian Shapelet evaluated at every (y,x) coordinate on the transformed grid. - """ - - hermite_y = hermite(n=self.n_y) - hermite_x = hermite(n=self.n_x) - - y = grid[:, 0] - x = grid[:, 1] - - shapelet_y = hermite_y(y / self.beta) - shapelet_x = hermite_x(x / self.beta) - - return ( - shapelet_y - * shapelet_x - * np.exp(-0.5 * (y**2 + x**2) / (self.beta**2)) - / self.beta - / ( - np.sqrt( - 2 ** (self.n_x + self.n_y) - * (np.pi) - * factorial(self.n_y) - * factorial(self.n_x) - ) - ) - ) - class ShapeletCartesianSph(ShapeletCartesian): def __init__( diff --git a/autogalaxy/profiles/light/linear/shapelets/exponential.py b/autogalaxy/profiles/light/linear/shapelets/exponential.py index 2fd12efa8..2599fcb1a 100644 --- a/autogalaxy/profiles/light/linear/shapelets/exponential.py +++ b/autogalaxy/profiles/light/linear/shapelets/exponential.py @@ -1,14 +1,7 @@ -import numpy as np -from scipy.special import factorial, genlaguerre -from typing import Optional, Tuple - -import autoarray as aa +from typing import Tuple from autogalaxy.profiles.light import standard as lp -from autogalaxy.profiles.light.decorators import ( - check_operated_only, -) from autogalaxy.profiles.light.linear.abstract import LightProfileLinear @@ -49,58 +42,6 @@ def __init__( super().__init__(n=n, m=m, centre=centre, ell_comps=ell_comps, beta=beta) - @aa.over_sample - @aa.grid_dec.to_array - @check_operated_only - @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum - def image_2d_from( - self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs - ) -> np.ndarray: - """ - Returns the Exponential Shapelet light profile's 2D image from a 2D grid of Exponential (y,x) coordinates. - - If the coordinates have not been transformed to the profile's geometry (e.g. translated to the - profile `centre`), this is performed automatically. - - Parameters - ---------- - grid - The 2D (y, x) coordinates in the original reference frame of the grid. - - Returns - ------- - image - The image of the Exponential Shapelet evaluated at every (y,x) coordinate on the transformed grid. - """ - - radial = (grid[:, 0] ** 2 + grid[:, 1] ** 2) / self.beta - theta = np.arctan(grid[:, 1] / grid[:, 0]) - - prefactor = ( - 1.0 - / np.sqrt(2 * np.pi) - / self.beta - * (self.n + 0.5) ** (-1 - np.abs(self.m)) - * (-1) ** (self.n + self.m) - * np.sqrt( - factorial(self.n - np.abs(self.m)) / 2 * self.n - + 1 / factorial(self.n + np.abs(self.m)) - ) - ) - - laguerre = genlaguerre(n=self.n - np.abs(self.m), alpha=2 * np.abs(self.m)) - shapelet = laguerre(radial / (self.n + 0.5)) - - return np.abs( - prefactor - * np.exp(-radial / (2 * self.n + 1)) - * radial ** (np.abs(self.m)) - * shapelet - * np.cos(self.m * theta) - + -1.0j * np.sin(self.m * theta) - ) - class ShapeletExponentialSph(ShapeletExponential): def __init__( diff --git a/autogalaxy/profiles/light/snr/abstract.py b/autogalaxy/profiles/light/snr/abstract.py index 49b34a766..d4f0525d0 100644 --- a/autogalaxy/profiles/light/snr/abstract.py +++ b/autogalaxy/profiles/light/snr/abstract.py @@ -3,8 +3,6 @@ import autoarray as aa -from scipy.optimize import root_scalar - class LightProfileSNR: def __init__(self, signal_to_noise_ratio: float = 10.0): @@ -78,13 +76,17 @@ def set_intensity_from( The psf of the simulated imaging which can change the S/N of the light profile due to spreading out the emission. """ + from scipy.optimize import root_scalar + self.intensity = 1.0 background_sky_level_counts = background_sky_level * exposure_time image_2d = self.image_2d_from(grid=grid) if psf is not None: - image_2d = psf.convolved_array_from(array=image_2d) + image_2d = psf.convolve_image_no_blurring( + image=image_2d, mask=image_2d.mask + ) brightest_value = np.max(image_2d) diff --git a/autogalaxy/profiles/light/snr/sersic.py b/autogalaxy/profiles/light/snr/sersic.py index d44a6b12a..2ea33deac 100644 --- a/autogalaxy/profiles/light/snr/sersic.py +++ b/autogalaxy/profiles/light/snr/sersic.py @@ -1,75 +1,75 @@ -from typing import Tuple - -from autogalaxy.profiles.light.snr.abstract import LightProfileSNR -from autogalaxy.profiles.light import standard as lp - - -class Sersic(lp.Sersic, LightProfileSNR): - def __init__( - self, - signal_to_noise_ratio: float = 10.0, - centre: Tuple[float, float] = (0.0, 0.0), - ell_comps: Tuple[float, float] = (0.0, 0.0), - effective_radius: float = 0.6, - sersic_index: float = 4.0, - ): - """ - An elliptical Sersic light profile. - - Instead of an `intensity` a `signal_to_noise_ratio` is input which sets the signal to noise of the brightest - pixel of the profile's image when used to simulate imaging data. - - Parameters - ---------- - signal_to_noise_ratio - The signal to noise of the light profile when it is used to simulate strong lens imaging. - centre - The (y,x) arc-second coordinates of the profile centre. - ell_comps - The first and second ellipticity components of the elliptical coordinate system. - effective_radius - The circular radius containing half the light of this profile. - sersic_index - Controls the concentration of the profile (lower -> less concentrated, higher -> more concentrated). - """ - super().__init__( - centre=centre, - ell_comps=ell_comps, - intensity=0.0, - effective_radius=effective_radius, - sersic_index=sersic_index, - ) - - LightProfileSNR.__init__(self, signal_to_noise_ratio=signal_to_noise_ratio) - - -class SersicSph(lp.SersicSph, LightProfileSNR): - def __init__( - self, - signal_to_noise_ratio: float = 10.0, - centre: Tuple[float, float] = (0.0, 0.0), - effective_radius: float = 0.6, - sersic_index: float = 4.0, - ): - """ - The spherical Sersic light profile. - - Parameters - ---------- - centre - The (y,x) arc-second coordinates of the profile centre. - intensity - Overall intensity normalisation of the light profile (units are dimensionless and derived from the data - the light profile's image is compared too, which is expected to be electrons per second). - effective_radius - The circular radius containing half the light of this profile. - sersic_index - Controls the concentration of the of the light profile. - """ - super().__init__( - centre=centre, - intensity=0.0, - effective_radius=effective_radius, - sersic_index=sersic_index, - ) - LightProfileSNR.__init__(self, signal_to_noise_ratio=signal_to_noise_ratio) +from typing import Tuple + +from autogalaxy.profiles.light.snr.abstract import LightProfileSNR +from autogalaxy.profiles.light import standard as lp + + +class Sersic(lp.Sersic, LightProfileSNR): + def __init__( + self, + signal_to_noise_ratio: float = 10.0, + centre: Tuple[float, float] = (0.0, 0.0), + ell_comps: Tuple[float, float] = (0.0, 0.0), + effective_radius: float = 0.6, + sersic_index: float = 4.0, + ): + """ + An elliptical Sersic light profile. + + Instead of an `intensity` a `signal_to_noise_ratio` is input which sets the signal to noise of the brightest + pixel of the profile's image when used to simulate imaging data. + + Parameters + ---------- + signal_to_noise_ratio + The signal to noise of the light profile when it is used to simulate strong lens imaging. + centre + The (y,x) arc-second coordinates of the profile centre. + ell_comps + The first and second ellipticity components of the elliptical coordinate system. + effective_radius + The circular radius containing half the light of this profile. + sersic_index + Controls the concentration of the profile (lower -> less concentrated, higher -> more concentrated). + """ + super().__init__( + centre=centre, + ell_comps=ell_comps, + intensity=0.0, + effective_radius=effective_radius, + sersic_index=sersic_index, + ) + + LightProfileSNR.__init__(self, signal_to_noise_ratio=signal_to_noise_ratio) + + +class SersicSph(lp.SersicSph, LightProfileSNR): + def __init__( + self, + signal_to_noise_ratio: float = 10.0, + centre: Tuple[float, float] = (0.0, 0.0), + effective_radius: float = 0.6, + sersic_index: float = 4.0, + ): + """ + The spherical Sersic light profile. + + Parameters + ---------- + centre + The (y,x) arc-second coordinates of the profile centre. + intensity + Overall intensity normalisation of the light profile (units are dimensionless and derived from the data + the light profile's image is compared too, which is expected to be electrons per second). + effective_radius + The circular radius containing half the light of this profile. + sersic_index + Controls the concentration of the of the light profile. + """ + super().__init__( + centre=centre, + intensity=0.0, + effective_radius=effective_radius, + sersic_index=sersic_index, + ) + LightProfileSNR.__init__(self, signal_to_noise_ratio=signal_to_noise_ratio) diff --git a/autogalaxy/profiles/light/standard/chameleon.py b/autogalaxy/profiles/light/standard/chameleon.py index 6e1ce199d..2935ddf76 100644 --- a/autogalaxy/profiles/light/standard/chameleon.py +++ b/autogalaxy/profiles/light/standard/chameleon.py @@ -1,3 +1,4 @@ +import jax.numpy as jnp import numpy as np from typing import Optional, Tuple @@ -66,23 +67,23 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray) -> np.ndarray: axis_ratio_factor = (1.0 + self.axis_ratio) ** 2.0 - return np.multiply( + return jnp.multiply( self._intensity / (1 + self.axis_ratio), - np.add( - np.divide( + jnp.add( + jnp.divide( 1.0, - np.sqrt( - np.add( - np.square(grid_radii), + jnp.sqrt( + jnp.add( + jnp.square(grid_radii.array), (4.0 * self.core_radius_0**2.0) / axis_ratio_factor, ) ), ), - -np.divide( + -jnp.divide( 1.0, - np.sqrt( - np.add( - np.square(grid_radii), + jnp.sqrt( + jnp.add( + jnp.square(grid_radii.array), (4.0 * self.core_radius_1**2.0) / axis_ratio_factor, ) ), @@ -94,7 +95,6 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray) -> np.ndarray: @aa.grid_dec.to_array @check_operated_only @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def image_2d_from( self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs ) -> np.ndarray: diff --git a/autogalaxy/profiles/light/standard/eff.py b/autogalaxy/profiles/light/standard/eff.py index 138e094f8..675834995 100644 --- a/autogalaxy/profiles/light/standard/eff.py +++ b/autogalaxy/profiles/light/standard/eff.py @@ -61,7 +61,6 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray) -> np.ndarray: @aa.grid_dec.to_array @check_operated_only @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def image_2d_from( self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs ) -> np.ndarray: diff --git a/autogalaxy/profiles/light/standard/gaussian.py b/autogalaxy/profiles/light/standard/gaussian.py index 87717ae5f..6feaee7b4 100644 --- a/autogalaxy/profiles/light/standard/gaussian.py +++ b/autogalaxy/profiles/light/standard/gaussian.py @@ -1,3 +1,4 @@ +import jax.numpy as jnp import numpy as np from typing import Optional, Tuple @@ -59,12 +60,12 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray) -> np.ndarray: grid_radii The radial distances from the centre of the profile, for each coordinate on the grid. """ - return np.multiply( + return jnp.multiply( self._intensity, - np.exp( + jnp.exp( -0.5 - * np.square( - np.divide(grid_radii, self.sigma / np.sqrt(self.axis_ratio)) + * jnp.square( + jnp.divide(grid_radii.array, self.sigma / jnp.sqrt(self.axis_ratio)) ) ), ) @@ -73,7 +74,6 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray) -> np.ndarray: @aa.grid_dec.to_array @check_operated_only @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def image_2d_from( self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs ) -> np.ndarray: diff --git a/autogalaxy/profiles/light/standard/moffat.py b/autogalaxy/profiles/light/standard/moffat.py index 8b6c69f38..adcc3af25 100644 --- a/autogalaxy/profiles/light/standard/moffat.py +++ b/autogalaxy/profiles/light/standard/moffat.py @@ -1,3 +1,4 @@ +import jax.numpy as jnp import numpy as np from typing import Optional, Tuple @@ -57,12 +58,12 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray) -> np.ndarray: grid_radii The radial distances from the centre of the profile, for each coordinate on the grid. """ - return np.multiply( + return jnp.multiply( self._intensity, - np.power( + jnp.power( 1 - + np.square( - np.divide(grid_radii, self.alpha / np.sqrt(self.axis_ratio)) + + jnp.square( + jnp.divide(grid_radii.array, self.alpha / jnp.sqrt(self.axis_ratio)) ), -self.beta, ), @@ -72,7 +73,6 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray) -> np.ndarray: @aa.grid_dec.to_array @check_operated_only @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def image_2d_from( self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs ) -> np.ndarray: diff --git a/autogalaxy/profiles/light/standard/sersic.py b/autogalaxy/profiles/light/standard/sersic.py index 675d052b8..0c0de357a 100644 --- a/autogalaxy/profiles/light/standard/sersic.py +++ b/autogalaxy/profiles/light/standard/sersic.py @@ -1,4 +1,7 @@ +import jax.numpy as jnp import numpy as np + +from numpy import seterr from typing import Optional, Tuple import autoarray as aa @@ -50,7 +53,7 @@ def elliptical_effective_radius(self) -> float: The elliptical effective radius instead describes the major-axis radius of the ellipse containing half the light, and may be more appropriate for highly flattened systems like disk galaxies. """ - return self.effective_radius / np.sqrt(self.axis_ratio) + return self.effective_radius / jnp.sqrt(self.axis_ratio) @property def sersic_constant(self) -> float: @@ -77,7 +80,7 @@ def image_2d_via_radii_from(self, radius: np.ndarray) -> np.ndarray: grid_radii The radial distances from the centre of the profile, for each coordinate on the grid. """ - return self._intensity * np.exp( + return self._intensity * jnp.exp( -self.sersic_constant * (((radius / self.effective_radius) ** (1.0 / self.sersic_index)) - 1) ) @@ -127,15 +130,15 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray, **kwargs) -> np.ndarra grid_radii The radial distances from the centre of the profile, for each coordinate on the grid. """ - np.seterr(all="ignore") - return np.multiply( + seterr(all="ignore") + return jnp.multiply( self._intensity, - np.exp( - np.multiply( + jnp.exp( + jnp.multiply( -self.sersic_constant, - np.add( - np.power( - np.divide(grid_radii, self.effective_radius), + jnp.add( + jnp.power( + jnp.divide(grid_radii.array, self.effective_radius), 1.0 / self.sersic_index, ), -1, @@ -148,7 +151,6 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray, **kwargs) -> np.ndarra @aa.grid_dec.to_array @check_operated_only @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def image_2d_from( self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs ) -> aa.Array2D: diff --git a/autogalaxy/profiles/light/standard/sersic_core.py b/autogalaxy/profiles/light/standard/sersic_core.py index f3dacf1a7..dbc444d04 100644 --- a/autogalaxy/profiles/light/standard/sersic_core.py +++ b/autogalaxy/profiles/light/standard/sersic_core.py @@ -1,3 +1,4 @@ +import jax.numpy as jnp import numpy as np from typing import Tuple @@ -63,7 +64,7 @@ def intensity_prime(self) -> float: return ( self._intensity * (2.0 ** (-self.gamma / self.alpha)) - * np.exp( + * jnp.exp( self.sersic_constant * ( ((2.0 ** (1.0 / self.alpha)) * self.radius_break) @@ -84,25 +85,27 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray, **kwargs) -> np.ndarra The radial distances from the centre of the profile, for each coordinate on the grid. """ - return np.multiply( - np.multiply( + return jnp.multiply( + jnp.multiply( self.intensity_prime, - np.power( - np.add( + jnp.power( + jnp.add( 1, - np.power(np.divide(self.radius_break, grid_radii), self.alpha), + jnp.power( + jnp.divide(self.radius_break, grid_radii.array), self.alpha + ), ), (self.gamma / self.alpha), ), ), - np.exp( - np.multiply( + jnp.exp( + jnp.multiply( -self.sersic_constant, ( - np.power( - np.divide( - np.add( - np.power(grid_radii, self.alpha), + jnp.power( + jnp.divide( + jnp.add( + jnp.power(grid_radii.array, self.alpha), (self.radius_break**self.alpha), ), (self.effective_radius**self.alpha), diff --git a/autogalaxy/profiles/light/standard/shapelets/cartesian.py b/autogalaxy/profiles/light/standard/shapelets/cartesian.py index a98856bc8..76785e471 100644 --- a/autogalaxy/profiles/light/standard/shapelets/cartesian.py +++ b/autogalaxy/profiles/light/standard/shapelets/cartesian.py @@ -1,5 +1,5 @@ +import jax.numpy as jnp import numpy as np -from scipy.special import hermite, factorial from typing import Optional, Tuple import autoarray as aa @@ -63,7 +63,6 @@ def coefficient_tag(self) -> str: @aa.grid_dec.to_array @check_operated_only @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def image_2d_from( self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs ) -> np.ndarray: @@ -83,12 +82,14 @@ def image_2d_from( image The image of the Cartesian Shapelet evaluated at every (y,x) coordinate on the transformed grid. """ + from jax.scipy.special import factorial + from scipy.special import hermite hermite_y = hermite(n=self.n_y) hermite_x = hermite(n=self.n_x) - y = grid[:, 0] - x = grid[:, 1] + y = grid.array[:, 0] + x = grid.array[:, 1] shapelet_y = hermite_y(y / self.beta) shapelet_x = hermite_x(x / self.beta) @@ -96,12 +97,12 @@ def image_2d_from( return ( shapelet_y * shapelet_x - * np.exp(-0.5 * (y**2 + x**2) / (self.beta**2)) + * jnp.exp(-0.5 * (y**2 + x**2) / (self.beta**2)) / self.beta / ( - np.sqrt( + jnp.sqrt( 2 ** (self.n_x + self.n_y) - * (np.pi) + * (jnp.pi) * factorial(self.n_y) * factorial(self.n_x) ) diff --git a/autogalaxy/profiles/light/standard/shapelets/exponential.py b/autogalaxy/profiles/light/standard/shapelets/exponential.py index d15d4eda0..9dbf5bee7 100644 --- a/autogalaxy/profiles/light/standard/shapelets/exponential.py +++ b/autogalaxy/profiles/light/standard/shapelets/exponential.py @@ -1,5 +1,5 @@ +import jax.numpy as jnp import numpy as np -from scipy.special import factorial, genlaguerre from typing import Optional, Tuple import autoarray as aa @@ -64,7 +64,6 @@ def coefficient_tag(self) -> str: @aa.grid_dec.to_array @check_operated_only @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def image_2d_from( self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs ) -> np.ndarray: @@ -84,32 +83,34 @@ def image_2d_from( image The image of the Exponential Shapelet evaluated at every (y,x) coordinate on the transformed grid. """ + from scipy.special import genlaguerre + from jax.scipy.special import factorial - radial = (grid[:, 0] ** 2 + grid[:, 1] ** 2) / self.beta - theta = np.arctan(grid[:, 1] / grid[:, 0]) + radial = (grid.array[:, 0] ** 2 + grid.array[:, 1] ** 2) / self.beta + theta = jnp.arctan(grid.array[:, 1] / grid.array[:, 0]) prefactor = ( 1.0 - / np.sqrt(2 * np.pi) + / jnp.sqrt(2 * jnp.pi) / self.beta - * (self.n + 0.5) ** (-1 - np.abs(self.m)) + * (self.n + 0.5) ** (-1 - jnp.abs(self.m)) * (-1) ** (self.n + self.m) - * np.sqrt( - factorial(self.n - np.abs(self.m)) / 2 * self.n - + 1 / factorial(self.n + np.abs(self.m)) + * jnp.sqrt( + factorial(self.n - jnp.abs(self.m)) / 2 * self.n + + 1 / factorial(self.n + jnp.abs(self.m)) ) ) - laguerre = genlaguerre(n=self.n - np.abs(self.m), alpha=2 * np.abs(self.m)) + laguerre = genlaguerre(n=self.n - jnp.abs(self.m), alpha=2 * jnp.abs(self.m)) shapelet = laguerre(radial / (self.n + 0.5)) - return np.abs( + return jnp.abs( prefactor - * np.exp(-radial / (2 * self.n + 1)) - * radial ** (np.abs(self.m)) + * jnp.exp(-radial / (2 * self.n + 1)) + * radial ** (jnp.abs(self.m)) * shapelet - * np.cos(self.m * theta) - + -1.0j * np.sin(self.m * theta) + * jnp.cos(self.m * theta) + + -1.0j * jnp.sin(self.m * theta) ) diff --git a/autogalaxy/profiles/light/standard/shapelets/polar.py b/autogalaxy/profiles/light/standard/shapelets/polar.py index f9da6ad4f..9733308fc 100644 --- a/autogalaxy/profiles/light/standard/shapelets/polar.py +++ b/autogalaxy/profiles/light/standard/shapelets/polar.py @@ -1,5 +1,5 @@ +import jax.numpy as jnp import numpy as np -from scipy.special import factorial, genlaguerre from typing import Optional, Tuple import autoarray as aa @@ -64,7 +64,6 @@ def coefficient_tag(self) -> str: @aa.grid_dec.to_array @check_operated_only @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def image_2d_from( self, grid: aa.type.Grid2DLike, operated_only: Optional[bool] = None, **kwargs ) -> np.ndarray: @@ -84,29 +83,33 @@ def image_2d_from( image The image of the Polar Shapelet evaluated at every (y,x) coordinate on the transformed grid. """ + from scipy.special import genlaguerre + from jax.scipy.special import factorial - laguerre = genlaguerre(n=(self.n - np.abs(self.m)) / 2.0, alpha=np.abs(self.m)) + laguerre = genlaguerre( + n=(self.n - jnp.abs(self.m)) / 2.0, alpha=jnp.abs(self.m) + ) const = ( - ((-1) ** ((self.n - np.abs(self.m)) // 2)) - * np.sqrt( - factorial((self.n - np.abs(self.m)) // 2) - / factorial((self.n + np.abs(self.m)) // 2) + ((-1) ** ((self.n - jnp.abs(self.m)) // 2)) + * jnp.sqrt( + factorial((self.n - jnp.abs(self.m)) // 2) + / factorial((self.n + jnp.abs(self.m)) // 2) ) / self.beta - / np.sqrt(np.pi) + / jnp.sqrt(jnp.pi) ) - rsq = (grid[:, 0] ** 2 + grid[:, 1] ** 2) / self.beta**2 - theta = np.arctan2(grid[:, 1], grid[:, 0]) - radial = rsq ** (abs(self.m / 2.0)) * np.exp(-rsq / 2.0) * laguerre(rsq) + rsq = (grid.array[:, 0] ** 2 + grid.array[:, 1] ** 2) / self.beta**2 + theta = jnp.arctan2(grid.array[:, 1], grid.array[:, 0]) + radial = rsq ** (abs(self.m / 2.0)) * jnp.exp(-rsq / 2.0) * laguerre(rsq) if self.m == 0: azimuthal = 1 elif self.m > 0: - azimuthal = np.sin((-1) * self.m * theta) + azimuthal = jnp.sin((-1) * self.m * theta) else: - azimuthal = np.cos((-1) * self.m * theta) + azimuthal = jnp.cos((-1) * self.m * theta) return const * radial * azimuthal diff --git a/autogalaxy/profiles/mass/__init__.py b/autogalaxy/profiles/mass/__init__.py index 5080042a4..37b7e0172 100644 --- a/autogalaxy/profiles/mass/__init__.py +++ b/autogalaxy/profiles/mass/__init__.py @@ -50,4 +50,4 @@ Chameleon, ChameleonSph, ) -from .sheets import ExternalShear, MassSheet, InputDeflections +from .sheets import ExternalShear, MassSheet diff --git a/autogalaxy/profiles/mass/abstract/abstract.py b/autogalaxy/profiles/mass/abstract/abstract.py index bfa1bbe5d..80a2da261 100644 --- a/autogalaxy/profiles/mass/abstract/abstract.py +++ b/autogalaxy/profiles/mass/abstract/abstract.py @@ -1,6 +1,5 @@ +import jax.numpy as jnp import numpy as np -from scipy.integrate import quad -from scipy.optimize import root_scalar from typing import Tuple import autoarray as aa @@ -33,8 +32,12 @@ def deflections_yx_2d_from(self, grid): def deflections_2d_via_potential_2d_from(self, grid): potential = self.potential_2d_from(grid=grid) - deflections_y_2d = np.gradient(potential.native, grid.native[:, 0, 0], axis=0) - deflections_x_2d = np.gradient(potential.native, grid.native[0, :, 1], axis=1) + deflections_y_2d = np.gradient( + potential.native.array, grid.native.array[:, 0, 0], axis=0 + ) + deflections_x_2d = np.gradient( + potential.native.array, grid.native.array[0, :, 1], axis=1 + ) return aa.Grid2D( values=np.stack((deflections_y_2d, deflections_x_2d), axis=-1), @@ -62,7 +65,7 @@ def potential_func(self, u, y, x): raise NotImplementedError def mass_integral(self, x): - return 2 * np.pi * x * self.convergence_func(grid_radius=x) + return 2 * jnp.pi * x * self.convergence_func(grid_radius=aa.ArrayIrregular(x)) @property def ellipticity_rescale(self): @@ -78,6 +81,7 @@ def mass_angular_within_circle_from(self, radius: float): radius : dim.Length The radius of the circle to compute the dimensionless mass within. """ + from scipy.integrate import quad return quad(self.mass_integral, a=0.0, b=radius)[0] @@ -120,6 +124,7 @@ def average_convergence_of_1_radius(self): This radius corresponds to the Einstein radius of the mass profile, and is a property of a number of \ mass profiles below. """ + from scipy.optimize import root_scalar def func(radius): return ( diff --git a/autogalaxy/profiles/mass/abstract/cse.py b/autogalaxy/profiles/mass/abstract/cse.py index 55df5d84a..9d096aa7a 100644 --- a/autogalaxy/profiles/mass/abstract/cse.py +++ b/autogalaxy/profiles/mass/abstract/cse.py @@ -1,6 +1,5 @@ from abc import ABC, abstractmethod import numpy as np -from scipy.linalg import lstsq from typing import Callable, List, Tuple @@ -85,6 +84,8 @@ def _decompose_convergence_via_cse_from( A list of amplitudes and core radii of every cored steep elliptical (cse) the mass profile is decomposed into. """ + from scipy.linalg import lstsq + error_sigma = 0.1 # error spread. Could be any value. r_samples = np.logspace(np.log10(radii_min), np.log10(radii_max), sample_points) @@ -166,8 +167,8 @@ def _deflections_2d_via_cse_from(self, grid: np.ndarray, **kwargs) -> np.ndarray ) q = self.axis_ratio q2 = q**2.0 - grid_y = grid[:, 0] - grid_x = grid[:, 1] + grid_y = grid.array[:, 0] + grid_x = grid.array[:, 1] gridx2 = grid_x**2.0 gridy2 = grid_y**2.0 term1 = q2 * gridx2 + gridy2 diff --git a/autogalaxy/profiles/mass/abstract/jax_utils.py b/autogalaxy/profiles/mass/abstract/jax_utils.py new file mode 100644 index 000000000..e241488f3 --- /dev/null +++ b/autogalaxy/profiles/mass/abstract/jax_utils.py @@ -0,0 +1,99 @@ +import jax.numpy as jnp + +from jax import custom_jvp + + +r1_s1 = [2.5, 2, 1.5, 1, 0.5] + + +def reg1(z, _, i_sqrt_pi): + v = z + for coef in r1_s1: + v = z - coef / v + return i_sqrt_pi / v + + +r2_s1 = [1.320522, 35.7668, 219.031, 1540.787, 3321.99, 36183.31] +r2_s2 = [1.841439, 61.57037, 364.2191, 2186.181, 9022.228, 24322.84, 32066.6] + + +def reg2(z, sqrt_pi, _): + mz2 = -(z**2) + f1 = sqrt_pi + f2 = 1.0 + for s in r2_s1: + f1 = s - f1 * mz2 + for s in r2_s2: + f2 = s - f2 * mz2 + + return jnp.exp(mz2) + 1j * z * f1 / f2 + + +r3_s1 = [5.9126262, 30.180142, 93.15558, 181.92853, 214.38239, 122.60793] +r3_s2 = [10.479857, 53.992907, 170.35400, 348.70392, 457.33448, 352.73063, 122.60793] + + +def reg3(z, sqrt_pi, _): + miz = -1j * z + f1 = sqrt_pi + f2 = 1 + for s in r3_s1: + f1 = s + f1 * miz + for s in r3_s2: + f2 = s + f2 * miz + + return f1 / f2 + + +@custom_jvp +def w_f_approx(z): + """Compute the Faddeeva function :math:`w_{\\mathrm F}(z)` using the + approximation given in Zaghloul (2017). + + :param z: complex number + :type z: ``complex`` or ``numpy.array(dtype=complex)`` + :return: :math:`w_\\mathrm{F}(z)` + :rtype: ``complex`` + """ + sqrt_pi = 1 / jnp.sqrt(jnp.pi) + i_sqrt_pi = 1j * sqrt_pi + + z_imag2 = z.imag**2 + abs_z2 = z.real**2 + z_imag2 + + # use a single partial fraction approx for all large abs(z)**2 + # to have better approx of the auto-derivatives + r1 = (abs_z2 >= 62.0) | ((abs_z2 >= 30.0) & (abs_z2 < 62.0) & (z_imag2 >= 1e-13)) + # region bounds for 5 taken directly from Zaghloul (2017) + # https://dl.acm.org/doi/pdf/10.1145/3119904 + r2_1 = (abs_z2 >= 30.0) & (abs_z2 < 62.0) & (z_imag2 < 1e-13) + r2_2 = (abs_z2 >= 2.5) & (abs_z2 < 30.0) & (z_imag2 < 0.072) + r2 = r2_1 | r2_2 + r3 = jnp.logical_not(r1) & jnp.logical_not(r2) + + # exploit symmetry to avoid overflow in some regions + r_flip = z.imag < 0 + z_adjust = jnp.where(r_flip, -z, z) + two_exp_zz = 2 * jnp.exp(-(z_adjust**2)) + + args = (z_adjust, sqrt_pi, i_sqrt_pi) + wz = jnp.empty_like(z) + wz = jnp.where(r1, reg1(*args), wz) + wz = jnp.where(r2, reg2(*args), wz) + wz = jnp.where(r3, reg3(*args), wz) + + # exploit symmetry to avoid overflow in some regions + wz = jnp.where(r_flip, two_exp_zz - wz, wz) + + return wz + + +@w_f_approx.defjvp +def w_f_approx_jvp(primals, tangents): + # define a custom jvp to avoid the issue using `jnp.where` with `jax.grad` + (z,) = primals + (z_dot,) = tangents + primal_out = w_f_approx(z) + i_sqrt_pi = 1j / jnp.sqrt(jnp.pi) + tangent_out = z_dot * 2 * (i_sqrt_pi - z * primal_out) + return primal_out, tangent_out diff --git a/autogalaxy/profiles/mass/abstract/mge_jax.py b/autogalaxy/profiles/mass/abstract/mge_jax.py new file mode 100644 index 000000000..81beab896 --- /dev/null +++ b/autogalaxy/profiles/mass/abstract/mge_jax.py @@ -0,0 +1,161 @@ +import jax.numpy as jnp + +from .jax_utils import w_f_approx + + +class MassProfileMGE: + """ + This class speeds up deflection angle calculations of certain mass profiles by decompositing them into many + Gaussians. + + This follows the method of Shajib 2019 - https://academic.oup.com/mnras/article/488/1/1387/5526256 + """ + + def __init__(self): + pass + + @staticmethod + def zeta_from(grid, amps, sigmas, axis_ratio): + """ + The key part to compute the deflection angle of each Gaussian. + """ + q2 = axis_ratio**2.0 + + scale_factor = axis_ratio / jnp.sqrt(2.0 * (1.0 - q2)) + + xs = jnp.array((grid.array[:, 1] * scale_factor).copy()) + ys = jnp.array((grid.array[:, 0] * scale_factor).copy()) + + y_sign = jnp.sign(ys) + ys = ys * y_sign + + z = xs + 1j * ys + zq = axis_ratio * xs + 1j * ys / axis_ratio + expv = -(xs**2.0) * (1.0 - q2) - ys**2.0 * (1.0 / q2 - 1.0) + sigma_ = sigmas.reshape((-1,) + (1,) * xs.ndim) + inv_sigma_ = 1 / sigma_ + amps_ = amps.reshape((-1,) + (1,) * xs.ndim) + + # process as one big vectorized calculation + # could try `jax.lax.scan` instead if this is too much memory + w = w_f_approx(inv_sigma_ * z) + wq = w_f_approx(inv_sigma_ * zq) + exp_factor = jnp.exp(inv_sigma_**2 * expv) + + sigma_func_real = w.imag - exp_factor * wq.imag + sigma_func_imag = (-w.real + exp_factor * wq.real) * y_sign + + output_grid = sigma_ * amps_ * (sigma_func_real + 1j * sigma_func_imag) + return output_grid.sum(axis=0) + + @staticmethod + def kesi(p): + """ + see Eq.(6) of 1906.08263 + """ + n_list = jnp.arange(0, 2 * p + 1, 1) + return (2.0 * p * jnp.log(10) / 3.0 + 2.0 * jnp.pi * n_list * 1j) ** (0.5) + + @staticmethod + def eta(p): + """ + see Eq.(6) of 1906.00263 + """ + + i = jnp.arange(1, p, 1) + kesi_last = 1 / 2**p + k = kesi_last + jnp.cumsum(jnp.cumprod((p + 1 - i) / i) * kesi_last) + + kesi_list = jnp.hstack( + [jnp.array([0.5]), jnp.ones(p), k[::-1], jnp.array([kesi_last])] + ) + coef = (-1) ** jnp.arange(0, 2 * p + 1, 1) + eta_const = 2.0 * jnp.sqrt(2.0 * jnp.pi) * 10 ** (p / 3.0) + eta_list = coef * kesi_list + return eta_const, eta_list + + def decompose_convergence_via_mge(self): + raise NotImplementedError() + + def _decompose_convergence_via_mge( + self, func, radii_min, radii_max, func_terms=28, func_gaussians=20 + ): + """ + + Parameters + ---------- + func : func + The function representing the profile that is decomposed into Gaussians. + normalization + A normalization factor tyh + func_terms + The number of terms used to approximate the input func. + func_gaussians + The number of Gaussians used to represent the input func. + + Returns + ------- + """ + + kesis = self.kesi(func_terms) # kesi in Eq.(6) of 1906.08263 + eta_constant, eta_n = self.eta(func_terms) # eta in Eqr.(6) of 1906.08263 + + # sigma is sampled from logspace between these radii. + + log_sigmas = jnp.linspace( + jnp.log(radii_min), jnp.log(radii_max), func_gaussians + ) + d_log_sigma = log_sigmas[1] - log_sigmas[0] + sigma_list = jnp.exp(log_sigmas) + + f_sigma = eta_constant * jnp.sum( + eta_n * jnp.real(func(sigma_list.reshape(-1, 1) * kesis)), axis=1 + ) + amplitude_list = f_sigma * d_log_sigma / jnp.sqrt(2.0 * jnp.pi) + amplitude_list = amplitude_list.at[0].multiply(0.5) + amplitude_list = amplitude_list.at[-1].multiply(0.5) + + return amplitude_list, sigma_list + + def convergence_2d_via_mge_from(self, grid_radii): + raise NotImplementedError() + + def _convergence_2d_via_mge_from( + self, grid_radii, func_terms=28, func_gaussians=20 + ): + """Calculate the projected convergence at a given set of arc-second gridded coordinates. + + Parameters + ---------- + grid + The grid of (y,x) arc-second coordinates the convergence is computed on. + + """ + amps, sigmas = self.decompose_convergence_via_mge( + func_terms=func_terms, func_gaussians=func_gaussians + ) + + inv_sigma_ = 1 / sigmas.reshape((-1,) + (1,) * grid_radii.array.ndim) + amps_ = amps.reshape((-1,) + (1,) * grid_radii.array.ndim) + convergence = amps_ * jnp.exp(-0.5 * (grid_radii.array * inv_sigma_) ** 2) + return convergence.sum(axis=0) + + def _deflections_2d_via_mge_from( + self, grid, sigmas_factor=1.0, func_terms=28, func_gaussians=20 + ): + axis_ratio = jnp.min(jnp.array([self.axis_ratio, 0.9999])) + + amps, sigmas = self.decompose_convergence_via_mge( + func_terms=func_terms, func_gaussians=func_gaussians + ) + sigmas *= sigmas_factor + + angle = self.zeta_from( + grid=grid, amps=amps, sigmas=sigmas, axis_ratio=axis_ratio + ) + + angle *= jnp.sqrt((2.0 * jnp.pi) / (1.0 - axis_ratio**2.0)) + + return self.rotated_grid_from_reference_frame_from( + jnp.vstack((-angle.imag, angle.real)).T + ) diff --git a/autogalaxy/profiles/mass/abstract/mge_numpy.py b/autogalaxy/profiles/mass/abstract/mge_numpy.py new file mode 100644 index 000000000..124d278cf --- /dev/null +++ b/autogalaxy/profiles/mass/abstract/mge_numpy.py @@ -0,0 +1,284 @@ +import numpy as np + + +def w_f_approx(z): + """ + Compute the Faddeeva function :math:`w_{\mathrm F}(z)` using the + approximation given in Zaghloul (2017). + :param z: complex number + :type z: ``complex`` or ``numpy.array(dtype=complex)`` + :return: :math:`w_\mathrm{F}(z)` + :rtype: ``complex`` + + # This function is copied from + # "https://github.com/sibirrer/lenstronomy/tree/main/lenstronomy/LensModel/Profiles" + # written by Anowar J. Shajib (see 1906.08263) + """ + + z = np.array(z) + + reg_minus_imag = z.imag < 0.0 + z[reg_minus_imag] = np.conj(z[reg_minus_imag]) + + sqrt_pi = 1 / np.sqrt(np.pi) + i_sqrt_pi = 1j * sqrt_pi + + wz = np.empty_like(z) + + z_imag2 = z.imag**2 + abs_z2 = z.real**2 + z_imag2 + + reg1 = abs_z2 >= 38000.0 + if np.any(reg1): + wz[reg1] = i_sqrt_pi / z[reg1] + + reg2 = (256.0 <= abs_z2) & (abs_z2 < 38000.0) + if np.any(reg2): + t = z[reg2] + wz[reg2] = i_sqrt_pi * t / (t * t - 0.5) + + reg3 = (62.0 <= abs_z2) & (abs_z2 < 256.0) + if np.any(reg3): + t = z[reg3] + wz[reg3] = (i_sqrt_pi / t) * (1 + 0.5 / (t * t - 1.5)) + + reg4 = (30.0 <= abs_z2) & (abs_z2 < 62.0) & (z_imag2 >= 1e-13) + if np.any(reg4): + t = z[reg4] + tt = t * t + wz[reg4] = (i_sqrt_pi * t) * (tt - 2.5) / (tt * (tt - 3.0) + 0.75) + + reg5 = (62.0 > abs_z2) & np.logical_not(reg4) & (abs_z2 > 2.5) & (z_imag2 < 0.072) + if np.any(reg5): + t = z[reg5] + u = -t * t + f1 = sqrt_pi + f2 = 1 + s1 = [1.320522, 35.7668, 219.031, 1540.787, 3321.99, 36183.31] + s2 = [1.841439, 61.57037, 364.2191, 2186.181, 9022.228, 24322.84, 32066.6] + + for s in s1: + f1 = s - f1 * u + for s in s2: + f2 = s - f2 * u + + wz[reg5] = np.exp(u) + 1j * t * f1 / f2 + + reg6 = (30.0 > abs_z2) & np.logical_not(reg5) + if np.any(reg6): + t3 = -1j * z[reg6] + + f1 = sqrt_pi + f2 = 1 + s1 = [5.9126262, 30.180142, 93.15558, 181.92853, 214.38239, 122.60793] + s2 = [ + 10.479857, + 53.992907, + 170.35400, + 348.70392, + 457.33448, + 352.73063, + 122.60793, + ] + + for s in s1: + f1 = f1 * t3 + s + for s in s2: + f2 = f2 * t3 + s + + wz[reg6] = f1 / f2 + + # wz[reg_minus_imag] = np.conj(wz[reg_minus_imag]) + + return wz + + +class MassProfileMGE: + """ + This class speeds up deflection angle calculations of certain mass profiles by decompositing them into many + Gaussians. + + This follows the method of Shajib 2019 - https://academic.oup.com/mnras/article/488/1/1387/5526256 + """ + + def __init__(self): + self.count = 0 + self.sigma_calc = 0 + self.z = 0 + self.zq = 0 + self.expv = 0 + + @staticmethod + def zeta_from(grid, amps, sigmas, axis_ratio): + """ + The key part to compute the deflection angle of each Gaussian. + Because of my optimization, there are blocks looking weird and indirect. What I'm doing here + is trying to avoid big matrix operation to save time. + I think there are still spaces we can optimize. + + It seems when using w_f_approx, it gives some errors if y < 0. So when computing for places + where y < 0, we first compute the value at - y, and then change its sign. + """ + + output_grid_final = np.zeros(grid.shape[0], dtype="complex128") + + q2 = axis_ratio**2.0 + + scale_factor = axis_ratio / (sigmas[0] * np.sqrt(2.0 * (1.0 - q2))) + + xs = np.array((grid.array[:, 1] * scale_factor).copy()) + ys = np.array((grid.array[:, 0] * scale_factor).copy()) + + ys_minus = ys < 0.0 + ys[ys_minus] *= -1 + z = xs + 1j * ys + zq = axis_ratio * xs + 1j * ys / axis_ratio + + expv = -(xs**2.0) * (1.0 - q2) - ys**2.0 * (1.0 / q2 - 1.0) + + for i in range(len(sigmas)): + if i > 0: + z /= sigmas[i] / sigmas[i - 1] + zq /= sigmas[i] / sigmas[i - 1] + expv /= (sigmas[i] / sigmas[i - 1]) ** 2.0 + + output_grid = -1j * (w_f_approx(z) - np.exp(expv) * w_f_approx(zq)) + + output_grid[ys_minus] = np.conj(output_grid[ys_minus]) + + output_grid_final += (amps[i] * sigmas[i]) * output_grid + + return output_grid_final + + @staticmethod + def kesi(p): + """ + see Eq.(6) of 1906.08263 + """ + n_list = np.arange(0, 2 * p + 1, 1) + return (2.0 * p * np.log(10) / 3.0 + 2.0 * np.pi * n_list * 1j) ** (0.5) + + @staticmethod + def eta(p): + """ + see Eq.(6) of 1906.00263 + """ + from scipy.special import comb + + eta_list = np.zeros(int(2 * p + 1)) + kesi_list = np.zeros(int(2 * p + 1)) + kesi_list[0] = 0.5 + kesi_list[1 : p + 1] = 1.0 + kesi_list[int(2 * p)] = 1.0 / 2.0**p + + for i in np.arange(1, p, 1): + kesi_list[2 * p - i] = kesi_list[2 * p - i + 1] + 2 ** (-p) * comb(p, i) + + for i in np.arange(0, 2 * p + 1, 1): + eta_list[i] = ( + (-1) ** i * 2.0 * np.sqrt(2.0 * np.pi) * 10 ** (p / 3.0) * kesi_list[i] + ) + + return eta_list + + def decompose_convergence_via_mge(self): + raise NotImplementedError() + + def _decompose_convergence_via_mge( + self, func, radii_min, radii_max, func_terms=28, func_gaussians=20 + ): + """ + + Parameters + ---------- + func : func + The function representing the profile that is decomposed into Gaussians. + normalization + A normalization factor tyh + func_terms + The number of terms used to approximate the input func. + func_gaussians + The number of Gaussians used to represent the input func. + + Returns + ------- + """ + + kesis = self.kesi(func_terms) # kesi in Eq.(6) of 1906.08263 + etas = self.eta(func_terms) # eta in Eqr.(6) of 1906.08263 + + def f(sigma): + """Eq.(5) of 1906.08263""" + return np.sum(etas * np.real(target_function(sigma * kesis))) + + # sigma is sampled from logspace between these radii. + + log_sigmas = np.linspace(np.log(radii_min), np.log(radii_max), func_gaussians) + d_log_sigma = log_sigmas[1] - log_sigmas[0] + sigma_list = np.exp(log_sigmas) + + amplitude_list = np.zeros(func_gaussians) + + for i in range(func_gaussians): + f_sigma = np.sum(etas * np.real(func(sigma_list[i] * kesis))) + if (i == -1) or (i == (func_gaussians - 1)): + amplitude_list[i] = 0.5 * f_sigma * d_log_sigma / np.sqrt(2.0 * np.pi) + else: + amplitude_list[i] = f_sigma * d_log_sigma / np.sqrt(2.0 * np.pi) + + return amplitude_list, sigma_list + + def convergence_2d_via_mge_from(self, grid_radii): + raise NotImplementedError() + + def _convergence_2d_via_mge_from(self, grid_radii, **kwargs): + """Calculate the projected convergence at a given set of arc-second gridded coordinates. + + Parameters + ---------- + grid + The grid of (y,x) arc-second coordinates the convergence is computed on. + + """ + + self.count = 0 + self.sigma_calc = 0 + self.z = 0 + self.zq = 0 + self.expv = 0 + + amps, sigmas = self.decompose_convergence_via_mge() + + convergence = 0.0 + + for i in range(len(sigmas)): + convergence += self.convergence_func_gaussian( + grid_radii=grid_radii.array, sigma=sigmas[i], intensity=amps[i] + ) + return convergence + + def convergence_func_gaussian(self, grid_radii, sigma, intensity): + return np.multiply( + intensity, np.exp(-0.5 * np.square(np.divide(grid_radii, sigma))) + ) + + def _deflections_2d_via_mge_from( + self, grid, sigmas_factor=1.0, func_terms=None, func_gaussians=None + ): + axis_ratio = np.array(self.axis_ratio) + + if axis_ratio > 0.9999: + axis_ratio = 0.9999 + + amps, sigmas = self.decompose_convergence_via_mge() + sigmas *= sigmas_factor + + angle = self.zeta_from( + grid=grid, amps=amps, sigmas=sigmas, axis_ratio=axis_ratio + ) + + angle *= np.sqrt((2.0 * np.pi) / (1.0 - axis_ratio**2.0)) + + return self.rotated_grid_from_reference_frame_from( + np.vstack((-angle.imag, angle.real)).T + ) diff --git a/autogalaxy/profiles/mass/abstract/mge.py b/autogalaxy/profiles/mass/abstract/mge_numpy_coleman.py similarity index 95% rename from autogalaxy/profiles/mass/abstract/mge.py rename to autogalaxy/profiles/mass/abstract/mge_numpy_coleman.py index 3f534ff91..5f5b8a97b 100644 --- a/autogalaxy/profiles/mass/abstract/mge.py +++ b/autogalaxy/profiles/mass/abstract/mge_numpy_coleman.py @@ -1,5 +1,4 @@ import numpy as np -from scipy.special import comb def w_f_approx(z): @@ -108,7 +107,6 @@ def __init__(self): self.expv = 0 @staticmethod - # @aa.util.numba.jit() def zeta_from(grid, amps, sigmas, axis_ratio): """ The key part to compute the deflection angle of each Gaussian. @@ -163,6 +161,8 @@ def eta(p): """ see Eq.(6) of 1906.00263 """ + from scipy.special import comb + eta_list = np.zeros(int(2 * p + 1)) kesi_list = np.zeros(int(2 * p + 1)) kesi_list[0] = 0.5 @@ -219,7 +219,7 @@ def f(sigma): for i in range(func_gaussians): f_sigma = np.sum(etas * np.real(func(sigma_list[i] * kesis))) - if (i == -1) or (i == (func_gaussians - 1)): + if (i == 0) or (i == (func_gaussians - 1)): amplitude_list[i] = 0.5 * f_sigma * d_log_sigma / np.sqrt(2.0 * np.pi) else: amplitude_list[i] = f_sigma * d_log_sigma / np.sqrt(2.0 * np.pi) diff --git a/autogalaxy/profiles/mass/dark/abstract.py b/autogalaxy/profiles/mass/dark/abstract.py index faba381d4..34dfc3430 100644 --- a/autogalaxy/profiles/mass/dark/abstract.py +++ b/autogalaxy/profiles/mass/dark/abstract.py @@ -1,13 +1,12 @@ +import jax.numpy as jnp import numpy as np -from scipy.optimize import fsolve from typing import Tuple import autoarray as aa from autogalaxy.profiles.mass.abstract.abstract import MassProfile from autogalaxy.cosmology.lensing import LensingCosmology -from autogalaxy.cosmology.wrap import Planck15 -from autogalaxy.profiles.mass.abstract.mge import ( +from autogalaxy.profiles.mass.abstract.mge_numpy import ( MassProfileMGE, ) @@ -58,7 +57,6 @@ def __init__( @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """Calculate the projected convergence at a given set of arc-second gridded coordinates. @@ -76,7 +74,6 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_via_mge_from(self, grid: aa.type.Grid2DLike, **kwargs): """Calculate the projected convergence at a given set of arc-second gridded coordinates. @@ -111,7 +108,7 @@ def tabulate_integral(self, grid, tabulate_bins, **kwargs): return eta_min, eta_max, minimum_log_eta, maximum_log_eta, bin_size - def decompose_convergence_via_mge(self): + def decompose_convergence_via_mge(self, **kwargs): rho_at_scale_radius = ( self.kappa_s / self.scale_radius ) # density parameter of 3D gNFW @@ -133,65 +130,92 @@ def gnfw_3d(r): amplitude_list *= np.sqrt(2.0 * np.pi) * sigma_list return amplitude_list, sigma_list - def coord_func_f(self, grid_radius): - if isinstance(grid_radius, float) or isinstance(grid_radius, complex): - grid_radius = np.array([grid_radius]) + def coord_func_f(self, grid_radius: jnp.ndarray) -> jnp.ndarray: + """ + Given an array `grid_radius` and a work array `f`, fill f[i] with - return self.coord_func_f_jit( - grid_radius=np.array(grid_radius), - f=np.ones(shape=grid_radius.shape[0], dtype="complex64"), - ) + • (1 / sqrt(r_i^2 − 1)) * arccos(1 / r_i) if r_i > 1 + • (1 / sqrt(1 − r_i^2)) * arccosh(1 / r_i) if r_i < 1 + • leave f[i] unchanged if r_i == 1 (you can adjust this if you want a different convention) - @staticmethod - @aa.util.numba.jit() - def coord_func_f_jit(grid_radius, f): - for index in range(f.shape[0]): - if np.real(grid_radius[index]) > 1.0: - f[index] = ( - 1.0 / np.sqrt(np.square(grid_radius[index]) - 1.0) - ) * np.arccos(np.divide(1.0, grid_radius[index])) - elif np.real(grid_radius[index]) < 1.0: - f[index] = ( - 1.0 / np.sqrt(1.0 - np.square(grid_radius[index])) - ) * np.arccosh(np.divide(1.0, grid_radius[index])) - - return f - - def coord_func_g(self, grid_radius): + This version uses only pure JAX ops, so it can be jitted or grad’ed without + any Python control flow on tracer values. + """ if isinstance(grid_radius, float) or isinstance(grid_radius, complex): - grid_radius = np.array([grid_radius]) + grid_radius = jnp.array([grid_radius]) + + f = jnp.ones(shape=grid_radius.shape[0], dtype="complex64") + + # compute both branches + r = grid_radius + inv_r = 1.0 / r + + # branch for r > 1 + out_gt = (1.0 / jnp.sqrt(r**2 - 1.0)) * jnp.arccos(inv_r) + + # branch for r < 1 + out_lt = (1.0 / jnp.sqrt(1.0 - r**2)) * jnp.arccosh(inv_r) + + # combine: if r>1 pick out_gt, elif r<1 pick out_lt, else keep original f + return jnp.where(r > 1.0, out_gt, jnp.where(r < 1.0, out_lt, f)) + + def coord_func_g(self, grid_radius: jnp.ndarray) -> jnp.ndarray: + """ + Vectorized version of the original looped `coord_func_g_jit`. + + Applies conditional logic element-wise: + - if r > 1: g = (1 - f_r) / (r^2 - 1) + - if r < 1: g = (f_r - 1) / (1 - r^2) + - else: g = 1/3 + + Parameters + ---------- + grid_radius : jnp.ndarray + The input grid radius values. + f_r : jnp.ndarray + Precomputed values from `coord_func_f`. + g : jnp.ndarray + Output array (will be overwritten). + + Returns + ------- + jnp.ndarray + The updated `g` array. + """ + # Convert single values to JAX arrays + if isinstance(grid_radius, (float, complex)): + grid_radius = jnp.array([grid_radius], dtype=jnp.complex64) + # Evaluate f_r f_r = self.coord_func_f(grid_radius=grid_radius) - return self.coord_func_g_jit( - grid_radius=np.array(grid_radius), - f_r=f_r, - g=np.zeros(shape=grid_radius.shape[0], dtype="complex64"), + r = jnp.real(grid_radius) + r2 = r**2 + + return jnp.where( + r > 1.0, + (1.0 - f_r) / (r2 - 1.0), + jnp.where( + r < 1.0, + (f_r - 1.0) / (1.0 - r2), + 1.0 / 3.0, + ), ) - @staticmethod - @aa.util.numba.jit() - def coord_func_g_jit(grid_radius, f_r, g): - for index in range(f_r.shape[0]): - if np.real(grid_radius[index]) > 1.0: - g[index] = (1.0 - f_r[index]) / (np.square(grid_radius[index]) - 1.0) - elif np.real(grid_radius[index]) < 1.0: - g[index] = (f_r[index] - 1.0) / (1.0 - np.square(grid_radius[index])) - else: - g[index] = 1.0 / 3.0 - - return g - def coord_func_h(self, grid_radius): - return np.log(grid_radius / 2.0) + self.coord_func_f(grid_radius=grid_radius) + return jnp.log(grid_radius / 2.0) + self.coord_func_f(grid_radius=grid_radius) def rho_at_scale_radius_solar_mass_per_kpc3( - self, redshift_object, redshift_source, cosmology: LensingCosmology = Planck15() + self, redshift_object, redshift_source, cosmology: LensingCosmology = None ): """ The Cosmic average density is defined at the redshift of the profile. """ + from autogalaxy.cosmology.wrap import Planck15 + + cosmology = cosmology or Planck15() + critical_surface_density = cosmology.critical_surface_density_between_redshifts_solar_mass_per_kpc2_from( redshift_0=redshift_object, redshift_1=redshift_source ) @@ -209,8 +233,13 @@ def delta_concentration( redshift_object, redshift_source, redshift_of_cosmic_average_density="profile", - cosmology: LensingCosmology = Planck15(), + cosmology: LensingCosmology = None, ): + + from autogalaxy.cosmology.wrap import Planck15 + + cosmology = cosmology or Planck15() + if redshift_of_cosmic_average_density == "profile": redshift_calc = redshift_object elif redshift_of_cosmic_average_density == "local": @@ -240,8 +269,15 @@ def concentration( redshift_profile, redshift_source, redshift_of_cosmic_average_density="profile", - cosmology: LensingCosmology = Planck15(), + cosmology: LensingCosmology = None, ): + + from autogalaxy.cosmology.wrap import Planck15 + + cosmology = cosmology or Planck15() + + from scipy.optimize import fsolve + """ Computes the NFW halo concentration, `c_{200m}` """ @@ -265,7 +301,7 @@ def concentration_func(concentration, delta_concentration): concentration * concentration * concentration - / (np.log(1 + concentration) - concentration / (1 + concentration)) + / (jnp.log(1 + concentration) - concentration / (1 + concentration)) ) - delta_concentration ) @@ -275,11 +311,15 @@ def radius_at_200( redshift_object, redshift_source, redshift_of_cosmic_average_density="profile", - cosmology: LensingCosmology = Planck15(), + cosmology: LensingCosmology = None, ): """ Returns `r_{200m}` for this halo in **arcseconds** """ + from autogalaxy.cosmology.wrap import Planck15 + + cosmology = cosmology or Planck15() + concentration = self.concentration( redshift_profile=redshift_object, redshift_source=redshift_source, @@ -294,8 +334,12 @@ def mass_at_200_solar_masses( redshift_object, redshift_source, redshift_of_cosmic_average_density="profile", - cosmology: LensingCosmology = Planck15(), + cosmology: LensingCosmology = None, ): + from autogalaxy.cosmology.wrap import Planck15 + + cosmology = cosmology or Planck15() + """ Returns `M_{200m}` of this NFW halo, in solar masses, at the given cosmology. """ @@ -328,7 +372,7 @@ def mass_at_200_solar_masses( return ( 200.0 - * ((4.0 / 3.0) * np.pi) + * ((4.0 / 3.0) * jnp.pi) * cosmic_average_density * (radius_at_200_kpc**3.0) ) diff --git a/autogalaxy/profiles/mass/dark/gnfw.py b/autogalaxy/profiles/mass/dark/gnfw.py index 96cda9a4e..047154085 100644 --- a/autogalaxy/profiles/mass/dark/gnfw.py +++ b/autogalaxy/profiles/mass/dark/gnfw.py @@ -1,8 +1,4 @@ -import inspect import numpy as np -from scipy import LowLevelCallable -from scipy import special -from scipy.integrate import quad from typing import Tuple import autoarray as aa @@ -10,85 +6,12 @@ from autogalaxy.profiles.mass.dark.abstract import AbstractgNFW -def jit_integrand(integrand_function): - from numba import cfunc - from numba.types import intc, CPointer, float64 - - jitted_function = aa.util.numba.jit(nopython=True, cache=True)(integrand_function) - no_args = len(inspect.getfullargspec(integrand_function).args) - - wrapped = None - - if no_args == 4: - # noinspection PyUnusedLocal - def wrapped(n, xx): - return jitted_function(xx[0], xx[1], xx[2], xx[3]) - - elif no_args == 5: - # noinspection PyUnusedLocal - def wrapped(n, xx): - return jitted_function(xx[0], xx[1], xx[2], xx[3], xx[4]) - - elif no_args == 6: - # noinspection PyUnusedLocal - def wrapped(n, xx): - return jitted_function(xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]) - - elif no_args == 7: - # noinspection PyUnusedLocal - def wrapped(n, xx): - return jitted_function(xx[0], xx[1], xx[2], xx[3], xx[4], xx[5], xx[6]) - - elif no_args == 8: - # noinspection PyUnusedLocal - def wrapped(n, xx): - return jitted_function( - xx[0], xx[1], xx[2], xx[3], xx[4], xx[5], xx[6], xx[7] - ) - - elif no_args == 9: - # noinspection PyUnusedLocal - def wrapped(n, xx): - return jitted_function( - xx[0], xx[1], xx[2], xx[3], xx[4], xx[5], xx[6], xx[7], xx[8] - ) - - elif no_args == 10: - # noinspection PyUnusedLocal - def wrapped(n, xx): - return jitted_function( - xx[0], xx[1], xx[2], xx[3], xx[4], xx[5], xx[6], xx[7], xx[8], xx[9] - ) - - elif no_args == 11: - # noinspection PyUnusedLocal - def wrapped(n, xx): - return jitted_function( - xx[0], - xx[1], - xx[2], - xx[3], - xx[4], - xx[5], - xx[6], - xx[7], - xx[8], - xx[9], - xx[10], - ) - - cf = cfunc(float64(intc, CPointer(float64))) - - return LowLevelCallable(cf(wrapped).ctypes) - - class gNFW(AbstractgNFW): def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): return self.deflections_2d_via_mge_from(grid=grid, **kwargs) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_mge_from(self, grid: aa.type.Grid2DLike, **kwargs): return self._deflections_2d_via_mge_from( grid=grid, sigmas_factor=self.axis_ratio @@ -96,7 +19,6 @@ def deflections_2d_via_mge_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_integral_from( self, grid: aa.type.Grid2DLike, tabulate_bins=1000, **kwargs ): @@ -112,7 +34,6 @@ def deflections_2d_via_integral_from( """ - @jit_integrand def surface_density_integrand(x, kappa_radius, scale_radius, inner_slope): return ( (3 - inner_slope) @@ -121,6 +42,9 @@ def surface_density_integrand(x, kappa_radius, scale_radius, inner_slope): ) def calculate_deflection_component(npow, yx_index): + + from scipy.integrate import quad + deflection_grid = np.zeros(grid.shape[0]) for i in range(grid.shape[0]): @@ -134,8 +58,8 @@ def calculate_deflection_component(npow, yx_index): a=0.0, b=1.0, args=( - grid[i, 0], - grid[i, 1], + grid.array[i, 0], + grid.array[i, 1], npow, self.axis_ratio, minimum_log_eta, @@ -160,6 +84,8 @@ def calculate_deflection_component(npow, yx_index): surface_density_integral = np.zeros((tabulate_bins,)) for i in range(tabulate_bins): + from scipy.integrate import quad + eta = 10.0 ** (minimum_log_eta + (i - 1) * bin_size) integral = quad( @@ -204,10 +130,13 @@ def deflection_func( return kap / (1.0 - (1.0 - axis_ratio**2) * u) ** (npow + 0.5) def convergence_func(self, grid_radius: float) -> float: + + from scipy.integrate import quad + def integral_y(y, eta): return (y + eta) ** (self.inner_slope - 4) * (1 - np.sqrt(1 - y**2)) - grid_radius = (1.0 / self.scale_radius) * grid_radius + grid_radius = np.array((1.0 / self.scale_radius) * grid_radius.array) for index in range(grid_radius.shape[0]): integral_y_value = quad( @@ -233,7 +162,6 @@ def integral_y(y, eta): @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def potential_2d_from(self, grid: aa.type.Grid2DLike, tabulate_bins=1000, **kwargs): """ Calculate the potential at a given set of arc-second gridded coordinates. @@ -247,7 +175,9 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, tabulate_bins=1000, **kwar """ - @jit_integrand + from scipy import special + from scipy.integrate import quad + def deflection_integrand(x, kappa_radius, scale_radius, inner_slope): return (x + kappa_radius / scale_radius) ** (inner_slope - 3) * ( (1 - np.sqrt(1 - x**2)) / x @@ -295,8 +225,8 @@ def deflection_integrand(x, kappa_radius, scale_radius, inner_slope): a=0.0, b=1.0, args=( - grid[i, 0], - grid[i, 1], + grid.array[i, 0], + grid.array[i, 1], self.axis_ratio, minimum_log_eta, maximum_log_eta, @@ -365,7 +295,6 @@ def __init__( @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -377,7 +306,7 @@ def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): """ eta = np.multiply( - 1.0 / self.scale_radius, self.radial_grid_from(grid, **kwargs) + 1.0 / self.scale_radius, self.radial_grid_from(grid, **kwargs).array ) deflection_grid = np.zeros(grid.shape[0]) @@ -394,6 +323,10 @@ def deflection_integrand(y, eta, inner_slope): return (y + eta) ** (inner_slope - 3) * ((1 - np.sqrt(1 - y**2)) / y) def deflection_func_sph(self, eta): + + from scipy import special + from scipy.integrate import quad + integral_y_2 = quad( self.deflection_integrand, a=0.0, diff --git a/autogalaxy/profiles/mass/dark/gnfw_virial_mass_conc.py b/autogalaxy/profiles/mass/dark/gnfw_virial_mass_conc.py index 838b67453..7a2292fbd 100644 --- a/autogalaxy/profiles/mass/dark/gnfw_virial_mass_conc.py +++ b/autogalaxy/profiles/mass/dark/gnfw_virial_mass_conc.py @@ -2,17 +2,16 @@ from autogalaxy.profiles.mass.dark.gnfw import gNFWSph -from astropy import units - import numpy as np from autogalaxy import cosmology as cosmo -from scipy.integrate import quad - def kappa_s_and_scale_radius( cosmology, virial_mass, c_2, overdens, redshift_object, redshift_source, inner_slope ): + from astropy import units + from scipy.integrate import quad + concentration = (2 - inner_slope) * c_2 # gNFW concentration critical_density = ( diff --git a/autogalaxy/profiles/mass/dark/gnfw_virial_mass_gnfw_conc.py b/autogalaxy/profiles/mass/dark/gnfw_virial_mass_gnfw_conc.py index 5be2e7840..e30205982 100644 --- a/autogalaxy/profiles/mass/dark/gnfw_virial_mass_gnfw_conc.py +++ b/autogalaxy/profiles/mass/dark/gnfw_virial_mass_gnfw_conc.py @@ -2,13 +2,9 @@ from autogalaxy.profiles.mass.dark.gnfw import gNFWSph -from astropy import units - import numpy as np from autogalaxy import cosmology as cosmo -from scipy.integrate import quad - def kappa_s_and_scale_radius( cosmology, @@ -19,6 +15,9 @@ def kappa_s_and_scale_radius( redshift_source, inner_slope, ): + from astropy import units + from scipy.integrate import quad + # gNFW concentration imported critical_density = ( diff --git a/autogalaxy/profiles/mass/dark/mcr_util.py b/autogalaxy/profiles/mass/dark/mcr_util.py index f3fc01197..f8d1b84bb 100644 --- a/autogalaxy/profiles/mass/dark/mcr_util.py +++ b/autogalaxy/profiles/mass/dark/mcr_util.py @@ -1,10 +1,6 @@ -from astropy import units - import numpy as np import warnings -from autogalaxy.cosmology.wrap import Planck15 - def kappa_s_and_scale_radius_for_duffy(mass_at_200, redshift_object, redshift_source): """ @@ -13,6 +9,11 @@ def kappa_s_and_scale_radius_for_duffy(mass_at_200, redshift_object, redshift_so Interprets mass as *`M_{200c}`*, not `M_{200m}`. """ + + from astropy import units + + from autogalaxy.cosmology.wrap import Planck15 + cosmology = Planck15() cosmic_average_density = ( @@ -64,11 +65,14 @@ def kappa_s_and_scale_radius_for_ludlow( Interprets mass as *`M_{200c}`*, not `M_{200m}`. """ + from astropy import units from colossus.cosmology import cosmology as col_cosmology from colossus.halo.concentration import concentration as col_concentration warnings.filterwarnings("ignore") + from autogalaxy.cosmology.wrap import Planck15 + cosmology = Planck15() col_cosmo = col_cosmology.setCosmology("planck15") diff --git a/autogalaxy/profiles/mass/dark/nfw.py b/autogalaxy/profiles/mass/dark/nfw.py index 489db98c8..7d87355da 100644 --- a/autogalaxy/profiles/mass/dark/nfw.py +++ b/autogalaxy/profiles/mass/dark/nfw.py @@ -1,5 +1,5 @@ +import jax.numpy as jnp import numpy as np -from scipy.integrate import quad from typing import Tuple import autoarray as aa @@ -48,7 +48,6 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -59,9 +58,10 @@ def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ + from scipy.integrate import quad def calculate_deflection_component(npow, index): - deflection_grid = self.axis_ratio * grid[:, index] + deflection_grid = np.array(self.axis_ratio * grid.array[:, index]) for i in range(grid.shape[0]): deflection_grid[i] *= ( @@ -71,8 +71,8 @@ def calculate_deflection_component(npow, index): a=0.0, b=1.0, args=( - grid[i, 0], - grid[i, 1], + grid.array[i, 0], + grid.array[i, 1], npow, self.axis_ratio, self.scale_radius, @@ -91,7 +91,6 @@ def calculate_deflection_component(npow, index): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_cse_from(self, grid: aa.type.Grid2DLike, **kwargs): return self._deflections_2d_via_cse_from(grid=grid, **kwargs) @@ -122,7 +121,6 @@ def deflection_func(u, y, x, npow, axis_ratio, scale_radius): @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_via_cse_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the projected 2D convergence from a grid of (y,x) arc second coordinates, by computing and summing @@ -143,13 +141,14 @@ def convergence_2d_via_cse_from(self, grid: aa.type.Grid2DLike, **kwargs): return self._convergence_2d_via_cse_from(grid_radii=elliptical_radii) def convergence_func(self, grid_radius: float) -> float: - grid_radius = (1.0 / self.scale_radius) * grid_radius + 0j - return np.real(2.0 * self.kappa_s * self.coord_func_g(grid_radius=grid_radius)) + grid_radius = (1.0 / self.scale_radius) * grid_radius.array + 0j + return np.real( + 2.0 * self.kappa_s * np.array(self.coord_func_g(grid_radius=grid_radius)) + ) @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the potential at a given set of arc-second gridded coordinates. @@ -160,6 +159,7 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ + from scipy.integrate import quad potential_grid = np.zeros(grid.shape[0]) @@ -169,8 +169,8 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): a=0.0, b=1.0, args=( - grid[i, 0], - grid[i, 1], + grid.array[i, 0], + grid.array[i, 1], self.axis_ratio, self.kappa_s, self.scale_radius, @@ -252,18 +252,8 @@ def nfw_2d(r): sample_points=sample_points, ) - @staticmethod - def coord_func(r): - if r > 1: - return (1.0 / np.sqrt(r**2 - 1)) * np.arctan(np.sqrt(r**2 - 1)) - elif r < 1: - return (1.0 / np.sqrt(1 - r**2)) * np.arctanh(np.sqrt(1 - r**2)) - elif r == 1: - return 1 - @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def shear_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Analytic calculation shear from Heyrovský & Karamazov 2024 @@ -283,8 +273,8 @@ def shear_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): # Define dimensionless length coords - x1 = grid[:, 1] / self.scale_radius - x2 = grid[:, 0] / self.scale_radius + x1 = grid.array[:, 1] / self.scale_radius + x2 = grid.array[:, 0] / self.scale_radius # Avoid nans due to x=0 x1 = np.where(np.abs(x1) < 1e-6, 1e-6, x1) @@ -304,7 +294,6 @@ def shear_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Analytic calculation convergence from Heyrovský & Karamazov 2024 @@ -328,8 +317,8 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): # Define dimensionless length coords - x1 = grid[:, 1] / self.scale_radius - x2 = grid[:, 0] / self.scale_radius + x1 = grid.array[:, 1] / self.scale_radius + x2 = grid.array[:, 0] / self.scale_radius # Avoid nans due to x=0 @@ -376,7 +365,6 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_analytic_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -387,11 +375,11 @@ def deflections_2d_via_analytic_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ - eta = np.multiply( - 1.0 / self.scale_radius, self.radial_grid_from(grid=grid, **kwargs) + eta = jnp.multiply( + 1.0 / self.scale_radius, self.radial_grid_from(grid=grid, **kwargs).array ) - deflection_grid = np.multiply( + deflection_grid = jnp.multiply( (4.0 * self.kappa_s * self.scale_radius / eta), self.deflection_func_sph(grid_radius=eta), ) @@ -400,12 +388,11 @@ def deflections_2d_via_analytic_from(self, grid: aa.type.Grid2DLike, **kwargs): def deflection_func_sph(self, grid_radius): grid_radius = grid_radius + 0j - return np.real(self.coord_func_h(grid_radius=grid_radius)) + return jnp.real(self.coord_func_h(grid_radius=grid_radius)) @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the potential at a given set of arc-second gridded coordinates. diff --git a/autogalaxy/profiles/mass/dark/nfw_hk24_util.py b/autogalaxy/profiles/mass/dark/nfw_hk24_util.py index 71bdce62c..0d24b679d 100644 --- a/autogalaxy/profiles/mass/dark/nfw_hk24_util.py +++ b/autogalaxy/profiles/mass/dark/nfw_hk24_util.py @@ -5,9 +5,6 @@ """ import numpy as np -from astropy.cosmology import Planck15 - -cosmo = Planck15 def semi_major_axis_from(x1: np.ndarray, x2: np.ndarray, e: np.ndarray) -> np.ndarray: diff --git a/autogalaxy/profiles/mass/dark/nfw_truncated.py b/autogalaxy/profiles/mass/dark/nfw_truncated.py index 773ef10c9..b33f4d0d7 100644 --- a/autogalaxy/profiles/mass/dark/nfw_truncated.py +++ b/autogalaxy/profiles/mass/dark/nfw_truncated.py @@ -1,10 +1,9 @@ -import numpy as np +import jax.numpy as jnp from typing import Tuple import autoarray as aa from autogalaxy.cosmology.lensing import LensingCosmology -from autogalaxy.cosmology.wrap import Planck15 from autogalaxy.profiles.mass.dark.abstract import AbstractgNFW @@ -29,7 +28,6 @@ def __init__( @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -40,11 +38,11 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ - eta = np.multiply( - 1.0 / self.scale_radius, self.radial_grid_from(grid=grid, **kwargs) + eta = jnp.multiply( + 1.0 / self.scale_radius, self.radial_grid_from(grid=grid, **kwargs).array ) - deflection_grid = np.multiply( + deflection_grid = jnp.multiply( (4.0 * self.kappa_s * self.scale_radius / eta), self.deflection_func_sph(grid_radius=eta), ) @@ -53,21 +51,23 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): def deflection_func_sph(self, grid_radius): grid_radius = grid_radius + 0j - return np.real(self.coord_func_m(grid_radius=grid_radius)) + return jnp.real(self.coord_func_m(grid_radius=grid_radius)) def convergence_func(self, grid_radius: float) -> float: grid_radius = ((1.0 / self.scale_radius) * grid_radius) + 0j - return np.real(2.0 * self.kappa_s * self.coord_func_l(grid_radius=grid_radius)) + return jnp.real( + 2.0 * self.kappa_s * self.coord_func_l(grid_radius=grid_radius.array) + ) @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return np.zeros(shape=grid.shape[0]) + return jnp.zeros(shape=grid.shape[0]) def coord_func_k(self, grid_radius): - return np.log( - np.divide( + return jnp.log( + jnp.divide( grid_radius, - np.sqrt(np.square(grid_radius) + np.square(self.tau)) + self.tau, + jnp.sqrt(jnp.square(grid_radius) + jnp.square(self.tau)) + self.tau, ) ) @@ -76,14 +76,14 @@ def coord_func_l(self, grid_radius): g_r = self.coord_func_g(grid_radius=grid_radius) k_r = self.coord_func_k(grid_radius=grid_radius) - return np.divide(self.tau**2.0, (self.tau**2.0 + 1.0) ** 2.0) * ( + return jnp.divide(self.tau**2.0, (self.tau**2.0 + 1.0) ** 2.0) * ( ((self.tau**2.0 + 1.0) * g_r) + (2 * f_r) - - (np.pi / (np.sqrt(self.tau**2.0 + grid_radius**2.0))) + - (jnp.pi / (jnp.sqrt(self.tau**2.0 + grid_radius**2.0))) + ( ( (self.tau**2.0 - 1.0) - / (self.tau * (np.sqrt(self.tau**2.0 + grid_radius**2.0))) + / (self.tau * (jnp.sqrt(self.tau**2.0 + grid_radius**2.0))) ) * k_r ) @@ -95,11 +95,11 @@ def coord_func_m(self, grid_radius): return (self.tau**2.0 / (self.tau**2.0 + 1.0) ** 2.0) * ( ((self.tau**2.0 + 2.0 * grid_radius**2.0 - 1.0) * f_r) - + (np.pi * self.tau) - + ((self.tau**2.0 - 1.0) * np.log(self.tau)) + + (jnp.pi * self.tau) + + ((self.tau**2.0 - 1.0) * jnp.log(self.tau)) + ( - np.sqrt(grid_radius**2.0 + self.tau**2.0) - * (((self.tau**2.0 - 1.0) / self.tau) * k_r - np.pi) + jnp.sqrt(grid_radius**2.0 + self.tau**2.0) + * (((self.tau**2.0 - 1.0) / self.tau) * k_r - jnp.pi) ) ) @@ -108,8 +108,12 @@ def mass_at_truncation_radius_solar_mass( redshift_profile, redshift_source, redshift_of_cosmic_average_density="profile", - cosmology: LensingCosmology = Planck15(), + cosmology: LensingCosmology = None, ): + from autogalaxy.cosmology.wrap import Planck15 + + cosmology = cosmology or Planck15() + mass_at_200 = self.mass_at_200_solar_masses( redshift_object=redshift_profile, redshift_source=redshift_source, @@ -121,8 +125,8 @@ def mass_at_truncation_radius_solar_mass( mass_at_200 * (self.tau**2.0 / (self.tau**2.0 + 1.0) ** 2.0) * ( - ((self.tau**2.0 - 1) * np.log(self.tau)) - + (self.tau * np.pi) + ((self.tau**2.0 - 1) * jnp.log(self.tau)) + + (self.tau * jnp.pi) - (self.tau**2.0 + 1) ) ) diff --git a/autogalaxy/profiles/mass/dark/nfw_virial_mass_conc.py b/autogalaxy/profiles/mass/dark/nfw_virial_mass_conc.py index ef890eead..d11cf8acd 100644 --- a/autogalaxy/profiles/mass/dark/nfw_virial_mass_conc.py +++ b/autogalaxy/profiles/mass/dark/nfw_virial_mass_conc.py @@ -1,92 +1,91 @@ -from typing import Tuple - -from autogalaxy.profiles.mass.dark.nfw import NFWSph - -from astropy import units - -import numpy as np -import warnings - -from autogalaxy.cosmology.wrap import Planck15 - - -def kappa_s_and_scale_radius( - virial_mass, concentration, virial_overdens, redshift_object, redshift_source -): - cosmology = Planck15() - - cosmic_average_density = ( - cosmology.critical_density(redshift_object).to(units.solMass / units.kpc**3) - ).value - - critical_surface_density = ( - cosmology.critical_surface_density_between_redshifts_solar_mass_per_kpc2_from( - redshift_0=redshift_object, redshift_1=redshift_source - ) - ) - - kpc_per_arcsec = cosmology.kpc_per_arcsec_from(redshift=redshift_object) - - virial_radius = ( - virial_mass / (virial_overdens * cosmic_average_density * (4.0 * np.pi / 3.0)) - ) ** ( - 1.0 / 3.0 - ) # r_vir - de_c = ( - virial_overdens - / 3.0 - * ( - concentration**3 - / (np.log(1.0 + concentration) - concentration / (1.0 + concentration)) - ) - ) # rho_c - - scale_radius_kpc = virial_radius / concentration # scale radius in kpc - rho_s = cosmic_average_density * de_c # rho_s - kappa_s = rho_s * scale_radius_kpc / critical_surface_density # kappa_s - scale_radius = scale_radius_kpc / kpc_per_arcsec # scale radius in arcsec - - return kappa_s, scale_radius, virial_radius - - -class NFWVirialMassConcSph(NFWSph): - def __init__( - self, - centre: Tuple[float, float] = (0.0, 0.0), - virial_mass: float = 1e12, - concentration: float = 10, - virial_overdens: float = 200, - redshift_object: float = 0.5, - redshift_source: float = 1.0, - ): - """ - Spherical NFW profile initialized with the mass and concentration of the halo. - - Parameters - ---------- - centre - The (y,x) arc-second coordinates of the profile centre. - virial_mass - The virial mass of the dark matter halo. - concentration - The concentration of the dark matter halo. - virial_overdens - The virial overdensity. - """ - self.virial_mass = virial_mass - self.concentration = concentration - self.virial_overdens = virial_overdens - - ( - kappa_s, - scale_radius, - virial_radius, - ) = kappa_s_and_scale_radius( - virial_mass=virial_mass, - concentration=concentration, - virial_overdens=virial_overdens, - redshift_object=redshift_object, - redshift_source=redshift_source, - ) - - super().__init__(centre=centre, kappa_s=kappa_s, scale_radius=scale_radius) +from typing import Tuple + +from autogalaxy.profiles.mass.dark.nfw import NFWSph + +import numpy as np + + +def kappa_s_and_scale_radius( + virial_mass, concentration, virial_overdens, redshift_object, redshift_source +): + + from astropy import units + from autogalaxy.cosmology.wrap import Planck15 + + cosmology = Planck15() + + cosmic_average_density = ( + cosmology.critical_density(redshift_object).to(units.solMass / units.kpc**3) + ).value + + critical_surface_density = ( + cosmology.critical_surface_density_between_redshifts_solar_mass_per_kpc2_from( + redshift_0=redshift_object, redshift_1=redshift_source + ) + ) + + kpc_per_arcsec = cosmology.kpc_per_arcsec_from(redshift=redshift_object) + + virial_radius = ( + virial_mass / (virial_overdens * cosmic_average_density * (4.0 * np.pi / 3.0)) + ) ** ( + 1.0 / 3.0 + ) # r_vir + de_c = ( + virial_overdens + / 3.0 + * ( + concentration**3 + / (np.log(1.0 + concentration) - concentration / (1.0 + concentration)) + ) + ) # rho_c + + scale_radius_kpc = virial_radius / concentration # scale radius in kpc + rho_s = cosmic_average_density * de_c # rho_s + kappa_s = rho_s * scale_radius_kpc / critical_surface_density # kappa_s + scale_radius = scale_radius_kpc / kpc_per_arcsec # scale radius in arcsec + + return kappa_s, scale_radius, virial_radius + + +class NFWVirialMassConcSph(NFWSph): + def __init__( + self, + centre: Tuple[float, float] = (0.0, 0.0), + virial_mass: float = 1e12, + concentration: float = 10, + virial_overdens: float = 200, + redshift_object: float = 0.5, + redshift_source: float = 1.0, + ): + """ + Spherical NFW profile initialized with the mass and concentration of the halo. + + Parameters + ---------- + centre + The (y,x) arc-second coordinates of the profile centre. + virial_mass + The virial mass of the dark matter halo. + concentration + The concentration of the dark matter halo. + virial_overdens + The virial overdensity. + """ + self.virial_mass = virial_mass + self.concentration = concentration + self.virial_overdens = virial_overdens + + ( + kappa_s, + scale_radius, + virial_radius, + ) = kappa_s_and_scale_radius( + virial_mass=virial_mass, + concentration=concentration, + virial_overdens=virial_overdens, + redshift_object=redshift_object, + redshift_source=redshift_source, + ) + + super().__init__(centre=centre, kappa_s=kappa_s, scale_radius=scale_radius) diff --git a/autogalaxy/profiles/mass/point/point.py b/autogalaxy/profiles/mass/point/point.py index 711db7c25..581484e62 100644 --- a/autogalaxy/profiles/mass/point/point.py +++ b/autogalaxy/profiles/mass/point/point.py @@ -40,7 +40,6 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): grid_radii = self.radial_grid_from(grid=grid, **kwargs) return self._cartesian_grid_via_radial_from( diff --git a/autogalaxy/profiles/mass/point/smbh.py b/autogalaxy/profiles/mass/point/smbh.py index 0a92246bb..40fc054ec 100644 --- a/autogalaxy/profiles/mass/point/smbh.py +++ b/autogalaxy/profiles/mass/point/smbh.py @@ -1,7 +1,6 @@ import numpy as np from typing import Tuple -from autogalaxy.cosmology.wrap import Planck15 from autogalaxy.profiles.mass.point.point import PointMass @@ -30,11 +29,12 @@ def __init__( redshift_source The redshift of the source galaxy, which is used to convert the mass of the SMBH to an Einstein radius. """ - - self.mass = mass + from autogalaxy.cosmology.wrap import Planck15 cosmology = Planck15() + self.mass = mass + critical_surface_density = ( cosmology.critical_surface_density_between_redshifts_from( redshift_0=redshift_object, diff --git a/autogalaxy/profiles/mass/sheets/__init__.py b/autogalaxy/profiles/mass/sheets/__init__.py index 071ad8176..cc554c05a 100644 --- a/autogalaxy/profiles/mass/sheets/__init__.py +++ b/autogalaxy/profiles/mass/sheets/__init__.py @@ -1,3 +1,2 @@ from .mass_sheet import MassSheet from .external_shear import ExternalShear -from .input_deflections import InputDeflections diff --git a/autogalaxy/profiles/mass/sheets/external_shear.py b/autogalaxy/profiles/mass/sheets/external_shear.py index 083c48963..fb71e7bf0 100644 --- a/autogalaxy/profiles/mass/sheets/external_shear.py +++ b/autogalaxy/profiles/mass/sheets/external_shear.py @@ -1,4 +1,4 @@ -import numpy as np +import jax.numpy as jnp import autoarray as aa @@ -40,23 +40,22 @@ def average_convergence_of_1_radius(self): @aa.grid_dec.to_array def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return np.zeros(shape=grid.shape[0]) + return jnp.zeros(shape=grid.shape[0]) @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): shear_angle = ( self.angle - 90 ) ##to be onsistent with autolens deflection angle calculation - phig = np.deg2rad(shear_angle) + phig = jnp.deg2rad(shear_angle) shear_amp = self.magnitude - phicoord = np.arctan2(grid[:, 0], grid[:, 1]) - rcoord = np.sqrt(grid[:, 0] ** 2.0 + grid[:, 1] ** 2.0) + phicoord = jnp.arctan2(grid.array[:, 0], grid.array[:, 1]) + rcoord = jnp.sqrt(grid.array[:, 0] ** 2.0 + grid.array[:, 1] ** 2.0) - return -0.5 * shear_amp * rcoord**2 * np.cos(2 * (phicoord - phig)) + return -0.5 * shear_amp * rcoord**2 * jnp.cos(2 * (phicoord - phig)) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -67,8 +66,8 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ - deflection_y = -np.multiply(self.magnitude, grid[:, 0]) - deflection_x = np.multiply(self.magnitude, grid[:, 1]) + deflection_y = -jnp.multiply(self.magnitude, grid.array[:, 0]) + deflection_x = jnp.multiply(self.magnitude, grid.array[:, 1]) return self.rotated_grid_from_reference_frame_from( - np.vstack((deflection_y, deflection_x)).T + jnp.vstack((deflection_y, deflection_x)).T ) diff --git a/autogalaxy/profiles/mass/sheets/input_deflections.py b/autogalaxy/profiles/mass/sheets/input_deflections.py deleted file mode 100644 index a9f050b4a..000000000 --- a/autogalaxy/profiles/mass/sheets/input_deflections.py +++ /dev/null @@ -1,118 +0,0 @@ -import numpy as np -from scipy.interpolate import griddata - -import autoarray as aa - -from autogalaxy.profiles.mass.abstract.abstract import MassProfile - -from autogalaxy import exc - - -class InputDeflections(MassProfile): - def __init__( - self, - deflections_y: aa.Array2D, - deflections_x: aa.Array2D, - image_plane_grid: aa.type.Grid2DLike, - preload_grid=None, - preload_blurring_grid=None, - # normalization_scale: float = 1.0, - ): - """ - Represents a known deflection angle map (e.g. from an already performed lens model or particle simulation - of a mass distribution) which can be used for model fitting. - - The image-plane grid of the delflection angles is used to align an input grid to the input deflections, so that - a new deflection angle map can be computed via interpolation using the scipy.interpolate.griddata method. - - A normalization scale can be included, which scales the overall normalization of the deflection angle map - interpolated by a multiplicative factor. - - Parameters - ---------- - deflections_y : aa.Array2D - The input array of the y components of the deflection angles. - deflections_x : aa.Array2D - The input array of the x components of the deflection angles. - image_plane_grid - The image-plane grid from which the deflection angles are defined. - grid_interp : aa.Grid2D - The grid that interpolated quantities are computed on. If this is input in advance, the interpolation - weight_list can be precomputed to speed up the calculation time. - normalization_scale - The calculated deflection angles are multiplied by this factor scaling their values up and doown. - """ - super().__init__() - - self.deflections_y = deflections_y - self.deflections_x = deflections_x - - self.image_plane_grid = image_plane_grid - - self.centre = image_plane_grid.origin - - self.preload_grid = preload_grid - self.preload_deflections = None - self.preload_blurring_grid = preload_blurring_grid - self.preload_blurring_deflections = None - - if self.preload_grid is not None: - self.normalization_scale = 1.0 - self.preload_deflections = self.deflections_yx_2d_from(grid=preload_grid) - - if self.preload_blurring_grid is not None: - self.normalization_scale = 1.0 - self.preload_blurring_deflections = self.deflections_yx_2d_from( - grid=preload_blurring_grid - ) - - self.normalization_scale = 1.0 # normalization_scale - - @aa.grid_dec.to_array - def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return self.convergence_2d_via_jacobian_from(grid=grid, **kwargs) - - @aa.grid_dec.to_array - def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return np.zeros(shape=grid.shape[0]) - - @aa.grid_dec.to_vector_yx - def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - if self.preload_grid is not None and self.preload_deflections is not None: - try: - if grid.shape_slim == self.preload_grid.shape_slim: - if np.allclose(grid, self.preload_grid, 1e-8): - return self.normalization_scale * self.preload_deflections - except AttributeError: - pass - - if ( - self.preload_blurring_grid is not None - and self.preload_blurring_deflections is not None - ): - try: - if grid.shape_slim == self.preload_blurring_grid.shape_slim: - if np.allclose(grid, self.preload_blurring_grid, 1e-8): - return ( - self.normalization_scale * self.preload_blurring_deflections - ) - except AttributeError: - pass - - deflections_y = self.normalization_scale * griddata( - points=self.image_plane_grid, values=self.deflections_y, xi=grid - ) - deflections_x = self.normalization_scale * griddata( - points=self.image_plane_grid, values=self.deflections_x, xi=grid - ) - - if np.isnan(deflections_y).any() or np.isnan(deflections_x).any(): - raise exc.ProfileException( - "The grid input into the DefectionsInput.deflections_yx_2d_from() method has (y,x)" - "coodinates extending beyond the input image_plane_grid." - "" - "Update the image_plane_grid to include deflection angles reaching to larger" - "radii or reduce the input grid. " - ) - - return np.stack((deflections_y, deflections_x), axis=-1) diff --git a/autogalaxy/profiles/mass/sheets/mass_sheet.py b/autogalaxy/profiles/mass/sheets/mass_sheet.py index ed9c1144a..b4c1414f4 100644 --- a/autogalaxy/profiles/mass/sheets/mass_sheet.py +++ b/autogalaxy/profiles/mass/sheets/mass_sheet.py @@ -1,3 +1,4 @@ +import jax.numpy as jnp import numpy as np from typing import Tuple @@ -26,15 +27,14 @@ def convergence_func(self, grid_radius: float) -> float: @aa.grid_dec.to_array def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return np.full(shape=grid.shape[0], fill_value=self.kappa) + return jnp.full(shape=grid.shape[0], fill_value=self.kappa) @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return np.zeros(shape=grid.shape[0]) + return jnp.zeros(shape=grid.shape[0]) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): grid_radii = self.radial_grid_from(grid=grid, **kwargs) return self._cartesian_grid_via_radial_from( diff --git a/autogalaxy/profiles/mass/stellar/chameleon.py b/autogalaxy/profiles/mass/stellar/chameleon.py index 580b94ad4..00a35a123 100644 --- a/autogalaxy/profiles/mass/stellar/chameleon.py +++ b/autogalaxy/profiles/mass/stellar/chameleon.py @@ -1,4 +1,4 @@ -import copy +import jax.numpy as jnp import numpy as np from typing import Tuple @@ -53,7 +53,6 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_analytic_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -72,13 +71,13 @@ def deflections_2d_via_analytic_from(self, grid: aa.type.Grid2DLike, **kwargs): * self.intensity / (1 + self.axis_ratio) * self.axis_ratio - / np.sqrt(1.0 - self.axis_ratio**2.0) + / jnp.sqrt(1.0 - self.axis_ratio**2.0) ) - core_radius_0 = np.sqrt( + core_radius_0 = jnp.sqrt( (4.0 * self.core_radius_0**2.0) / (1.0 + self.axis_ratio) ** 2 ) - core_radius_1 = np.sqrt( + core_radius_1 = jnp.sqrt( (4.0 * self.core_radius_1**2.0) / (1.0 + self.axis_ratio) ** 2 ) @@ -89,45 +88,44 @@ def deflections_2d_via_analytic_from(self, grid: aa.type.Grid2DLike, **kwargs): grid=grid, axis_ratio=self.axis_ratio, core_radius=core_radius_1 ) - deflection_y0 = np.arctanh( - np.divide( - np.multiply(np.sqrt(1.0 - self.axis_ratio**2.0), grid[:, 0]), - np.add(psi0, self.axis_ratio**2.0 * core_radius_0), + deflection_y0 = jnp.arctanh( + jnp.divide( + jnp.multiply(jnp.sqrt(1.0 - self.axis_ratio**2.0), grid.array[:, 0]), + jnp.add(psi0, self.axis_ratio**2.0 * core_radius_0), ) ) - deflection_x0 = np.arctan( - np.divide( - np.multiply(np.sqrt(1.0 - self.axis_ratio**2.0), grid[:, 1]), - np.add(psi0, core_radius_0), + deflection_x0 = jnp.arctan( + jnp.divide( + jnp.multiply(jnp.sqrt(1.0 - self.axis_ratio**2.0), grid.array[:, 1]), + jnp.add(psi0, core_radius_0), ) ) - deflection_y1 = np.arctanh( - np.divide( - np.multiply(np.sqrt(1.0 - self.axis_ratio**2.0), grid[:, 0]), - np.add(psi1, self.axis_ratio**2.0 * core_radius_1), + deflection_y1 = jnp.arctanh( + jnp.divide( + jnp.multiply(jnp.sqrt(1.0 - self.axis_ratio**2.0), grid.array[:, 0]), + jnp.add(psi1, self.axis_ratio**2.0 * core_radius_1), ) ) - deflection_x1 = np.arctan( - np.divide( - np.multiply(np.sqrt(1.0 - self.axis_ratio**2.0), grid[:, 1]), - np.add(psi1, core_radius_1), + deflection_x1 = jnp.arctan( + jnp.divide( + jnp.multiply(jnp.sqrt(1.0 - self.axis_ratio**2.0), grid.array[:, 1]), + jnp.add(psi1, core_radius_1), ) ) - deflection_y = np.subtract(deflection_y0, deflection_y1) - deflection_x = np.subtract(deflection_x0, deflection_x1) + deflection_y = jnp.subtract(deflection_y0, deflection_y1) + deflection_x = jnp.subtract(deflection_x0, deflection_x1) return self.rotated_grid_from_reference_frame_from( - np.multiply(factor, np.vstack((deflection_y, deflection_x)).T) + jnp.multiply(factor, jnp.vstack((deflection_y, deflection_x)).T) ) @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """Calculate the projected convergence at a given set of arc-second gridded coordinates. Parameters @@ -144,7 +142,7 @@ def convergence_func(self, grid_radius: float) -> float: @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return np.zeros(shape=grid.shape[0]) + return jnp.zeros(shape=grid.shape[0]) def image_2d_via_radii_from(self, grid_radii: np.ndarray): """Calculate the intensity of the Chamelon light profile on a grid of radial coordinates. @@ -157,23 +155,23 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray): axis_ratio_factor = (1.0 + self.axis_ratio) ** 2.0 - return np.multiply( + return jnp.multiply( self.intensity / (1 + self.axis_ratio), - np.add( - np.divide( + jnp.add( + jnp.divide( 1.0, - np.sqrt( - np.add( - np.square(grid_radii), + jnp.sqrt( + jnp.add( + jnp.square(grid_radii.array), (4.0 * self.core_radius_0**2.0) / axis_ratio_factor, ) ), ), - -np.divide( + -jnp.divide( 1.0, - np.sqrt( - np.add( - np.square(grid_radii), + jnp.sqrt( + jnp.add( + jnp.square(grid_radii.array), (4.0 * self.core_radius_1**2.0) / axis_ratio_factor, ) ), diff --git a/autogalaxy/profiles/mass/stellar/gaussian.py b/autogalaxy/profiles/mass/stellar/gaussian.py index 42fa8d540..433ebbba1 100644 --- a/autogalaxy/profiles/mass/stellar/gaussian.py +++ b/autogalaxy/profiles/mass/stellar/gaussian.py @@ -1,7 +1,9 @@ -import copy import numpy as np -from scipy.special import wofz -from scipy.integrate import quad +from autofit.jax_wrapper import use_jax + +if use_jax: + import jax + from typing import Tuple import autoarray as aa @@ -59,7 +61,6 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_analytic_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -87,7 +88,6 @@ def deflections_2d_via_analytic_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -100,9 +100,10 @@ def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): Note: sigma is divided by sqrt(q) here. """ + from scipy.integrate import quad def calculate_deflection_component(npow, index): - deflection_grid = self.axis_ratio * grid[:, index] + deflection_grid = np.array(self.axis_ratio * grid.array[:, index]) for i in range(grid.shape[0]): deflection_grid[i] *= ( @@ -113,8 +114,8 @@ def calculate_deflection_component(npow, index): a=0.0, b=1.0, args=( - grid[i, 0], - grid[i, 1], + grid.array[i, 0], + grid.array[i, 1], npow, self.axis_ratio, self.sigma / np.sqrt(self.axis_ratio), @@ -144,7 +145,6 @@ def deflection_func(u, y, x, npow, axis_ratio, sigma): @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """Calculate the projected convergence at a given set of arc-second gridded coordinates. @@ -180,7 +180,7 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray): np.exp( -0.5 * np.square( - np.divide(grid_radii, self.sigma / np.sqrt(self.axis_ratio)) + np.divide(grid_radii.array, self.sigma / np.sqrt(self.axis_ratio)) ) ), ) @@ -188,19 +188,25 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray): @property def axis_ratio(self): axis_ratio = super().axis_ratio - return axis_ratio if axis_ratio < 0.9999 else 0.9999 + if use_jax: + return jax.lax.select(axis_ratio < 0.9999, axis_ratio, 0.9999) + else: + return axis_ratio if axis_ratio < 0.9999 else 0.9999 def zeta_from(self, grid: aa.type.Grid2DLike): + + from scipy.special import wofz + q2 = self.axis_ratio**2.0 - ind_pos_y = grid[:, 0] >= 0 + ind_pos_y = grid.array[:, 0] >= 0 shape_grid = np.shape(grid) output_grid = np.zeros((shape_grid[0]), dtype=np.complex128) scale_factor = self.axis_ratio / (self.sigma * np.sqrt(2.0 * (1.0 - q2))) - xs_0 = grid[:, 1][ind_pos_y] * scale_factor - ys_0 = grid[:, 0][ind_pos_y] * scale_factor - xs_1 = grid[:, 1][~ind_pos_y] * scale_factor - ys_1 = -grid[:, 0][~ind_pos_y] * scale_factor + xs_0 = grid.array[:, 1][ind_pos_y] * scale_factor + ys_0 = grid.array[:, 0][ind_pos_y] * scale_factor + xs_1 = grid.array[:, 1][~ind_pos_y] * scale_factor + ys_1 = -grid.array[:, 0][~ind_pos_y] * scale_factor output_grid[ind_pos_y] = -1j * ( wofz(xs_0 + 1j * ys_0) diff --git a/autogalaxy/profiles/mass/stellar/sersic.py b/autogalaxy/profiles/mass/stellar/sersic.py index 0d0b8ec97..093f8d68c 100644 --- a/autogalaxy/profiles/mass/stellar/sersic.py +++ b/autogalaxy/profiles/mass/stellar/sersic.py @@ -1,12 +1,11 @@ -import copy import numpy as np -from scipy.integrate import quad + from typing import List, Tuple import autoarray as aa from autogalaxy.profiles.mass.abstract.abstract import MassProfile -from autogalaxy.profiles.mass.abstract.mge import ( +from autogalaxy.profiles.mass.abstract.mge_numpy import ( MassProfileMGE, ) from autogalaxy.profiles.mass.abstract.cse import ( @@ -129,8 +128,9 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum - def deflections_2d_via_mge_from(self, grid: aa.type.Grid2DLike, **kwargs): + def deflections_2d_via_mge_from( + self, grid: aa.type.Grid2DLike, func_terms=28, func_gaussians=20, **kwargs + ): """ Calculate the projected 2D deflection angles from a grid of (y,x) arc second coordinates, by computing and summing the convergence of each individual cse used to decompose the mass profile. @@ -145,12 +145,14 @@ def deflections_2d_via_mge_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the convergence is computed on. """ return self._deflections_2d_via_mge_from( - grid=grid, sigmas_factor=np.sqrt(self.axis_ratio) + grid=grid, + sigmas_factor=np.sqrt(self.axis_ratio), + func_terms=func_terms, + func_gaussians=func_gaussians, ) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_cse_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the projected 2D deflection angles from a grid of (y,x) arc second coordinates, by computing and @@ -170,7 +172,6 @@ def deflections_2d_via_cse_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """Calculate the projected convergence at a given set of arc-second gridded coordinates. @@ -187,8 +188,9 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum - def convergence_2d_via_mge_from(self, grid: aa.type.Grid2DLike, **kwargs): + def convergence_2d_via_mge_from( + self, grid: aa.type.Grid2DLike, func_terms=28, func_gaussians=20, **kwargs + ): """ Calculate the projected convergence at a given set of arc-second gridded coordinates. @@ -201,12 +203,15 @@ def convergence_2d_via_mge_from(self, grid: aa.type.Grid2DLike, **kwargs): eccentric_radii = self.eccentric_radii_grid_from(grid=grid, **kwargs) - return self._convergence_2d_via_mge_from(grid_radii=eccentric_radii) + return self._convergence_2d_via_mge_from( + grid_radii=eccentric_radii, + func_terms=func_terms, + func_gaussians=func_gaussians, + ) @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_via_cse_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the projected 2D convergence from a grid of (y,x) arc second coordinates, by computing and summing @@ -244,10 +249,15 @@ def image_2d_via_radii_from(self, radius: np.ndarray): """ return self.intensity * np.exp( -self.sersic_constant - * (((radius / self.effective_radius) ** (1.0 / self.sersic_index)) - 1) + * ( + ((radius.array / self.effective_radius) ** (1.0 / self.sersic_index)) + - 1 + ) ) - def decompose_convergence_via_mge(self) -> Tuple[List, List]: + def decompose_convergence_via_mge( + self, func_terms=28, func_gaussians=20 + ) -> Tuple[List, List]: radii_min = self.effective_radius / 100.0 radii_max = self.effective_radius * 20.0 @@ -262,7 +272,11 @@ def sersic_2d(r): ) return self._decompose_convergence_via_mge( - func=sersic_2d, radii_min=radii_min, radii_max=radii_max + func=sersic_2d, + radii_min=radii_min, + radii_max=radii_max, + func_terms=func_terms, + func_gaussians=func_gaussians, ) def decompose_convergence_via_cse( @@ -359,7 +373,6 @@ def elliptical_effective_radius(self): class Sersic(AbstractSersic, MassProfileMGE, MassProfileCSE): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -370,14 +383,15 @@ def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ + from scipy.integrate import quad def calculate_deflection_component(npow, index): sersic_constant = self.sersic_constant - deflection_grid = self.axis_ratio * grid[:, index] + deflection_grid = self.axis_ratio * grid.array[:, index] for i in range(grid.shape[0]): - deflection_grid[i] *= ( + deflection_grid = deflection_grid.at[i].multiply( self.intensity * self.mass_to_light_ratio * quad( @@ -385,8 +399,8 @@ def calculate_deflection_component(npow, index): a=0.0, b=1.0, args=( - grid[i, 0], - grid[i, 1], + grid.array[i, 0], + grid.array[i, 1], npow, self.axis_ratio, self.sersic_index, diff --git a/autogalaxy/profiles/mass/stellar/sersic_core.py b/autogalaxy/profiles/mass/stellar/sersic_core.py index 3f1c2abda..496e4f7f4 100644 --- a/autogalaxy/profiles/mass/stellar/sersic_core.py +++ b/autogalaxy/profiles/mass/stellar/sersic_core.py @@ -1,3 +1,4 @@ +import jax.numpy as jnp import numpy as np from typing import Tuple @@ -71,25 +72,27 @@ def image_2d_via_radii_from(self, grid_radii: np.ndarray): grid_radii The radial distance from the centre of the profile. for each coordinate on the grid. """ - return np.multiply( - np.multiply( + return jnp.multiply( + jnp.multiply( self.intensity_prime, - np.power( - np.add( + jnp.power( + jnp.add( 1, - np.power(np.divide(self.radius_break, grid_radii), self.alpha), + jnp.power( + jnp.divide(self.radius_break, grid_radii.array), self.alpha + ), ), (self.gamma / self.alpha), ), ), - np.exp( - np.multiply( + jnp.exp( + jnp.multiply( -self.sersic_constant, ( - np.power( - np.divide( - np.add( - np.power(grid_radii, self.alpha), + jnp.power( + jnp.divide( + jnp.add( + jnp.power(grid_radii.array, self.alpha), (self.radius_break**self.alpha), ), (self.effective_radius**self.alpha), @@ -131,7 +134,7 @@ def intensity_prime(self): return ( self.intensity * (2.0 ** (-self.gamma / self.alpha)) - * np.exp( + * jnp.exp( self.sersic_constant * ( ((2.0 ** (1.0 / self.alpha)) * self.radius_break) diff --git a/autogalaxy/profiles/mass/stellar/sersic_gradient.py b/autogalaxy/profiles/mass/stellar/sersic_gradient.py index 3b2495548..92c07fd0d 100644 --- a/autogalaxy/profiles/mass/stellar/sersic_gradient.py +++ b/autogalaxy/profiles/mass/stellar/sersic_gradient.py @@ -1,5 +1,4 @@ import numpy as np -from scipy.integrate import quad from typing import List, Tuple import autoarray as aa @@ -52,7 +51,6 @@ def __init__( @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles at a given set of arc-second gridded coordinates. @@ -63,11 +61,12 @@ def deflections_2d_via_integral_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ + from scipy.integrate import quad def calculate_deflection_component(npow, index): sersic_constant = self.sersic_constant - deflection_grid = self.axis_ratio * grid[:, index] + deflection_grid = np.array(self.axis_ratio * grid.array[:, index]) for i in range(grid.shape[0]): deflection_grid[i] *= ( @@ -78,8 +77,8 @@ def calculate_deflection_component(npow, index): a=0.0, b=1.0, args=( - grid[i, 0], - grid[i, 1], + grid.array[i, 0], + grid.array[i, 1], npow, self.axis_ratio, self.sersic_index, @@ -126,7 +125,6 @@ def deflection_func( @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """Calculate the projected convergence at a given set of arc-second gridded coordinates. @@ -150,7 +148,7 @@ def convergence_func(self, grid_radius: float) -> float: * self.image_2d_via_radii_from(grid_radius) ) - def decompose_convergence_via_mge(self): + def decompose_convergence_via_mge(self, **kwargs): radii_min = self.effective_radius / 100.0 radii_max = self.effective_radius * 20.0 diff --git a/autogalaxy/profiles/mass/total/dual_pseudo_isothermal.py b/autogalaxy/profiles/mass/total/dual_pseudo_isothermal.py index 0b0855de4..dd29d739d 100644 --- a/autogalaxy/profiles/mass/total/dual_pseudo_isothermal.py +++ b/autogalaxy/profiles/mass/total/dual_pseudo_isothermal.py @@ -1,5 +1,5 @@ from typing import Tuple -import numpy as np +import jax.numpy as jnp import autoarray as aa from autogalaxy.profiles.mass.abstract.abstract import MassProfile @@ -60,7 +60,7 @@ def __init__( self.kappa_scale = kappa_scale def _ellip(self): - ellip = np.sqrt(self.ell_comps[0] ** 2 + self.ell_comps[1] ** 2) + ellip = jnp.sqrt(self.ell_comps[0] ** 2 + self.ell_comps[1] ** 2) MAX_ELLIP = 0.99999 return min(ellip, MAX_ELLIP) @@ -71,8 +71,8 @@ def _deflection_angle(self, radii): r_ra = radii / self.ra r_rs = radii / self.rs # c.f. Eliasdottir '07 eq. A20 - f = r_ra / (1 + np.sqrt(1 + r_ra * r_ra)) - r_rs / ( - 1 + np.sqrt(1 + r_rs * r_rs) + f = r_ra / (1 + jnp.sqrt(1 + r_ra * r_ra)) - r_rs / ( + 1 + jnp.sqrt(1 + r_rs * r_rs) ) ra, rs = self.ra, self.rs @@ -89,12 +89,11 @@ def _convergence(self, radii): self.kappa_scale * (a * s) / (s - a) - * (1 / np.sqrt(a**2 + radsq) - 1 / np.sqrt(s**2 + radsq)) + * (1 / jnp.sqrt(a**2 + radsq) - 1 / jnp.sqrt(s**2 + radsq)) ) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles on a grid of (y,x) arc-second coordinates. @@ -105,25 +104,28 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ ellip = self._ellip() - grid_radii = np.sqrt( - grid[:, 1] ** 2 * (1 - ellip) + grid[:, 0] ** 2 * (1 + ellip) + grid_radii = jnp.sqrt( + grid.array[:, 1] ** 2 * (1 - ellip) + grid.array[:, 0] ** 2 * (1 + ellip) ) # Compute the deflection magnitude of a *non-elliptical* profile alpha_circ = self._deflection_angle(grid_radii) # This is in axes aligned to the major/minor axis - deflection_y = alpha_circ * np.sqrt(1 + ellip) * (grid[:, 0] / grid_radii) - deflection_x = alpha_circ * np.sqrt(1 - ellip) * (grid[:, 1] / grid_radii) + deflection_y = ( + alpha_circ * jnp.sqrt(1 + ellip) * (grid.array[:, 0] / grid_radii) + ) + deflection_x = ( + alpha_circ * jnp.sqrt(1 - ellip) * (grid.array[:, 1] / grid_radii) + ) # And here we convert back to the real axes return self.rotated_grid_from_reference_frame_from( - grid=np.multiply(1.0, np.vstack((deflection_y, deflection_x)).T), **kwargs + grid=jnp.multiply(1.0, jnp.vstack((deflection_y, deflection_x)).T), **kwargs ) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Returns the two dimensional projected convergence on a grid of (y,x) arc-second coordinates. @@ -137,8 +139,8 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the convergence is computed on. """ ellip = self._ellip() - grid_radii = np.sqrt( - grid[:, 1] ** 2 * (1 - ellip) + grid[:, 0] ** 2 * (1 + ellip) + grid_radii = jnp.sqrt( + grid.array[:, 1] ** 2 * (1 - ellip) + grid.array[:, 0] ** 2 * (1 + ellip) ) # Compute the convergence and deflection of a *circular* profile @@ -146,8 +148,8 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): alpha_circ = self._deflection_angle(grid_radii) asymm_term = ( - ellip * (1 - ellip) * grid[:, 1] ** 2 - - ellip * (1 + ellip) * grid[:, 0] ** 2 + ellip * (1 - ellip) * grid.array[:, 1] ** 2 + - ellip * (1 + ellip) * grid.array[:, 0] ** 2 ) / grid_radii**2 # convergence = 1/2 \nabla \alpha = 1/2 \nabla^2 potential @@ -157,7 +159,7 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return np.zeros(shape=grid.shape[0]) + return jnp.zeros(shape=grid.shape[0]) class dPIESph(dPIE): @@ -217,7 +219,6 @@ def __init__( @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles on a grid of (y,x) arc-second coordinates. @@ -229,17 +230,16 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ radii = self.radial_grid_from(grid=grid, **kwargs) - alpha = self._deflection_angle(radii) + alpha = self._deflection_angle(radii.array) # now we decompose the deflection into y/x components - defl_y = alpha * grid[:, 0] / radii - defl_x = alpha * grid[:, 1] / radii + defl_y = alpha * grid.array[:, 0] / radii.array + defl_x = alpha * grid.array[:, 1] / radii.array return aa.Grid2DIrregular.from_yx_1d(defl_y, defl_x) @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Returns the two dimensional projected convergence on a grid of (y,x) arc-second coordinates. @@ -253,10 +253,10 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the convergence is computed on. """ # already transformed to center on profile centre so this works - radsq = grid[:, 0] ** 2 + grid[:, 1] ** 2 + radsq = grid.array[:, 0] ** 2 + grid.array[:, 1] ** 2 - return self._convergence(np.sqrt(radsq)) + return self._convergence(jnp.sqrt(radsq)) @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return np.zeros(shape=grid.shape[0]) + return jnp.zeros(shape=grid.shape[0]) diff --git a/autogalaxy/profiles/mass/total/isothermal.py b/autogalaxy/profiles/mass/total/isothermal.py index f1329c53c..2b0cd5004 100644 --- a/autogalaxy/profiles/mass/total/isothermal.py +++ b/autogalaxy/profiles/mass/total/isothermal.py @@ -1,4 +1,5 @@ -import numpy as np +import jax.numpy as jnp + from typing import Tuple import autoarray as aa @@ -30,13 +31,10 @@ def psi_from(grid, axis_ratio, core_radius): The value of the Psi term. """ - return np.sqrt( - np.add( - np.multiply( - axis_ratio**2.0, np.add(np.square(grid[:, 1]), core_radius**2.0) - ), - np.square(grid[:, 0]), - ) + return jnp.sqrt( + (axis_ratio**2.0 * (grid.array[:, 1] ** 2.0 + core_radius**2.0)) + + grid.array[:, 0] ** 2.0 + + 1e-16 ) @@ -71,11 +69,10 @@ def __init__( @property def axis_ratio(self): axis_ratio = super().axis_ratio - return min(axis_ratio, 0.99999) + return jnp.minimum(axis_ratio, 0.99999) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles on a grid of (y,x) arc-second coordinates. @@ -93,25 +90,28 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): 2.0 * self.einstein_radius_rescaled * self.axis_ratio - / np.sqrt(1 - self.axis_ratio**2) + / jnp.sqrt(1 - self.axis_ratio**2) ) psi = psi_from(grid=grid, axis_ratio=self.axis_ratio, core_radius=0.0) - deflection_y = np.arctanh( - np.divide(np.multiply(np.sqrt(1 - self.axis_ratio**2), grid[:, 0]), psi) + deflection_y = jnp.arctanh( + jnp.divide( + jnp.multiply(jnp.sqrt(1 - self.axis_ratio**2), grid.array[:, 0]), psi + ) ) - deflection_x = np.arctan( - np.divide(np.multiply(np.sqrt(1 - self.axis_ratio**2), grid[:, 1]), psi) + deflection_x = jnp.arctan( + jnp.divide( + jnp.multiply(jnp.sqrt(1 - self.axis_ratio**2), grid.array[:, 1]), psi + ) ) return self.rotated_grid_from_reference_frame_from( - grid=np.multiply(factor, np.vstack((deflection_y, deflection_x)).T), + grid=jnp.multiply(factor, jnp.vstack((deflection_y, deflection_x)).T), **kwargs, ) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def shear_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the (gamma_y, gamma_x) shear vector field on a grid of (y,x) arc-second coordinates. @@ -133,15 +133,19 @@ def shear_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): gamma_2 = ( -2 - * convergence - * np.divide(grid[:, 1] * grid[:, 0], grid[:, 1] ** 2 + grid[:, 0] ** 2) + * convergence.array + * jnp.divide( + grid.array[:, 1] * grid.array[:, 0], + grid.array[:, 1] ** 2 + grid.array[:, 0] ** 2, + ) ) - gamma_1 = -convergence * np.divide( - grid[:, 1] ** 2 - grid[:, 0] ** 2, grid[:, 1] ** 2 + grid[:, 0] ** 2 + gamma_1 = -convergence.array * jnp.divide( + grid.array[:, 1] ** 2 - grid.array[:, 0] ** 2, + grid.array[:, 1] ** 2 + grid.array[:, 0] ** 2, ) shear_field = self.rotated_grid_from_reference_frame_from( - grid=np.vstack((gamma_2, gamma_1)).T, angle=self.angle * 2 + grid=jnp.vstack((gamma_2, gamma_1)).T, angle=self.angle * 2 ) return aa.VectorYX2DIrregular(values=shear_field, grid=grid) @@ -173,7 +177,6 @@ def axis_ratio(self): @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the potential on a grid of (y,x) arc-second coordinates. @@ -188,7 +191,6 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles on a grid of (y,x) arc-second coordinates. @@ -200,6 +202,6 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ return self._cartesian_grid_via_radial_from( grid=grid, - radius=np.full(grid.shape[0], 2.0 * self.einstein_radius_rescaled), + radius=jnp.full(grid.shape[0], 2.0 * self.einstein_radius_rescaled), **kwargs, ) diff --git a/autogalaxy/profiles/mass/total/jax_utils.py b/autogalaxy/profiles/mass/total/jax_utils.py new file mode 100644 index 000000000..5237f34cd --- /dev/null +++ b/autogalaxy/profiles/mass/total/jax_utils.py @@ -0,0 +1,47 @@ +import jax +import jax.numpy as jnp +from jax.tree_util import Partial as partial + + +# A version of scan that will *not* re-compile partial functions when variables change +# taken from https://github.com/google/jax/issues/14743#issuecomment-1456900634 +scan = jax.jit(jax.lax.scan, static_argnames=("length", "reverse", "unroll")) + + +def body_fun(carry, n, factor, ei2phi, slope): + omega_nm1, partial_sum = carry + two_n = 2 * n + two_minus_slope = 2 - slope + ratio = (two_n - two_minus_slope) / (two_n + two_minus_slope) + omega_n = -factor * ratio * ei2phi * omega_nm1 + partial_sum = partial_sum + omega_n + return (omega_n, partial_sum), None + + +def omega(eiphi, slope, factor, n_terms=20): + """JAX implementation of the numerical evaluation of the angular component of + the complex deflection angle for the elliptical power law profile as given as + given by Tessore and Metcalf 2015. Based on equation 29, and gives + omega (e.g. can be used as a drop in replacement for the exp(i * phi) * special.hyp2f1 + term in equation 13). + + Parameters + ---------- + eiphi: + `exp(i * phi)` where `phi` is the elliptical angle of the profile + slope: + The density slope of the power-law (lower value -> shallower profile, higher value + -> steeper profile). + factor: + The second flattening of and ellipse with axis ration q give by `f = (1 - q) / (1 + q)` + n_terms: + The number of terms to calculate for the series expansion, defaults to 20 (this should + be sufficient most of the time) + """ + # use modified scan with a partial'ed function to avoid re-compile + (_, partial_sum), _ = scan( + partial(body_fun, factor=factor, ei2phi=eiphi**2, slope=slope), + (eiphi, eiphi), + jnp.arange(1, n_terms), + ) + return partial_sum diff --git a/autogalaxy/profiles/mass/total/power_law.py b/autogalaxy/profiles/mass/total/power_law.py index 9fc619e15..829189acb 100644 --- a/autogalaxy/profiles/mass/total/power_law.py +++ b/autogalaxy/profiles/mass/total/power_law.py @@ -1,5 +1,6 @@ -import numpy as np -from scipy import special +import jax.numpy as jnp +from .jax_utils import omega + from typing import Tuple import autoarray as aa @@ -45,14 +46,13 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): alpha_x = alpha[:, 1] alpha_y = alpha[:, 0] - x = grid[:, 1] - self.centre[1] - y = grid[:, 0] - self.centre[0] + x = grid.array[:, 1] - self.centre[1] + y = grid.array[:, 0] - self.centre[0] return (x * alpha_x + y * alpha_y) / (3 - self.slope) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles on a grid of (y,x) arc-second coordinates. @@ -74,25 +74,22 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): 2.0 / (self.axis_ratio**-0.5 + self.axis_ratio**0.5) ) * self.einstein_radius - factor = np.divide(1.0 - self.axis_ratio, 1.0 + self.axis_ratio) - b = np.multiply(einstein_radius, np.sqrt(self.axis_ratio)) - angle = np.arctan2( - grid[:, 0], np.multiply(self.axis_ratio, grid[:, 1]) + factor = jnp.divide(1.0 - self.axis_ratio, 1.0 + self.axis_ratio) + b = jnp.multiply(einstein_radius, jnp.sqrt(self.axis_ratio)) + angle = jnp.arctan2( + grid.array[:, 0], jnp.multiply(self.axis_ratio, grid.array[:, 1]) ) # Note, this angle is not the position angle - R = np.sqrt( - np.add(np.multiply(self.axis_ratio**2, grid[:, 1] ** 2), grid[:, 0] ** 2) + z = jnp.add( + jnp.multiply(jnp.cos(angle), 1 + 0j), jnp.multiply(jnp.sin(angle), 0 + 1j) ) - z = np.add( - np.multiply(np.cos(angle), 1 + 0j), np.multiply(np.sin(angle), 0 + 1j) + + R = jnp.sqrt( + (self.axis_ratio * grid.array[:, 1]) ** 2 + grid.array[:, 0] ** 2 + 1e-16 ) + zh = omega(z, slope, factor, n_terms=20) complex_angle = ( - 2.0 - * b - / (1.0 + self.axis_ratio) - * (b / R) ** (slope - 1.0) - * z - * special.hyp2f1(1.0, 0.5 * slope, 2.0 - 0.5 * slope, -factor * z**2) + 2.0 * b / (1.0 + self.axis_ratio) * (b / R) ** (slope - 1.0) * zh ) deflection_y = complex_angle.imag @@ -104,17 +101,15 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): deflection_x *= rescale_factor return self.rotated_grid_from_reference_frame_from( - grid=np.vstack((deflection_y, deflection_x)).T + grid=jnp.vstack((deflection_y, deflection_x)).T ) def convergence_func(self, grid_radius: float) -> float: - if grid_radius > 0.0: - return self.einstein_radius_rescaled * grid_radius ** (-(self.slope - 1)) - return np.inf + return self.einstein_radius_rescaled * grid_radius.array ** (-(self.slope - 1)) @staticmethod def potential_func(u, y, x, axis_ratio, slope, core_radius): - _eta_u = np.sqrt((u * ((x**2) + (y**2 / (1 - (1 - axis_ratio**2) * u))))) + _eta_u = jnp.sqrt((u * ((x**2) + (y**2 / (1 - (1 - axis_ratio**2) * u))))) return ( (_eta_u / u) * ((3.0 - slope) * _eta_u) ** -1.0 @@ -152,14 +147,14 @@ def __init__( @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - eta = self.radial_grid_from(grid=grid, **kwargs) + eta = self.radial_grid_from(grid=grid, **kwargs).array deflection_r = ( 2.0 * self.einstein_radius_rescaled - * np.divide( - np.power(eta, (3.0 - self.slope)), np.multiply((3.0 - self.slope), eta) + * jnp.divide( + jnp.power(eta, (3.0 - self.slope)), + jnp.multiply((3.0 - self.slope), eta), ) ) diff --git a/autogalaxy/profiles/mass/total/power_law_broken.py b/autogalaxy/profiles/mass/total/power_law_broken.py index 233240550..4e17c5c6d 100644 --- a/autogalaxy/profiles/mass/total/power_law_broken.py +++ b/autogalaxy/profiles/mass/total/power_law_broken.py @@ -1,4 +1,4 @@ -import copy +import jax.numpy as jnp import numpy as np from typing import Tuple @@ -31,7 +31,7 @@ def __init__( super().__init__(centre=centre, ell_comps=ell_comps) self.einstein_radius = einstein_radius - self.einstein_radius_elliptical = np.sqrt(self.axis_ratio) * einstein_radius + self.einstein_radius_elliptical = jnp.sqrt(self.axis_ratio) * einstein_radius self.break_radius = break_radius self.inner_slope = inner_slope self.outer_slope = outer_slope @@ -52,14 +52,13 @@ def __init__( @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Returns the dimensionless density kappa=Sigma/Sigma_c (eq. 1) """ # Ell radius - radius = np.hypot(grid[:, 1] * self.axis_ratio, grid[:, 0]) + radius = jnp.hypot(grid.array[:, 1] * self.axis_ratio, grid.array[:, 0]) # Inside break radius kappa_inner = self.kB * (self.break_radius / radius) ** self.inner_slope @@ -73,20 +72,19 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): - return np.zeros(shape=grid.shape[0]) + return jnp.zeros(shape=grid.shape[0]) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid, max_terms=20, **kwargs): """ Returns the complex deflection angle from eq. 18 and 19 """ # Rotate coordinates - z = grid[:, 1] + 1j * grid[:, 0] + z = grid.array[:, 1] + 1j * grid.array[:, 0] # Ell radius - R = np.hypot(z.real * self.axis_ratio, z.imag) + R = jnp.hypot(z.real * self.axis_ratio, z.imag) # Factors common to eq. 18 and 19 factors = ( @@ -128,8 +126,8 @@ def deflections_yx_2d_from(self, grid, max_terms=20, **kwargs): ).conjugate() return self.rotated_grid_from_reference_frame_from( - grid=np.multiply( - 1.0, np.vstack((np.imag(deflections), np.real(deflections))).T + grid=jnp.multiply( + 1.0, jnp.vstack((jnp.imag(deflections), jnp.real(deflections))).T ) ) @@ -142,13 +140,13 @@ def hyp2f1_series(t, q, r, z, max_terms=20): # u from eq. 25 q_ = (1 - q**2) / (q**2) - u = 0.5 * (1 - np.sqrt(1 - q_ * (r / z) ** 2)) + u = 0.5 * (1 - jnp.sqrt(1 - q_ * (r / z) ** 2)) # First coefficient a_n = 1.0 # Storage for sum - F = np.zeros_like(z, dtype="complex64") + F = jnp.zeros_like(z, dtype="complex64") for n in range(max_terms): F += a_n * (u**n) diff --git a/autogalaxy/profiles/mass/total/power_law_core.py b/autogalaxy/profiles/mass/total/power_law_core.py index 3a5a52d49..af2069e17 100644 --- a/autogalaxy/profiles/mass/total/power_law_core.py +++ b/autogalaxy/profiles/mass/total/power_law_core.py @@ -1,6 +1,5 @@ -import copy +import jax.numpy as jnp import numpy as np -from scipy.integrate import quad from typing import Tuple import autoarray as aa @@ -52,7 +51,6 @@ def einstein_radius_rescaled(self): @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Returns the two dimensional projected convergence on a grid of (y,x) arc-second coordinates. @@ -65,20 +63,13 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): grid The grid of (y,x) arc-second coordinates the convergence is computed on. """ - - covnergence_grid = np.zeros(grid.shape[0]) - grid_eta = self.elliptical_radii_grid_from(grid=grid, **kwargs) - for i in range(grid.shape[0]): - covnergence_grid[i] = self.convergence_func(grid_eta[i]) - - return covnergence_grid + return self.convergence_func(grid_radius=grid_eta) @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the potential on a grid of (y,x) arc-second coordinates. @@ -88,6 +79,7 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): grid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ + from scipy.integrate import quad potential_grid = np.zeros(grid.shape[0]) @@ -97,8 +89,8 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): a=0.0, b=1.0, args=( - grid[i, 0], - grid[i, 1], + grid.array[i, 0], + grid.array[i, 1], self.axis_ratio, self.slope, self.core_radius, @@ -109,7 +101,6 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles on a grid of (y,x) arc-second coordinates. @@ -120,11 +111,12 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ + from scipy.integrate import quad def calculate_deflection_component(npow, index): einstein_radius_rescaled = self.einstein_radius_rescaled - deflection_grid = self.axis_ratio * grid[:, index] + deflection_grid = np.array(self.axis_ratio * grid.array[:, index]) for i in range(grid.shape[0]): deflection_grid[i] *= ( @@ -134,8 +126,8 @@ def calculate_deflection_component(npow, index): a=0.0, b=1.0, args=( - grid[i, 0], - grid[i, 1], + grid.array[i, 0], + grid.array[i, 1], npow, self.axis_ratio, self.slope, @@ -219,7 +211,6 @@ def __init__( @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ Calculate the deflection angles on a grid of (y,x) arc-second coordinates. @@ -231,17 +222,17 @@ def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, **kwargs): """ eta = self.radial_grid_from(grid=grid, **kwargs) - deflection = np.multiply( + deflection = jnp.multiply( 2.0 * self.einstein_radius_rescaled, - np.divide( - np.add( - np.power( - np.add(self.core_radius**2, np.square(eta)), + jnp.divide( + jnp.add( + jnp.power( + jnp.add(self.core_radius**2, jnp.square(eta.array)), (3.0 - self.slope) / 2.0, ), -self.core_radius ** (3 - self.slope), ), - np.multiply((3.0 - self.slope), eta), + jnp.multiply((3.0 - self.slope), eta.array), ), ) return self._cartesian_grid_via_radial_from(grid=grid, radius=deflection) diff --git a/autogalaxy/profiles/mass/total/power_law_multipole.py b/autogalaxy/profiles/mass/total/power_law_multipole.py index 663713462..16e5a2a88 100644 --- a/autogalaxy/profiles/mass/total/power_law_multipole.py +++ b/autogalaxy/profiles/mass/total/power_law_multipole.py @@ -1,4 +1,4 @@ -from astropy import units +import jax.numpy as jnp import numpy as np from typing import Tuple @@ -26,14 +26,14 @@ def radial_and_angle_grid_from( ------- The radial and polar coordinate grids of the input (y,x) Cartesian grid. """ - y, x = grid.T + y, x = grid.array.T - x_shifted = np.subtract(x, centre[1]) - y_shifted = np.subtract(y, centre[0]) + x_shifted = jnp.subtract(x, centre[1]) + y_shifted = jnp.subtract(y, centre[0]) - radial_grid = np.sqrt(x_shifted**2 + y_shifted**2) + radial_grid = jnp.sqrt(x_shifted**2 + y_shifted**2) - angle_grid = np.arctan2(y_shifted, x_shifted) + angle_grid = jnp.arctan2(y_shifted, x_shifted) return radial_grid, angle_grid @@ -113,6 +113,8 @@ def __init__( grid=grid ) """ + from astropy import units + super().__init__(centre=centre, ell_comps=(0.0, 0.0)) self.m = int(m) @@ -142,13 +144,12 @@ def jacobian( The polar angle coordinates of the input (y,x) Cartesian grid of coordinates. """ return ( - a_r * np.sin(polar_angle_grid) + a_angle * np.cos(polar_angle_grid), - a_r * np.cos(polar_angle_grid) - a_angle * np.sin(polar_angle_grid), + a_r * jnp.sin(polar_angle_grid) + a_angle * jnp.cos(polar_angle_grid), + a_r * jnp.cos(polar_angle_grid) - a_angle * jnp.sin(polar_angle_grid), ) @aa.grid_dec.to_vector_yx @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def deflections_yx_2d_from( self, grid: aa.type.Grid1D2DLike, **kwargs ) -> np.ndarray: @@ -173,7 +174,7 @@ def deflections_yx_2d_from( ) / (self.m**2.0 - (3.0 - self.slope) ** 2.0) * self.k_m - * np.cos(self.m * (polar_angle_grid - self.angle_m)) + * jnp.cos(self.m * (polar_angle_grid - self.angle_m)) ) a_angle = ( @@ -184,10 +185,10 @@ def deflections_yx_2d_from( ) / (self.m**2.0 - (3.0 - self.slope) ** 2.0) * self.k_m - * np.sin(self.m * (polar_angle_grid - self.angle_m)) + * jnp.sin(self.m * (polar_angle_grid - self.angle_m)) ) - return np.stack( + return jnp.stack( self.jacobian(a_r=a_r, a_angle=a_angle, polar_angle_grid=polar_angle_grid), axis=-1, ) @@ -195,7 +196,6 @@ def deflections_yx_2d_from( @aa.over_sample @aa.grid_dec.to_array @aa.grid_dec.transform - @aa.grid_dec.relocate_to_radial_minimum def convergence_2d_from(self, grid: aa.type.Grid1D2DLike, **kwargs) -> np.ndarray: """ Returns the two dimensional projected convergence on a grid of (y,x) arc-second coordinates. @@ -212,7 +212,7 @@ def convergence_2d_from(self, grid: aa.type.Grid1D2DLike, **kwargs) -> np.ndarra / 2.0 * (self.einstein_radius / r) ** (self.slope - 1) * self.k_m - * np.cos(self.m * (angle - self.angle_m)) + * jnp.cos(self.m * (angle - self.angle_m)) ) @aa.grid_dec.to_array @@ -225,4 +225,4 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, **kwargs) -> np.ndarray: grid The grid of (y,x) arc-second coordinates the deflection angles are computed on. """ - return np.zeros(shape=grid.shape[0]) + return jnp.zeros(shape=grid.shape[0]) diff --git a/autogalaxy/profiles/plot/basis_plotters.py b/autogalaxy/profiles/plot/basis_plotters.py index 1cbdd763e..93d4bbc6b 100644 --- a/autogalaxy/profiles/plot/basis_plotters.py +++ b/autogalaxy/profiles/plot/basis_plotters.py @@ -8,8 +8,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.profiles.plot.light_profile_plotters import LightProfilePlotter @@ -21,12 +19,10 @@ def __init__( self, basis: Basis, grid: aa.type.Grid1D2DLike, - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, ): """ Plots the attributes of `Basis` objects using the matplotlib methods `plot()` and `imshow()` and many @@ -38,8 +34,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `LightProfile` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `LightProfile` and plotted via the visuals object. Parameters ---------- @@ -51,14 +46,10 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. - include_1d - Specifies which attributes of the `LightProfile` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `LightProfile` are extracted and plotted as visuals for 2D plots. """ from autogalaxy.profiles.light.linear import ( @@ -76,19 +67,11 @@ def __init__( super().__init__( mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) - def get_visuals_1d(self) -> Visuals1D: - return self.get_1d.via_light_obj_from(light_obj=self.basis) - - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_light_obj_from(light_obj=self.basis, grid=self.grid) - def light_profile_plotter_from( self, light_profile: LightProfile, @@ -113,7 +96,6 @@ def light_profile_plotter_from( grid=self.grid, mat_plot_1d=self.mat_plot_1d, visuals_1d=self.get_1d.via_light_obj_from(light_obj=light_profile), - include_1d=self.include_1d, ) def subplot_image(self): @@ -135,7 +117,7 @@ def subplot_image(self): for light_profile in self.basis.light_profile_list: self.mat_plot_2d.plot_array( array=light_profile.image_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels(title=light_profile.coefficient_tag), ) diff --git a/autogalaxy/profiles/plot/light_profile_plotters.py b/autogalaxy/profiles/plot/light_profile_plotters.py index f4d37f8f8..e8521bb7b 100644 --- a/autogalaxy/profiles/plot/light_profile_plotters.py +++ b/autogalaxy/profiles/plot/light_profile_plotters.py @@ -11,8 +11,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.util import error_util from autogalaxy import exc @@ -23,12 +21,10 @@ def __init__( self, light_profile: LightProfile, grid: aa.type.Grid1D2DLike, - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, ): """ Plots the attributes of `LightProfile` objects using the matplotlib methods `plot()` and `imshow()` and many @@ -40,8 +36,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `LightProfile` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `LightProfile` and plotted via the visuals object. Parameters ---------- @@ -53,14 +48,10 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. - include_1d - Specifies which attributes of the `LightProfile` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `LightProfile` are extracted and plotted as visuals for 2D plots. """ from autogalaxy.profiles.light.linear import ( @@ -77,21 +68,11 @@ def __init__( super().__init__( mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) - def get_visuals_1d(self) -> Visuals1D: - return self.get_1d.via_light_obj_from(light_obj=self.light_profile) - - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_light_obj_from( - light_obj=self.light_profile, grid=self.grid - ) - def figures_1d(self, image: bool = False): """ Plots the individual attributes of the plotter's `LightProfile` object in 1D, which are computed via the @@ -120,7 +101,7 @@ def figures_1d(self, image: bool = False): self.mat_plot_1d.plot_yx( y=image_1d, x=image_1d.grid_radial, - visuals_1d=self.get_visuals_1d(), + visuals_1d=self.visuals_1d, auto_labels=aplt.AutoLabels( title=r"Image ($\mathrm{e^{-}}\,\mathrm{s^{-1}}$) vs Radius (arcsec)", yunit="", @@ -146,7 +127,7 @@ def figures_2d(self, image: bool = False): if image: self.mat_plot_2d.plot_array( array=self.light_profile.image_2d_from(grid=self.grid), - visuals_2d=self.get_visuals_2d(), + visuals_2d=self.visuals_2d, auto_labels=aplt.AutoLabels(title="Image", filename="image_2d"), ) @@ -156,12 +137,10 @@ def __init__( self, light_profile_pdf_list: List[LightProfile], grid: aa.type.Grid2DLike, - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, sigma: Optional[float] = 3.0, ): """ @@ -179,8 +158,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `LightProfile` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `LightProfile` and plotted via the visuals object. Parameters ---------- @@ -192,14 +170,10 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. - include_1d - Specifies which attributes of the `LightProfile` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `LightProfile` are extracted and plotted as visuals for 2D plots. sigma The confidence interval in terms of a sigma value at which the errors are computed (e.g. a value of sigma=3.0 uses confidence intevals at ~0.01 and 0.99 the PDF). @@ -209,10 +183,8 @@ def __init__( grid=grid, mat_plot_1d=mat_plot_1d, visuals_1d=visuals_1d, - include_1d=include_1d, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, - include_2d=include_2d, ) self.light_profile_pdf_list = light_profile_pdf_list @@ -265,13 +237,13 @@ def figures_1d(self, image: bool = False): profile_1d_list=image_1d_list, low_limit=self.low_limit ) - visuals_1d_via_light_obj_list = self.get_1d.via_light_obj_list_from( - light_obj_list=self.light_profile_pdf_list, low_limit=self.low_limit - ) - visuals_1d_with_shaded_region = self.visuals_1d.__class__( - shaded_region=errors_image_1d + visuals_1d_via_light_obj_list = Visuals1D().add_half_light_radius_errors( + light_obj_list=self.light_profile_pdf_list, + low_limit=self.low_limit, ) + visuals_1d_with_shaded_region = Visuals1D(shaded_region=errors_image_1d) + visuals_1d = visuals_1d_via_light_obj_list + visuals_1d_with_shaded_region self.mat_plot_1d.plot_yx( diff --git a/autogalaxy/profiles/plot/mass_profile_plotters.py b/autogalaxy/profiles/plot/mass_profile_plotters.py index c7b7527a4..c2d9ea4bd 100644 --- a/autogalaxy/profiles/plot/mass_profile_plotters.py +++ b/autogalaxy/profiles/plot/mass_profile_plotters.py @@ -11,8 +11,6 @@ from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.one_d import Visuals1D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.one_d import Include1D -from autogalaxy.plot.include.two_d import Include2D from autogalaxy.util import error_util @@ -22,12 +20,10 @@ def __init__( self, mass_profile: MassProfile, grid: aa.type.Grid2DLike, - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, ): """ Plots the attributes of `MassProfile` objects using the matplotlib methods `plot()` and `imshow()` and many @@ -39,8 +35,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `MassProfile` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `MassProfile` and plotted via the visuals object. Parameters ---------- @@ -52,21 +47,15 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. - include_1d - Specifies which attributes of the `MassProfile` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `MassProfile` are extracted and plotted as visuals for 2D plots. """ super().__init__( mat_plot_2d=mat_plot_2d, - include_2d=include_2d, visuals_2d=visuals_2d, mat_plot_1d=mat_plot_1d, - include_1d=include_1d, visuals_1d=visuals_1d, ) @@ -76,20 +65,12 @@ def __init__( self._mass_plotter = MassPlotter( mass_obj=self.mass_profile, grid=self.grid, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) self.figures_2d = self._mass_plotter.figures_2d - def get_visuals_1d(self) -> Visuals1D: - return self.get_1d.via_mass_obj_from(mass_obj=self.mass_profile, grid=self.grid) - - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_mass_obj_from(mass_obj=self.mass_profile, grid=self.grid) - def figures_1d(self, convergence: bool = False, potential: bool = False): """ Plots the individual attributes of the plotter's `MassProfile` object in 1D, which are computed via the @@ -120,7 +101,7 @@ def figures_1d(self, convergence: bool = False, potential: bool = False): self.mat_plot_1d.plot_yx( y=convergence_1d, x=convergence_1d.grid_radial, - visuals_1d=self.get_visuals_1d(), + visuals_1d=self.visuals_1d, auto_labels=aplt.AutoLabels( title="Convergence vs Radius (arcsec)", yunit="", @@ -136,7 +117,7 @@ def figures_1d(self, convergence: bool = False, potential: bool = False): self.mat_plot_1d.plot_yx( y=potential_1d, x=potential_1d.grid_radial, - visuals_1d=self.get_visuals_1d(), + visuals_1d=self.visuals_1d, auto_labels=aplt.AutoLabels( title="Potential vs Radius (arcsec)", yunit="", @@ -152,12 +133,10 @@ def __init__( self, mass_profile_pdf_list: List[MassProfile], grid: aa.Grid2D, - mat_plot_1d: MatPlot1D = MatPlot1D(), - visuals_1d: Visuals1D = Visuals1D(), - include_1d: Include1D = Include1D(), - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_1d: MatPlot1D = None, + visuals_1d: Visuals1D = None, + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, sigma: Optional[float] = 3.0, ): """ @@ -175,8 +154,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `MassProfile` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `MassProfile` and plotted via the visuals object. Parameters ---------- @@ -188,14 +166,10 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 1D plots. visuals_1d Contains 1D visuals that can be overlaid on 1D plots. - include_1d - Specifies which attributes of the `MassProfile` are extracted and plotted as visuals for 1D plots. mat_plot_2d Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `MassProfile` are extracted and plotted as visuals for 2D plots. sigma The confidence interval in terms of a sigma value at which the errors are computed (e.g. a value of sigma=3.0 uses confidence intevals at ~0.01 and 0.99 the PDF). @@ -205,10 +179,8 @@ def __init__( grid=grid, mat_plot_1d=mat_plot_1d, visuals_1d=visuals_1d, - include_1d=include_1d, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, - include_2d=include_2d, ) self.mass_profile_pdf_list = mass_profile_pdf_list @@ -263,12 +235,12 @@ def figures_1d(self, convergence=False, potential=False): profile_1d_list=convergence_1d_list, low_limit=self.low_limit ) - visuals_1d_via_lensing_obj_list = self.get_1d.via_mass_obj_list_from( + visuals_1d_via_lensing_obj_list = Visuals1D().add_einstein_radius_errors( mass_obj_list=self.mass_profile_pdf_list, grid=self.grid, low_limit=self.low_limit, ) - visuals_1d_with_shaded_region = self.visuals_1d.__class__( + visuals_1d_with_shaded_region = Visuals1D( shaded_region=errors_convergence_1d ) @@ -307,14 +279,12 @@ def figures_1d(self, convergence=False, potential=False): profile_1d_list=potential_1d_list, low_limit=self.low_limit ) - visuals_1d_via_lensing_obj_list = self.get_1d.via_mass_obj_list_from( + visuals_1d_via_lensing_obj_list = Visuals1D().add_einstein_radius_errors( mass_obj_list=self.mass_profile_pdf_list, grid=self.grid, low_limit=self.low_limit, ) - visuals_1d_with_shaded_region = self.visuals_1d.__class__( - shaded_region=errors_potential_1d - ) + visuals_1d_with_shaded_region = Visuals1D(shaded_region=errors_potential_1d) visuals_1d = visuals_1d_via_lensing_obj_list + visuals_1d_with_shaded_region diff --git a/autogalaxy/quantity/model/analysis.py b/autogalaxy/quantity/model/analysis.py index 4c764957d..48621ba26 100644 --- a/autogalaxy/quantity/model/analysis.py +++ b/autogalaxy/quantity/model/analysis.py @@ -1,18 +1,14 @@ from autoconf.dictable import to_dict -from autoconf.fitsable import hdu_list_for_output_from import autofit as af from autogalaxy.analysis.analysis.analysis import Analysis from autogalaxy.cosmology.lensing import LensingCosmology -from autogalaxy.cosmology.wrap import Planck15 from autogalaxy.quantity.dataset_quantity import DatasetQuantity from autogalaxy.quantity.model.result import ResultQuantity from autogalaxy.quantity.model.visualizer import VisualizerQuantity from autogalaxy.quantity.fit_quantity import FitQuantity -from autogalaxy import exc - class AnalysisQuantity(Analysis): Result = ResultQuantity @@ -22,7 +18,7 @@ def __init__( self, dataset: DatasetQuantity, func_str: str, - cosmology: LensingCosmology = Planck15(), + cosmology: LensingCosmology = None, title_prefix: str = None, ): """ @@ -94,13 +90,7 @@ def log_likelihood_function(self, instance: af.ModelInstance) -> float: float The log likelihood indicating how well this model instance fitted the imaging data. """ - - try: - fit = self.fit_quantity_for_instance(instance=instance) - - return fit.figure_of_merit - except (exc.GridException, ValueError) as e: - raise exc.FitException from e + return self.fit_quantity_for_instance(instance=instance).figure_of_merit def fit_quantity_for_instance(self, instance: af.ModelInstance) -> FitQuantity: """ diff --git a/autogalaxy/quantity/model/plotter_interface.py b/autogalaxy/quantity/model/plotter_interface.py index d15741191..0a573b74e 100644 --- a/autogalaxy/quantity/model/plotter_interface.py +++ b/autogalaxy/quantity/model/plotter_interface.py @@ -51,7 +51,7 @@ def dataset_quantity(self, dataset: DatasetQuantity): def fit_quantity( self, fit: FitQuantity, - visuals_2d: Visuals2D = Visuals2D(), + visuals_2d: Visuals2D = None, fit_quanaity_plotter_cls=FitQuantityPlotter, ): """ @@ -86,7 +86,6 @@ def should_plot(name): fit=fit, mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d, - include_2d=self.include_2d, ) if should_plot("subplot_fit"): diff --git a/autogalaxy/quantity/plot/fit_quantity_plotters.py b/autogalaxy/quantity/plot/fit_quantity_plotters.py index 83632cb2c..d0371ab3f 100644 --- a/autogalaxy/quantity/plot/fit_quantity_plotters.py +++ b/autogalaxy/quantity/plot/fit_quantity_plotters.py @@ -7,7 +7,6 @@ from autogalaxy.plot.abstract_plotters import Plotter from autogalaxy.plot.mat_plot.two_d import MatPlot2D from autogalaxy.plot.visuals.two_d import Visuals2D -from autogalaxy.plot.include.two_d import Include2D # TODO : Ew, this is a mass, but it works. Clean up one day! @@ -17,9 +16,8 @@ class FitQuantityPlotter(Plotter): def __init__( self, fit: FitQuantity, - mat_plot_2d: MatPlot2D = MatPlot2D(), - visuals_2d: Visuals2D = Visuals2D(), - include_2d: Include2D = Include2D(), + mat_plot_2d: MatPlot2D = None, + visuals_2d: Visuals2D = None, ): """ Plots the attributes of `FitQuantity` objects using the matplotlib method `imshow()` and many @@ -31,8 +29,7 @@ def __init__( customize the figure's appearance. Overlaid on the figure are visuals, contained in the `Visuals1D` and `Visuals2D` objects. Attributes may be - extracted from the `FitQuantity` and plotted via the visuals object, if the corresponding entry is `True` in - the `Include1D` or `Include2D` object or the `config/visualize/include.ini` file. + extracted from the `FitQuantity` and plotted via the visuals object. Parameters ---------- @@ -42,24 +39,11 @@ def __init__( Contains objects which wrap the matplotlib function calls that make 2D plots. visuals_2d Contains 2D visuals that can be overlaid on 2D plots. - include_2d - Specifies which attributes of the `FitQuantity` are extracted and plotted as visuals for 2D plots. """ - super().__init__( - mat_plot_2d=mat_plot_2d, include_2d=include_2d, visuals_2d=visuals_2d - ) + super().__init__(mat_plot_2d=mat_plot_2d, visuals_2d=visuals_2d) self.fit = fit - def get_visuals_2d(self) -> Visuals2D: - return self.get_2d.via_fit_imaging_from(fit=self.fit) - - def get_visuals_2d_y(self) -> Visuals2D: - return self.get_2d.via_fit_imaging_from(fit=self.fit.y) - - def get_visuals_2d_x(self) -> Visuals2D: - return self.get_2d.via_fit_imaging_from(fit=self.fit.x) - def figures_2d( self, image: bool = False, @@ -97,9 +81,7 @@ def figures_2d( if isinstance(self.fit.dataset.data, aa.Array2D): fit_plotter = FitImagingPlotterMeta( fit=self.fit, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) @@ -116,9 +98,7 @@ def figures_2d( else: fit_plotter_y = FitImagingPlotterMeta( fit=self.fit.y, - get_visuals_2d=self.get_visuals_2d_y, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) @@ -135,9 +115,7 @@ def figures_2d( fit_plotter_x = FitImagingPlotterMeta( fit=self.fit.y, - get_visuals_2d=self.get_visuals_2d_x, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) @@ -160,9 +138,7 @@ def subplot_fit(self): if isinstance(self.fit.dataset.data, aa.Array2D): fit_plotter = FitImagingPlotterMeta( fit=self.fit, - get_visuals_2d=self.get_visuals_2d, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) @@ -179,9 +155,7 @@ def subplot_fit(self): else: fit_plotter_y = FitImagingPlotterMeta( fit=self.fit.y, - get_visuals_2d=self.get_visuals_2d_y, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) @@ -197,9 +171,7 @@ def subplot_fit(self): fit_plotter_x = FitImagingPlotterMeta( fit=self.fit.x, - get_visuals_2d=self.get_visuals_2d_x, mat_plot_2d=self.mat_plot_2d, - include_2d=self.include_2d, visuals_2d=self.visuals_2d, ) diff --git a/autogalaxy/util/mock/mock_cosmology.py b/autogalaxy/util/mock/mock_cosmology.py index 858bdc111..d41f918fb 100644 --- a/autogalaxy/util/mock/mock_cosmology.py +++ b/autogalaxy/util/mock/mock_cosmology.py @@ -1,8 +1,5 @@ -from astropy import constants import math -from autogalaxy.cosmology.wrap import Planck15 - # Mock Cosmology # @@ -14,7 +11,7 @@ def to(self, *args, **kwargs): return Value(value=self.value) -class MockCosmology(Planck15): +class MockCosmology: def __init__( self, arcsec_per_kpc=0.5, @@ -22,7 +19,6 @@ def __init__( critical_surface_density=2.0, cosmic_average_density=2.0, ): - super().__init__() self.arcsec_per_kpc = arcsec_per_kpc self.kpc_per_arcsec = kpc_per_arcsec @@ -39,6 +35,8 @@ def angular_diameter_distance(self, z): return Value(value=1.0) def angular_diameter_distance_z1z2(self, z1, z2): + from astropy import constants + const = constants.c.to("kpc / s") ** 2.0 / ( 4 * math.pi * constants.G.to("kpc3 / (solMass s2)") ) @@ -46,3 +44,137 @@ def angular_diameter_distance_z1z2(self, z1, z2): def critical_density(self, z): return Value(value=self.cosmic_average_density) + + def cosmic_average_density_solar_mass_per_kpc3_from(self, redshift: float) -> float: + """ + Critical density of the Universe at an input `redshift` in units of solar masses per kiloparsecs**3. + + For simplicity, **PyAutoLens** internally uses only certain units to perform lensing cosmology calculations. + This function therefore returns only the value of the astropy function it wraps, omitting the units instance. + + Parameters + ---------- + redshift + Redshift at which the critiical density in solMass/kpc^3 of the Universe is calculated. + """ + cosmic_average_density_kpc = ( + self.critical_density(z=redshift).to("solMass / kpc^3").value + ) + + return cosmic_average_density_kpc + + def critical_surface_density_between_redshifts_solar_mass_per_kpc2_from( + self, redshift_0: float, redshift_1: float + ) -> float: + """ + The critical surface density for lensing, often written as $\sigma_{cr}$, is given by: + + critical_surface_density = (c^2 * D_s) / (4 * pi * G * D_ls * D_l) + + c = speed of light + G = Newton's gravity constant + D_s = Angular diameter distance of source redshift to earth + D_ls = Angular diameter distance of lens redshift to source redshift + D_l = Angular diameter distance of lens redshift to earth + + This function returns the critical surface density in units of solar masses / kpc^2, which are convenient + units for converting the inferred masses of a model from angular units (e.g. dimensionless units inferred + from data in arcseconds) to solar masses. + + Parameters + ---------- + redshift_0 + The redshift of the first strong lens galaxy (E.g. the lens galaxy) for which the critical surface + density is calculated. + redshift_1 + The redshift of the second strong lens galaxy (E.g. the lens galaxy) for which the critical surface + density is calculated. + """ + from astropy import constants + + const = constants.c.to("kpc / s") ** 2.0 / ( + 4 * math.pi * constants.G.to("kpc3 / (solMass s2)") + ) + + angular_diameter_distance_of_redshift_0_to_earth_kpc = ( + self.angular_diameter_distance_to_earth_in_kpc_from(redshift=redshift_0) + ) + + angular_diameter_distance_of_redshift_1_to_earth_kpc = ( + self.angular_diameter_distance_to_earth_in_kpc_from(redshift=redshift_1) + ) + + angular_diameter_distance_between_redshifts_kpc = ( + self.angular_diameter_distance_between_redshifts_in_kpc_from( + redshift_0=redshift_0, redshift_1=redshift_1 + ) + ) + + return ( + const + * angular_diameter_distance_of_redshift_1_to_earth_kpc + / ( + angular_diameter_distance_between_redshifts_kpc + * angular_diameter_distance_of_redshift_0_to_earth_kpc + ) + ).value + + def angular_diameter_distance_to_earth_in_kpc_from(self, redshift: float) -> float: + """ + Angular diameter distance from the input `redshift` to redshift zero (e.g. us, the observer on earth) in + kiloparsecs. + + This gives the proper (sometimes called 'physical') transverse distance corresponding to an angle of 1 radian + for an object at redshift `z`. + + Weinberg, 1972, pp 421-424; Weedman, 1986, pp 65-67; Peebles, 1993, pp 325-327. + + For simplicity, **PyAutoLens** internally uses only certain units to perform lensing cosmology calculations. + This function therefore returns only the value of the astropy function it wraps, omitting the units instance. + + Parameters + ---------- + redshift + Input redshift from which the angular diameter distance to Earth is calculated. + """ + angular_diameter_distance_kpc = self.angular_diameter_distance(z=redshift).to( + "kpc" + ) + + return angular_diameter_distance_kpc.value + + def angular_diameter_distance_between_redshifts_in_kpc_from( + self, redshift_0: float, redshift_1: float + ) -> float: + """ + Angular diameter distance from an input `redshift_0` to another input `redshift_1`. + + For simplicity, **PyAutoLens** internally uses only certain units to perform lensing cosmology calculations. + This function therefore returns only the value of the astropy function it wraps, omitting the units instance. + + Parameters + ---------- + redshift_0 + Redshift from which the angular diameter distance to the other redshift is calculated. + redshift_1 + Redshift from which the angular diameter distance to the other redshift is calculated. + """ + angular_diameter_distance_between_redshifts_kpc = ( + self.angular_diameter_distance_z1z2(redshift_0, redshift_1).to("kpc") + ) + + return angular_diameter_distance_between_redshifts_kpc.value + + def kpc_per_arcsec_from(self, redshift: float) -> float: + """ + Separation in transverse proper kpc corresponding to an arcminute at redshift `z`. + + For simplicity, **PyAutoLens** internally uses only certain units to perform lensing cosmology calculations. + This function therefore returns only the value of the astropy function it wraps, omitting the units instance. + + Parameters + ---------- + redshift + Input redshift from which the transverse proper kpc value is calculated at. + """ + return 1.0 / self.arcsec_per_kpc_proper(z=redshift).value diff --git a/autogalaxy/util/shear_field.py b/autogalaxy/util/shear_field.py index 179e8f09a..d77d5b1ea 100644 --- a/autogalaxy/util/shear_field.py +++ b/autogalaxy/util/shear_field.py @@ -1,5 +1,4 @@ import logging -from matplotlib.patches import Ellipse import numpy as np import typing @@ -47,11 +46,12 @@ def phis(self) -> aa.ArrayIrregular: ) @property - def elliptical_patches(self) -> typing.List[Ellipse]: + def elliptical_patches(self) -> "typing.List[Ellipse]": """ If we treat this vector field as a set of weak lensing shear measurements, the elliptical patch representing each galaxy ellipticity. This patch is used for visualizing an ellipse of each galaxy in an image. """ + from matplotlib.patches import Ellipse return [ Ellipse( diff --git a/docs/api/plot.rst b/docs/api/plot.rst index 3fe971efe..38ab6de3c 100644 --- a/docs/api/plot.rst +++ b/docs/api/plot.rst @@ -37,7 +37,6 @@ Create figures and subplots showing quantities of standard **PyAutoGalaxy** obje FitImagingPlotter FitInterferometerPlotter GalaxiesPlotter - AdaptPlotter FitImagingPlotter FitInterferometerPlotter MultiFigurePlotter diff --git a/docs/general/model_cookbook.rst b/docs/general/model_cookbook.rst index c2e7b534a..1dfaf8afd 100644 --- a/docs/general/model_cookbook.rst +++ b/docs/general/model_cookbook.rst @@ -234,8 +234,8 @@ profiles. The following example notebooks show how to compose and fit these models: -https://github.com/Jammy2211/autogalaxy_workspace/blob/release/notebooks/imaging/modeling/features/multi_gaussian_expansion.ipynb -https://github.com/Jammy2211/autogalaxy_workspace/blob/release/notebooks/imaging/modeling/features/shapelets.ipynb +https://github.com/Jammy2211/autogalaxy_workspace/blob/release/notebooks/modeling/imaging/features/multi_gaussian_expansion.ipynb +https://github.com/Jammy2211/autogalaxy_workspace/blob/release/notebooks/modeling/imaging/features/shapelets.ipynb Model Linking (Advanced) ------------------------ diff --git a/docs/installation/conda.rst b/docs/installation/conda.rst index be8a89fe5..394428eb6 100644 --- a/docs/installation/conda.rst +++ b/docs/installation/conda.rst @@ -106,7 +106,6 @@ For interferometer analysis there are two optional dependencies that must be ins .. code-block:: bash pip install pynufft - pip install pylops==2.3.1 **PyAutoGalaxy** will run without these libraries and it is recommended that you only install them if you intend to do interferometer analysis. diff --git a/docs/installation/overview.rst b/docs/installation/overview.rst index 87beb953c..b4fcddafa 100644 --- a/docs/installation/overview.rst +++ b/docs/installation/overview.rst @@ -65,5 +65,3 @@ Dependencies And the following optional dependencies: **pynufft**: https://github.com/jyhmiinlin/pynufft - -**PyLops**: https://github.com/PyLops/pylops diff --git a/docs/installation/pip.rst b/docs/installation/pip.rst index 54fa54c78..a23a01e80 100644 --- a/docs/installation/pip.rst +++ b/docs/installation/pip.rst @@ -86,7 +86,6 @@ For interferometer analysis there are two optional dependencies that must be ins .. code-block:: bash pip install pynufft - pip install pylops==2.3.1 **PyAutoGalaxy** will run without these libraries and it is recommended that you only install them if you intend to do interferometer analysis. diff --git a/docs/installation/source.rst b/docs/installation/source.rst index ec1d3ca02..5028ca403 100644 --- a/docs/installation/source.rst +++ b/docs/installation/source.rst @@ -56,7 +56,6 @@ For unit tests to pass you will also need the following optional requirements: .. code-block:: bash pip install pynufft - pip install pylops==2.3.1 If you are using a ``conda`` environment, add the source repository as follows: diff --git a/eden.ini b/eden.ini index d16b30eb0..a22a58033 100644 --- a/eden.ini +++ b/eden.ini @@ -1,3 +1,3 @@ -[eden] -name=autogalaxy -prefix=ag +[eden] +name=autogalaxy +prefix=ag diff --git a/files/citations.bib b/files/citations.bib index c17bec016..d7bc603ab 100644 --- a/files/citations.bib +++ b/files/citations.bib @@ -33,17 +33,6 @@ @article{astropy2 Bdsk-Url-1 = {https://doi.org/10.3847/1538-3881/aabc4f} } -@article{PyLops, -abstract = {Linear operators and optimisation are at the core of many algorithms used in signal and image processing, remote sensing, and inverse problems. For small to medium-scale problems, existing software packages (e.g., MATLAB, Python numpy and scipy) allow for explicitly building dense (or sparse) matrices and performing algebraic operations (e.g., computation of matrix-vector products and manipulation of matrices) with syntax that closely represents their corresponding analytical forms. However, many real application, large-scale operators do not lend themselves to explicit matrix representations, usually forcing practitioners to forego of the convenient linear-algebra syntax available for their explicit-matrix counterparts. PyLops is an open-source Python library providing a flexible and scalable framework for the creation and combination of so-called linear operators, class-based entities that represent matrices and inherit their associated syntax convenience, but do not rely on the creation of explicit matrices. We show that PyLops operators can dramatically reduce the memory load and CPU computations compared to explicit-matrix calculations, while still allowing users to seamlessly use their existing knowledge of compact matrix-based syntax that scales to any problem size because no explicit matrices are required.}, -archivePrefix = {arXiv}, -arxivId = {1907.12349}, -author = {Ravasi, Matteo and Vasconcelos, Ivan}, -eprint = {1907.12349}, -file = {:home/jammy/Documents/Papers/Software/PyLops.pdf:pdf}, -title = {{PyLops -- A Linear-Operator Python Library for large scale optimization}}, -url = {http://arxiv.org/abs/1907.12349}, -year = {2019} -} @article{colossus, abstract = {This paper introduces Colossus, a public, open-source python package for calculations related to cosmology, the large-scale structure (LSS) of matter in the universe, and the properties of dark matter halos. The code is designed to be fast and easy to use, with a coherent, well-documented user interface. The cosmology module implements Friedman-Lemaitre-Robertson-Walker cosmologies including curvature, relativistic species, and different dark energy equations of state, and provides fast computations of the linear matter power spectrum, variance, and correlation function. The LSS module is concerned with the properties of peaks in Gaussian random fields and halos in a statistical sense, including their peak height, peak curvature, halo bias, and mass function. The halo module deals with spherical overdensity radii and masses, density profiles, concentration, and the splashback radius. To facilitate the rapid exploration of these quantities, Colossus implements more than 40 different fitting functions from the literature. I discuss the core routines in detail, with particular emphasis on their accuracy. Colossus is available at bitbucket.org/bdiemer/colossus.}, diff --git a/files/citations.md b/files/citations.md index 3e6588046..68c78b7e9 100644 --- a/files/citations.md +++ b/files/citations.md @@ -18,7 +18,6 @@ This work uses the following software packages: - `NumPy` https://github.com/numpy/numpy [@numpy] - `PyAutoFit` https://github.com/rhayes777/PyAutoFit [@pyautofit] - `PyAutoGalaxy` https://github.com/Jammy2211/PyAutoGalaxy [@Nightingale2018] [@pyautogalaxy] -- `PyLops` https://github.com/equinor/pylops [@pylops] - `PyNUFFT` https://github.com/jyhmiinlin/pynufft [@pynufft] - `PySwarms` https://github.com/ljvmiranda921/pyswarms [@pyswarms] - `Python` https://www.python.org/ [@python] diff --git a/files/citations.tex b/files/citations.tex index cce7006df..b3c11ab2c 100644 --- a/files/citations.tex +++ b/files/citations.tex @@ -50,9 +50,6 @@ \section*{Software Citations} \href{https://github.com/Jammy2211/PyAutoGalaxy}{\textt{PyAutoGalaxy}} \citep{Nightingale2018, pyautogalaxy} -\item -\href{https://github.com/equinor/pylops}{\textt{PyLops}} -\citep{pylops} \item \href{https://github.com/jyhmiinlin/pynufft}{\textt{PyNUFFT}} diff --git a/paper/paper.bib b/paper/paper.bib index 7748bc669..5df87d1aa 100644 --- a/paper/paper.bib +++ b/paper/paper.bib @@ -30,16 +30,7 @@ @article{astropy2 Volume = {156}, Year = 2018, Bdsk-Url-1 = {https://doi.org/10.3847/1538-3881/aabc4f}} -@article{PyLops, -archivePrefix = {arXiv}, -arxivId = {1907.12349}, -author = {Ravasi, Matteo and Vasconcelos, Ivan}, -eprint = {1907.12349}, -file = {:home/jammy/Documents/Papers/Software/PyLops.pdf:pdf}, -title = {{PyLops -- A Linear-Operator Python Library for large scale optimization}}, -url = {http://arxiv.org/abs/1907.12349}, -year = {2019} -} + @article{colossus, archivePrefix = {arXiv}, arxivId = {1712.04512}, diff --git a/paper/paper.md b/paper/paper.md index d790aba5b..011da2511 100644 --- a/paper/paper.md +++ b/paper/paper.md @@ -127,7 +127,7 @@ reconstruct the source galaxies of strong gravitational lenses in `PyAutoGalaxy` `PyAutoGalaxy` includes a comprehensive visualization library for the analysis of both direct imaging and interferometer datasets and tools for preprocessing data to formats suitable for galaxy model-fitting. The `astropy` cosmology module handles unit conversions and calculations are optimized using the packages `NumPy` [@numpy], `numba` [@numba], - `PyNUFFT` [@pynufft] and `PyLops` [@PyLops]. +and `PyNUFFT` [@pynufft]. To perform model-fitting, `PyAutoGalaxy` adopts the probabilistic programming language `PyAutoFit` (https://github.com/rhayes777/PyAutoFit). `PyAutoFit` allows users to compose a @@ -172,7 +172,6 @@ taken without a local `PyAutoGalaxy` installation. - `numba` [@numba] - `NumPy` [@numpy] - `PyAutoFit` [@pyautofit] -- `PyLops` [@PyLops] - `PyNUFFT` [@pynufft] - `pyprojroot` (https://github.com/chendaniely/pyprojroot) - `PySwarms` [@pyswarms] diff --git a/pyproject.toml b/pyproject.toml index fbd922b7d..eb3a25ead 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,6 @@ local_scheme = "no-local-version" [project.optional-dependencies] optional=[ "numba", - "pylops>=1.10.0,<=2.3.1", "pynufft", "ultranest==3.6.2", "zeus-mcmc==2.5.4", diff --git a/test_autogalaxy/aggregator/conftest.py b/test_autogalaxy/aggregator/conftest.py index 6a125ca14..43fc14484 100644 --- a/test_autogalaxy/aggregator/conftest.py +++ b/test_autogalaxy/aggregator/conftest.py @@ -6,6 +6,7 @@ from autoconf import conf import autofit as af import autogalaxy as ag + from autoconf.conf import with_config from autofit.non_linear.samples import Sample diff --git a/test_autogalaxy/aggregator/ellipse/conftest.py b/test_autogalaxy/aggregator/ellipse/conftest.py index 4df8107f6..92b0503f6 100644 --- a/test_autogalaxy/aggregator/ellipse/conftest.py +++ b/test_autogalaxy/aggregator/ellipse/conftest.py @@ -18,6 +18,7 @@ def set_test_mode(): def clean(database_file): + database_sqlite = path.join(conf.instance.output_path, f"{database_file}.sqlite") if path.exists(database_sqlite): diff --git a/test_autogalaxy/analysis/test_plotter_interface.py b/test_autogalaxy/analysis/test_plotter_interface.py index e76e6a9a6..e7132c878 100644 --- a/test_autogalaxy/analysis/test_plotter_interface.py +++ b/test_autogalaxy/analysis/test_plotter_interface.py @@ -16,9 +16,7 @@ def make_plotter_interface_plotter_setup(): return path.join("{}".format(directory), "files") -def test__galaxies( - masked_imaging_7x7, galaxies_7x7, include_2d_all, plot_path, plot_patch -): +def test__galaxies(masked_imaging_7x7, galaxies_7x7, plot_path, plot_patch): if path.exists(plot_path): shutil.rmtree(plot_path) @@ -44,9 +42,7 @@ def test__galaxies( def test__inversion( - masked_imaging_7x7, rectangular_inversion_7x7_3x3, - include_2d_all, plot_path, plot_patch, ): @@ -71,6 +67,7 @@ def test__inversion( for row in reader: for key, value in zip(header_list, row): + print(value) reconstruction_dict[key].append(float(value)) # Convert lists to NumPy arrays @@ -82,7 +79,6 @@ def test__inversion( def test__adapt_images( masked_imaging_7x7, - include_2d_all, adapt_galaxy_name_image_dict_7x7, fit_imaging_x2_galaxy_inversion_7x7, plot_path, diff --git a/test_autogalaxy/analysis/test_preloads.py b/test_autogalaxy/analysis/test_preloads.py deleted file mode 100644 index 284962428..000000000 --- a/test_autogalaxy/analysis/test_preloads.py +++ /dev/null @@ -1,130 +0,0 @@ -import numpy as np -from os import path - -import autofit as af - -import autogalaxy as ag - - -def test__set_blurred_image(): - # Blurred image is all zeros so preloads as zeros - - fit_0 = ag.m.MockFitImaging(blurred_image=np.zeros(2)) - fit_1 = ag.m.MockFitImaging(blurred_image=np.zeros(2)) - - preloads = ag.Preloads(blurred_image=1) - preloads.set_blurred_image(fit_0=fit_0, fit_1=fit_1) - - assert preloads.blurred_image is None - - # Blurred image are different, indicating the model parameters change the grid, so no preloading. - - fit_0 = ag.m.MockFitImaging(blurred_image=np.array([1.0])) - fit_1 = ag.m.MockFitImaging(blurred_image=np.array([2.0])) - - preloads = ag.Preloads(blurred_image=1) - preloads.set_blurred_image(fit_0=fit_0, fit_1=fit_1) - - assert preloads.blurred_image is None - - # Blurred images are the same meaning they are fixed in the model, so do preload. - - fit_0 = ag.m.MockFitImaging(blurred_image=np.array([1.0])) - fit_1 = ag.m.MockFitImaging(blurred_image=np.array([1.0])) - - preloads = ag.Preloads(blurred_image=1) - preloads.set_blurred_image(fit_0=fit_0, fit_1=fit_1) - - assert (preloads.blurred_image == 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 = ag.Preloads( - blurred_image=np.zeros(3), - w_tilde=None, - use_w_tilde=False, - 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"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 = ag.Preloads( - blurred_image=1, - w_tilde=1, - use_w_tilde=True, - image_plane_mesh_grid_pg_list=1, - mapper_list=1, - operated_mapping_matrix=1, - curvature_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"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 = True\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_autogalaxy/config/general.yaml b/test_autogalaxy/config/general.yaml index 2acec5ada..184efbab5 100644 --- a/test_autogalaxy/config/general.yaml +++ b/test_autogalaxy/config/general.yaml @@ -1,44 +1,41 @@ -analysis: - n_cores: 1 - preload_attempts: 250 -fits: - flip_for_ds9: true -grid: - remove_projected_centre: false -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. - use_border_relocator: false # If True, by default a pixelization's border is used to relocate all pixels outside its border to the border. -hpc: - hpc_mode: false - iterations_per_update: 5000 -adapt: - adapt_minimum_percent: 0.01 - adapt_noise_limit: 100000000.0 -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 -pixelization: - voronoi_nn_max_interpolation_neighbors: 300 -structures: - native_binned_only: false # If True, data structures are only stored in their native and binned format. This is used to reduce memory usage in autocti. -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: true - 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. +analysis: + n_cores: 1 +fits: + flip_for_ds9: true +grid: + remove_projected_centre: false +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. + use_border_relocator: false # If True, by default a pixelization's border is used to relocate all pixels outside its border to the border. +hpc: + hpc_mode: false + iterations_per_update: 5000 +adapt: + adapt_minimum_percent: 0.01 + adapt_noise_limit: 100000000.0 +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 +pixelization: + voronoi_nn_max_interpolation_neighbors: 300 +structures: + native_binned_only: false # If True, data structures are only stored in their native and binned format. This is used to reduce memory usage in autocti. +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: true \ No newline at end of file diff --git a/test_autogalaxy/config/grids.yaml b/test_autogalaxy/config/grids.yaml deleted file mode 100644 index a779246ac..000000000 --- a/test_autogalaxy/config/grids.yaml +++ /dev/null @@ -1,78 +0,0 @@ -interpolate: - convergence_2d_from: - Isothermal: false - IsothermalSph: true - deflections_yx_2d_from: - Isothermal: false - IsothermalSph: true - image_2d_from: - sersic: false - sersicSph: true - potential_2d_from: - Isothermal: 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: - MockGridRadialMinimum: 2.5 - MockIsothermal: 0.0001 - MockIsothermalSph: 0.03 - Chameleon: 0.0001 - ChameleonSph: 0.0001 - DevVaucouleurs: 0.0001 - DevVaucouleursSph: 0.0001 - ExponentialGradient: 0.0001 - ElsonFreeFall: 0.0001 - ElsonFreeFallSph: 0.0001 - Exponential: 0.0001 - ExponentialCore: 0.0001 - ExponentialCoreSph: 0.0001 - ExponentialSph: 0.0001 - ExternalShear: 0.0001 - Gaussian: 0.0001 - GaussianSph: 0.0001 - gNFW: 0.0001 - gNFWMCRLudlow: 0.0001 - gNFWSph: 0.0001 - Isothermal: 0.0001 - IsothermalCore: 0.0001 - IsothermalCoreSph: 0.0001 - IsothermalSph: 0.0001 - MassSheet: 0.0001 - Moffat: 0.0001 - MoffatSph: 0.0001 - NFW: 0.0001 - NFWMCRDuffySph: 0.0001 - NFWMCRLudlow: 0.0001 - NFWMCRLudlowSph: 0.0001 - NFWMCRScatterLudlow: 0.0001 - NFWMCRScatterLudlowSph: 0.0001 - NFWSph: 0.0001 - NFWTruncatedMCRDuffySph: 0.0001 - NFWTruncatedMCRLudlowSph: 0.0001 - NFWTruncatedMCRScatterLudlowSph: 0.0001 - NFWTruncatedSph: 0.0001 - PointMass: 0.0001 - PowerLaw: 0.0001 - PowerLawBroken: 0.0001 - PowerLawBrokenSph: 0.0001 - PowerLawCore: 0.0001 - PowerLawCoreSph: 0.0001 - PowerLawSph: 0.0001 - Sersic: 0.0001 - SersicCore: 0.0001 - SersicCoreSph: 0.0001 - SersicGradient: 0.0001 - SersicSph: 0.0001 - ExponentialGradientSph: 0.0001 - SersicGradientSph: 0.0001 - EllProfile: 0.0001 - SersicAdaptTest: 0.0001 diff --git a/test_autogalaxy/config/lensing.yaml b/test_autogalaxy/config/lensing.yaml index 9d68e82f6..319dc389d 100644 --- a/test_autogalaxy/config/lensing.yaml +++ b/test_autogalaxy/config/lensing.yaml @@ -1,11 +1,4 @@ -general: - calculation_grid: - convergence_threshold: 0.1 - pixels: 81 -grids: - radial_minimum: - radial_minimum: - isothermal: 0.01 - isothermalsph: 0.01 - mockisothermal: 0.01 - mockisothermalsph: 0.01 +general: + calculation_grid: + convergence_threshold: 0.1 + pixels: 81 diff --git a/test_autogalaxy/config/notation.yaml b/test_autogalaxy/config/notation.yaml index eaf0f0594..f88e205dc 100644 --- a/test_autogalaxy/config/notation.yaml +++ b/test_autogalaxy/config/notation.yaml @@ -1,83 +1,82 @@ -label: - label: - alpha: \alpha - angle_binary: \theta - beta: \beta - break_radius: \theta_{\rm B} - centre_0: y - centre_1: x - coefficient: \lambda - 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 + 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 + 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_autogalaxy/config/output.yaml b/test_autogalaxy/config/output.yaml index 5cb8812dc..4a44b384b 100644 --- a/test_autogalaxy/config/output.yaml +++ b/test_autogalaxy/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_autogalaxy/config/text.yaml b/test_autogalaxy/config/text.yaml index e5f604ce1..9803defba 100644 --- a/test_autogalaxy/config/text.yaml +++ b/test_autogalaxy/config/text.yaml @@ -1,11 +1,11 @@ -label_format: - format: - mass: '{:.4e}' - mass_value: mass_value - param0: '{:.2f}' - param00: '{:.2f}' - param000: '{:.2f}' - param11: '{:.4f}' - param12: '{:.2e}' - radius: '{:.2f}' - radius_value: radius_value +label_format: + format: + mass: '{:.4e}' + mass_value: mass_value + param0: '{:.2f}' + param00: '{:.2f}' + param000: '{:.2f}' + param11: '{:.4f}' + param12: '{:.2e}' + radius: '{:.2f}' + radius_value: radius_value diff --git a/test_autogalaxy/config/visualize.yaml b/test_autogalaxy/config/visualize.yaml index 1c0b5d16c..af4a18bcb 100644 --- a/test_autogalaxy/config/visualize.yaml +++ b/test_autogalaxy/config/visualize.yaml @@ -3,29 +3,6 @@ general: backend: default imshow_origin: upper zoom_around_mask: true -include: - include_1d: - einstein_radius: true - half_light_radius: true - include_2d: - border: true - tangential_caustics: false - radial_caustics: false - tangential_critical_curves: false - radial_critical_curves: false - grid: false - light_profile_centres: true - mapper_image_plane_mesh_grid: false - mapper_source_plane_data_grid: false - mapper_source_plane_mesh_grid: false - mask: true - mass_profile_centres: true - multiple_images: false - origin: true - parallel_overscan: true - positions: true - serial_overscan: true - serial_prescan: true mat_wrap: Axis: figure: @@ -293,47 +270,39 @@ mat_wrap_2d: TangentialCausticsPlot: figure: c: w,g - pointsize: 21 - style: -- - width: 5 + linestyle: -- + linewidth: 5 subplot: c: g - pointsize: 23 - style: -- - width: 7 + linestyle: -- + linewidth: 7 TangentialCriticalCurvesPlot: figure: c: w,k - pointsize: 20 - style: '-' - width: 4 + linestyle: '-' + linewidth: 4 subplot: c: b - pointsize: 22 - style: '-' - width: 6 + linestyle: '-' + linewidth: 6 RadialCausticsPlot: figure: c: w,g - pointsize: 21 - style: -- - width: 5 + linestyle: -- + linewidth: 5 subplot: c: g - pointsize: 23 - style: -- - width: 7 + linestyle: -- + linewidth: 7 RadialCriticalCurvesPlot: figure: c: w,k - pointsize: 20 - style: '-' - width: 4 + linestyle: '-' + linewidth: 4 subplot: c: b - pointsize: 22 - style: '-' - width: 6 + linestyle: '-' + linewidth: 6 LightProfileCentresScatter: figure: c: k,r diff --git a/test_autogalaxy/conftest.py b/test_autogalaxy/conftest.py index 5fb97e1c1..1d27ed90e 100644 --- a/test_autogalaxy/conftest.py +++ b/test_autogalaxy/conftest.py @@ -1,5 +1,11 @@ +import jax.numpy as jnp + + +def pytest_configure(): + _ = jnp.sum(jnp.array([0.0])) # Force backend init + + import os -import shutil from os import path import pytest @@ -8,6 +14,12 @@ from autoconf import conf from autogalaxy import fixtures +import logging + +logger = logging.getLogger(__name__) + +logger.setLevel(level="INFO") + class PlotPatch: def __init__(self): @@ -29,13 +41,10 @@ def make_plot_patch(monkeypatch): @pytest.fixture(autouse=True) def set_config_path(request): - output_path = path.join(directory, "output") conf.instance.push( new_path=path.join(directory, "config"), - output_path=output_path, + output_path=path.join(directory, "output"), ) - yield - shutil.rmtree(output_path, ignore_errors=True) @pytest.fixture(autouse=True, scope="session") @@ -135,11 +144,6 @@ def make_mask_2d_7x7(): return fixtures.make_mask_2d_7x7() -@pytest.fixture(name="convolver_7x7") -def make_convolver_7x7(): - return fixtures.make_convolver_7x7() - - @pytest.fixture(name="mask_2d_7x7_1_pix") def make_mask_2d_7x7_1_pix(): return fixtures.make_mask_2d_7x7_1_pix() @@ -379,16 +383,6 @@ def make_voronoi_mapper_9_3x3(): return fixtures.make_voronoi_mapper_9_3x3() -@pytest.fixture(name="include_1d_all") -def make_include_1d_all(): - return fixtures.make_include_1d_all() - - -@pytest.fixture(name="include_2d_all") -def make_include_2d_all(): - return fixtures.make_include_2d_all() - - @pytest.fixture(name="samples_summary_with_result") def make_samples_summary_with_result(): return fixtures.make_samples_summary_with_result() diff --git a/test_autogalaxy/cosmology/test_model.py b/test_autogalaxy/cosmology/test_model.py index ae8e9564e..8154a82da 100644 --- a/test_autogalaxy/cosmology/test_model.py +++ b/test_autogalaxy/cosmology/test_model.py @@ -1,10 +1,11 @@ import pytest -import autogalaxy as ag - def test__cosmology(Planck15): - cosmology = ag.cosmo.FlatwCDMWrap() + + from autogalaxy.cosmology.model import FlatwCDMWrap + + cosmology = FlatwCDMWrap() critical_surface_density = ( cosmology.critical_surface_density_between_redshifts_from( @@ -14,7 +15,9 @@ def test__cosmology(Planck15): assert critical_surface_density == pytest.approx(17613991217.945473, 1.0e-4) - cosmology = ag.cosmo.FlatLambdaCDMWrap() + from autogalaxy.cosmology.model import FlatLambdaCDMWrap + + cosmology = FlatLambdaCDMWrap() critical_surface_density = ( cosmology.critical_surface_density_between_redshifts_from( diff --git a/test_autogalaxy/galaxy/plot/test_adapt_plotters.py b/test_autogalaxy/galaxy/plot/test_adapt_plotters.py index 8e1eec666..5b3a2fa68 100644 --- a/test_autogalaxy/galaxy/plot/test_adapt_plotters.py +++ b/test_autogalaxy/galaxy/plot/test_adapt_plotters.py @@ -15,10 +15,9 @@ def make_adapt_plotter_setup(): def test__plot_adapt_adapt_images( - adapt_galaxy_name_image_dict_7x7, mask_2d_7x7, include_2d_all, plot_path, plot_patch + adapt_galaxy_name_image_dict_7x7, mask_2d_7x7, plot_path, plot_patch ): adapt_plotter = aplt.AdaptPlotter( - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) diff --git a/test_autogalaxy/galaxy/plot/test_galaxies_plotter.py b/test_autogalaxy/galaxy/plot/test_galaxies_plotter.py index 71a88e3ed..eddee94c0 100644 --- a/test_autogalaxy/galaxy/plot/test_galaxies_plotter.py +++ b/test_autogalaxy/galaxy/plot/test_galaxies_plotter.py @@ -19,14 +19,12 @@ def test__all_individual_plotter__output_file_with_default_name( grid_2d_7x7, mask_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): plotter = aplt.GalaxiesPlotter( galaxies=galaxies_7x7, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -40,14 +38,12 @@ def test__figures_of_galaxies( galaxies_x2_7x7, grid_2d_7x7, mask_2d_7x7, - include_2d_all, plot_path, plot_patch, ): plotter = aplt.GalaxiesPlotter( galaxies=galaxies_x2_7x7, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(path=plot_path, format="png")), ) @@ -64,15 +60,11 @@ def test__figures_of_galaxies( assert path.join(plot_path, "image_2d_of_galaxy_1.png") not in plot_patch.paths -def test__galaxies_sub_plot_output( - galaxies_x2_7x7, grid_2d_7x7, include_2d_all, include_1d_all, plot_path, plot_patch -): +def test__galaxies_sub_plot_output(galaxies_x2_7x7, grid_2d_7x7, plot_path, plot_patch): plotter = aplt.GalaxiesPlotter( galaxies=galaxies_x2_7x7, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) diff --git a/test_autogalaxy/galaxy/plot/test_galaxy_plotters.py b/test_autogalaxy/galaxy/plot/test_galaxy_plotters.py index 911cf83bf..e03fd3f29 100644 --- a/test_autogalaxy/galaxy/plot/test_galaxy_plotters.py +++ b/test_autogalaxy/galaxy/plot/test_galaxy_plotters.py @@ -15,12 +15,11 @@ def make_galaxy_plotter_setup(): def test__figures_1d__all_are_output( - gal_x1_lp_x1_mp, grid_2d_7x7, mask_2d_7x7, include_1d_all, plot_path, plot_patch + gal_x1_lp_x1_mp, grid_2d_7x7, mask_2d_7x7, plot_path, plot_patch ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d(image=True, convergence=True, potential=True) @@ -34,7 +33,6 @@ def test__figures_1d__all_are_output( galaxy_plotter = aplt.GalaxyPDFPlotter( galaxy_pdf_list=[gal_x1_lp_x1_mp, gal_x1_lp_x1_mp, gal_x1_lp_x1_mp], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d(image=True, convergence=True, potential=True) @@ -45,12 +43,11 @@ def test__figures_1d__all_are_output( def test__figures_1d_decomposed__all_are_output( - gal_x1_lp_x1_mp, grid_2d_7x7, mask_2d_7x7, include_1d_all, plot_path, plot_patch + gal_x1_lp_x1_mp, grid_2d_7x7, mask_2d_7x7, plot_path, plot_patch ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d_decomposed(image=True, convergence=True, potential=True) @@ -64,7 +61,6 @@ def test__figures_1d_decomposed__all_are_output( galaxy_plotter = aplt.GalaxyPDFPlotter( galaxy_pdf_list=[gal_x1_lp_x1_mp, gal_x1_lp_x1_mp, gal_x1_lp_x1_mp], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) @@ -76,7 +72,7 @@ def test__figures_1d_decomposed__all_are_output( def test__figures_1d_decomposed__light_profiles_different_centres_making_offset_radial_grid( - grid_2d_7x7, mask_2d_7x7, include_1d_all, plot_path, plot_patch + grid_2d_7x7, mask_2d_7x7, plot_path, plot_patch ): lp_0 = ag.lp.SersicSph(centre=(0.0, 0.0)) lp_1 = ag.lp.SersicSph(centre=(1.0, 1.0)) @@ -89,7 +85,6 @@ def test__figures_1d_decomposed__light_profiles_different_centres_making_offset_ galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d_decomposed(image=True, convergence=True, potential=True) @@ -110,7 +105,6 @@ def test__figures_1d_decomposed__light_profiles_different_centres_making_offset_ galaxy_plotter = aplt.GalaxyPDFPlotter( galaxy_pdf_list=[gal_0, gal_1], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=aplt.MatPlot1D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_1d_decomposed(image=True, convergence=True, potential=True) @@ -125,14 +119,12 @@ def test__figures_2d__all_are_output( grid_2d_7x7, mask_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.figures_2d(image=True, convergence=True) @@ -145,14 +137,12 @@ def test__subplots_galaxy_quantities__all_are_output( gal_x1_lp_x1_mp, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): galaxy_plotter = aplt.GalaxyPlotter( galaxy=gal_x1_lp_x1_mp, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) galaxy_plotter.subplot_of_light_profiles(image=True) diff --git a/test_autogalaxy/galaxy/test_galaxies.py b/test_autogalaxy/galaxy/test_galaxies.py index 5167723b0..ea16d74ab 100644 --- a/test_autogalaxy/galaxy/test_galaxies.py +++ b/test_autogalaxy/galaxy/test_galaxies.py @@ -29,7 +29,7 @@ def test__image_2d_from(grid_2d_7x7, gal_x1_lp): image = galaxies.image_2d_from(grid=grid_2d_7x7) - assert image == pytest.approx(galaxy_image, 1.0e-4) + assert image == pytest.approx(galaxy_image.array, 1.0e-4) # Overwrite one value so intensity in each pixel is different grid_2d_7x7[5] = np.array([2.0, 2.0]) @@ -45,7 +45,7 @@ def test__image_2d_from(grid_2d_7x7, gal_x1_lp): image = galaxies.image_2d_from(grid=grid_2d_7x7) - assert image == pytest.approx(g0_image + g1_image, 1.0e-4) + assert image == pytest.approx(g0_image.array + g1_image.array, 1.0e-4) def test__image_2d_list_from(grid_2d_7x7): @@ -65,8 +65,8 @@ def test__image_2d_list_from(grid_2d_7x7): image = galaxies.image_2d_from(grid=grid_2d_7x7) - assert image[0] == pytest.approx(lp0_image[0] + lp1_image[0], 1.0e-4) - assert image[1] == pytest.approx(lp0_image[1] + lp1_image[1], 1.0e-4) + assert image[0] == pytest.approx(lp0_image.array[0] + lp1_image.array[0], 1.0e-4) + assert image[1] == pytest.approx(lp0_image.array[1] + lp1_image.array[1], 1.0e-4) image_of_galaxies = galaxies.image_2d_list_from(grid=grid_2d_7x7) @@ -89,14 +89,14 @@ def test__image_2d_from__operated_only_input(grid_2d_7x7, lp_0, lp_operated_0): galaxies = ag.Galaxies(galaxies=[galaxy_0, galaxy_1, galaxy_2]) image_2d = galaxies.image_2d_from(grid=grid_2d_7x7, operated_only=False) - assert image_2d == pytest.approx(image_2d_not_operated, 1.0e-4) + assert image_2d == pytest.approx(image_2d_not_operated.array, 1.0e-4) image_2d = galaxies.image_2d_from(grid=grid_2d_7x7, operated_only=True) - assert image_2d == pytest.approx(3.0 * image_2d_operated, 1.0e-4) + assert image_2d == pytest.approx(3.0 * image_2d_operated.array, 1.0e-4) image_2d = galaxies.image_2d_from(grid=grid_2d_7x7, operated_only=None) assert image_2d == pytest.approx( - image_2d_not_operated + 3.0 * image_2d_operated, 1.0e-4 + image_2d_not_operated.array + 3.0 * image_2d_operated.array, 1.0e-4 ) @@ -113,18 +113,18 @@ def test__image_2d_list_from__operated_only_input(grid_2d_7x7, lp_0, lp_operated galaxies = ag.Galaxies(galaxies=[galaxy_0, galaxy_1, galaxy_2]) image_2d_list = galaxies.image_2d_list_from(grid=grid_2d_7x7, operated_only=False) - assert image_2d_list[0] == pytest.approx(image_2d_not_operated, 1.0e-4) + assert image_2d_list[0] == pytest.approx(image_2d_not_operated.array, 1.0e-4) assert image_2d_list[1] == pytest.approx(np.zeros((9)), 1.0e-4) assert image_2d_list[2] == pytest.approx(np.zeros((9)), 1.0e-4) image_2d_list = galaxies.image_2d_list_from(grid=grid_2d_7x7, operated_only=True) - assert image_2d_list[0] == pytest.approx(image_2d_operated, 1.0e-4) - assert image_2d_list[1] == pytest.approx(2.0 * image_2d_operated, 1.0e-4) + assert image_2d_list[0] == pytest.approx(image_2d_operated.array, 1.0e-4) + assert image_2d_list[1] == pytest.approx(2.0 * image_2d_operated.array, 1.0e-4) assert image_2d_list[2] == pytest.approx(np.zeros((9)), 1.0e-4) image_2d_list = galaxies.image_2d_list_from(grid=grid_2d_7x7, operated_only=None) assert image_2d_list[0] + image_2d_list[1] == pytest.approx( - image_2d_not_operated + 3.0 * image_2d_operated, 1.0e-4 + image_2d_not_operated.array + 3.0 * image_2d_operated.array, 1.0e-4 ) @@ -179,7 +179,9 @@ def test__convergence_2d_from(grid_2d_7x7): convergence = galaxies.convergence_2d_from(grid=grid_2d_7x7) - assert convergence == pytest.approx(g0_convergence + g1_convergence, 1.0e-8) + assert convergence.array == pytest.approx( + g0_convergence.array + g1_convergence.array, 1.0e-8 + ) def test__potential_2d_from(grid_2d_7x7): @@ -194,7 +196,7 @@ def test__potential_2d_from(grid_2d_7x7): potential = galaxies.potential_2d_from(grid=grid_2d_7x7) - assert potential == pytest.approx(g0_potential + g1_potential, 1.0e-8) + assert potential == pytest.approx(g0_potential.array + g1_potential.array, 1.0e-8) def test__deflections_yx_2d_from(grid_2d_7x7): @@ -212,7 +214,9 @@ def test__deflections_yx_2d_from(grid_2d_7x7): deflections = galaxies.deflections_yx_2d_from(grid=grid_2d_7x7) - assert deflections == pytest.approx(g0_deflections + g1_deflections, 1.0e-4) + assert deflections == pytest.approx( + g0_deflections.array + g1_deflections.array, 1.0e-4 + ) def test__has(): diff --git a/test_autogalaxy/galaxy/test_galaxy.py b/test_autogalaxy/galaxy/test_galaxy.py index ca087dfad..bb1098104 100644 --- a/test_autogalaxy/galaxy/test_galaxy.py +++ b/test_autogalaxy/galaxy/test_galaxy.py @@ -53,7 +53,7 @@ def test__image_2d_from(grid_2d_7x7, gal_x2_lp): gal_image = gal_x2_lp.image_2d_from(grid=grid_2d_7x7) - assert gal_image == pytest.approx(lp_image, 1.0e-4) + assert gal_image == pytest.approx(lp_image.array, 1.0e-4) def test__image_2d_from__operated_only_input(grid_2d_7x7, lp_0, lp_operated_0): @@ -298,13 +298,13 @@ def test__light_profile_2d_quantity_from_grid__symmetric_profiles_give_symmetric assert gal_x2_lp.image_2d_from( grid=ag.Grid2DIrregular([[0.0, 0.0]]) ) == pytest.approx( - gal_x2_lp.image_2d_from(grid=ag.Grid2DIrregular([[100.0, 0.0]])), 1.0e-4 + gal_x2_lp.image_2d_from(grid=ag.Grid2DIrregular([[100.0, 0.0]])).array, 1.0e-4 ) assert gal_x2_lp.image_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) ) == pytest.approx( - gal_x2_lp.image_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])), 1.0e-4 + gal_x2_lp.image_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array, 1.0e-4 ) lp_0 = ag.lp.Sersic( @@ -349,25 +349,25 @@ def test__light_profile_2d_quantity_from_grid__symmetric_profiles_give_symmetric assert gal_x4_lp.image_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) ) == pytest.approx( - gal_x4_lp.image_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])), 1e-5 + gal_x4_lp.image_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array, 1e-5 ) assert gal_x4_lp.image_2d_from( grid=ag.Grid2DIrregular([[0.0, 49.0]]) ) == pytest.approx( - gal_x4_lp.image_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])), 1e-5 + gal_x4_lp.image_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])).array, 1e-5 ) assert gal_x4_lp.image_2d_from( grid=ag.Grid2DIrregular([[100.0, 49.0]]) ) == pytest.approx( - gal_x4_lp.image_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]])), 1e-5 + gal_x4_lp.image_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]])).array, 1e-5 ) assert gal_x4_lp.image_2d_from( grid=ag.Grid2DIrregular([[49.0, 49.0]]) ) == pytest.approx( - gal_x4_lp.image_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])), 1e-5 + gal_x4_lp.image_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])).array, 1e-5 ) @@ -383,37 +383,41 @@ def test__mass_profile_2d_quantity_from_grid__symmetric_profiles_give_symmetric_ assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[99.0, 0.0]])), 1.0e-4 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[99.0, 0.0]])).array, + 1.0e-4, ) assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])), 1.0e-4 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array, + 1.0e-4, ) assert gal_x4_mp.potential_2d_from( grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[99.0, 0.0]])), 1e-6 + gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[99.0, 0.0]])).array, 1e-6 ) assert gal_x4_mp.potential_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])), 1e-6 + gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array, 1e-6 ) assert gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[99.0, 0.0]])), 1e-6 + gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[99.0, 0.0]])).array, + abs=1e-6, ) assert gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])), 1e-6 + gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array, + 1e-6, ) mp_0 = ag.mp.IsothermalSph(einstein_radius=1.0) @@ -435,108 +439,125 @@ def test__mass_profile_2d_quantity_from_grid__symmetric_profiles_give_symmetric_ assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])), 1e-5 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array, + 1e-5, ) assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[0.0, 49.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])), 1e-5 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])).array, + 1e-5, ) assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[100.0, 49.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]])), 1e-5 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]])).array, + 1e-5, ) assert gal_x4_mp.convergence_2d_from( grid=ag.Grid2DIrregular([[49.0, 49.0]]) ) == pytest.approx( - gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])), 1e-5 + gal_x4_mp.convergence_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])).array, + 1e-5, ) assert gal_x4_mp.potential_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) ) == pytest.approx( - gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])), 1e-5 + gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array, 1e-5 ) assert gal_x4_mp.potential_2d_from( grid=ag.Grid2DIrregular([[0.0, 49.0]]) ) == pytest.approx( - gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])), 1e-5 + gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])).array, 1e-5 ) assert gal_x4_mp.potential_2d_from( grid=ag.Grid2DIrregular([[100.0, 49.0]]) ) == pytest.approx( - gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]])), 1e-5 + gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]])).array, + 1e-5, ) assert gal_x4_mp.potential_2d_from( grid=ag.Grid2DIrregular([[49.0, 49.0]]) ) == pytest.approx( - gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])), 1e-5 + gal_x4_mp.potential_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])).array, 1e-5 ) assert -1.0 * gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) )[0, 0] == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]]))[0, 0], + gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array[ + 0, 0 + ], 1e-5, ) assert 1.0 * gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[0.0, 49.0]]) )[0, 0] == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]]))[0, 0], + gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])).array[ + 0, 0 + ], 1e-5, ) assert 1.0 * gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[100.0, 49.0]]) )[0, 0] == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]]))[ - 0, 0 - ], + gal_x4_mp.deflections_yx_2d_from( + grid=ag.Grid2DIrregular([[100.0, 51.0]]) + ).array[0, 0], 1e-5, ) assert -1.0 * gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[49.0, 49.0]]) )[0, 0] == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]]))[0, 0], + gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])).array[ + 0, 0 + ], 1e-5, ) assert 1.0 * gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[49.0, 0.0]]) )[0, 1] == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]]))[0, 1], + gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 0.0]])).array[ + 0, 1 + ], 1e-5, ) assert -1.0 * gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[0.0, 49.0]]) )[0, 1] == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]]))[0, 1], + gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 51.0]])).array[ + 0, 1 + ], 1e-5, ) assert -1.0 * gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[100.0, 49.0]]) )[0, 1] == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[100.0, 51.0]]))[ - 0, 1 - ], + gal_x4_mp.deflections_yx_2d_from( + grid=ag.Grid2DIrregular([[100.0, 51.0]]) + ).array[0, 1], 1e-5, ) assert -1.0 * gal_x4_mp.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[49.0, 49.0]]) )[0, 1] == pytest.approx( - gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]]))[0, 1], + gal_x4_mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[51.0, 51.0]])).array[ + 0, 1 + ], 1e-5, ) @@ -546,8 +567,8 @@ def test__centre_of_profile_in_right_place(): galaxy = ag.Galaxy( redshift=0.5, - mass=ag.mp.Isothermal(centre=(2.0, 1.0), einstein_radius=1.0), - mass_0=ag.mp.Isothermal(centre=(2.0, 1.0), einstein_radius=1.0), + mass=ag.mp.Isothermal(centre=(1.99999, 0.99999), einstein_radius=1.0), + mass_0=ag.mp.Isothermal(centre=(1.99999, 0.99999), einstein_radius=1.0), ) convergence = galaxy.convergence_2d_from(grid=grid) @@ -568,8 +589,8 @@ def test__centre_of_profile_in_right_place(): galaxy = ag.Galaxy( redshift=0.5, - mass=ag.mp.IsothermalSph(centre=(2.0, 1.0), einstein_radius=1.0), - mass_0=ag.mp.IsothermalSph(centre=(2.0, 1.0), einstein_radius=1.0), + mass=ag.mp.IsothermalSph(centre=(1.99999, 0.99999), einstein_radius=1.0), + mass_0=ag.mp.IsothermalSph(centre=(1.99999, 0.99999), einstein_radius=1.0), ) convergence = galaxy.convergence_2d_from(grid=grid) max_indexes = np.unravel_index( diff --git a/test_autogalaxy/galaxy/test_to_inversion.py b/test_autogalaxy/galaxy/test_to_inversion.py index 3d45987ff..e032748cb 100644 --- a/test_autogalaxy/galaxy/test_to_inversion.py +++ b/test_autogalaxy/galaxy/test_to_inversion.py @@ -100,7 +100,7 @@ def test__image_plane_mesh_grid_list(masked_imaging_7x7): def test__mapper_galaxy_dict(masked_imaging_7x7): - mesh = ag.mesh.Rectangular(shape=(3, 3)) + mesh = ag.mesh.RectangularUniform(shape=(3, 3)) pixelization = ag.m.MockPixelization(mesh=mesh) @@ -118,7 +118,7 @@ def test__mapper_galaxy_dict(masked_imaging_7x7): assert mapper_list[0].pixels == 9 assert mapper_galaxy_dict[mapper_list[0]] == galaxy_pix - mesh = ag.mesh.Rectangular(shape=(4, 3)) + mesh = ag.mesh.RectangularUniform(shape=(4, 3)) pixelization = ag.m.MockPixelization(mesh=mesh) galaxy_pix_2 = ag.Galaxy(redshift=0.5, pixelization=pixelization) @@ -151,7 +151,9 @@ def test__mapper_galaxy_dict(masked_imaging_7x7): def test__inversion_imaging_from(grid_2d_7x7, masked_imaging_7x7): - g_linear = ag.Galaxy(redshift=0.5, light_linear=ag.lp_linear.Sersic()) + g_linear = ag.Galaxy( + redshift=0.5, light_linear=ag.lp_linear.Sersic(centre=(0.05, 0.05)) + ) to_inversion = ag.GalaxiesToInversion( dataset=masked_imaging_7x7, @@ -161,10 +163,10 @@ def test__inversion_imaging_from(grid_2d_7x7, masked_imaging_7x7): inversion = to_inversion.inversion - assert inversion.reconstruction[0] == pytest.approx(0.00543437, 1.0e-2) + assert inversion.reconstruction[0] == pytest.approx(0.186868464426, 1.0e-2) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=0.0), ) @@ -184,7 +186,9 @@ def test__inversion_imaging_from(grid_2d_7x7, masked_imaging_7x7): def test__inversion_interferometer_from(grid_2d_7x7, interferometer_7): - g_linear = ag.Galaxy(redshift=0.5, light_linear=ag.lp_linear.Sersic()) + g_linear = ag.Galaxy( + redshift=0.5, light_linear=ag.lp_linear.Sersic(centre=(0.05, 0.05)) + ) to_inversion = ag.GalaxiesToInversion( dataset=interferometer_7, @@ -196,12 +200,12 @@ def test__inversion_interferometer_from(grid_2d_7x7, interferometer_7): inversion = to_inversion.inversion - assert inversion.reconstruction[0] == pytest.approx(0.0012073, 1.0e-2) + assert inversion.reconstruction[0] == pytest.approx(0.04124846952, 1.0e-2) interferometer_7.data = ag.Visibilities.ones(shape_slim=(7,)) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(7, 7)), + mesh=ag.mesh.RectangularUniform(shape=(7, 7)), regularization=ag.reg.Constant(coefficient=0.0), ) diff --git a/test_autogalaxy/imaging/model/test_analysis_imaging.py b/test_autogalaxy/imaging/model/test_analysis_imaging.py index 318cff56c..7d3173ec9 100644 --- a/test_autogalaxy/imaging/model/test_analysis_imaging.py +++ b/test_autogalaxy/imaging/model/test_analysis_imaging.py @@ -37,25 +37,3 @@ def test__figure_of_merit__matches_correct_fit_given_galaxy_profiles( fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=galaxies) assert fit.log_likelihood == fit_figure_of_merit - - -def test__profile_log_likelihood_function(masked_imaging_7x7): - pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), - regularization=ag.reg.Constant(coefficient=1.0), - ) - - galaxy = ag.Galaxy(redshift=0.5, pixelization=pixelization) - - model = af.Collection(galaxies=af.Collection(galaxy=galaxy)) - - instance = model.instance_from_unit_vector([]) - - analysis = ag.AnalysisImaging(dataset=masked_imaging_7x7) - - run_time_dict, info_dict = analysis.profile_log_likelihood_function( - instance=instance - ) - - assert "regularization_term_0" in run_time_dict - assert "log_det_regularization_matrix_term_0" in run_time_dict diff --git a/test_autogalaxy/imaging/model/test_plotter_interface_imaging.py b/test_autogalaxy/imaging/model/test_plotter_interface_imaging.py index d24358750..58f59479e 100644 --- a/test_autogalaxy/imaging/model/test_plotter_interface_imaging.py +++ b/test_autogalaxy/imaging/model/test_plotter_interface_imaging.py @@ -13,7 +13,7 @@ def make_plotter_interface_plotter_setup(): return path.join("{}".format(directory), "files") -def test__imaging(imaging_7x7, include_2d_all, plot_path, plot_patch): +def test__imaging(imaging_7x7, plot_path, plot_patch): if path.exists(plot_path): shutil.rmtree(plot_path) @@ -44,7 +44,6 @@ def test__imaging_combined(imaging_7x7, plot_path, plot_patch): def test__fit_imaging( masked_imaging_7x7, fit_imaging_x2_galaxy_inversion_7x7, - include_2d_all, plot_path, plot_patch, ): diff --git a/test_autogalaxy/imaging/model/test_result_imaging.py b/test_autogalaxy/imaging/model/test_result_imaging.py index 208146d7d..d824b5c1d 100644 --- a/test_autogalaxy/imaging/model/test_result_imaging.py +++ b/test_autogalaxy/imaging/model/test_result_imaging.py @@ -48,7 +48,9 @@ def test___image_dict(analysis_imaging_7x7): def test___linear_light_profiles_in_result(analysis_imaging_7x7): galaxies = af.ModelInstance() - galaxies.galaxy = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic()) + galaxies.galaxy = ag.Galaxy( + redshift=0.5, bulge=ag.lp_linear.Sersic(centre=(0.05, 0.05)) + ) instance = af.ModelInstance() instance.galaxies = galaxies @@ -64,5 +66,5 @@ def test___linear_light_profiles_in_result(analysis_imaging_7x7): ag.lp_linear.LightProfileLinear, ) assert result.max_log_likelihood_galaxies[0].bulge.intensity == pytest.approx( - 0.0054343, 1.0e-4 + 0.18686846, 1.0e-4 ) diff --git a/test_autogalaxy/imaging/plot/test_fit_imaging_plotters.py b/test_autogalaxy/imaging/plot/test_fit_imaging_plotters.py index b88b5ae0e..6ed807b02 100644 --- a/test_autogalaxy/imaging/plot/test_fit_imaging_plotters.py +++ b/test_autogalaxy/imaging/plot/test_fit_imaging_plotters.py @@ -15,11 +15,10 @@ def make_fit_imaging_plotter_setup(): def test__fit_individuals__source_and_galaxy__dependent_on_input( - fit_imaging_x2_galaxy_7x7, include_2d_all, plot_path, plot_patch + fit_imaging_x2_galaxy_7x7, plot_path, plot_patch ): fit_plotter = aplt.FitImagingPlotter( fit=fit_imaging_x2_galaxy_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -40,12 +39,9 @@ def test__fit_individuals__source_and_galaxy__dependent_on_input( assert path.join(plot_path, "chi_squared_map.png") in plot_patch.paths -def test__figures_of_galaxies( - fit_imaging_x2_galaxy_7x7, include_2d_all, plot_path, plot_patch -): +def test__figures_of_galaxies(fit_imaging_x2_galaxy_7x7, plot_path, plot_patch): fit_plotter = aplt.FitImagingPlotter( fit=fit_imaging_x2_galaxy_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -74,12 +70,9 @@ def test__figures_of_galaxies( assert path.join(plot_path, "model_image_of_galaxy_1.png") in plot_patch.paths -def test__subplot_of_galaxy( - fit_imaging_x2_galaxy_7x7, include_2d_all, plot_path, plot_patch -): +def test__subplot_of_galaxy(fit_imaging_x2_galaxy_7x7, plot_path, plot_patch): fit_plotter = aplt.FitImagingPlotter( fit=fit_imaging_x2_galaxy_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) fit_plotter.subplot_of_galaxies() diff --git a/test_autogalaxy/imaging/test_fit_imaging.py b/test_autogalaxy/imaging/test_fit_imaging.py index 3b3103fc2..a5489c6bb 100644 --- a/test_autogalaxy/imaging/test_fit_imaging.py +++ b/test_autogalaxy/imaging/test_fit_imaging.py @@ -32,18 +32,18 @@ def test__fit_figure_of_merit( masked_imaging_7x7, masked_imaging_covariance_7x7, ): - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) - g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) + g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) + g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[g0, g1]) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-75938.05, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-71.46911964, 1.0e-4) basis = ag.lp_basis.Basis( profile_list=[ - ag.lp.Sersic(intensity=1.0), - ag.lp.Sersic(intensity=1.0), + ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05)), + ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05)), ] ) @@ -52,10 +52,10 @@ def test__fit_figure_of_merit( fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[g0]) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-75938.05, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-71.46911964, 1.0e-4) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=1.0), ) @@ -66,21 +66,23 @@ def test__fit_figure_of_merit( ) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-22.9005, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-22.91411868616, 1.0e-4) - galaxy_light = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) + galaxy_light = ag.Galaxy( + redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05)) + ) fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[galaxy_light, galaxy_pix]) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-6840.5851, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-29.235208518732776, 1.0e-4) g0_linear_light = ag.Galaxy( - redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=1.0) + redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=1.0, centre=(0.05, 0.05)) ) g1_linear_light = ag.Galaxy( - redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=4.0) + redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=4.0, centre=(0.05, 0.05)) ) fit = ag.FitImaging( @@ -88,12 +90,12 @@ def test__fit_figure_of_merit( ) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-14.52327, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-14.544339716, 1.0e-4) basis = ag.lp_basis.Basis( profile_list=[ - ag.lp_linear.Sersic(sersic_index=1.0), - ag.lp_linear.Sersic(sersic_index=4.0), + ag.lp_linear.Sersic(sersic_index=1.0, centre=(0.05, 0.05)), + ag.lp_linear.Sersic(sersic_index=4.0, centre=(0.05, 0.05)), ] ) @@ -102,12 +104,12 @@ def test__fit_figure_of_merit( fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[g0]) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-14.52327, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-14.544339716, 1.0e-4) basis = ag.lp_basis.Basis( profile_list=[ - ag.lp_linear.Sersic(sersic_index=1.0), - ag.lp_linear.Sersic(sersic_index=4.0), + ag.lp_linear.Sersic(sersic_index=1.0, centre=(0.05, 0.05)), + ag.lp_linear.Sersic(sersic_index=4.0, centre=(0.05, 0.05)), ], regularization=ag.reg.Constant(coefficient=1.0), ) @@ -117,13 +119,13 @@ def test__fit_figure_of_merit( fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[g0]) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-29.21448984, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-25.83890655, 1.0e-4) g0_operated_light = ag.Galaxy( - redshift=0.5, bulge=ag.lp_operated.Sersic(intensity=1.0) + redshift=0.5, bulge=ag.lp_operated.Sersic(intensity=1.0, centre=(0.05, 0.05)) ) g1_operated_light = ag.Galaxy( - redshift=0.5, bulge=ag.lp_operated.Sersic(intensity=1.0) + redshift=0.5, bulge=ag.lp_operated.Sersic(intensity=1.0, centre=(0.05, 0.05)) ) fit = ag.FitImaging( @@ -131,13 +133,15 @@ def test__fit_figure_of_merit( ) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-342374.9618, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-289.6050404, 1.0e-4) g0_linear_operated_light = ag.Galaxy( - redshift=0.5, bulge=ag.lp_linear_operated.Sersic(sersic_index=1.0) + redshift=0.5, + bulge=ag.lp_linear_operated.Sersic(sersic_index=1.0, centre=(0.05, 0.05)), ) g1_linear_operated_light = ag.Galaxy( - redshift=0.5, bulge=ag.lp_linear_operated.Sersic(sersic_index=4.0) + redshift=0.5, + bulge=ag.lp_linear_operated.Sersic(sersic_index=4.0, centre=(0.05, 0.05)), ) fit = ag.FitImaging( @@ -146,22 +150,22 @@ def test__fit_figure_of_merit( ) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-14.7237273, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-14.7635041, 1.0e-4) fit = ag.FitImaging( dataset=masked_imaging_7x7, galaxies=[g0_linear_light, galaxy_pix] ) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-22.87827302, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-22.8918119554022, 1.0e-4) - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) - g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) + g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) + g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) fit = ag.FitImaging(dataset=masked_imaging_covariance_7x7, galaxies=[g0, g1]) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-130242.56, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-107.62350171, 1.0e-4) def test__fit__model_dataset__sky___handles_special_behaviour(masked_imaging_7x7): @@ -184,8 +188,12 @@ def test__fit__model_dataset__grid_offset__handles_special_behaviour( masked_imaging_7x7, masked_imaging_7x7_sub_2, ): - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(centre=(-1.0, -2.0), intensity=1.0)) - g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(centre=(-1.0, -2.0), intensity=1.0)) + g0 = ag.Galaxy( + redshift=0.5, bulge=ag.lp.Sersic(centre=(-1.05, -2.05), intensity=1.0) + ) + g1 = ag.Galaxy( + redshift=0.5, bulge=ag.lp.Sersic(centre=(-1.05, -2.05), intensity=1.0) + ) fit = ag.FitImaging( dataset=masked_imaging_7x7, @@ -193,10 +201,14 @@ def test__fit__model_dataset__grid_offset__handles_special_behaviour( dataset_model=ag.DatasetModel(grid_offset=(1.0, 2.0)), ) - assert fit.figure_of_merit == pytest.approx(-75938.05, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-71.4691196459, 1.0e-4) - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(centre=(-1.0, -2.0), intensity=1.0)) - g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(centre=(-1.0, -2.0), intensity=1.0)) + g0 = ag.Galaxy( + redshift=0.5, bulge=ag.lp.Sersic(centre=(-1.05, -2.05), intensity=1.0) + ) + g1 = ag.Galaxy( + redshift=0.5, bulge=ag.lp.Sersic(centre=(-1.05, -2.05), intensity=1.0) + ) fit = ag.FitImaging( dataset=masked_imaging_7x7_sub_2, @@ -204,10 +216,10 @@ def test__fit__model_dataset__grid_offset__handles_special_behaviour( dataset_model=ag.DatasetModel(grid_offset=(1.0, 2.0)), ) - assert fit.figure_of_merit == pytest.approx(-14.91028771456, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-14.93272811, 1.0e-4) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=1.0), ) @@ -219,7 +231,7 @@ def test__fit__model_dataset__grid_offset__handles_special_behaviour( dataset_model=ag.DatasetModel(grid_offset=(1.0, 2.0)), ) - assert fit.figure_of_merit == pytest.approx(-22.9005, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-22.914118686169, 1.0e-4) def test__galaxy_model_image_dict(masked_imaging_7x7): @@ -239,48 +251,52 @@ def test__galaxy_model_image_dict(masked_imaging_7x7): g0_blurred_image_2d = g0.blurred_image_2d_from( grid=masked_imaging_7x7.grids.lp, blurring_grid=masked_imaging_7x7.grids.blurring, - convolver=masked_imaging_7x7.convolver, + psf=masked_imaging_7x7.psf, ) g1_blurred_image_2d = g1.blurred_image_2d_from( grid=masked_imaging_7x7.grids.lp, blurring_grid=masked_imaging_7x7.grids.blurring, - convolver=masked_imaging_7x7.convolver, + psf=masked_imaging_7x7.psf, ) - assert fit.galaxy_model_image_dict[g0] == pytest.approx(g0_blurred_image_2d, 1.0e-4) - assert fit.galaxy_model_image_dict[g1] == pytest.approx(g1_blurred_image_2d, 1.0e-4) + assert fit.galaxy_model_image_dict[g0] == pytest.approx( + g0_blurred_image_2d.array, 1.0e-4 + ) + assert fit.galaxy_model_image_dict[g1] == pytest.approx( + g1_blurred_image_2d.array, 1.0e-4 + ) assert fit.galaxy_model_image_dict[g2] == pytest.approx( - g0_blurred_image_2d + g1_blurred_image_2d, 1.0e-4 + g0_blurred_image_2d.array + g1_blurred_image_2d.array, 1.0e-4 ) assert (fit.galaxy_model_image_dict[g3].slim == np.zeros(9)).all() assert fit.model_data == pytest.approx( - fit.galaxy_model_image_dict[g0] - + fit.galaxy_model_image_dict[g1] - + fit.galaxy_model_image_dict[g2], + fit.galaxy_model_image_dict[g0].array + + fit.galaxy_model_image_dict[g1].array + + fit.galaxy_model_image_dict[g2].array, 1.0e-4, ) # Linear Light Profiles only - g0_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic()) + g0_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic(centre=(0.05, 0.05))) fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[g0_linear, g3]) assert fit.galaxy_model_image_dict[g0_linear][4] == pytest.approx( - 1.50112088e00, 1.0e-4 + 1.5355385003, 1.0e-4 ) assert (fit.galaxy_model_image_dict[g3] == np.zeros(9)).all() - assert fit.model_data.native == pytest.approx( - fit.galaxy_model_image_dict[g0_linear].native, 1.0e-4 + assert fit.model_data.native.array == pytest.approx( + fit.galaxy_model_image_dict[g0_linear].native.array, 1.0e-4 ) # Pixelization + Regularizaiton only pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=1.0), ) @@ -291,22 +307,22 @@ def test__galaxy_model_image_dict(masked_imaging_7x7): assert (fit.galaxy_model_image_dict[g0] == np.zeros(9)).all() - assert fit.galaxy_model_image_dict[g1][4] == pytest.approx(1.2570779, 1.0e-4) - assert fit.galaxy_model_image_dict[g1].native == pytest.approx( - fit.inversion.mapped_reconstructed_image.native, 1.0e-4 + assert fit.galaxy_model_image_dict[g1][4] == pytest.approx(1.25795063, 1.0e-4) + assert fit.galaxy_model_image_dict[g1].native.array == pytest.approx( + fit.inversion.mapped_reconstructed_image.native.array, 1.0e-4 ) - assert fit.model_data.native == pytest.approx( - fit.galaxy_model_image_dict[g1].native, 1.0e-4 + assert fit.model_data.native.array == pytest.approx( + fit.galaxy_model_image_dict[g1].native.array, 1.0e-4 ) # Linear Light PRofiles + Pixelization + Regularizaiton - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) - g1_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic()) + g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) + g1_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic(centre=(0.05, 0.05))) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=1.0), ) @@ -323,15 +339,15 @@ def test__galaxy_model_image_dict(masked_imaging_7x7): assert (fit.galaxy_model_image_dict[g3] == np.zeros(9)).all() - assert fit.galaxy_model_image_dict[g0][4] == pytest.approx(276.227301, 1.0e-4) + assert fit.galaxy_model_image_dict[g0][4] == pytest.approx(8.2172158101, 1.0e-4) assert fit.galaxy_model_image_dict[g1_linear][4] == pytest.approx( - -277.619503, 1.0e-4 + -9.658085312, 1.0e-4 ) assert fit.galaxy_model_image_dict[galaxy_pix_0][4] == pytest.approx( - 1.085283555, 1.0e-4 + 1.10780906, 1.0e-4 ) assert fit.galaxy_model_image_dict[galaxy_pix_1][4] == pytest.approx( - 1.085283673, 1.0e-4 + 1.10780906, 1.0e-4 ) mapped_reconstructed_image = ( @@ -341,11 +357,12 @@ def test__galaxy_model_image_dict(masked_imaging_7x7): ) assert mapped_reconstructed_image == pytest.approx( - fit.inversion.mapped_reconstructed_image, 1.0e-4 + fit.inversion.mapped_reconstructed_image.array, 1.0e-4 ) assert fit.model_data == pytest.approx( - fit.galaxy_model_image_dict[g0] + fit.inversion.mapped_reconstructed_image, + fit.galaxy_model_image_dict[g0].array + + fit.inversion.mapped_reconstructed_image.array, 1.0e-4, ) @@ -355,7 +372,7 @@ def test__model_images_of_galaxies_list(masked_imaging_7x7): galaxy_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic()) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=1.0), ) @@ -366,13 +383,13 @@ def test__model_images_of_galaxies_list(masked_imaging_7x7): ) assert fit.model_images_of_galaxies_list[0] == pytest.approx( - fit.galaxy_model_image_dict[galaxy_light], 1.0e-4 + fit.galaxy_model_image_dict[galaxy_light].array, 1.0e-4 ) - assert fit.model_images_of_galaxies_list[1] == pytest.approx( - fit.galaxy_model_image_dict[galaxy_linear], 1.0e-4 + assert fit.model_images_of_galaxies_list[1].array == pytest.approx( + fit.galaxy_model_image_dict[galaxy_linear].array, 1.0e-4 ) assert fit.model_images_of_galaxies_list[2] == pytest.approx( - fit.galaxy_model_image_dict[galaxy_pix], 1.0e-4 + fit.galaxy_model_image_dict[galaxy_pix].array, 1.0e-4 ) @@ -448,8 +465,8 @@ def test___unmasked_blurred_images(masked_imaging_7x7): def test__light_profile_linear__intensity_dict(masked_imaging_7x7): - linear_light_0 = ag.lp_linear.Sersic(sersic_index=1.0) - linear_light_1 = ag.lp_linear.Sersic(sersic_index=4.0) + linear_light_0 = ag.lp_linear.Sersic(sersic_index=1.0, centre=(0.05, 0.05)) + linear_light_1 = ag.lp_linear.Sersic(sersic_index=4.0, centre=(0.05, 0.05)) g0_linear_light = ag.Galaxy(redshift=0.5, bulge=linear_light_0) @@ -460,10 +477,10 @@ def test__light_profile_linear__intensity_dict(masked_imaging_7x7): ) assert fit.linear_light_profile_intensity_dict[linear_light_0] == pytest.approx( - 7.093227476666252, 1.0e-4 + 8.88030654536974, 1.0e-4 ) assert fit.linear_light_profile_intensity_dict[linear_light_1] == pytest.approx( - -0.04694839915145, 1.0e-4 + -1.665197975, 1.0e-4 ) basis = ag.lp_basis.Basis(profile_list=[linear_light_0, linear_light_1]) @@ -473,14 +490,14 @@ def test__light_profile_linear__intensity_dict(masked_imaging_7x7): fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[g_basis]) assert fit.linear_light_profile_intensity_dict[linear_light_0] == pytest.approx( - 7.093227476666252, 1.0e-4 + 8.8803065453, 1.0e-4 ) assert fit.linear_light_profile_intensity_dict[linear_light_1] == pytest.approx( - -0.04694839915145, 1.0e-4 + -1.66519797593, 1.0e-4 ) - linear_light_2 = ag.lp_linear.Sersic(sersic_index=2.0) - linear_light_3 = ag.lp_linear.Sersic(sersic_index=3.0) + linear_light_2 = ag.lp_linear.Sersic(sersic_index=2.0, centre=(0.05, 0.05)) + linear_light_3 = ag.lp_linear.Sersic(sersic_index=3.0, centre=(0.05, 0.05)) basis = ag.lp_basis.Basis(profile_list=[linear_light_2, linear_light_3]) @@ -489,22 +506,25 @@ def test__light_profile_linear__intensity_dict(masked_imaging_7x7): fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[g0_linear_light, g_basis]) assert fit.linear_light_profile_intensity_dict[linear_light_0] == pytest.approx( - -21.77759470, 1.0e-4 + -37.819608481, 1.0e-4 ) assert fit.linear_light_profile_intensity_dict[linear_light_2] == pytest.approx( - 29.3935231947, 1.0e-4 + 81.76657216, 1.0e-4 ) assert fit.linear_light_profile_intensity_dict[linear_light_3] == pytest.approx( - -4.77469646, 1.0e-4 + -41.402749460449, 1.0e-4 ) def test__galaxies_linear_light_profiles_to_light_profiles(masked_imaging_7x7): - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) + g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) - g0_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=1.0)) - - g1_linear = ag.Galaxy(redshift=1.0, bulge=ag.lp_linear.Sersic(sersic_index=4.0)) + g0_linear = ag.Galaxy( + redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=1.0, centre=(0.05, 0.05)) + ) + g1_linear = ag.Galaxy( + redshift=1.0, bulge=ag.lp_linear.Sersic(sersic_index=4.0, centre=(0.05, 0.05)) + ) fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[g0, g0_linear, g1_linear]) @@ -513,21 +533,23 @@ def test__galaxies_linear_light_profiles_to_light_profiles(masked_imaging_7x7): galaxies = fit.galaxies_linear_light_profiles_to_light_profiles assert galaxies[0].bulge.intensity == pytest.approx(1.0, 1.0e-4) - assert galaxies[1].bulge.intensity == pytest.approx(7.0932274, 1.0e-4) - assert galaxies[2].bulge.intensity == pytest.approx(-1.04694839, 1.0e-4) + assert galaxies[1].bulge.intensity == pytest.approx(8.8803030953, 1.0e-4) + assert galaxies[2].bulge.intensity == pytest.approx(-2.665197940, 1.0e-4) - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) + g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) basis = ag.lp_basis.Basis( profile_list=[ - ag.lp_linear.Sersic(sersic_index=1.0), - ag.lp.Sersic(intensity=0.1, sersic_index=2.0), - ag.lp_linear.Sersic(sersic_index=3.0), + ag.lp_linear.Sersic(sersic_index=1.0, centre=(0.05, 0.05)), + ag.lp.Sersic(intensity=0.1, sersic_index=2.0, centre=(0.05, 0.05)), + ag.lp_linear.Sersic(sersic_index=3.0, centre=(0.05, 0.05)), ] ) g0_linear = ag.Galaxy(redshift=0.5, bulge=basis) - g1_linear = ag.Galaxy(redshift=1.0, bulge=ag.lp_linear.Sersic(sersic_index=4.0)) + g1_linear = ag.Galaxy( + redshift=1.0, bulge=ag.lp_linear.Sersic(sersic_index=4.0, centre=(0.05, 0.05)) + ) fit = ag.FitImaging(dataset=masked_imaging_7x7, galaxies=[g0, g0_linear, g1_linear]) @@ -541,10 +563,10 @@ def test__galaxies_linear_light_profiles_to_light_profiles(masked_imaging_7x7): assert galaxies[0].bulge.intensity == pytest.approx(1.0, 1.0e-4) assert galaxies[1].bulge.profile_list[0].intensity == pytest.approx( - -14.74483, 1.0e-4 + -24.52668307515, 1.0e-4 ) assert galaxies[1].bulge.profile_list[1].intensity == pytest.approx(0.1, 1.0e-4) assert galaxies[1].bulge.profile_list[2].intensity == pytest.approx( - 23.0021210, 1.0e-4 + 90.36651920, 1.0e-4 ) - assert galaxies[2].bulge.intensity == pytest.approx(-6.58608, 1.0e-4) + assert galaxies[2].bulge.intensity == pytest.approx(-64.44560420348, 1.0e-4) diff --git a/test_autogalaxy/imaging/test_simulate_and_fit_imaging.py b/test_autogalaxy/imaging/test_simulate_and_fit_imaging.py index e60c00cce..170b8ef6a 100644 --- a/test_autogalaxy/imaging/test_simulate_and_fit_imaging.py +++ b/test_autogalaxy/imaging/test_simulate_and_fit_imaging.py @@ -97,7 +97,7 @@ def test__simulate_imaging_data_and_fit__known_likelihood(): ) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(16, 16)), + mesh=ag.mesh.RectangularUniform(shape=(16, 16)), regularization=ag.reg.Constant(coefficient=(1.0)), ) @@ -108,14 +108,14 @@ def test__simulate_imaging_data_and_fit__known_likelihood(): dataset = simulator.via_galaxies_from(galaxies=[galaxy_0, galaxy_1], grid=grid) mask = ag.Mask2D.circular( - shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=2.0 + shape_native=dataset.data.shape_native, pixel_scales=0.2, radius=2.005 ) masked_dataset = dataset.apply_mask(mask=mask) fit = ag.FitImaging(dataset=masked_dataset, galaxies=[galaxy_0, galaxy_1]) - assert fit.figure_of_merit == pytest.approx(538.9777105858, 1.0e-2) + assert fit.figure_of_merit == pytest.approx(579.015739085647, 1.0e-2) # Check that using a Basis gives the same result. @@ -134,7 +134,7 @@ def test__simulate_imaging_data_and_fit__known_likelihood(): fit = ag.FitImaging(dataset=masked_dataset, galaxies=[galaxy_0, galaxy_1]) - assert fit.figure_of_merit == pytest.approx(538.9777105858, 1.0e-2) + assert fit.figure_of_merit == pytest.approx(579.015739085647, 1.0e-2) def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standard_light_profiles(): @@ -150,8 +150,8 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standa galaxy = ag.Galaxy( redshift=0.5, - bulge=ag.lp.Sersic(intensity=0.1, sersic_index=1.0), - disk=ag.lp.Sersic(intensity=0.2, sersic_index=4.0), + bulge=ag.lp.Sersic(centre=(0.05, 0.05), intensity=0.1, sersic_index=1.0), + disk=ag.lp.Sersic(centre=(0.05, 0.05), intensity=0.2, sersic_index=4.0), ) simulator = ag.SimulatorImaging( @@ -166,18 +166,19 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standa mask = ag.Mask2D.circular( shape_native=dataset.data.shape_native, pixel_scales=0.2, - radius=0.8, + radius=0.81, ) masked_dataset = dataset.apply_mask(mask=mask) + masked_dataset = masked_dataset.apply_over_sampling(over_sample_size_lp=1) fit = ag.FitImaging(dataset=masked_dataset, galaxies=[galaxy]) galaxy_linear = ag.Galaxy( redshift=0.5, - bulge=ag.lp_linear.Sersic(sersic_index=1.0), - disk=ag.lp_linear.Sersic(sersic_index=4.0), + bulge=ag.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=1.0), + disk=ag.lp_linear.Sersic(centre=(0.05, 0.05), sersic_index=4.0), ) fit_linear = ag.FitImaging( @@ -202,10 +203,10 @@ def test__simulate_imaging_data_and_fit__linear_light_profiles_agree_with_standa galaxy_image = galaxy.blurred_image_2d_from( grid=masked_dataset.grids.lp, - convolver=masked_dataset.convolver, + psf=masked_dataset.psf, blurring_grid=masked_dataset.grids.blurring, ) assert fit_linear.galaxy_model_image_dict[galaxy_linear] == pytest.approx( - galaxy_image, 1.0e-4 + galaxy_image.array, 1.0e-4 ) diff --git a/test_autogalaxy/imaging/test_simulator.py b/test_autogalaxy/imaging/test_simulator.py index 257783e5e..7580bdb2d 100644 --- a/test_autogalaxy/imaging/test_simulator.py +++ b/test_autogalaxy/imaging/test_simulator.py @@ -37,7 +37,9 @@ def test__from_fits__all_imaging_data_structures_are_flipped_for_ds9(): create_fits(fits_path=image_path, array=[[1.0, 0.0], [0.0, 0.0]]) create_fits(fits_path=noise_map_path, array=[[2.0, 1.0], [1.0, 1.0]]) - create_fits(fits_path=psf_path, array=[[1.0, 1.0], [0.0, 0.0]]) + create_fits( + fits_path=psf_path, array=[[1.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]] + ) dataset = ag.Imaging.from_fits( data_path=image_path, @@ -48,7 +50,9 @@ def test__from_fits__all_imaging_data_structures_are_flipped_for_ds9(): assert (dataset.data.native == np.array([[0.0, 0.0], [1.0, 0.0]])).all() assert (dataset.noise_map.native == np.array([[1.0, 1.0], [2.0, 1.0]])).all() - assert (dataset.psf.native == np.array([[0.0, 0.0], [0.5, 0.5]])).all() + assert dataset.psf.native == pytest.approx( + np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.5, 0.5, 0.0]]), 1.0e-4 + ) dataset.output_to_fits( data_path=image_path, @@ -67,7 +71,9 @@ def test__from_fits__all_imaging_data_structures_are_flipped_for_ds9(): hdu_list = fits.open(psf_path) psf = np.array(hdu_list[0].data).astype("float64") - assert (psf == np.array([[0.5, 0.5], [0.0, 0.0]])).all() + assert psf == pytest.approx( + np.array([[0.5, 0.5, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]), 1.0e-4 + ) clean_fits(fits_path=fits_path) @@ -101,7 +107,7 @@ def test__simulator__via_galaxies_from(): assert dataset.data.native[0, 0] != imaging_via_image.data.native[0, 0] assert dataset.data.native[10, 10] == imaging_via_image.data.native[10, 10] assert dataset.psf == pytest.approx(imaging_via_image.psf, 1.0e-4) - assert (dataset.noise_map == imaging_via_image.noise_map).all() + assert dataset.noise_map == pytest.approx(imaging_via_image.noise_map, 1.0e-4) def test__simulator__simulate_imaging_from_galaxy__source_galaxy__compare_to_imaging(): @@ -146,4 +152,4 @@ def test__simulator__simulate_imaging_from_galaxy__source_galaxy__compare_to_ima assert dataset.shape_native == (11, 11) assert dataset.data == pytest.approx(imaging_via_image.data, 1.0e-4) assert (dataset.psf == imaging_via_image.psf).all() - assert (dataset.noise_map == imaging_via_image.noise_map).all() + assert dataset.noise_map == pytest.approx(imaging_via_image.noise_map, 1.0e-4) diff --git a/test_autogalaxy/interferometer/model/test_analysis_interferometer.py b/test_autogalaxy/interferometer/model/test_analysis_interferometer.py index 7f3f59b10..362d1e799 100644 --- a/test_autogalaxy/interferometer/model/test_analysis_interferometer.py +++ b/test_autogalaxy/interferometer/model/test_analysis_interferometer.py @@ -38,25 +38,3 @@ def test__fit_figure_of_merit__matches_correct_fit_given_galaxy_profiles( fit = ag.FitInterferometer(dataset=interferometer_7, galaxies=galaxies) assert fit.log_likelihood == fit_figure_of_merit - - -def test__profile_log_likelihood_function(interferometer_7): - pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), - regularization=ag.reg.Constant(coefficient=1.0), - ) - - galaxy = ag.Galaxy(redshift=0.5, pixelization=pixelization) - - model = af.Collection(galaxies=af.Collection(galaxy=galaxy)) - - instance = model.instance_from_unit_vector([]) - - analysis = ag.AnalysisInterferometer(dataset=interferometer_7) - - run_time_dict, info_dict = analysis.profile_log_likelihood_function( - instance=instance - ) - - assert "regularization_term_0" in run_time_dict - assert "log_det_regularization_matrix_term_0" in run_time_dict diff --git a/test_autogalaxy/interferometer/model/test_plotter_interface_interferometer.py b/test_autogalaxy/interferometer/model/test_plotter_interface_interferometer.py index a9f6caca8..a779f7d4c 100644 --- a/test_autogalaxy/interferometer/model/test_plotter_interface_interferometer.py +++ b/test_autogalaxy/interferometer/model/test_plotter_interface_interferometer.py @@ -15,7 +15,7 @@ def make_plotter_interface_plotter_setup(): return path.join("{}".format(directory), "files") -def test__interferometer(interferometer_7, include_2d_all, plot_path, plot_patch): +def test__interferometer(interferometer_7, plot_path, plot_patch): plotter_interface = PlotterInterfaceInterferometer(image_path=plot_path) plotter_interface.interferometer(dataset=interferometer_7) @@ -32,7 +32,6 @@ def test__interferometer(interferometer_7, include_2d_all, plot_path, plot_patch def test__fit_interferometer( interferometer_7, fit_interferometer_x2_galaxy_inversion_7x7, - include_2d_all, plot_path, plot_patch, ): diff --git a/test_autogalaxy/interferometer/plot/test_fit_interferometer_plotters.py b/test_autogalaxy/interferometer/plot/test_fit_interferometer_plotters.py index ce6797133..174351865 100644 --- a/test_autogalaxy/interferometer/plot/test_fit_interferometer_plotters.py +++ b/test_autogalaxy/interferometer/plot/test_fit_interferometer_plotters.py @@ -14,13 +14,11 @@ def make_fit_dataset_plotter_setup(): def test__fit_sub_plot_real_space( fit_interferometer_7x7, fit_interferometer_x2_galaxy_inversion_7x7, - include_2d_all, plot_path, plot_patch, ): fit_plotter = aplt.FitInterferometerPlotter( fit=fit_interferometer_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -32,7 +30,6 @@ def test__fit_sub_plot_real_space( fit_plotter = aplt.FitInterferometerPlotter( fit=fit_interferometer_x2_galaxy_inversion_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) diff --git a/test_autogalaxy/interferometer/test_fit_interferometer.py b/test_autogalaxy/interferometer/test_fit_interferometer.py index e55deff70..9bbe190aa 100644 --- a/test_autogalaxy/interferometer/test_fit_interferometer.py +++ b/test_autogalaxy/interferometer/test_fit_interferometer.py @@ -9,24 +9,25 @@ def test__model_visibilities(interferometer_7): fit = ag.FitInterferometer(dataset=interferometer_7, galaxies=[g0]) - assert fit.model_data.slim[0] == pytest.approx(np.array([1.48496 + 0.0]), 1.0e-4) - assert fit.log_likelihood == pytest.approx(-34.16859, 1.0e-4) + assert fit.model_data.slim[0].real == pytest.approx(1.48496, abs=1.0e-4) + assert fit.model_data.slim[0].imag == pytest.approx(0.0, abs=1.0e-4) + assert fit.log_likelihood == pytest.approx(-34.1685958, abs=1.0e-4) def test__fit_figure_of_merit(interferometer_7): - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) + g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) - g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) + g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) fit = ag.FitInterferometer(dataset=interferometer_7, galaxies=[g0, g1]) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-2398107.3849, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-1994.35383952, 1.0e-4) basis = ag.lp_basis.Basis( profile_list=[ - ag.lp.Sersic(intensity=1.0), - ag.lp.Sersic(intensity=1.0), + ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05)), + ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05)), ] ) @@ -35,10 +36,10 @@ def test__fit_figure_of_merit(interferometer_7): fit = ag.FitInterferometer(dataset=interferometer_7, galaxies=[g0]) assert fit.perform_inversion is False - assert fit.figure_of_merit == pytest.approx(-2398107.3849, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-1994.3538395, 1.0e-4) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=0.01), ) @@ -51,12 +52,14 @@ def test__fit_figure_of_merit(interferometer_7): ) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-66.90612, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-71.770448724198, 1.0e-4) - galaxy_light = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) + galaxy_light = ag.Galaxy( + redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05)) + ) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=1.0), ) @@ -69,14 +72,14 @@ def test__fit_figure_of_merit(interferometer_7): ) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-283424.48941, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-196.15073725528504, 1.0e-4) g0_linear_light = ag.Galaxy( - redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=1.0) + redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=1.0, centre=(0.05, 0.05)) ) g1_linear_light = ag.Galaxy( - redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=4.0) + redshift=0.5, bulge=ag.lp_linear.Sersic(sersic_index=4.0, centre=(0.05, 0.05)) ) fit = ag.FitInterferometer( @@ -88,58 +91,35 @@ def test__fit_figure_of_merit(interferometer_7): basis = ag.lp_basis.Basis( profile_list=[ - ag.lp_linear.Sersic(sersic_index=1.0), - ag.lp_linear.Sersic(sersic_index=4.0), + ag.lp_linear.Sersic(sersic_index=1.0, centre=(0.05, 0.05)), + ag.lp_linear.Sersic(sersic_index=4.0, centre=(0.05, 0.05)), ] ) fit = ag.FitInterferometer( - dataset=interferometer_7, galaxies=[g0_linear_light, g1_linear_light] + dataset=interferometer_7, galaxies=[ag.Galaxy(redshift=0.5, bulge=basis)] ) assert fit.perform_inversion is True - assert fit.figure_of_merit == pytest.approx(-23.44419, 1.0e-4) + assert fit.figure_of_merit == pytest.approx(-23.44419235, 1.0e-4) fit = ag.FitInterferometer( dataset=interferometer_7, galaxies=[g0_linear_light, galaxy_pix] ) - assert fit.log_evidence == pytest.approx(-35.16806296, 1e-4) - assert fit.figure_of_merit == pytest.approx(-35.16806296, 1.0e-4) - - -def test___fit_figure_of_merit__different_settings( - interferometer_7, interferometer_7_lop -): - pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), - regularization=ag.reg.Constant(coefficient=0.01), - ) - - g0 = ag.Galaxy(redshift=0.5, pixelization=pixelization) - - fit = ag.FitInterferometer( - dataset=interferometer_7_lop, - galaxies=[ag.Galaxy(redshift=0.5), g0], - settings_inversion=ag.SettingsInversion( - use_w_tilde=False, use_linear_operators=True - ), - ) - - assert (fit.noise_map.slim == np.full(fill_value=2.0 + 2.0j, shape=(7,))).all() - assert fit.log_evidence == pytest.approx(-71.5177, 1e-4) - assert fit.figure_of_merit == pytest.approx(-71.5177, 1.0e-4) + assert fit.log_evidence == pytest.approx(-37.4081355120388, 1e-4) + assert fit.figure_of_merit == pytest.approx(-37.4081355120388, 1.0e-4) def test___galaxy_model_image_dict(interferometer_7): # Normal Light Profiles Only - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) - g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=2.0)) + g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) + g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=2.0, centre=(0.05, 0.05))) g2 = ag.Galaxy( redshift=0.5, - light_profile_0=ag.lp.Sersic(intensity=1.0), - light_profile_1=ag.lp.Sersic(intensity=2.0), + light_profile_0=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05)), + light_profile_1=ag.lp.Sersic(intensity=2.0, centre=(0.05, 0.05)), ) fit = ag.FitInterferometer( @@ -151,13 +131,15 @@ def test___galaxy_model_image_dict(interferometer_7): g0_image = g0.image_2d_from(grid=interferometer_7.grids.lp) g1_image = g1.image_2d_from(grid=interferometer_7.grids.lp) - assert fit.galaxy_model_image_dict[g0] == pytest.approx(g0_image, 1.0e-4) - assert fit.galaxy_model_image_dict[g1] == pytest.approx(g1_image, 1.0e-4) - assert fit.galaxy_model_image_dict[g2] == pytest.approx(g0_image + g1_image, 1.0e-4) + assert fit.galaxy_model_image_dict[g0] == pytest.approx(g0_image.array, 1.0e-4) + assert fit.galaxy_model_image_dict[g1] == pytest.approx(g1_image.array, 1.0e-4) + assert fit.galaxy_model_image_dict[g2] == pytest.approx( + g0_image.array + g1_image.array, 1.0e-4 + ) # Linear Light Profiles Only - g0_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic()) + g0_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic(centre=(0.05, 0.05))) fit = ag.FitInterferometer( dataset=interferometer_7, @@ -166,13 +148,13 @@ def test___galaxy_model_image_dict(interferometer_7): ) assert fit.galaxy_model_image_dict[g0_linear][4] == pytest.approx( - 0.99967378, 1.0e-4 + 0.9876689631, 1.0e-4 ) # Pixelization + Regularizaiton only pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=1.0), ) @@ -206,14 +188,14 @@ def test___galaxy_model_image_dict(interferometer_7): assert (fit.galaxy_model_image_dict[g0].native == 0.0 + 0.0j * np.zeros((7,))).all() - assert fit.galaxy_model_image_dict[galaxy_pix_0] == pytest.approx( - inversion.mapped_reconstructed_image.slim, 1.0e-4 + assert fit.galaxy_model_image_dict[galaxy_pix_0].array == pytest.approx( + inversion.mapped_reconstructed_image.slim.array, 1.0e-4 ) # Linear Light PRofiles + Pixelization + Regularizaiton pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=2.0), ) @@ -226,14 +208,14 @@ def test___galaxy_model_image_dict(interferometer_7): ) assert fit.galaxy_model_image_dict[g0_linear][4] == pytest.approx( - -1.65495642e03, 1.0e-2 + -46.8820117, 1.0e-2 ) - assert fit.galaxy_model_image_dict[g1] == pytest.approx(g1_image, 1.0e-4) + assert fit.galaxy_model_image_dict[g1] == pytest.approx(g1_image.array, 1.0e-4) assert fit.galaxy_model_image_dict[galaxy_pix_0][4] == pytest.approx( - -0.000164926, 1.0e-2 + -0.00541699, 1.0e-2 ) assert fit.galaxy_model_image_dict[galaxy_pix_1][4] == pytest.approx( - -0.000153471881, 1.0e-2 + -0.00563034, 1.0e-2 ) mapped_reconstructed_image = ( @@ -242,20 +224,20 @@ def test___galaxy_model_image_dict(interferometer_7): + fit.galaxy_model_image_dict[galaxy_pix_1] ) - assert mapped_reconstructed_image == pytest.approx( - fit.inversion.mapped_reconstructed_image, 1.0e-4 + assert mapped_reconstructed_image.array == pytest.approx( + fit.inversion.mapped_reconstructed_image.array, 1.0e-4 ) def test___galaxy_model_visibilities_dict(interferometer_7): # Normal Light Profiles Only - g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0)) - g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=2.0)) + g0 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05))) + g1 = ag.Galaxy(redshift=0.5, bulge=ag.lp.Sersic(intensity=2.0, centre=(0.05, 0.05))) g2 = ag.Galaxy( redshift=0.5, - light_profile_0=ag.lp.Sersic(intensity=1.0), - light_profile_1=ag.lp.Sersic(intensity=2.0), + light_profile_0=ag.lp.Sersic(intensity=1.0, centre=(0.05, 0.05)), + light_profile_1=ag.lp.Sersic(intensity=2.0, centre=(0.05, 0.05)), ) fit = ag.FitInterferometer( @@ -271,19 +253,19 @@ def test___galaxy_model_visibilities_dict(interferometer_7): grid=interferometer_7.grids.lp, transformer=interferometer_7.transformer ) - assert fit.galaxy_model_visibilities_dict[g0] == pytest.approx( - g0_visibilities, 1.0e-4 + assert fit.galaxy_model_visibilities_dict[g0].array == pytest.approx( + g0_visibilities.array, 1.0e-4 ) - assert fit.galaxy_model_visibilities_dict[g1] == pytest.approx( - g1_visibilities, 1.0e-4 + assert fit.galaxy_model_visibilities_dict[g1].array == pytest.approx( + g1_visibilities.array, 1.0e-4 ) - assert fit.galaxy_model_visibilities_dict[g2] == pytest.approx( - g0_visibilities + g1_visibilities, 1.0e-4 + assert fit.galaxy_model_visibilities_dict[g2].array == pytest.approx( + g0_visibilities.array + g1_visibilities.array, 1.0e-4 ) # Linear Light Profiles Only - g0_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic()) + g0_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic(centre=(0.05, 0.05))) fit = ag.FitInterferometer( dataset=interferometer_7, @@ -292,13 +274,13 @@ def test___galaxy_model_visibilities_dict(interferometer_7): ) assert fit.galaxy_model_visibilities_dict[g0_linear][0] == pytest.approx( - 0.9999355379224923 - 1.6755584672528312e-20j, 1.0e-4 + 0.9965209248910107 + 0.00648675263899049j, 1.0e-4 ) # Pixelization + Regularizaiton only pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=1.0), ) @@ -332,13 +314,13 @@ def test___galaxy_model_visibilities_dict(interferometer_7): assert (fit.galaxy_model_visibilities_dict[g0] == 0.0 + 0.0j * np.zeros((7,))).all() - assert fit.galaxy_model_visibilities_dict[galaxy_pix_0] == pytest.approx( - inversion.mapped_reconstructed_data, 1.0e-4 + assert fit.galaxy_model_visibilities_dict[galaxy_pix_0].array == pytest.approx( + inversion.mapped_reconstructed_data.array, 1.0e-4 ) # Linear Light PRofiles + Pixelization + Regularizaiton pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=2.0), ) @@ -351,17 +333,17 @@ def test___galaxy_model_visibilities_dict(interferometer_7): ) assert fit.galaxy_model_visibilities_dict[g0_linear][0] == pytest.approx( - -1655.3897388539438 + 2.7738811036788807e-17j, 1.0e-4 + -47.30219078770512 - 0.3079088489343429j, 1.0e-4 ) - assert fit.galaxy_model_visibilities_dict[g1] == pytest.approx( - g1_visibilities, 1.0e-4 + assert fit.galaxy_model_visibilities_dict[g1].array == pytest.approx( + g1_visibilities.array, 1.0e-4 ) assert fit.galaxy_model_visibilities_dict[galaxy_pix_0][0] == pytest.approx( - -0.00023567176731092987 + 0.2291185445396378j, 1.0e-4 + -0.00889895 + 0.22151583j, 1.0e-4 ) assert fit.galaxy_model_visibilities_dict[galaxy_pix_1][0] == pytest.approx( - -0.0002255902723656833 + 0.057279636670966916j, 1.0e-4 + -0.00857457 + 0.05537896j, 1.0e-4 ) mapped_reconstructed_visibilities = ( @@ -370,8 +352,8 @@ def test___galaxy_model_visibilities_dict(interferometer_7): + fit.galaxy_model_visibilities_dict[galaxy_pix_1] ) - assert mapped_reconstructed_visibilities == pytest.approx( - fit.inversion.mapped_reconstructed_data, 1.0e-4 + assert mapped_reconstructed_visibilities.array == pytest.approx( + fit.inversion.mapped_reconstructed_data.array, 1.0e-4 ) @@ -380,7 +362,7 @@ def test__model_visibilities_of_galaxies_list(interferometer_7): galaxy_linear = ag.Galaxy(redshift=0.5, bulge=ag.lp_linear.Sersic()) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(3, 3)), + mesh=ag.mesh.RectangularUniform(shape=(3, 3)), regularization=ag.reg.Constant(coefficient=1.0), ) @@ -390,12 +372,12 @@ def test__model_visibilities_of_galaxies_list(interferometer_7): dataset=interferometer_7, galaxies=[galaxy_light, galaxy_linear, galaxy_pix] ) - assert fit.model_visibilities_of_galaxies_list[0] == pytest.approx( - fit.galaxy_model_visibilities_dict[galaxy_light], 1.0e-4 + assert fit.model_visibilities_of_galaxies_list[0].array == pytest.approx( + fit.galaxy_model_visibilities_dict[galaxy_light].array, 1.0e-4 ) - assert fit.model_visibilities_of_galaxies_list[1] == pytest.approx( - fit.galaxy_model_visibilities_dict[galaxy_linear], 1.0e-4 + assert fit.model_visibilities_of_galaxies_list[1].array == pytest.approx( + fit.galaxy_model_visibilities_dict[galaxy_linear].array, 1.0e-4 ) - assert fit.model_visibilities_of_galaxies_list[2] == pytest.approx( - fit.galaxy_model_visibilities_dict[galaxy_pix], 1.0e-4 + assert fit.model_visibilities_of_galaxies_list[2].array == pytest.approx( + fit.galaxy_model_visibilities_dict[galaxy_pix].array, 1.0e-4 ) diff --git a/test_autogalaxy/interferometer/test_simulate_and_fit_interferometer.py b/test_autogalaxy/interferometer/test_simulate_and_fit_interferometer.py index c89db5e56..f2c85f8fc 100644 --- a/test_autogalaxy/interferometer/test_simulate_and_fit_interferometer.py +++ b/test_autogalaxy/interferometer/test_simulate_and_fit_interferometer.py @@ -75,7 +75,7 @@ def test__perfect_fit__chi_squared_0(): assert fit.chi_squared == pytest.approx(0.0) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(7, 7)), + mesh=ag.mesh.RectangularUniform(shape=(7, 7)), regularization=ag.reg.Constant(coefficient=0.0001), ) @@ -115,7 +115,7 @@ def test__simulate_interferometer_data_and_fit__known_likelihood(): ) pixelization = ag.Pixelization( - mesh=ag.mesh.Rectangular(shape=(16, 16)), + mesh=ag.mesh.RectangularUniform(shape=(16, 16)), regularization=ag.reg.Constant(coefficient=(1.0)), ) @@ -209,13 +209,13 @@ def test__linear_light_profiles_agree_with_standard_light_profiles(): galaxy_image = galaxy.image_2d_from(grid=dataset.grids.lp) assert fit_linear.galaxy_model_image_dict[galaxy_linear] == pytest.approx( - galaxy_image, 1.0e-4 + galaxy_image.array, 1.0e-4 ) galaxy_visibilities = galaxy.visibilities_from( grid=dataset.grids.lp, transformer=dataset.transformer ) - assert fit_linear.galaxy_model_visibilities_dict[galaxy_linear] == pytest.approx( - galaxy_visibilities, 1.0e-4 - ) + assert fit_linear.galaxy_model_visibilities_dict[ + galaxy_linear + ].array == pytest.approx(galaxy_visibilities.array, 1.0e-4) diff --git a/test_autogalaxy/interferometer/test_simulator.py b/test_autogalaxy/interferometer/test_simulator.py index 5b38f01fa..fa95a0a72 100644 --- a/test_autogalaxy/interferometer/test_simulator.py +++ b/test_autogalaxy/interferometer/test_simulator.py @@ -29,7 +29,7 @@ def test__from_plane__same_as_plane_input(): image=galaxies.image_2d_from(grid=grid) ) - assert (dataset.data == interferometer_via_image.data).all() + assert (dataset.data == interferometer_via_image.data.array).all() assert (dataset.uv_wavelengths == interferometer_via_image.uv_wavelengths).all() assert (dataset.noise_map == interferometer_via_image.noise_map).all() @@ -70,6 +70,6 @@ def test__simulate_interferometer_from_galaxy__source_galaxy__compare_to_interfe image=galaxies.image_2d_from(grid=grid) ) - assert dataset.data == pytest.approx(interferometer_via_image.data, 1.0e-4) + assert dataset.data == pytest.approx(interferometer_via_image.data.array, 1.0e-4) assert (dataset.uv_wavelengths == interferometer_via_image.uv_wavelengths).all() assert (interferometer_via_image.noise_map == dataset.noise_map).all() diff --git a/test_autogalaxy/operate/test_deflections.py b/test_autogalaxy/operate/test_deflections.py index a69414f88..67749599d 100644 --- a/test_autogalaxy/operate/test_deflections.py +++ b/test_autogalaxy/operate/test_deflections.py @@ -14,7 +14,7 @@ def critical_curve_via_magnification_from(mass_profile, grid): inverse_magnification = 1 / magnification critical_curves_indices = measure.find_contours( - np.array(inverse_magnification.native), 0 + np.array(inverse_magnification.native._array), 0 ) no_critical_curves = len(critical_curves_indices) @@ -122,19 +122,10 @@ def test__convergence_2d_via_hessian_from(): convergence = mp.convergence_2d_via_hessian_from(grid=grid, buffer=buffer) - assert convergence.in_list[0] == pytest.approx(0.461447, 1.0e-4) - assert convergence.in_list[1] == pytest.approx(0.568875, 1.0e-4) - assert convergence.in_list[2] == pytest.approx(0.538326, 1.0e-4) - assert convergence.in_list[3] == pytest.approx(0.539390, 1.0e-4) - - mp = ag.mp.Isothermal(centre=(0.0, 0.0), ell_comps=(0.3, 0.4), einstein_radius=1.5) - - convergence = mp.convergence_2d_via_hessian_from(grid=grid, buffer=buffer) - - assert convergence.in_list[0] == pytest.approx(0.35313, 1.0e-4) - assert convergence.in_list[1] == pytest.approx(0.46030, 1.0e-4) - assert convergence.in_list[2] == pytest.approx(0.43484, 1.0e-4) - assert convergence.in_list[3] == pytest.approx(1.00492, 1.0e-4) + assert convergence.in_list[0] == pytest.approx(0.46208, 1.0e-1) + assert convergence.in_list[1] == pytest.approx(0.56840, 1.0e-1) + assert convergence.in_list[2] == pytest.approx(0.53815, 1.0e-1) + assert convergence.in_list[3] == pytest.approx(0.53927, 1.0e-1) def test__magnification_2d_via_hessian_from(): @@ -245,7 +236,7 @@ def test__tangential_critical_curve_list_from__compare_via_magnification(): )[0] tangential_critical_curve_list = mp.tangential_critical_curve_list_from( - grid=grid, pixel_scale=0.2 + grid=grid, ) assert tangential_critical_curve_list[0] == pytest.approx( @@ -257,7 +248,7 @@ def test__tangential_critical_curve_list_from__compare_via_magnification(): )[0] tangential_critical_curve_list = mp.tangential_critical_curve_list_from( - grid=grid, pixel_scale=0.2 + grid=grid, ) assert tangential_critical_curve_list[0] == pytest.approx( @@ -268,7 +259,7 @@ def test__tangential_critical_curve_list_from__compare_via_magnification(): def test__radial_critical_curve_list_from(): grid = ag.Grid2D.uniform(shape_native=(50, 50), pixel_scales=0.2) - mp = ag.mp.IsothermalSph(centre=(0.0, 0.0), einstein_radius=2.0) + mp = ag.mp.PowerLawSph(centre=(0.0, 0.0), einstein_radius=2.0, slope=1.5) radial_critical_curve_list = mp.radial_critical_curve_list_from(grid=grid) @@ -278,7 +269,7 @@ def test__radial_critical_curve_list_from(): assert -0.05 < y_centre < 0.05 assert -0.05 < x_centre < 0.05 - mp = ag.mp.IsothermalSph(centre=(0.5, 1.0), einstein_radius=2.0) + mp = ag.mp.PowerLawSph(centre=(0.5, 1.0), einstein_radius=2.0, slope=1.5) radial_critical_curve_list = mp.radial_critical_curve_list_from(grid=grid) @@ -290,10 +281,11 @@ def test__radial_critical_curve_list_from(): def test__radial_critical_curve_list_from__compare_via_magnification(): + grid = ag.Grid2D.uniform(shape_native=(50, 50), pixel_scales=0.2) - mp = ag.mp.Isothermal( - centre=(0.0, 0.0), einstein_radius=2, ell_comps=(0.109423, -0.019294) + mp = ag.mp.PowerLaw( + centre=(0.0, 0.0), einstein_radius=2, ell_comps=(0.109423, -0.019294), slope=1.5 ) critical_curve_radial_via_magnification = critical_curve_via_magnification_from( @@ -343,7 +335,7 @@ def test__tangential_caustic_list_from___compare_via_magnification(): )[0] tangential_caustic_list = mp.tangential_caustic_list_from( - grid=grid, pixel_scale=0.2 + grid=grid, ) assert sum(tangential_caustic_list[0]) == pytest.approx( @@ -354,7 +346,7 @@ def test__tangential_caustic_list_from___compare_via_magnification(): def test__radial_caustic_list_from(): grid = ag.Grid2D.uniform(shape_native=(20, 20), pixel_scales=0.2) - mp = ag.mp.IsothermalSph(centre=(0.0, 0.0), einstein_radius=2.0) + mp = ag.mp.PowerLawSph(centre=(0.0, 0.0), einstein_radius=2.0, slope=1.5) radial_caustic_list = mp.radial_caustic_list_from(grid=grid) @@ -364,12 +356,12 @@ def test__radial_caustic_list_from(): ) assert np.mean(x_caustic_radial**2 + y_caustic_radial**2) == pytest.approx( - mp.einstein_radius**2, 5e-1 + 0.25, 5e-1 ) grid = ag.Grid2D.uniform(shape_native=(50, 50), pixel_scales=0.2) - mp = ag.mp.IsothermalSph(centre=(0.0, 0.0), einstein_radius=2.0) + mp = ag.mp.PowerLawSph(centre=(0.0, 0.0), einstein_radius=2.0, slope=1.5) radial_caustic_list = mp.radial_caustic_list_from(grid=grid) @@ -379,7 +371,7 @@ def test__radial_caustic_list_from(): assert -0.2 < y_centre < 0.2 assert -0.35 < x_centre < 0.35 - mp = ag.mp.IsothermalSph(centre=(0.5, 1.0), einstein_radius=2.0) + mp = ag.mp.PowerLawSph(centre=(0.5, 1.0), einstein_radius=2.0, slope=1.5) radial_caustic_list = mp.radial_caustic_list_from(grid=grid) @@ -391,17 +383,17 @@ def test__radial_caustic_list_from(): def test__radial_caustic_list_from___compare_via_magnification(): - grid = ag.Grid2D.uniform(shape_native=(60, 60), pixel_scales=0.08) + grid = ag.Grid2D.uniform(shape_native=(180, 180), pixel_scales=0.02) - mp = ag.mp.Isothermal( - centre=(0.0, 0.0), einstein_radius=2, ell_comps=(0.109423, -0.019294) + mp = ag.mp.PowerLaw( + centre=(0.0, 0.0), einstein_radius=2, ell_comps=(0.109423, -0.019294), slope=1.5 ) caustic_radial_via_magnification = caustics_via_magnification_from( mass_profile=mp, grid=grid )[1] - radial_caustic_list = mp.radial_caustic_list_from(grid=grid, pixel_scale=0.08) + radial_caustic_list = mp.radial_caustic_list_from(grid=grid) assert sum(radial_caustic_list[0]) == pytest.approx( sum(caustic_radial_via_magnification), 7e-1 @@ -411,13 +403,13 @@ def test__radial_caustic_list_from___compare_via_magnification(): def test__radial_critical_curve_area_list_from(): grid = ag.Grid2D.uniform(shape_native=(50, 50), pixel_scales=0.2) - mp = ag.mp.IsothermalSph(centre=(0.0, 0.0), einstein_radius=2.0) + mp = ag.mp.PowerLawSph(centre=(0.0, 0.0), einstein_radius=2.0, slope=1.5) area_within_radial_critical_curve_list = mp.radial_critical_curve_area_list_from( grid=grid ) - assert area_within_radial_critical_curve_list[0] == pytest.approx(0.0455, 1e-1) + assert area_within_radial_critical_curve_list[0] == pytest.approx(0.78293, 1e-1) def test__tangential_critical_curve_area_list_from(): @@ -540,64 +532,3 @@ def test__convergence_2d_via_jacobian_from__compare_via_jacobian_and_analytic(): mean_error = np.mean(convergence_via_jacobian.slim - convergence_via_analytic.slim) assert mean_error < 1e-1 - - -def test__evaluation_grid__changes_resolution_based_on_pixel_scale_input(): - from autogalaxy.operate.deflections import evaluation_grid - - @evaluation_grid - def mock_func(lensing_obj, grid, pixel_scale=0.05): - return grid - - grid = ag.Grid2D.uniform(shape_native=(4, 4), pixel_scales=0.05) - - evaluation_grid = mock_func(lensing_obj=None, grid=grid, pixel_scale=0.05) - - assert (evaluation_grid == grid).all() - - evaluation_grid = mock_func(lensing_obj=None, grid=grid, pixel_scale=0.1) - downscaled_grid = ag.Grid2D.uniform(shape_native=(2, 2), pixel_scales=0.1) - - assert (evaluation_grid == downscaled_grid).all() - - evaluation_grid = mock_func(lensing_obj=None, grid=grid, pixel_scale=0.025) - upscaled_grid = ag.Grid2D.uniform(shape_native=(8, 8), pixel_scales=0.025) - - assert (evaluation_grid == upscaled_grid).all() - - evaluation_grid = mock_func(lensing_obj=None, grid=grid, pixel_scale=0.03) - upscaled_grid = ag.Grid2D.uniform(shape_native=(6, 6), pixel_scales=0.03) - - assert (evaluation_grid == upscaled_grid).all() - - -def test__evaluation_grid__changes_to_uniform_and_zoomed_in_if_masked(): - from autogalaxy.operate.deflections import evaluation_grid - - @evaluation_grid - def mock_func(lensing_obj, grid, pixel_scale=0.05): - return grid - - mask = ag.Mask2D.circular(shape_native=(11, 11), pixel_scales=1.0, radius=3.0) - - grid = ag.Grid2D.from_mask(mask=mask) - - evaluation_grid = mock_func(lensing_obj=None, grid=grid, pixel_scale=1.0) - grid_uniform = ag.Grid2D.uniform(shape_native=(7, 7), pixel_scales=1.0) - - assert (evaluation_grid[0] == np.array([3.0, -3.0])).all() - assert (evaluation_grid == grid_uniform).all() - - mask = ag.Mask2D.circular( - shape_native=(29, 29), pixel_scales=1.0, radius=3.0, centre=(5.0, 5.0) - ) - - grid = ag.Grid2D.from_mask(mask=mask) - - evaluation_grid = mock_func(lensing_obj=None, grid=grid, pixel_scale=1.0) - grid_uniform = ag.Grid2D.uniform( - shape_native=(7, 7), pixel_scales=1.0, origin=(5.0, 5.0) - ) - - assert (evaluation_grid[0] == np.array([8.0, 2.0])).all() - assert (evaluation_grid == grid_uniform).all() diff --git a/test_autogalaxy/operate/test_image.py b/test_autogalaxy/operate/test_image.py index 7d773a683..0577b8b83 100644 --- a/test_autogalaxy/operate/test_image.py +++ b/test_autogalaxy/operate/test_image.py @@ -9,14 +9,16 @@ def test__blurred_image_2d_from( - grid_2d_7x7, blurring_grid_2d_7x7, psf_3x3, convolver_7x7 + grid_2d_7x7, + blurring_grid_2d_7x7, + psf_3x3, ): lp = ag.lp.Sersic(intensity=1.0) image_2d = lp.image_2d_from(grid=grid_2d_7x7) blurring_image_2d = lp.image_2d_from(grid=blurring_grid_2d_7x7) - blurred_image_2d_manual = convolver_7x7.convolve_image( + blurred_image_2d_manual = psf_3x3.convolve_image( image=image_2d, blurring_image=blurring_image_2d ) @@ -25,17 +27,15 @@ def test__blurred_image_2d_from( ) assert blurred_image_2d_manual.native == pytest.approx( - lp_blurred_image_2d.native, 1.0e-4 + lp_blurred_image_2d.native.array, 1.0e-4 ) lp_blurred_image_2d = lp.blurred_image_2d_from( - grid=grid_2d_7x7, - blurring_grid=blurring_grid_2d_7x7, - convolver=convolver_7x7, + grid=grid_2d_7x7, blurring_grid=blurring_grid_2d_7x7, psf=psf_3x3 ) assert blurred_image_2d_manual.native == pytest.approx( - lp_blurred_image_2d.native, 1.0e-4 + lp_blurred_image_2d.native.array, 1.0e-4 ) light_not_operated = ag.lp.Sersic(intensity=1.0) @@ -55,14 +55,16 @@ def test__blurred_image_2d_from( grid=grid_2d_7x7, psf=psf_3x3, blurring_grid=blurring_grid_2d_7x7 ) - blurred_image_2d_manual_not_operated = convolver_7x7.convolve_image( + blurred_image_2d_manual_not_operated = psf_3x3.convolve_image( image=image_2d_not_operated, blurring_image=blurring_image_2d_not_operated, ) assert ( blurred_image_2d - == pytest.approx(blurred_image_2d_manual_not_operated + image_2d_operated), + == pytest.approx( + blurred_image_2d_manual_not_operated.array + image_2d_operated.array + ), 1.0e-4, ) @@ -88,7 +90,7 @@ def test__x1_galaxies__padded_image__compare_to_galaxy_images_using_padded_grid_ assert padded_image.shape_native == (9, 9) assert padded_image == pytest.approx( - padded_g0_image + padded_g1_image + padded_g2_image, 1.0e-4 + padded_g0_image.array + padded_g1_image.array + padded_g2_image.array, 1.0e-4 ) @@ -101,6 +103,7 @@ def test__unmasked_blurred_image_2d_from(): mask = ag.Mask2D( mask=[[True, True, True], [True, False, True], [True, True, True]], pixel_scales=1.0, + origin=(0.3, 0.3), ) grid = ag.Grid2D.from_mask(mask=mask, over_sample_size=1) @@ -112,9 +115,9 @@ def test__unmasked_blurred_image_2d_from(): assert unmasked_blurred_image_2d.native == pytest.approx( np.array( [ - [1.31618566e-01, 2.48460648e02, 1.91885830e-01], - [9.66709359e-02, 8.29737297e01, 1.65678804e02], - [4.12176698e-02, 8.74484826e-02, 1.01484934e-01], + [0.21305245, 0.6141556, 0.10010613], + [0.18998845, 0.50114327, 0.43959065], + [0.07793524, 0.16386363, 0.15628968], ] ), 1.0e-4, @@ -161,11 +164,13 @@ def test__visibilities_from_grid_and_transformer(grid_2d_7x7, transformer_7x7_7) image_2d = lp.image_2d_from(grid=grid_2d_7x7) visibilities = transformer_7x7_7.visibilities_from(image=image_2d) - assert visibilities == pytest.approx(lp_visibilities, 1.0e-4) + assert visibilities == pytest.approx(lp_visibilities.array, 1.0e-4) def test__blurred_image_2d_list_from( - grid_2d_7x7, blurring_grid_2d_7x7, psf_3x3, convolver_7x7 + grid_2d_7x7, + blurring_grid_2d_7x7, + psf_3x3, ): lp_0 = ag.lp.Gaussian(intensity=1.0) lp_1 = ag.lp.Gaussian(intensity=2.0) @@ -185,23 +190,21 @@ def test__blurred_image_2d_list_from( ) assert blurred_image_2d_list[0].native == pytest.approx( - lp_0_blurred_image_2d.native, 1.0e-4 + lp_0_blurred_image_2d.native.array, 1.0e-4 ) assert blurred_image_2d_list[1].native == pytest.approx( - lp_1_blurred_image_2d.native, 1.0e-4 + lp_1_blurred_image_2d.native.array, 1.0e-4 ) blurred_image_2d_list = gal.blurred_image_2d_list_from( - grid=grid_2d_7x7, - blurring_grid=blurring_grid_2d_7x7, - convolver=convolver_7x7, + grid=grid_2d_7x7, blurring_grid=blurring_grid_2d_7x7, psf=psf_3x3 ) assert blurred_image_2d_list[0].native == pytest.approx( - lp_0_blurred_image_2d.native, 1.0e-4 + lp_0_blurred_image_2d.native.array, 1.0e-4 ) assert blurred_image_2d_list[1].native == pytest.approx( - lp_1_blurred_image_2d.native, 1.0e-4 + lp_1_blurred_image_2d.native.array, 1.0e-4 ) lp_operated = ag.lp_operated.Gaussian(intensity=3.0) @@ -215,23 +218,21 @@ def test__blurred_image_2d_list_from( ) assert blurred_image_2d_list[0].native == pytest.approx( - lp_0_blurred_image_2d.native, 1.0e-4 + lp_0_blurred_image_2d.native.array, 1.0e-4 ) assert blurred_image_2d_list[1].native == pytest.approx( - image_2d_operated.native, 1.0e-4 + image_2d_operated.native.array, 1.0e-4 ) blurred_image_2d_list = gal.blurred_image_2d_list_from( - grid=grid_2d_7x7, - blurring_grid=blurring_grid_2d_7x7, - convolver=convolver_7x7, + grid=grid_2d_7x7, blurring_grid=blurring_grid_2d_7x7, psf=psf_3x3 ) assert blurred_image_2d_list[0].native == pytest.approx( - lp_0_blurred_image_2d.native, 1.0e-4 + lp_0_blurred_image_2d.native.array, 1.0e-4 ) assert blurred_image_2d_list[1].native == pytest.approx( - image_2d_operated.native, 1.0e-4 + image_2d_operated.native.array, 1.0e-4 ) @@ -294,9 +295,7 @@ def test__visibilities_list_from(grid_2d_7x7, transformer_7x7_7): assert (lp_1_visibilities == visibilities_list[1]).all() -def test__galaxy_blurred_image_2d_dict_from( - grid_2d_7x7, blurring_grid_2d_7x7, convolver_7x7 -): +def test__galaxy_blurred_image_2d_dict_from(grid_2d_7x7, blurring_grid_2d_7x7, psf_3x3): lp_0 = ag.lp.Sersic(intensity=1.0) g0 = ag.Galaxy(redshift=0.5, light_profile=lp_0) @@ -310,24 +309,30 @@ def test__galaxy_blurred_image_2d_dict_from( blurred_image_2d_list = galaxies.blurred_image_2d_list_from( grid=grid_2d_7x7, - convolver=convolver_7x7, + psf=psf_3x3, blurring_grid=blurring_grid_2d_7x7, ) blurred_image_dict = galaxies.galaxy_blurred_image_2d_dict_from( grid=grid_2d_7x7, - convolver=convolver_7x7, + psf=psf_3x3, blurring_grid=blurring_grid_2d_7x7, ) - assert (blurred_image_dict[g0] == blurred_image_2d_list[1]).all() - assert (blurred_image_dict[g1] == blurred_image_2d_list[0]).all() - assert (blurred_image_dict[g2] == blurred_image_2d_list[2]).all() + assert blurred_image_dict[g0].array == pytest.approx( + blurred_image_2d_list[1].array, 1.0e-4 + ) + assert blurred_image_dict[g1].array == pytest.approx( + blurred_image_2d_list[0].array, 1.0e-4 + ) + assert blurred_image_dict[g2].array == pytest.approx( + blurred_image_2d_list[2].array, 1.0e-4 + ) image_2d = lp_0.image_2d_from(grid=grid_2d_7x7) blurring_image_2d = lp_0.image_2d_from(grid=blurring_grid_2d_7x7) - image_2d_convolved = convolver_7x7.convolve_image( + image_2d_convolved = psf_3x3.convolve_image( image=image_2d, blurring_image=blurring_image_2d ) diff --git a/test_autogalaxy/plot/mat_wrap/config/visualize/include.ini b/test_autogalaxy/plot/mat_wrap/config/visualize/include.ini deleted file mode 100644 index ca5f8aa1b..000000000 --- a/test_autogalaxy/plot/mat_wrap/config/visualize/include.ini +++ /dev/null @@ -1,16 +0,0 @@ -[include_2d] -origin=True -mask=True -border=True -positions=True -critical_curves=False -caustics=False -multiple_images=False -light_profile_centres=True -mass_profile_centres=True -mapper_image_plane_mesh_grid=True -mapper_source_plane_mesh_grid=False -mapper_source_plane_data_grid=False -parallel_overscan=True -serial_prescan=True -serial_overscan=True \ No newline at end of file diff --git a/test_autogalaxy/plot/mat_wrap/test_get_visuals.py b/test_autogalaxy/plot/mat_wrap/test_get_visuals.py deleted file mode 100644 index 14ce0f6cd..000000000 --- a/test_autogalaxy/plot/mat_wrap/test_get_visuals.py +++ /dev/null @@ -1,301 +0,0 @@ -from os import path -import pytest - -import autogalaxy as ag -import autogalaxy.plot as aplt - -from autogalaxy.plot.get_visuals.one_d import GetVisuals1D -from autogalaxy.plot.get_visuals.two_d import GetVisuals2D - -directory = path.dirname(path.realpath(__file__)) - - -@pytest.fixture(name="plot_path") -def make_profile_plotter_setup(): - return path.join( - "{}".format(path.dirname(path.realpath(__file__))), "files", "plots", "profiles" - ) - - -def test__1d__via_light_obj_from(lp_0): - visuals_1d = aplt.Visuals1D() - include_1d = aplt.Include1D(half_light_radius=True) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_light_obj_from(light_obj=lp_0) - - assert visuals_1d_via.half_light_radius == lp_0.half_light_radius - - include_1d = aplt.Include1D(half_light_radius=False) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_light_obj_from(light_obj=lp_0) - - assert visuals_1d_via.half_light_radius is None - - -def test__1d__via_light_obj_list_from(lp_0): - visuals_1d = aplt.Visuals1D() - include_1d = aplt.Include1D(half_light_radius=True) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_light_obj_list_from( - light_obj_list=[lp_0, lp_0], low_limit=1.0 - ) - - assert visuals_1d_via.half_light_radius == lp_0.half_light_radius - assert visuals_1d_via.half_light_radius_errors[0][0] == lp_0.half_light_radius - - include_1d = aplt.Include1D(half_light_radius=False) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_light_obj_list_from( - light_obj_list=[lp_0, lp_0], low_limit=1.0 - ) - - assert visuals_1d_via.half_light_radius is None - assert visuals_1d_via.half_light_radius_errors is None - - -def test__1d__via_mass_obj_from(mp_0, grid_2d_7x7): - visuals_1d = aplt.Visuals1D() - include_1d = aplt.Include1D(einstein_radius=True) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_mass_obj_from(mass_obj=mp_0, grid=grid_2d_7x7) - - assert visuals_1d_via.einstein_radius == mp_0.einstein_radius_from(grid=grid_2d_7x7) - - include_1d = aplt.Include1D(einstein_radius=False) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_mass_obj_from(mass_obj=mp_0, grid=grid_2d_7x7) - - assert visuals_1d_via.einstein_radius is None - - -def test__1d__via_mass_obj_list_from(mp_0, grid_2d_7x7): - visuals_1d = aplt.Visuals1D() - include_1d = aplt.Include1D(einstein_radius=True) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_mass_obj_list_from( - mass_obj_list=[mp_0, mp_0], grid=grid_2d_7x7, low_limit=1.0 - ) - - assert visuals_1d_via.einstein_radius == mp_0.einstein_radius_from(grid=grid_2d_7x7) - assert visuals_1d_via.einstein_radius_errors[0][0] == mp_0.einstein_radius_from( - grid=grid_2d_7x7 - ) - - include_1d = aplt.Include1D(einstein_radius=False) - - get_visuals = GetVisuals1D(include=include_1d, visuals=visuals_1d) - - visuals_1d_via = get_visuals.via_mass_obj_list_from( - mass_obj_list=[mp_0, mp_0], grid=grid_2d_7x7, low_limit=1.0 - ) - - assert visuals_1d_via.einstein_radius is None - assert visuals_1d_via.einstein_radius_errors is None - - -def test__2d__via_light_obj_from(lp_0, grid_2d_7x7): - visuals_2d = aplt.Visuals2D(vectors=2) - include_2d = aplt.Include2D( - origin=True, mask=True, border=True, light_profile_centres=True - ) - - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_light_obj_from(light_obj=lp_0, grid=grid_2d_7x7) - - assert visuals_2d_via.origin.in_list == [(0.0, 0.0)] - assert (visuals_2d_via.mask == grid_2d_7x7.mask).all() - assert (visuals_2d_via.border == grid_2d_7x7.mask.derive_grid.border).all() - assert visuals_2d_via.light_profile_centres.in_list == [lp_0.centre] - assert visuals_2d_via.vectors == 2 - - include_2d = aplt.Include2D( - origin=False, mask=False, border=False, light_profile_centres=False - ) - - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_light_obj_from(light_obj=lp_0, grid=grid_2d_7x7) - - assert visuals_2d_via.origin is None - assert visuals_2d_via.mask is None - assert visuals_2d_via.border is None - assert visuals_2d_via.light_profile_centres is None - assert visuals_2d_via.vectors == 2 - - -def test__2d__via_mass_obj(mp_0, grid_2d_7x7): - visuals_2d = aplt.Visuals2D(vectors=2) - include_2d = aplt.Include2D( - origin=True, - mask=True, - border=True, - mass_profile_centres=True, - tangential_critical_curves=True, - radial_critical_curves=True, - ) - - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_mass_obj_from(mass_obj=mp_0, grid=grid_2d_7x7) - - assert visuals_2d_via.origin.in_list == [(0.0, 0.0)] - assert (visuals_2d_via.mask == grid_2d_7x7.mask).all() - assert (visuals_2d_via.border == grid_2d_7x7.mask.derive_grid.border).all() - assert visuals_2d_via.mass_profile_centres.in_list == [mp_0.centre] - assert ( - visuals_2d_via.tangential_critical_curves[0] - == mp_0.tangential_critical_curve_list_from(grid=grid_2d_7x7)[0] - ).all() - assert visuals_2d_via.vectors == 2 - - include_2d = aplt.Include2D( - origin=False, - mask=False, - border=False, - mass_profile_centres=False, - tangential_critical_curves=False, - radial_critical_curves=False, - ) - - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_mass_obj_from(mass_obj=mp_0, grid=grid_2d_7x7) - - assert visuals_2d_via.origin is None - assert visuals_2d_via.mask is None - assert visuals_2d_via.border is None - assert visuals_2d_via.mass_profile_centres is None - assert visuals_2d_via.tangential_critical_curves is None - assert visuals_2d_via.radial_critical_curves is None - assert visuals_2d_via.vectors == 2 - - -def test__2d__via_light_mass_obj(gal_x1_lp_x1_mp, grid_2d_7x7): - visuals_2d = aplt.Visuals2D(vectors=2) - include_2d = aplt.Include2D( - origin=True, - mask=True, - border=True, - light_profile_centres=True, - mass_profile_centres=True, - tangential_critical_curves=True, - radial_critical_curves=True, - ) - - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_light_mass_obj_from( - light_mass_obj=gal_x1_lp_x1_mp, grid=grid_2d_7x7 - ) - - assert visuals_2d_via.origin.in_list == [(0.0, 0.0)] - assert (visuals_2d_via.mask == grid_2d_7x7.mask).all() - assert (visuals_2d_via.border == grid_2d_7x7.mask.derive_grid.border).all() - assert visuals_2d_via.light_profile_centres.in_list == [ - gal_x1_lp_x1_mp.light_profile_0.centre - ] - assert visuals_2d_via.mass_profile_centres.in_list == [ - gal_x1_lp_x1_mp.mass_profile_0.centre - ] - assert ( - visuals_2d_via.tangential_critical_curves[0] - == gal_x1_lp_x1_mp.tangential_critical_curve_list_from(grid=grid_2d_7x7)[0] - ).all() - assert visuals_2d_via.radial_critical_curves is None - assert visuals_2d_via.vectors == 2 - - include_2d = aplt.Include2D( - origin=False, - mask=False, - border=False, - light_profile_centres=False, - mass_profile_centres=False, - tangential_critical_curves=False, - radial_critical_curves=False, - ) - - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_light_mass_obj_from( - light_mass_obj=gal_x1_lp_x1_mp, grid=grid_2d_7x7 - ) - - assert visuals_2d_via.origin is None - assert visuals_2d_via.mask is None - assert visuals_2d_via.border is None - assert visuals_2d_via.light_profile_centres is None - assert visuals_2d_via.mass_profile_centres is None - assert visuals_2d_via.tangential_critical_curves is None - assert visuals_2d_via.radial_critical_curves is None - assert visuals_2d_via.vectors == 2 - - -def test__via_fit_imaging_from(fit_imaging_x2_galaxy_7x7, grid_2d_7x7): - visuals_2d = aplt.Visuals2D(origin=(1.0, 1.0), vectors=2) - include_2d = aplt.Include2D( - origin=True, - mask=True, - border=True, - light_profile_centres=True, - mass_profile_centres=True, - tangential_critical_curves=True, - radial_critical_curves=True, - ) - - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_fit_imaging_from(fit=fit_imaging_x2_galaxy_7x7) - - assert visuals_2d_via.origin == (1.0, 1.0) - assert (visuals_2d_via.mask == fit_imaging_x2_galaxy_7x7.mask).all() - assert ( - visuals_2d_via.border == fit_imaging_x2_galaxy_7x7.mask.derive_grid.border - ).all() - assert visuals_2d_via.light_profile_centres.in_list == [(0.0, 0.0), (0.0, 0.0)] - assert visuals_2d_via.mass_profile_centres.in_list == [(0.0, 0.0)] - assert ( - visuals_2d_via.tangential_critical_curves[0] - == fit_imaging_x2_galaxy_7x7.galaxies.tangential_critical_curve_list_from( - grid=grid_2d_7x7 - )[0] - ).all() - assert visuals_2d_via.radial_critical_curves is None - assert visuals_2d_via.vectors == 2 - - include_2d = aplt.Include2D( - origin=False, - mask=False, - border=False, - light_profile_centres=False, - mass_profile_centres=False, - tangential_critical_curves=False, - radial_critical_curves=False, - ) - - get_visuals = GetVisuals2D(include=include_2d, visuals=visuals_2d) - - visuals_2d_via = get_visuals.via_fit_imaging_from(fit=fit_imaging_x2_galaxy_7x7) - - assert visuals_2d_via.origin == (1.0, 1.0) - assert visuals_2d_via.mask is None - assert visuals_2d_via.border is None - assert visuals_2d_via.light_profile_centres is None - assert visuals_2d_via.mass_profile_centres is None - assert visuals_2d_via.tangential_critical_curves is None - assert visuals_2d_via.radial_critical_curves is None - assert visuals_2d_via.vectors == 2 diff --git a/test_autogalaxy/plot/mat_wrap/test_mat_obj.py b/test_autogalaxy/plot/mat_wrap/test_mat_obj.py index 16c76cab1..53e4f154e 100644 --- a/test_autogalaxy/plot/mat_wrap/test_mat_obj.py +++ b/test_autogalaxy/plot/mat_wrap/test_mat_obj.py @@ -16,16 +16,16 @@ def test__mat_obj__all_load_from_config_correctly(): tangential_critical_curves_plot = aplt.TangentialCriticalCurvesPlot() - assert tangential_critical_curves_plot.config_dict["width"] == 4 + assert tangential_critical_curves_plot.config_dict["linewidth"] == 4 tangential_caustics_plot = aplt.TangentialCausticsPlot() - assert tangential_caustics_plot.config_dict["width"] == 5 + assert tangential_caustics_plot.config_dict["linewidth"] == 5 radial_critical_curves_plot = aplt.RadialCriticalCurvesPlot() - assert radial_critical_curves_plot.config_dict["width"] == 4 + assert radial_critical_curves_plot.config_dict["linewidth"] == 4 radial_caustics_plot = aplt.RadialCausticsPlot() - assert radial_caustics_plot.config_dict["width"] == 5 + assert radial_caustics_plot.config_dict["linewidth"] == 5 diff --git a/test_autogalaxy/plot/mat_wrap/test_visuals.py b/test_autogalaxy/plot/mat_wrap/test_visuals.py new file mode 100644 index 000000000..1cd20d1ca --- /dev/null +++ b/test_autogalaxy/plot/mat_wrap/test_visuals.py @@ -0,0 +1,83 @@ +from os import path +import pytest + +import autogalaxy.plot as aplt + +directory = path.dirname(path.realpath(__file__)) + + +@pytest.fixture(name="plot_path") +def make_profile_plotter_setup(): + return path.join( + "{}".format(path.dirname(path.realpath(__file__))), "files", "plots", "profiles" + ) + + +def test__1d__add_half_light_radius(lp_0): + + visuals_1d_via = aplt.Visuals1D().add_half_light_radius(light_obj=lp_0) + + assert visuals_1d_via.half_light_radius == lp_0.half_light_radius + + +def test__1d__add_half_light_radius_errors(lp_0): + + visuals_1d_via = aplt.Visuals1D().add_half_light_radius_errors( + light_obj_list=[lp_0, lp_0], low_limit=1.0 + ) + + assert visuals_1d_via.half_light_radius == lp_0.half_light_radius + assert visuals_1d_via.half_light_radius_errors[0][0] == lp_0.half_light_radius + + +def test__1d__add_einstein_radius(mp_0, grid_2d_7x7): + + visuals_1d_via = aplt.Visuals1D().add_einstein_radius( + mass_obj=mp_0, grid=grid_2d_7x7 + ) + + assert visuals_1d_via.einstein_radius == mp_0.einstein_radius_from(grid=grid_2d_7x7) + + +def test__1d__add_einstein_radius_errors(mp_0, grid_2d_7x7): + + visuals_1d_via = aplt.Visuals1D().add_einstein_radius_errors( + mass_obj_list=[mp_0, mp_0], grid=grid_2d_7x7, low_limit=1.0 + ) + + assert visuals_1d_via.einstein_radius == mp_0.einstein_radius_from(grid=grid_2d_7x7) + assert visuals_1d_via.einstein_radius_errors[0][0] == mp_0.einstein_radius_from( + grid=grid_2d_7x7 + ) + + +def test__2d__add_critical_curve(gal_x1_mp, grid_2d_7x7): + + visuals_2d_via = aplt.Visuals2D().add_critical_curves_or_caustics( + mass_obj=gal_x1_mp, grid=grid_2d_7x7, plane_index=0 + ) + + assert ( + visuals_2d_via.tangential_critical_curves[0] + == gal_x1_mp.tangential_critical_curve_list_from(grid=grid_2d_7x7)[0] + ).all() + assert ( + visuals_2d_via.radial_critical_curves[0] + == gal_x1_mp.radial_critical_curve_list_from(grid=grid_2d_7x7)[0] + ).all() + + +def test__2d__add_caustic(gal_x1_mp, grid_2d_7x7): + + visuals_2d_via = aplt.Visuals2D().add_critical_curves_or_caustics( + mass_obj=gal_x1_mp, grid=grid_2d_7x7, plane_index=1 + ) + + assert ( + visuals_2d_via.tangential_caustics[0] + == gal_x1_mp.tangential_caustic_list_from(grid=grid_2d_7x7)[0] + ).all() + assert ( + visuals_2d_via.radial_caustics[0] + == gal_x1_mp.radial_caustic_list_from(grid=grid_2d_7x7)[0] + ).all() diff --git a/test_autogalaxy/profiles/files/config/grids/radial_minimum.ini b/test_autogalaxy/profiles/files/config/grids/radial_minimum.ini deleted file mode 100644 index 589fba3d9..000000000 --- a/test_autogalaxy/profiles/files/config/grids/radial_minimum.ini +++ /dev/null @@ -1,32 +0,0 @@ -[radial_minimum] -EllProfile=1.0 -MockGridRadialMinimum=2.5 -IsothermalSph=1.0 -SersicSph=1.0 -Sersic=1.0 -ExternalShear=1.0 -Gaussian=1.0 -Isothermal=1.0 -Exponential=1.0 -SersicCore=1.0 -SersicCoreSph=1.0 -DevVaucouleurs=1.0 -DevVaucouleursSph=1.0 -ExponentialSph=1.0 -GaussianSph=1.0 -MassSheet=1.0 -SersicGradientSph=1.0 -SersicGradient=1.0 -gNFWSph=1.0 -EllMassProfile=1.0 -PowerLawCore=1.0 -PowerLawCoreSph=1.0 -PowerLaw=1.0 -PowerLawSph=1.0 -IsothermalCore=1.0 -IsothermalCoreSph=1.0 -gNFW=1.0 -NFWTruncatedSph=1.0 -NFW=1.0 -NFWSph=1.0 -PointMass=1.0 \ No newline at end of file diff --git a/test_autogalaxy/profiles/light/linear/test_abstract.py b/test_autogalaxy/profiles/light/linear/test_abstract.py index f8ca3ad0e..72b949f0a 100644 --- a/test_autogalaxy/profiles/light/linear/test_abstract.py +++ b/test_autogalaxy/profiles/light/linear/test_abstract.py @@ -9,14 +9,14 @@ ) -def test__mapping_matrix_from(grid_2d_7x7, blurring_grid_2d_7x7, convolver_7x7): +def test__mapping_matrix_from(grid_2d_7x7, blurring_grid_2d_7x7, psf_3x3): lp_0 = ag.lp_linear.Sersic(effective_radius=1.0) lp_1 = ag.lp_linear.Sersic(effective_radius=2.0) lp_linear_obj_func_list = LightProfileLinearObjFuncList( grid=grid_2d_7x7, blurring_grid=blurring_grid_2d_7x7, - convolver=convolver_7x7, + psf=psf_3x3, light_profile_list=[lp_0, lp_1], ) @@ -26,30 +26,26 @@ def test__mapping_matrix_from(grid_2d_7x7, blurring_grid_2d_7x7, convolver_7x7): lp_1_image = lp_1.image_2d_from(grid=grid_2d_7x7) assert lp_linear_obj_func_list.mapping_matrix[:, 0] == pytest.approx( - lp_0_image, 1.0e-4 + lp_0_image.array, 1.0e-4 ) assert lp_linear_obj_func_list.mapping_matrix[:, 1] == pytest.approx( - lp_1_image, 1.0e-4 + lp_1_image.array, 1.0e-4 ) lp_0_blurred_image = lp_0.blurred_image_2d_from( - grid=grid_2d_7x7, - blurring_grid=blurring_grid_2d_7x7, - convolver=convolver_7x7, + grid=grid_2d_7x7, blurring_grid=blurring_grid_2d_7x7, psf=psf_3x3 ) lp_1_blurred_image = lp_1.blurred_image_2d_from( - grid=grid_2d_7x7, - blurring_grid=blurring_grid_2d_7x7, - convolver=convolver_7x7, + grid=grid_2d_7x7, blurring_grid=blurring_grid_2d_7x7, psf=psf_3x3 ) assert lp_linear_obj_func_list.operated_mapping_matrix_override[ :, 0 - ] == pytest.approx(lp_0_blurred_image, 1.0e-4) + ] == pytest.approx(lp_0_blurred_image.array, 1.0e-4) assert lp_linear_obj_func_list.operated_mapping_matrix_override[ :, 1 - ] == pytest.approx(lp_1_blurred_image, 1.0e-4) + ] == pytest.approx(lp_1_blurred_image.array, 1.0e-4) def test__lp_from(): diff --git a/test_autogalaxy/profiles/light/shapelets/test_polar.py b/test_autogalaxy/profiles/light/shapelets/test_polar.py index 070da644b..eef873e91 100644 --- a/test_autogalaxy/profiles/light/shapelets/test_polar.py +++ b/test_autogalaxy/profiles/light/shapelets/test_polar.py @@ -26,7 +26,7 @@ def test__elliptical__image_2d_from(): image = shapelet.image_2d_from(grid=ag.Grid2DIrregular([[0.0, 1.0], [0.5, 0.25]])) - assert image == pytest.approx(np.array([0.0, -0.33177]), 1e-4) + assert image == pytest.approx(np.array([0.0, -0.33177]), abs=1e-4) shapelet = ag.lp_linear.ShapeletPolar( n=2, m=0, centre=(0.0, 0.0), ell_comps=(0.5, 0.7), beta=1.0 @@ -34,4 +34,4 @@ def test__elliptical__image_2d_from(): image = shapelet.image_2d_from(grid=ag.Grid2DIrregular([[0.0, 1.0], [0.5, 0.25]])) - assert image == pytest.approx(np.array([0.0, -0.33177]), 1e-4) + assert image == pytest.approx(np.array([0.0, -0.33177]), abs=1e-4) diff --git a/test_autogalaxy/profiles/light/standard/test_abstract.py b/test_autogalaxy/profiles/light/standard/test_abstract.py index f499ebd50..8281e187c 100644 --- a/test_autogalaxy/profiles/light/standard/test_abstract.py +++ b/test_autogalaxy/profiles/light/standard/test_abstract.py @@ -57,9 +57,9 @@ def test__image_1d_from__grid_2d_in__returns_1d_image_via_projected_quantities() image_1d = lp.image_1d_from(grid=grid_2d) image_2d = lp.image_2d_from(grid=grid_2d) - assert image_1d[0] == pytest.approx(image_2d.native[2, 2], 1.0e-4) - assert image_1d[1] == pytest.approx(image_2d.native[2, 3], 1.0e-4) - assert image_1d[2] == pytest.approx(image_2d.native[2, 4], 1.0e-4) + assert image_1d[0] == pytest.approx(image_2d.native.array[2, 2], 1.0e-4) + assert image_1d[1] == pytest.approx(image_2d.native.array[2, 3], 1.0e-4) + assert image_1d[2] == pytest.approx(image_2d.native.array[2, 4], 1.0e-4) lp = ag.lp.Gaussian( centre=(0.2, 0.2), ell_comps=(0.3, 0.3), intensity=1.0, sigma=1.0 @@ -73,7 +73,7 @@ def test__image_1d_from__grid_2d_in__returns_1d_image_via_projected_quantities() image_projected = lp.image_2d_from(grid=grid_2d_projected) - assert image_1d == pytest.approx(image_projected, 1.0e-4) + assert image_1d == pytest.approx(image_projected.array, 1.0e-4) assert (image_1d.grid_radial == np.array([0.0, 1.0, 2.0])).all() diff --git a/test_autogalaxy/profiles/light/standard/test_chameleon.py b/test_autogalaxy/profiles/light/standard/test_chameleon.py index 0425e1c53..3cdd5ab0b 100644 --- a/test_autogalaxy/profiles/light/standard/test_chameleon.py +++ b/test_autogalaxy/profiles/light/standard/test_chameleon.py @@ -54,4 +54,4 @@ def test__image_2d_from(): image_spherical = spherical.image_2d_from(grid=grid) - assert image_elliptical == pytest.approx(image_spherical, 1.0e-4) + assert image_elliptical.array == pytest.approx(image_spherical.array, 1.0e-4) diff --git a/test_autogalaxy/profiles/light/standard/test_dev_vaucouleurs.py b/test_autogalaxy/profiles/light/standard/test_dev_vaucouleurs.py index 2f9b25a4a..7dfb54ddf 100644 --- a/test_autogalaxy/profiles/light/standard/test_dev_vaucouleurs.py +++ b/test_autogalaxy/profiles/light/standard/test_dev_vaucouleurs.py @@ -45,4 +45,4 @@ def test__image_2d_from(): image_spherical = spherical.image_2d_from(grid=grid) - assert image_elliptical == pytest.approx(image_spherical, 1.0e-4) + assert image_elliptical.array == pytest.approx(image_spherical.array, 1.0e-4) diff --git a/test_autogalaxy/profiles/light/standard/test_eff.py b/test_autogalaxy/profiles/light/standard/test_eff.py index e104f1d62..6100a9d77 100644 --- a/test_autogalaxy/profiles/light/standard/test_eff.py +++ b/test_autogalaxy/profiles/light/standard/test_eff.py @@ -59,7 +59,7 @@ def test__image_2d_from(): image_elliptical = elliptical.image_2d_from(grid=grid) image_spherical = spherical.image_2d_from(grid=grid) - assert image_elliptical == pytest.approx(image_spherical, 1.0e-4) + assert image_elliptical.array == pytest.approx(image_spherical.array, 1.0e-4) def test__half_light_radius(): diff --git a/test_autogalaxy/profiles/light/standard/test_exponential.py b/test_autogalaxy/profiles/light/standard/test_exponential.py index 5a326e5a2..8eac22961 100644 --- a/test_autogalaxy/profiles/light/standard/test_exponential.py +++ b/test_autogalaxy/profiles/light/standard/test_exponential.py @@ -44,4 +44,4 @@ def test__image_2d_from(): image_elliptical = elliptical.image_2d_from(grid=grid) image_spherical = spherical.image_2d_from(grid=grid) - assert image_elliptical == pytest.approx(image_spherical, 1.0e-4) + assert image_elliptical.array == pytest.approx(image_spherical.array, 1.0e-4) diff --git a/test_autogalaxy/profiles/light/standard/test_gaussian.py b/test_autogalaxy/profiles/light/standard/test_gaussian.py index 88cf98e5b..609827a5e 100644 --- a/test_autogalaxy/profiles/light/standard/test_gaussian.py +++ b/test_autogalaxy/profiles/light/standard/test_gaussian.py @@ -45,4 +45,4 @@ def test__image_2d_from(): image_elliptical = elliptical.image_2d_from(grid=grid) image_spherical = spherical.image_2d_from(grid=grid) - assert image_elliptical == pytest.approx(image_spherical, 1.0e-4) + assert image_elliptical.array == pytest.approx(image_spherical.array, 1.0e-4) diff --git a/test_autogalaxy/profiles/light/standard/test_sersic.py b/test_autogalaxy/profiles/light/standard/test_sersic.py index 6e47a8f28..be6ef75db 100644 --- a/test_autogalaxy/profiles/light/standard/test_sersic.py +++ b/test_autogalaxy/profiles/light/standard/test_sersic.py @@ -54,4 +54,4 @@ def test__image_2d_from(): image_spherical = spherical.image_2d_from(grid=grid) - assert image_elliptical == pytest.approx(image_spherical, 1.0e-4) + assert image_elliptical.array == pytest.approx(image_spherical.array, 1.0e-4) diff --git a/test_autogalaxy/profiles/light/standard/test_sersic_core.py b/test_autogalaxy/profiles/light/standard/test_sersic_core.py index 05367e2ef..5aa66b3c1 100644 --- a/test_autogalaxy/profiles/light/standard/test_sersic_core.py +++ b/test_autogalaxy/profiles/light/standard/test_sersic_core.py @@ -44,4 +44,4 @@ def test__image_2d_from(): image_spherical = spherical.image_2d_from(grid=grid) - assert image_elliptical == pytest.approx(image_spherical, 1.0e-4) + assert image_elliptical.array == pytest.approx(image_spherical.array, 1.0e-4) diff --git a/test_autogalaxy/profiles/light/test_decorators.py b/test_autogalaxy/profiles/light/test_decorators.py index 4f2d693be..e7916359a 100644 --- a/test_autogalaxy/profiles/light/test_decorators.py +++ b/test_autogalaxy/profiles/light/test_decorators.py @@ -34,21 +34,21 @@ def test__decorator_changes_behaviour_correctly(): lp_image_2d = lp.image_2d_from(grid=grid) image_2d = lp.image_2d_from(grid=grid) - assert image_2d == pytest.approx(lp_image_2d, 1.0e-4) + assert image_2d == pytest.approx(lp_image_2d.array, 1.0e-4) image_2d = lp.image_2d_from(grid=grid, operated_only=True) assert image_2d == pytest.approx(np.zeros(shape=(9,)), 1.0e-4) image_2d = lp.image_2d_from(grid=grid, operated_only=False) - assert image_2d == pytest.approx(lp_image_2d, 1.0e-4) + assert image_2d == pytest.approx(lp_image_2d.array, 1.0e-4) lp = ag.lp_operated.Gaussian() image_2d = lp.image_2d_from(grid=grid) - assert image_2d == pytest.approx(lp_image_2d, 1.0e-4) + assert image_2d == pytest.approx(lp_image_2d.array, 1.0e-4) image_2d = lp.image_2d_from(grid=grid, operated_only=True) - assert image_2d == pytest.approx(lp_image_2d, 1.0e-4) + assert image_2d == pytest.approx(lp_image_2d.array, 1.0e-4) image_2d = lp.image_2d_from(grid=grid, operated_only=False) assert image_2d == pytest.approx(np.zeros(shape=(9,)), 1.0e-4) diff --git a/test_autogalaxy/profiles/mass/abstract/test_abstract.py b/test_autogalaxy/profiles/mass/abstract/test_abstract.py index 56ef5f258..4e8f817f4 100644 --- a/test_autogalaxy/profiles/mass/abstract/test_abstract.py +++ b/test_autogalaxy/profiles/mass/abstract/test_abstract.py @@ -166,7 +166,7 @@ def test__extract_attribute(): def test__regression__centre_of_profile_in_right_place(): grid = ag.Grid2D.uniform(shape_native=(7, 7), pixel_scales=1.0) - mass_profile = ag.mp.Isothermal(centre=(2.0, 1.0), einstein_radius=1.0) + mass_profile = ag.mp.Isothermal(centre=(1.999999, 0.9999999), einstein_radius=1.0) convergence = mass_profile.convergence_2d_from(grid=grid) max_indexes = np.unravel_index( convergence.native.argmax(), convergence.shape_native @@ -178,6 +178,7 @@ def test__regression__centre_of_profile_in_right_place(): assert max_indexes == (1, 4) deflections = mass_profile.deflections_yx_2d_from(grid=grid) + assert deflections.native[1, 4, 0] > 0 assert deflections.native[2, 4, 0] < 0 assert deflections.native[1, 4, 1] > 0 @@ -190,7 +191,9 @@ def test__regression__centre_of_profile_in_right_place(): ) assert max_indexes == (1, 4) - mass_profile = ag.mp.IsothermalSph(centre=(2.0, 1.0), einstein_radius=1.0) + mass_profile = ag.mp.IsothermalSph( + centre=(1.9999999, 0.999999), einstein_radius=1.0 + ) potential = mass_profile.potential_2d_from(grid=grid) max_indexes = np.unravel_index(potential.native.argmin(), potential.shape_native) assert max_indexes == (1, 4) @@ -209,14 +212,18 @@ def test__decorators__convergence_1d_from__grid_2d_in__returns_1d_image_via_proj over_sample_size=1, ) - sie = ag.mp.Isothermal(centre=(0.0, 0.0), ell_comps=(0.0, 0.0), einstein_radius=1.0) + sie = ag.mp.Isothermal( + centre=(1e-6, 1e-6), ell_comps=(0.0, 0.0), einstein_radius=1.0 + ) convergence_1d = sie.convergence_1d_from(grid=grid_2d) convergence_2d = sie.convergence_2d_from(grid=grid_2d) - assert convergence_1d[0] == pytest.approx(convergence_2d.native[2, 2], 1.0e-4) - assert convergence_1d[1] == pytest.approx(convergence_2d.native[2, 3], 1.0e-4) - assert convergence_1d[2] == pytest.approx(convergence_2d.native[2, 4], 1.0e-4) + print(convergence_2d.native.array) + + assert convergence_1d[0] == pytest.approx(convergence_2d.native.array[2, 2], 1.0e-4) + assert convergence_1d[1] == pytest.approx(convergence_2d.native.array[2, 3], 1.0e-4) + assert convergence_1d[2] == pytest.approx(convergence_2d.native.array[2, 4], 1.0e-4) sie = ag.mp.Isothermal(centre=(0.2, 0.2), ell_comps=(0.3, 0.3), einstein_radius=1.0) @@ -228,7 +235,7 @@ def test__decorators__convergence_1d_from__grid_2d_in__returns_1d_image_via_proj convergence_projected = sie.convergence_2d_from(grid=grid_2d_projected) - assert convergence_1d == pytest.approx(convergence_projected, 1.0e-4) + assert convergence_1d == pytest.approx(convergence_projected.array, 1.0e-4) assert (convergence_1d.grid_radial == np.array([0.0, 1.0, 2.0])).all() @@ -240,18 +247,18 @@ def test__decorators__convergence_1d_from__grid_2d_irregular_in__returns_1d_quan convergence_1d = sie.convergence_1d_from(grid=grid_2d) convergence_2d = sie.convergence_2d_from(grid=grid_2d) - assert convergence_1d[0] == pytest.approx(convergence_2d[0], 1.0e-4) - assert convergence_1d[1] == pytest.approx(convergence_2d[1], 1.0e-4) - assert convergence_1d[2] == pytest.approx(convergence_2d[2], 1.0e-4) + assert convergence_1d[0] == pytest.approx(convergence_2d[0].array, 1.0e-4) + assert convergence_1d[1] == pytest.approx(convergence_2d[1].array, 1.0e-4) + assert convergence_1d[2] == pytest.approx(convergence_2d[2].array, 1.0e-4) sie = ag.mp.Isothermal(centre=(0.2, 0.2), ell_comps=(0.3, 0.3), einstein_radius=1.0) convergence_1d = sie.convergence_1d_from(grid=grid_2d) convergence_2d = sie.convergence_2d_from(grid=grid_2d) - assert convergence_1d[0] == pytest.approx(convergence_2d[0], 1.0e-4) - assert convergence_1d[1] == pytest.approx(convergence_2d[1], 1.0e-4) - assert convergence_1d[2] == pytest.approx(convergence_2d[2], 1.0e-4) + assert convergence_1d[0] == pytest.approx(convergence_2d[0].array, 1.0e-4) + assert convergence_1d[1] == pytest.approx(convergence_2d[1].array, 1.0e-4) + assert convergence_1d[2] == pytest.approx(convergence_2d[2].array, 1.0e-4) def test__decorators__convergence_1d_from__grid_1d_in__returns_1d_quantities_via_projection(): @@ -262,9 +269,9 @@ def test__decorators__convergence_1d_from__grid_1d_in__returns_1d_quantities_via convergence_1d = sie.convergence_1d_from(grid=grid_1d) convergence_2d = sie.convergence_2d_from(grid=grid_1d) - assert convergence_1d[0] == pytest.approx(convergence_2d[0], 1.0e-4) - assert convergence_1d[1] == pytest.approx(convergence_2d[1], 1.0e-4) - assert convergence_1d[2] == pytest.approx(convergence_2d[2], 1.0e-4) + assert convergence_1d[0] == pytest.approx(convergence_2d[0].array, 1.0e-4) + assert convergence_1d[1] == pytest.approx(convergence_2d[1].array, 1.0e-4) + assert convergence_1d[2] == pytest.approx(convergence_2d[2].array, 1.0e-4) sie = ag.mp.Isothermal(centre=(0.5, 0.5), ell_comps=(0.2, 0.2), einstein_radius=1.0) @@ -274,9 +281,9 @@ def test__decorators__convergence_1d_from__grid_1d_in__returns_1d_quantities_via convergence_2d = sie.convergence_2d_from(grid=grid_2d_radial) - assert convergence_1d[0] == pytest.approx(convergence_2d[0], 1.0e-4) - assert convergence_1d[1] == pytest.approx(convergence_2d[1], 1.0e-4) - assert convergence_1d[2] == pytest.approx(convergence_2d[2], 1.0e-4) + assert convergence_1d[0] == pytest.approx(convergence_2d[0].array, 1.0e-4) + assert convergence_1d[1] == pytest.approx(convergence_2d[1].array, 1.0e-4) + assert convergence_1d[2] == pytest.approx(convergence_2d[2].array, 1.0e-4) def test__decorators__potential_1d_from__grid_2d_in__returns_1d_image_via_projected_quantities(): @@ -287,9 +294,9 @@ def test__decorators__potential_1d_from__grid_2d_in__returns_1d_image_via_projec potential_1d = sie.potential_1d_from(grid=grid_2d) potential_2d = sie.potential_2d_from(grid=grid_2d) - assert potential_1d[0] == pytest.approx(potential_2d.native[2, 2], 1.0e-4) - assert potential_1d[1] == pytest.approx(potential_2d.native[2, 3], 1.0e-4) - assert potential_1d[2] == pytest.approx(potential_2d.native[2, 4], 1.0e-4) + assert potential_1d[0] == pytest.approx(potential_2d.native.array[2, 2], abs=1.0e-4) + assert potential_1d[1] == pytest.approx(potential_2d.native.array[2, 3], abs=1.0e-4) + assert potential_1d[2] == pytest.approx(potential_2d.native.array[2, 4], abs=1.0e-4) sie = ag.mp.Isothermal(centre=(0.2, 0.2), ell_comps=(0.3, 0.3), einstein_radius=1.0) @@ -301,5 +308,5 @@ def test__decorators__potential_1d_from__grid_2d_in__returns_1d_image_via_projec potential_projected = sie.potential_2d_from(grid=grid_2d_projected) - assert potential_1d == pytest.approx(potential_projected, 1.0e-4) + assert potential_1d == pytest.approx(potential_projected.array, abs=1.0e-4) assert (potential_1d.grid_radial == np.array([0.0, 1.0, 2.0])).all() diff --git a/test_autogalaxy/profiles/mass/dark/test_abstract.py b/test_autogalaxy/profiles/mass/dark/test_abstract.py index 6a4670ef0..e3cfecc2f 100644 --- a/test_autogalaxy/profiles/mass/dark/test_abstract.py +++ b/test_autogalaxy/profiles/mass/dark/test_abstract.py @@ -267,7 +267,10 @@ def test__mass_at_200__unit_conversions_work(): def test__values_of_quantities_for_real_cosmology(): - cosmology = ag.cosmo.LambdaCDMWrap(H0=70.0, Om0=0.3, Ode0=0.7) + + from autogalaxy.cosmology.model import LambdaCDMWrap + + cosmology = LambdaCDMWrap(H0=70.0, Om0=0.3, Ode0=0.7) mp = ag.mp.NFWTruncatedSph(kappa_s=0.5, scale_radius=5.0, truncation_radius=10.0) diff --git a/test_autogalaxy/profiles/mass/dark/test_gnfw.py b/test_autogalaxy/profiles/mass/dark/test_gnfw.py index a26d862a2..d87d5930f 100644 --- a/test_autogalaxy/profiles/mass/dark/test_gnfw.py +++ b/test_autogalaxy/profiles/mass/dark/test_gnfw.py @@ -68,7 +68,7 @@ def test__deflections_2d_via_mge_from(): grid=ag.Grid2DIrregular([[0.1875, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_mge, 1.0e-3) + assert deflections_via_integral == pytest.approx(deflections_via_mge.array, 1.0e-3) mp = ag.mp.gNFWSph( centre=(0.3, 0.2), kappa_s=2.5, inner_slope=1.5, scale_radius=4.0 @@ -81,7 +81,7 @@ def test__deflections_2d_via_mge_from(): grid=ag.Grid2DIrregular([[0.1875, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_mge, 1.0e-3) + assert deflections_via_integral == pytest.approx(deflections_via_mge.array, 1.0e-3) mp = ag.mp.gNFW( centre=(0.0, 0.0), @@ -98,7 +98,7 @@ def test__deflections_2d_via_mge_from(): grid=ag.Grid2DIrregular([[0.1875, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_mge, 1.0e-3) + assert deflections_via_integral == pytest.approx(deflections_via_mge.array, 1.0e-3) mp = ag.mp.gNFW( centre=(0.3, 0.2), @@ -115,7 +115,7 @@ def test__deflections_2d_via_mge_from(): grid=ag.Grid2DIrregular([[0.1875, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_mge, 1.0e-3) + assert deflections_via_integral == pytest.approx(deflections_via_mge.array, 1.0e-3) def test__deflections_yx_2d_from(): @@ -126,7 +126,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_mge, 1.0e-4) + assert deflections == pytest.approx(deflections_via_mge.array, 1.0e-4) mp = ag.mp.gNFWSph() @@ -135,7 +135,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_mge, 1.0e-4) + assert deflections == pytest.approx(deflections_via_mge.array, 1.0e-4) elliptical = ag.mp.gNFW( centre=(0.1, 0.2), @@ -149,7 +149,7 @@ def test__deflections_yx_2d_from(): ) assert elliptical.deflections_yx_2d_from(grid) == pytest.approx( - spherical.deflections_yx_2d_from(grid), 1e-4 + spherical.deflections_yx_2d_from(grid).array, 1e-4 ) @@ -258,7 +258,7 @@ def test__potential_2d_from(): ) assert elliptical.convergence_2d_from(grid) == pytest.approx( - spherical.convergence_2d_from(grid), 1e-4 + spherical.convergence_2d_from(grid).array, 1e-4 ) @@ -278,15 +278,15 @@ def test__compare_to_nfw(): ) assert nfw.deflections_yx_2d_from(grid) == pytest.approx( - gnfw.deflections_yx_2d_from(grid), 1e-3 + gnfw.deflections_yx_2d_from(grid).array, 1e-3 ) assert nfw.deflections_yx_2d_from(grid) == pytest.approx( - gnfw.deflections_yx_2d_from(grid), 1e-3 + gnfw.deflections_yx_2d_from(grid).array, 1e-3 ) assert nfw.potential_2d_from(grid) == pytest.approx( - gnfw.potential_2d_from(grid), 1e-3 + gnfw.potential_2d_from(grid).array, 1e-3 ) assert nfw.potential_2d_from(grid) == pytest.approx( - gnfw.potential_2d_from(grid), 1e-3 + gnfw.potential_2d_from(grid).array, 1e-3 ) diff --git a/test_autogalaxy/profiles/mass/dark/test_nfw.py b/test_autogalaxy/profiles/mass/dark/test_nfw.py index 79acdb81d..9260afcbd 100644 --- a/test_autogalaxy/profiles/mass/dark/test_nfw.py +++ b/test_autogalaxy/profiles/mass/dark/test_nfw.py @@ -64,7 +64,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) nfw = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0) @@ -75,7 +75,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) nfw = ag.mp.NFW( centre=(0.0, 0.0), @@ -91,7 +91,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) nfw = ag.mp.NFW( centre=(0.3, 0.2), @@ -107,7 +107,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) def test__deflections_2d__numerical_precision_of_csv_compared_to_integral(): @@ -125,7 +125,7 @@ def test__deflections_2d__numerical_precision_of_csv_compared_to_integral(): grid=ag.Grid2DIrregular([[1.0, 2.0]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) nfw = ag.mp.NFW( centre=(0.3, 0.2), @@ -141,7 +141,7 @@ def test__deflections_2d__numerical_precision_of_csv_compared_to_integral(): grid=ag.Grid2DIrregular([[100.0, 200.0]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) deflections_via_integral = nfw.deflections_2d_via_integral_from( grid=ag.Grid2DIrregular([[-1000.0, -2000.0]]) @@ -150,7 +150,7 @@ def test__deflections_2d__numerical_precision_of_csv_compared_to_integral(): grid=ag.Grid2DIrregular([[-1000.0, -2000.0]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) def test__deflections_yx_2d_from(): @@ -161,7 +161,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) + assert deflections == pytest.approx(deflections_via_integral.array, 1.0e-4) def test__convergence_2d_via_mge_from(): @@ -291,74 +291,60 @@ def test__convergence_2d_from(): assert convergence == pytest.approx(1.388511, 1e-3) -def test__potential_2d_from(): - nfw = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0) - - potential = nfw.potential_2d_from(grid=ag.Grid2DIrregular([[0.1875, 0.1625]])) - - assert potential == pytest.approx(0.03702, 1e-3) - - nfw = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0) - - potential = nfw.potential_2d_from(grid=ag.Grid2DIrregular([[0.1875, 0.1625]])) - - assert potential == pytest.approx(0.03702, 1e-3) - - nfw = ag.mp.NFW( - centre=(0.3, 0.2), - ell_comps=(0.03669, 0.172614), - kappa_s=2.5, - scale_radius=4.0, - ) - - potential = nfw.potential_2d_from(grid=ag.Grid2DIrregular([[0.1625, 0.1625]])) - - assert potential == pytest.approx(0.05380, 1e-3) - - nfw_spherical = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0) - nfw_elliptical = ag.mp.NFW( - centre=(0.3, 0.2), - ell_comps=(0.0, 0.0), - kappa_s=2.5, - scale_radius=4.0, - ) - - potential_spherical = nfw_spherical.potential_2d_from( - grid=ag.Grid2DIrregular([[0.1875, 0.1625]]) - ) - potential_elliptical = nfw_elliptical.potential_2d_from( - grid=ag.Grid2DIrregular([[0.1875, 0.1625]]) - ) - - assert potential_spherical == pytest.approx(potential_elliptical, 1e-3) +# def test__potential_2d_from(): +# nfw = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0) +# +# potential = nfw.potential_2d_from(grid=ag.Grid2DIrregular([[0.1875, 0.1625]])) +# +# assert potential == pytest.approx(0.03702, 1e-3) +# +# nfw = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0) +# +# potential = nfw.potential_2d_from(grid=ag.Grid2DIrregular([[0.1875, 0.1625]])) +# +# assert potential == pytest.approx(0.03702, 1e-3) +# +# nfw = ag.mp.NFW( +# centre=(0.3, 0.2), +# ell_comps=(0.03669, 0.172614), +# kappa_s=2.5, +# scale_radius=4.0, +# ) +# +# potential = nfw.potential_2d_from(grid=ag.Grid2DIrregular([[0.1625, 0.1625]])) +# +# assert potential == pytest.approx(0.05380, 1e-3) +# +# nfw_spherical = ag.mp.NFWSph(centre=(0.3, 0.2), kappa_s=2.5, scale_radius=4.0) +# nfw_elliptical = ag.mp.NFW( +# centre=(0.3, 0.2), +# ell_comps=(0.0, 0.0), +# kappa_s=2.5, +# scale_radius=4.0, +# ) +# +# potential_spherical = nfw_spherical.potential_2d_from( +# grid=ag.Grid2DIrregular([[0.1875, 0.1625]]) +# ) +# potential_elliptical = nfw_elliptical.potential_2d_from( +# grid=ag.Grid2DIrregular([[0.1875, 0.1625]]) +# ) +# +# assert potential_spherical == pytest.approx(potential_elliptical, 1e-3) def test__shear_yx_2d_from(): mp = ag.mp.NFWSph(centre=(0.0, 0.0), kappa_s=1.0, scale_radius=1.0) - shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[0.01, 1.0]])) - - assert shear[0, 0] == pytest.approx(-0.01120694, 1e-3) - assert shear[0, 1] == pytest.approx(-0.56057913, 1e-3) - shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[2.0, 1.0]])) - assert shear[0, 0] == pytest.approx(-0.24712463, 1e-3) - assert shear[0, 1] == pytest.approx(0.185340150, 1e-3) + assert shear[0, 0] == pytest.approx(-0.24712463, abs=1e-3) + assert shear[0, 1] == pytest.approx(0.185340150, abs=1e-3) shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[3.0, 5.0]])) - assert shear[0, 0] == pytest.approx(-0.09588857, 1e-3) - assert shear[0, 1] == pytest.approx(-0.05114060, 1e-3) - - mp = ag.mp.NFW( - centre=(0.0, 0.0), ell_comps=(0.0, 0.0), kappa_s=1.0, scale_radius=1.0 - ) - - shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[0.01, 1.0]])) - - assert shear[0, 0] == pytest.approx(-0.01120694, 1e-3) - assert shear[0, 1] == pytest.approx(-0.56057913, 1e-3) + assert shear[0, 0] == pytest.approx(-0.09588857, abs=1e-3) + assert shear[0, 1] == pytest.approx(-0.05114060, abs=1e-3) mp = ag.mp.NFW( centre=(0.0, 0.0), ell_comps=(0.3, 0.4), kappa_s=1.0, scale_radius=1.0 @@ -366,5 +352,5 @@ def test__shear_yx_2d_from(): shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[2.0, 1.0]])) - assert shear[0, 0] == pytest.approx(-0.08554797, 1e-3) - assert shear[0, 1] == pytest.approx(0.111356360, 1e-3) + assert shear[0, 0] == pytest.approx(-0.08554797, abs=1e-3) + assert shear[0, 1] == pytest.approx(0.111356360, abs=1e-3) diff --git a/test_autogalaxy/profiles/mass/dark/test_nfw_mcr.py b/test_autogalaxy/profiles/mass/dark/test_nfw_mcr.py index 40613105e..7d8465412 100644 --- a/test_autogalaxy/profiles/mass/dark/test_nfw_mcr.py +++ b/test_autogalaxy/profiles/mass/dark/test_nfw_mcr.py @@ -1,4 +1,3 @@ -import numpy as np import pytest import autogalaxy as ag @@ -7,7 +6,10 @@ def test__mass_and_concentration_consistent_with_normal_nfw(): - cosmology = ag.cosmo.FlatLambdaCDMWrap(H0=70.0, Om0=0.3) + + from autogalaxy.cosmology.model import FlatLambdaCDMWrap + + cosmology = FlatLambdaCDMWrap(H0=70.0, Om0=0.3) mp = ag.mp.NFWMCRDuffySph( centre=(1.0, 2.0), @@ -41,24 +43,22 @@ def test__mass_and_concentration_consistent_with_normal_nfw(): assert mass_at_200_via_kappa_s == mass_at_200_via_mass assert concentration_via_kappa_s == concentration_via_mass - assert isinstance(mp.kappa_s, float) - assert mp.centre == (1.0, 2.0) assert mp.axis_ratio == 1.0 - assert isinstance(mp.axis_ratio, float) assert mp.angle == 0.0 - assert isinstance(mp.angle, float) assert mp.inner_slope == 1.0 - assert isinstance(mp.inner_slope, float) assert mp.scale_radius == pytest.approx(0.273382, 1.0e-4) def test__mass_and_concentration_consistent_with_normal_nfw__scatter_0(): - cosmology = ag.cosmo.FlatLambdaCDMWrap(H0=70.0, Om0=0.3) + + from autogalaxy.cosmology.model import FlatLambdaCDMWrap + + cosmology = FlatLambdaCDMWrap(H0=70.0, Om0=0.3) mp = ag.mp.NFWMCRLudlowSph( centre=(1.0, 2.0), @@ -92,19 +92,10 @@ def test__mass_and_concentration_consistent_with_normal_nfw__scatter_0(): assert mass_at_200_via_kappa_s == mass_at_200_via_mass assert concentration_via_kappa_s == concentration_via_mass - assert isinstance(mp.kappa_s, float) - assert mp.centre == (1.0, 2.0) - assert mp.axis_ratio == 1.0 - assert isinstance(mp.axis_ratio, float) - assert mp.angle == 0.0 - assert isinstance(mp.angle, float) - assert mp.inner_slope == 1.0 - assert isinstance(mp.inner_slope, float) - assert mp.scale_radius == pytest.approx(0.21157, 1.0e-4) deflections_ludlow = mp.deflections_yx_2d_from(grid=grid) @@ -114,7 +105,10 @@ def test__mass_and_concentration_consistent_with_normal_nfw__scatter_0(): def test__same_as_above_but_elliptical(): - cosmology = ag.cosmo.FlatLambdaCDMWrap(H0=70.0, Om0=0.3) + + from autogalaxy.cosmology.model import FlatLambdaCDMWrap + + cosmology = FlatLambdaCDMWrap(H0=70.0, Om0=0.3) mp = ag.mp.NFWMCRLudlow( centre=(1.0, 2.0), @@ -150,20 +144,13 @@ def test__same_as_above_but_elliptical(): assert mass_at_200_via_kappa_s == mass_at_200_via_mass assert concentration_via_kappa_s == concentration_via_mass - assert isinstance(mp.kappa_s, float) - assert mp.centre == (1.0, 2.0) axis_ratio, angle = ag.convert.axis_ratio_and_angle_from(ell_comps=(0.1, 0.2)) assert mp.axis_ratio == axis_ratio - assert isinstance(mp.axis_ratio, float) - assert mp.angle == angle - assert isinstance(mp.angle, float) - assert mp.inner_slope == 1.0 - assert isinstance(mp.inner_slope, float) assert mp.scale_radius == pytest.approx(0.211578, 1.0e-4) @@ -174,7 +161,10 @@ def test__same_as_above_but_elliptical(): def test__same_as_above_but_generalized_elliptical(): - cosmology = ag.cosmo.FlatLambdaCDMWrap(H0=70.0, Om0=0.3) + + from autogalaxy.cosmology.model import FlatLambdaCDMWrap + + cosmology = FlatLambdaCDMWrap(H0=70.0, Om0=0.3) mp = ag.mp.gNFWMCRLudlow( centre=(1.0, 2.0), @@ -212,20 +202,13 @@ def test__same_as_above_but_generalized_elliptical(): assert mass_at_200_via_kappa_s == mass_at_200_via_mass assert concentration_via_kappa_s == concentration_via_mass - assert isinstance(mp.kappa_s, float) - assert mp.centre == (1.0, 2.0) axis_ratio, angle = ag.convert.axis_ratio_and_angle_from(ell_comps=(0.1, 0.2)) assert mp.axis_ratio == axis_ratio - assert isinstance(mp.axis_ratio, float) - assert mp.angle == angle - assert isinstance(mp.angle, float) - assert mp.inner_slope == 2.0 - assert isinstance(mp.inner_slope, float) assert mp.scale_radius == pytest.approx(0.21157, 1.0e-4) diff --git a/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py b/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py index 91f621a44..a9d972325 100644 --- a/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py +++ b/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py @@ -58,4 +58,4 @@ def test__scatter_is_nonzero(): deflections_sph = mp.deflections_yx_2d_from(grid=grid) deflections_ell = nfw_ell.deflections_yx_2d_from(grid=grid) - assert deflections_sph[0] != pytest.approx(deflections_ell[0], 1.0e-4) + assert deflections_sph[0] != pytest.approx(deflections_ell[0].array, 1.0e-4) diff --git a/test_autogalaxy/profiles/mass/dark/test_nfw_truncated.py b/test_autogalaxy/profiles/mass/dark/test_nfw_truncated.py index 25392def6..7f5082674 100644 --- a/test_autogalaxy/profiles/mass/dark/test_nfw_truncated.py +++ b/test_autogalaxy/profiles/mass/dark/test_nfw_truncated.py @@ -16,22 +16,22 @@ def test__deflections_yx_2d_from(): deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[2.0, 0.0]])) factor = (4.0 * 1.0 * 1.0) / (2.0 / 1.0) - assert deflections[0, 0] == pytest.approx(factor * 0.38209715, 1.0e-4) - assert deflections[0, 1] == pytest.approx(0.0, 1.0e-4) + assert deflections[0, 0] == pytest.approx(factor * 0.38209715, abs=1.0e-4) + assert deflections[0, 1] == pytest.approx(0.0, abs=1.0e-4) deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 2.0]])) - assert deflections[0, 0] == pytest.approx(0.0, 1.0e-4) - assert deflections[0, 1] == pytest.approx(factor * 0.38209715, 1.0e-4) + assert deflections[0, 0] == pytest.approx(0.0, abs=1.0e-4) + assert deflections[0, 1] == pytest.approx(factor * 0.38209715, abs=1.0e-4) deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[1.0, 1.0]])) factor = (4.0 * 1.0 * 1.0) / (np.sqrt(2) / 1.0) assert deflections[0, 0] == pytest.approx( - (1.0 / np.sqrt(2)) * factor * 0.3125838, 1.0e-4 + (1.0 / np.sqrt(2)) * factor * 0.3125838, abs=1.0e-4 ) assert deflections[0, 1] == pytest.approx( - (1.0 / np.sqrt(2)) * factor * 0.3125838, 1.0e-4 + (1.0 / np.sqrt(2)) * factor * 0.3125838, abs=1.0e-4 ) mp = ag.mp.NFWTruncatedSph( @@ -41,8 +41,8 @@ def test__deflections_yx_2d_from(): deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[2.0, 0.0]])) factor = (4.0 * 2.0 * 1.0) / (2.0 / 1.0) - assert deflections[0, 0] == pytest.approx(factor * 0.38209715, 1.0e-4) - assert deflections[0, 1] == pytest.approx(0.0, 1.0e-4) + assert deflections[0, 0] == pytest.approx(factor * 0.38209715, abs=1.0e-4) + assert deflections[0, 1] == pytest.approx(0.0, abs=1.0e-4) mp = ag.mp.NFWTruncatedSph( centre=(0.0, 0.0), kappa_s=1.0, scale_radius=4.0, truncation_radius=2.0 @@ -50,8 +50,8 @@ def test__deflections_yx_2d_from(): deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([(2.0, 0.0)])) - assert deflections[0, 0] == pytest.approx(2.1702661386, 1.0e-4) - assert deflections[0, 1] == pytest.approx(0.0, 1.0e-4) + assert deflections[0, 0] == pytest.approx(2.1702661386, abs=1.0e-4) + assert deflections[0, 1] == pytest.approx(0.0, abs=1.0e-4) def test__convergence_2d_from(): @@ -61,11 +61,11 @@ def test__convergence_2d_from(): convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[2.0, 0.0]])) - assert convergence == pytest.approx(2.0 * 0.046409642, 1.0e-4) + assert convergence == pytest.approx(2.0 * 0.046409642, abs=1.0e-4) convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[1.0, 1.0]])) - assert convergence == pytest.approx(2.0 * 0.10549515, 1.0e-4) + assert convergence == pytest.approx(2.0 * 0.10549515, abs=1.0e-4) mp = ag.mp.NFWTruncatedSph( centre=(0.0, 0.0), kappa_s=3.0, scale_radius=1.0, truncation_radius=2.0 @@ -73,7 +73,7 @@ def test__convergence_2d_from(): convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[2.0, 0.0]])) - assert convergence == pytest.approx(6.0 * 0.046409642, 1.0e-4) + assert convergence == pytest.approx(6.0 * 0.046409642, abs=1.0e-4) mp = ag.mp.NFWTruncatedSph( centre=(0.0, 0.0), kappa_s=3.0, scale_radius=5.0, truncation_radius=2.0 @@ -81,7 +81,7 @@ def test__convergence_2d_from(): convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[2.0, 0.0]])) - assert convergence == pytest.approx(1.51047026, 1.0e-4) + assert convergence == pytest.approx(1.51047026, abs=1.0e-4) def test__mass_at_truncation_radius(): @@ -127,7 +127,7 @@ def test__mass_at_truncation_radius(): # mass_at_truncation_radius = mp.mass_at_truncation_radius(redshift_galaxy=0.5, redshift_source=1.0, # unit_length='arcsec', unit_mass='solMass', cosmology=cosmology) # - # assert mass_at_truncation_radius == pytest.approx(0.0000421512, 1.0e-4) + # assert mass_at_truncation_radius == pytest.approx(0.0000421512, abs=1.0e-4) # # mp = ag.mp.NFWTruncatedSph(centre=(0.0, 0.0), kappa_s=2.0, scale_radius=8.0, # truncation_radius=4.0) @@ -135,7 +135,7 @@ def test__mass_at_truncation_radius(): # mass_at_truncation_radius = mp.mass_at_truncation_radius(redshift_galaxy=0.5, redshift_source=1.0, # unit_length='arcsec', unit_mass='solMass', cosmology=cosmology) # - # assert mass_at_truncation_radius == pytest.approx(0.00033636625, 1.0e-4) + # assert mass_at_truncation_radius == pytest.approx(0.00033636625, abs=1.0e-4) def test__compare_nfw_and_truncated_nfw_with_large_truncation_radius(): @@ -152,7 +152,7 @@ def test__compare_nfw_and_truncated_nfw_with_large_truncation_radius(): grid=ag.Grid2DIrregular([[2.0, 2.0], [3.0, 1.0], [-1.0, -9.0]]) ) - assert truncated_nfw_convergence == pytest.approx(nfw_convergence, 1.0e-4) + assert truncated_nfw_convergence == pytest.approx(nfw_convergence, abs=1.0e-4) truncated_nfw_deflections = truncated_nfw.deflections_yx_2d_from( grid=ag.Grid2DIrregular([[2.0, 2.0], [3.0, 1.0], [-1.0, -9.0]]) @@ -161,4 +161,4 @@ def test__compare_nfw_and_truncated_nfw_with_large_truncation_radius(): grid=ag.Grid2DIrregular([[2.0, 2.0], [3.0, 1.0], [-1.0, -9.0]]) ) - assert truncated_nfw_deflections == pytest.approx(nfw_deflections, 1.0e-4) + assert truncated_nfw_deflections == pytest.approx(nfw_deflections.array, abs=1.0e-4) diff --git a/test_autogalaxy/profiles/mass/dark/test_nfw_truncated_mcr.py b/test_autogalaxy/profiles/mass/dark/test_nfw_truncated_mcr.py index 6a3c5ff98..64adf18fb 100644 --- a/test_autogalaxy/profiles/mass/dark/test_nfw_truncated_mcr.py +++ b/test_autogalaxy/profiles/mass/dark/test_nfw_truncated_mcr.py @@ -7,7 +7,10 @@ def test__duffy__mass_and_concentration_consistent_with_normal_truncated_nfw(): - cosmology = ag.cosmo.FlatLambdaCDMWrap(H0=70.0, Om0=0.3) + + from autogalaxy.cosmology.model import FlatLambdaCDMWrap + + cosmology = FlatLambdaCDMWrap(H0=70.0, Om0=0.3) mp = ag.mp.NFWTruncatedMCRDuffySph( centre=(1.0, 2.0), @@ -42,24 +45,19 @@ def test__duffy__mass_and_concentration_consistent_with_normal_truncated_nfw(): assert mass_at_200_via_kappa_s == mass_at_200_via_mass assert concentration_via_kappa_s == concentration_via_mass - assert isinstance(mp.kappa_s, float) - assert mp.centre == (1.0, 2.0) - assert mp.axis_ratio == 1.0 - assert isinstance(mp.axis_ratio, float) - assert mp.angle == 0.0 - assert isinstance(mp.angle, float) - assert mp.inner_slope == 1.0 - assert isinstance(mp.inner_slope, float) assert mp.scale_radius == pytest.approx(0.273382, 1.0e-4) def test__ludlow__mass_and_concentration_consistent_with_normal_truncated_nfw__scatter_0(): - cosmology = ag.cosmo.FlatLambdaCDMWrap(H0=70.0, Om0=0.3) + + from autogalaxy.cosmology.model import FlatLambdaCDMWrap + + cosmology = FlatLambdaCDMWrap(H0=70.0, Om0=0.3) mp = ag.mp.NFWTruncatedMCRLudlowSph( centre=(1.0, 2.0), @@ -94,18 +92,10 @@ def test__ludlow__mass_and_concentration_consistent_with_normal_truncated_nfw__s assert mass_at_200_via_kappa_s == mass_at_200_via_mass assert concentration_via_kappa_s == concentration_via_mass - assert isinstance(mp.kappa_s, float) - assert mp.centre == (1.0, 2.0) - assert mp.axis_ratio == 1.0 - assert isinstance(mp.axis_ratio, float) - assert mp.angle == 0.0 - assert isinstance(mp.angle, float) - assert mp.inner_slope == 1.0 - assert isinstance(mp.inner_slope, float) assert mp.scale_radius == pytest.approx(0.21157, 1.0e-4) assert mp.truncation_radius == pytest.approx(33.7134116, 1.0e-4) diff --git a/test_autogalaxy/profiles/mass/point/test_smbh_binary.py b/test_autogalaxy/profiles/mass/point/test_smbh_binary.py index f4333a81f..fcca199a0 100644 --- a/test_autogalaxy/profiles/mass/point/test_smbh_binary.py +++ b/test_autogalaxy/profiles/mass/point/test_smbh_binary.py @@ -156,5 +156,5 @@ def test__deflections_yx_2d_from(): deflections_1 = smbh_1.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[1.0, 1.0]])) assert deflections[0, 0] == pytest.approx( - deflections_0[0, 0] + deflections_1[0, 0], 1e-2 + deflections_0.array[0, 0] + deflections_1.array[0, 0], 1e-2 ) diff --git a/test_autogalaxy/profiles/mass/sheets/test_decorators.py b/test_autogalaxy/profiles/mass/sheets/test_decorators.py deleted file mode 100644 index c79027a81..000000000 --- a/test_autogalaxy/profiles/mass/sheets/test_decorators.py +++ /dev/null @@ -1,32 +0,0 @@ -import autogalaxy as ag -import numpy as np - -grid = ag.Grid2DIrregular([[1.0, 1.0], [2.0, 2.0], [3.0, 3.0], [2.0, 4.0]]) - - -def test__mass_quantity_functions__output_is_autoarray_structure(): - grid = ag.Grid2D.uniform(shape_native=(2, 2), pixel_scales=1.0) - - mass_sheet = ag.mp.MassSheet() - - convergence = mass_sheet.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = mass_sheet.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = mass_sheet.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - shear = ag.mp.ExternalShear() - - convergence = shear.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = shear.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = shear.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) diff --git a/test_autogalaxy/profiles/mass/sheets/test_input_deflections.py b/test_autogalaxy/profiles/mass/sheets/test_input_deflections.py deleted file mode 100644 index d717d9202..000000000 --- a/test_autogalaxy/profiles/mass/sheets/test_input_deflections.py +++ /dev/null @@ -1,303 +0,0 @@ -import autogalaxy as ag -import numpy as np -import pytest -from autogalaxy import exc - - -grid = ag.Grid2DIrregular([[1.0, 1.0], [2.0, 2.0], [3.0, 3.0], [2.0, 4.0]]) - - -def test__deflections_yx_2d_from__grid_coordinates_overlap_image_grid_of_deflections(): - deflections_y = ag.Array2D.no_mask( - values=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - deflections_x = ag.Array2D.no_mask( - values=[[9.0, 8.0, 7.0], [6.0, 5.0, 4.0], [3.0, 2.0, 1.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - - image_plane_grid = ag.Grid2D.uniform( - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - input_deflections = ag.mp.InputDeflections( - deflections_y=deflections_y, - deflections_x=deflections_x, - image_plane_grid=image_plane_grid, - ) - - grid = ag.Grid2D.uniform( - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - deflections = input_deflections.deflections_yx_2d_from(grid=grid) - - assert deflections[:, 0] == pytest.approx(deflections_y, 1.0e-4) - assert deflections[:, 1] == pytest.approx(deflections_x, 1.0e-4) - - grid = ag.Grid2D.no_mask( - values=np.array( - [ - [0.1, 0.0], - [0.0, 0.0], - [-0.1, -0.1], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - ] - ), - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - deflections = input_deflections.deflections_yx_2d_from(grid=grid) - - assert deflections[0:3, 0] == pytest.approx([2.0, 5.0, 7.0], 1.0e-4) - assert deflections[0:3, 1] == pytest.approx([8.0, 5.0, 3.0], 1.0e-4) - - -def test__deflections_yx_2d_from__grid_coordinates_dont_overlap_image_grid_of_deflections__uses_interpolation(): - deflections_y = ag.Array2D.no_mask( - values=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - deflections_x = ag.Array2D.no_mask( - values=[[9.0, 8.0, 7.0], [6.0, 5.0, 4.0], [3.0, 2.0, 1.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - - image_plane_grid = ag.Grid2D.uniform( - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - input_deflections = ag.mp.InputDeflections( - deflections_y=deflections_y, - deflections_x=deflections_x, - image_plane_grid=image_plane_grid, - ) - - grid = ag.Grid2D.no_mask( - values=np.array( - [ - [0.05, 0.03], - [0.02, 0.01], - [-0.08, -0.04], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - ] - ), - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - deflections = input_deflections.deflections_yx_2d_from(grid=grid) - - assert deflections[0:3, 0] == pytest.approx([3.8, 4.5, 7.0], 1.0e-4) - assert deflections[0:3, 1] == pytest.approx([6.2, 5.5, 3.0], 1.0e-4) - - -def test__deflections_yx_2d_from__preload_grid_deflections_used_if_preload_grid_input(): - deflections_y = ag.Array2D.no_mask( - values=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - deflections_x = ag.Array2D.no_mask( - values=[[9.0, 8.0, 7.0], [6.0, 5.0, 4.0], [3.0, 2.0, 1.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - - image_plane_grid = ag.Grid2D.uniform( - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - grid = ag.Grid2D.no_mask( - values=np.array( - [ - [0.05, 0.03], - [0.02, 0.01], - [-0.08, -0.04], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - ] - ), - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - input_deflections = ag.mp.InputDeflections( - deflections_y=deflections_y, - deflections_x=deflections_x, - image_plane_grid=image_plane_grid, - preload_grid=grid, - ) - - input_deflections.preload_deflections[0, 0] = 1.0 - - deflections = input_deflections.deflections_yx_2d_from(grid=grid) - - assert (deflections == input_deflections.preload_deflections).all() - - -def test__deflections_yx_2d_from__input_grid_extends_beyond_image_plane_grid__raises_exception(): - deflections_y = ag.Array2D.no_mask( - values=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - deflections_x = ag.Array2D.no_mask( - values=[[9.0, 8.0, 7.0], [6.0, 5.0, 4.0], [3.0, 2.0, 1.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - - image_plane_grid = ag.Grid2D.uniform( - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - input_deflections = ag.mp.InputDeflections( - deflections_y=deflections_y, - deflections_x=deflections_x, - image_plane_grid=image_plane_grid, - ) - - grid = ag.Grid2D.no_mask( - values=np.array( - [ - [0.0999, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - ] - ), - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - input_deflections.deflections_yx_2d_from(grid=grid) - - grid = ag.Grid2D.no_mask( - values=np.array( - [ - [0.0, 0.0999], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - ] - ), - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - input_deflections.deflections_yx_2d_from(grid=grid) - - with pytest.raises(exc.ProfileException): - grid = ag.Grid2D.no_mask( - values=np.array( - [ - [0.11, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - ] - ), - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - input_deflections.deflections_yx_2d_from(grid=grid) - - with pytest.raises(exc.ProfileException): - grid = ag.Grid2D.no_mask( - values=np.array( - [ - [0.0, 0.11], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - [0.0, 0.0], - ] - ), - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - input_deflections.deflections_yx_2d_from(grid=grid) - - -def test__convergence_2d_from_potential_2d_from(): - deflections_y = ag.Array2D.no_mask( - values=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - deflections_x = ag.Array2D.no_mask( - values=[[9.0, 8.0, 7.0], [6.0, 5.0, 4.0], [3.0, 2.0, 1.0]], - pixel_scales=0.1, - origin=(0.0, 0.0), - ) - - image_plane_grid = ag.Grid2D.uniform( - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - input_deflections = ag.mp.InputDeflections( - deflections_y=deflections_y, - deflections_x=deflections_x, - image_plane_grid=image_plane_grid, - ) - - grid = ag.Grid2D.uniform( - shape_native=deflections_y.shape_native, - pixel_scales=deflections_y.pixel_scales, - ) - - convergence = input_deflections.convergence_2d_from(grid=grid) - - convergence_via_jacobian = input_deflections.convergence_2d_via_jacobian_from( - grid=grid - ) - - assert (convergence == convergence_via_jacobian).all() - - potential = input_deflections.potential_2d_from(grid=grid) - - assert (potential == np.zeros(shape=(9,))).all() diff --git a/test_autogalaxy/profiles/mass/sheets/test_mass_sheet.py b/test_autogalaxy/profiles/mass/sheets/test_mass_sheet.py index 1921a8159..2d0b1b9f0 100644 --- a/test_autogalaxy/profiles/mass/sheets/test_mass_sheet.py +++ b/test_autogalaxy/profiles/mass/sheets/test_mass_sheet.py @@ -13,14 +13,14 @@ def test__deflections_yx_2d_from(): deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[2.0, 0.0]])) assert deflections[0, 0] == pytest.approx(2.0, 1e-3) - assert deflections[0, 1] == pytest.approx(0.0, 1e-3) + assert deflections[0, 1] == pytest.approx(0.0, abs=1e-3) mp = ag.mp.MassSheet(centre=(0.0, 0.0), kappa=-1.0) deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[2.0, 0.0]])) assert deflections[0, 0] == pytest.approx(-2.0, 1e-3) - assert deflections[0, 1] == pytest.approx(0.0, 1e-3) + assert deflections[0, 1] == pytest.approx(0.0, abs=1e-3) # The radial coordinate at (1.0, 1.0) is sqrt(2) # This is decomposed into (y,x) angles of sin(45) = cos(45) = sqrt(2) / 2.0 diff --git a/test_autogalaxy/profiles/mass/stellar/test_chameleon.py b/test_autogalaxy/profiles/mass/stellar/test_chameleon.py index ef2030db3..2312839d1 100644 --- a/test_autogalaxy/profiles/mass/stellar/test_chameleon.py +++ b/test_autogalaxy/profiles/mass/stellar/test_chameleon.py @@ -32,7 +32,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) + assert deflections == pytest.approx(deflections_via_integral.array, 1.0e-4) mp = ag.mp.ChameleonSph() @@ -41,7 +41,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) + assert deflections == pytest.approx(deflections_via_integral.array, 1.0e-4) def test__spherical_and_elliptical_identical(): @@ -59,7 +59,7 @@ def test__spherical_and_elliptical_identical(): elliptical_deflections = elliptical.deflections_yx_2d_from(grid=grid) spherical_deflections = spherical.deflections_yx_2d_from(grid=grid) - assert elliptical_deflections == pytest.approx(spherical_deflections, 1.0e-4) + assert elliptical_deflections == pytest.approx(spherical_deflections.array, 1.0e-4) def test__convergence_2d_from(): @@ -99,5 +99,5 @@ def test__convergence_2d_from(): ) assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1.0e-4 + spherical.convergence_2d_from(grid=grid).array, 1.0e-4 ) diff --git a/test_autogalaxy/profiles/mass/stellar/test_dev_vaucouleurs.py b/test_autogalaxy/profiles/mass/stellar/test_dev_vaucouleurs.py index e4d777212..d6bcda389 100644 --- a/test_autogalaxy/profiles/mass/stellar/test_dev_vaucouleurs.py +++ b/test_autogalaxy/profiles/mass/stellar/test_dev_vaucouleurs.py @@ -14,7 +14,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections == pytest.approx(deflections_via_cse.array, 1.0e-4) mp = ag.mp.DevVaucouleursSph() @@ -23,7 +23,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections == pytest.approx(deflections_via_cse.array, 1.0e-4) def test__deflections_via_integral_from(): @@ -59,7 +59,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) mp = ag.mp.DevVaucouleurs( centre=(0.4, 0.2), @@ -76,7 +76,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) def test__convergence_2d_via_mge_from(): diff --git a/test_autogalaxy/profiles/mass/stellar/test_exponential.py b/test_autogalaxy/profiles/mass/stellar/test_exponential.py index 6165333bf..2583590aa 100644 --- a/test_autogalaxy/profiles/mass/stellar/test_exponential.py +++ b/test_autogalaxy/profiles/mass/stellar/test_exponential.py @@ -14,7 +14,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections == pytest.approx(deflections_via_cse.array, 1.0e-4) mp = ag.mp.ExponentialSph() @@ -23,7 +23,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections == pytest.approx(deflections_via_cse.array, 1.0e-4) def test__deflections_2d_via_integral_from(): @@ -74,7 +74,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) mp = ag.mp.Exponential( centre=(-0.4, -0.2), @@ -91,7 +91,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) def test__convergence_2d_via_mge_from(): diff --git a/test_autogalaxy/profiles/mass/stellar/test_gaussian.py b/test_autogalaxy/profiles/mass/stellar/test_gaussian.py index 3a653451c..af9d24ce5 100644 --- a/test_autogalaxy/profiles/mass/stellar/test_gaussian.py +++ b/test_autogalaxy/profiles/mass/stellar/test_gaussian.py @@ -20,7 +20,7 @@ def test__deflections_2d_via_analytic_from(): ) assert deflections[0, 0] == pytest.approx(1.024423, 1.0e-4) - assert deflections[0, 1] == pytest.approx(0.0, 1.0e-4) + assert deflections[0, 1] == pytest.approx(0.0, abs=1.0e-4) mp = ag.mp.Gaussian( centre=(0.0, 0.0), @@ -84,7 +84,7 @@ def test__deflections_2d_via_integral_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_analytic, 1.0e-3) + assert deflections == pytest.approx(deflections_via_analytic.array, 1.0e-3) mp = ag.mp.Gaussian( centre=(0.0, 0.0), @@ -101,7 +101,7 @@ def test__deflections_2d_via_integral_from(): grid=ag.Grid2DIrregular([[0.5, 0.2]]) ) - assert deflections == pytest.approx(deflections_via_analytic, 1.0e-3) + assert deflections == pytest.approx(deflections_via_analytic.array, 1.0e-3) mp = ag.mp.Gaussian( centre=(0.0, 0.0), @@ -118,7 +118,7 @@ def test__deflections_2d_via_integral_from(): grid=ag.Grid2DIrregular([[0.5, 0.2]]) ) - assert deflections == pytest.approx(deflections_via_analytic, 1.0e-3) + assert deflections == pytest.approx(deflections_via_analytic.array, 1.0e-3) mp = ag.mp.Gaussian( centre=(0.0, 0.0), @@ -135,7 +135,7 @@ def test__deflections_2d_via_integral_from(): grid=ag.Grid2DIrregular([[0.5, 0.2]]) ) - assert deflections == pytest.approx(deflections_via_analytic, 1.0e-3) + assert deflections == pytest.approx(deflections_via_analytic.array, 1.0e-3) def test__deflections_yx_2d_from(): @@ -146,7 +146,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) + assert deflections == pytest.approx(deflections_via_integral.array, 1.0e-4) def test__convergence_2d_from(): @@ -214,7 +214,7 @@ def test__image_2d_via_radii_from__correct_value(): centre=(0.0, 0.0), ell_comps=(0.0, 0.0), intensity=1.0, sigma=1.0 ) - intensity = mp.image_2d_via_radii_from(grid_radii=1.0) + intensity = mp.image_2d_via_radii_from(grid_radii=ag.ArrayIrregular(1.0)) assert intensity == pytest.approx(0.60653, 1e-2) @@ -222,15 +222,14 @@ def test__image_2d_via_radii_from__correct_value(): centre=(0.0, 0.0), ell_comps=(0.0, 0.0), intensity=2.0, sigma=1.0 ) - intensity = mp.image_2d_via_radii_from(grid_radii=1.0) + intensity = mp.image_2d_via_radii_from(grid_radii=ag.ArrayIrregular(1.0)) assert intensity == pytest.approx(2.0 * 0.60653, 1e-2) mp = ag.mp.Gaussian( centre=(0.0, 0.0), ell_comps=(0.0, 0.0), intensity=1.0, sigma=2.0 ) - - intensity = mp.image_2d_via_radii_from(grid_radii=1.0) + intensity = mp.image_2d_via_radii_from(grid_radii=ag.ArrayIrregular(1.0)) assert intensity == pytest.approx(0.882496, 1e-2) @@ -238,6 +237,6 @@ def test__image_2d_via_radii_from__correct_value(): centre=(0.0, 0.0), ell_comps=(0.0, 0.0), intensity=1.0, sigma=2.0 ) - intensity = mp.image_2d_via_radii_from(grid_radii=3.0) + intensity = mp.image_2d_via_radii_from(grid_radii=ag.ArrayIrregular(3.0)) assert intensity == pytest.approx(0.32465, 1e-2) diff --git a/test_autogalaxy/profiles/mass/stellar/test_sersic.py b/test_autogalaxy/profiles/mass/stellar/test_sersic.py index a3c6fb979..e222b7f87 100644 --- a/test_autogalaxy/profiles/mass/stellar/test_sersic.py +++ b/test_autogalaxy/profiles/mass/stellar/test_sersic.py @@ -57,7 +57,7 @@ def test__deflections_2d_via_mge_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_mge, 1.0e-3) + assert deflections_via_integral == pytest.approx(deflections_via_mge.array, 1.0e-3) mp = ag.mp.Sersic( centre=(-0.4, -0.2), @@ -75,7 +75,7 @@ def test__deflections_2d_via_mge_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_mge, 1.0e-3) + assert deflections_via_integral == pytest.approx(deflections_via_mge.array, 1.0e-3) def test__deflections_2d_via_cse_from(): @@ -95,7 +95,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) mp = ag.mp.Sersic( centre=(-0.4, -0.2), @@ -113,7 +113,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-3) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-3) mp = ag.mp.Sersic( centre=(-0.4, -0.2), @@ -131,7 +131,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-3) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-3) def test__deflections_yx_2d_from(): @@ -142,7 +142,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) + assert deflections == pytest.approx(deflections_via_integral.array, 1.0e-4) mp = ag.mp.SersicSph() @@ -151,7 +151,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) + assert deflections == pytest.approx(deflections_via_integral.array, 1.0e-4) elliptical = ag.mp.Sersic( centre=(0.0, 0.0), @@ -173,7 +173,7 @@ def test__deflections_yx_2d_from(): elliptical_deflections = elliptical.deflections_2d_via_integral_from(grid=grid) spherical_deflections = spherical.deflections_2d_via_integral_from(grid=grid) - assert elliptical_deflections == pytest.approx(spherical_deflections, 1.0e-4) + assert elliptical_deflections == pytest.approx(spherical_deflections.array, 1.0e-4) def test__convergence_2d_via_mge_from(): diff --git a/test_autogalaxy/profiles/mass/stellar/test_sersic_core.py b/test_autogalaxy/profiles/mass/stellar/test_sersic_core.py index c17bcb03d..488c1e107 100644 --- a/test_autogalaxy/profiles/mass/stellar/test_sersic_core.py +++ b/test_autogalaxy/profiles/mass/stellar/test_sersic_core.py @@ -6,95 +6,96 @@ grid = ag.Grid2DIrregular([[1.0, 1.0], [2.0, 2.0], [3.0, 3.0], [2.0, 4.0]]) -def test__deflections_2d_via_mge_from(): - mp = ag.mp.SersicCore( - centre=(1.0, 2.0), - ell_comps=ag.convert.ell_comps_from(axis_ratio=0.5, angle=70.0), - intensity=0.45, - effective_radius=0.5, - radius_break=0.01, - gamma=0.0, - alpha=2.0, - sersic_index=2.2, - ) - - deflections = mp.deflections_2d_via_mge_from(grid=ag.Grid2DIrregular([[2.5, -2.5]])) - - assert deflections[0, 0] == pytest.approx(0.0015047, 1e-4) - assert deflections[0, 1] == pytest.approx(-0.004493, 1e-4) - - mp = ag.mp.SersicCore( - centre=(1.0, 2.0), - ell_comps=ag.convert.ell_comps_from(axis_ratio=0.5, angle=70.0), - intensity=2.0 * 0.45, - effective_radius=0.5, - radius_break=0.01, - gamma=0.0, - alpha=2.0, - sersic_index=2.2, - ) - - deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[2.5, -2.5]])) - - assert deflections[0, 0] == pytest.approx(2.0 * 0.0015047, 1e-4) - assert deflections[0, 1] == pytest.approx(2.0 * -0.004493, 1e-4) - - mp = ag.mp.SersicCore( - centre=(1.0, 2.0), - ell_comps=ag.convert.ell_comps_from(axis_ratio=0.5, angle=70.0), - intensity=0.45, - effective_radius=0.5, - radius_break=0.01, - gamma=0.0, - alpha=2.0, - sersic_index=2.2, - mass_to_light_ratio=2.0, - ) - - deflections = mp.deflections_2d_via_mge_from(grid=ag.Grid2DIrregular([[2.5, -2.5]])) - - assert deflections[0, 0] == pytest.approx(2.0 * 0.0015047, 1e-4) - assert deflections[0, 1] == pytest.approx(2.0 * -0.004493, 1e-4) - - -def test__deflections_yx_2d_from(): - mp = ag.mp.SersicCore() - - deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[1.0, 0.0]])) - deflections_via_integral = mp.deflections_2d_via_mge_from( - grid=ag.Grid2DIrregular([[1.0, 0.0]]) - ) - - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) - - mp = ag.mp.SersicCoreSph() - - deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[1.0, 0.0]])) - deflections_via_integral = mp.deflections_2d_via_mge_from( - grid=ag.Grid2DIrregular([[1.0, 0.0]]) - ) - - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) - - elliptical = ag.mp.SersicCore( - centre=(0.0, 0.0), - ell_comps=(0.0, 0.0), - effective_radius=1.0, - sersic_index=4.0, - mass_to_light_ratio=1.0, - ) - - spherical = ag.mp.SersicCore( - centre=(0.0, 0.0), - effective_radius=1.0, - sersic_index=4.0, - mass_to_light_ratio=1.0, - ) - - elliptical_deflections = elliptical.deflections_2d_via_integral_from(grid=grid) - spherical_deflections = spherical.deflections_2d_via_integral_from(grid=grid) - - assert elliptical_deflections == pytest.approx(spherical_deflections, 1.0e-4) +# def test__deflections_2d_via_mge_from(): +# mp = ag.mp.SersicCore( +# centre=(1.0, 2.0), +# ell_comps=ag.convert.ell_comps_from(axis_ratio=0.5, angle=70.0), +# intensity=0.45, +# effective_radius=0.5, +# radius_break=0.01, +# gamma=0.0, +# alpha=2.0, +# sersic_index=2.2, +# ) +# +# deflections = mp.deflections_2d_via_mge_from(grid=ag.Grid2DIrregular([[2.5, -2.5]])) +# +# assert deflections[0, 0] == pytest.approx(0.0015047, 1e-4) +# assert deflections[0, 1] == pytest.approx(-0.004493, 1e-4) +# +# mp = ag.mp.SersicCore( +# centre=(1.0, 2.0), +# ell_comps=ag.convert.ell_comps_from(axis_ratio=0.5, angle=70.0), +# intensity=2.0 * 0.45, +# effective_radius=0.5, +# radius_break=0.01, +# gamma=0.0, +# alpha=2.0, +# sersic_index=2.2, +# ) +# +# deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[2.5, -2.5]])) +# +# assert deflections[0, 0] == pytest.approx(2.0 * 0.0015047, 1e-4) +# assert deflections[0, 1] == pytest.approx(2.0 * -0.004493, 1e-4) +# +# mp = ag.mp.SersicCore( +# centre=(1.0, 2.0), +# ell_comps=ag.convert.ell_comps_from(axis_ratio=0.5, angle=70.0), +# intensity=0.45, +# effective_radius=0.5, +# radius_break=0.01, +# gamma=0.0, +# alpha=2.0, +# sersic_index=2.2, +# mass_to_light_ratio=2.0, +# ) +# +# deflections = mp.deflections_2d_via_mge_from(grid=ag.Grid2DIrregular([[2.5, -2.5]])) +# +# assert deflections[0, 0] == pytest.approx(2.0 * 0.0015047, 1e-4) +# assert deflections[0, 1] == pytest.approx(2.0 * -0.004493, 1e-4) + + +# def test__deflections_yx_2d_from(): +# mp = ag.mp.SersicCore() +# +# deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[1.0, 0.0]])) +# deflections_via_integral = mp.deflections_2d_via_mge_from( +# grid=ag.Grid2DIrregular([[1.0, 0.0]]) +# ) +# +# assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) +# +# mp = ag.mp.SersicCoreSph() +# +# deflections = mp.deflections_yx_2d_from(grid=ag.Grid2DIrregular([[1.0, 0.0]])) +# deflections_via_integral = mp.deflections_2d_via_mge_from( +# grid=ag.Grid2DIrregular([[1.0, 0.0]]) +# ) +# +# assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) +# +# elliptical = ag.mp.SersicCore( +# centre=(0.0, 0.0), +# ell_comps=(0.0, 0.0), +# effective_radius=1.0, +# sersic_index=4.0, +# mass_to_light_ratio=1.0, +# ) +# +# spherical = ag.mp.SersicCore( +# centre=(0.0, 0.0), +# effective_radius=1.0, +# sersic_index=4.0, +# mass_to_light_ratio=1.0, +# ) +# +# elliptical_deflections = elliptical.deflections_2d_via_integral_from(grid=grid) +# spherical_deflections = spherical.deflections_2d_via_integral_from(grid=grid) +# +# assert elliptical_deflections == pytest.approx(spherical_deflections, 1.0e-4) +# def test__convergence_2d_from(): @@ -146,24 +147,24 @@ def test__convergence_2d_from(): ell_convergence_2d = elliptical.convergence_2d_from(grid=grid) sph_convergence_2d = spherical.convergence_2d_from(grid=grid) - assert ell_convergence_2d == pytest.approx(sph_convergence_2d, 1.0e-4) - - -def test__convergence_2d_via_mge_from(): - mp = ag.mp.SersicCore( - ell_comps=(0.2, 0.4), - effective_radius=5.0, - sersic_index=4.0, - radius_break=0.01, - intensity=0.1, - gamma=1.0, - alpha=1.0, - mass_to_light_ratio=1.0, - ) - - convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[0.0, 1.0]])) - convergence_via_mge = mp.convergence_2d_via_mge_from( - grid=ag.Grid2DIrregular([[0.0, 1.0]]) - ) - - assert convergence == pytest.approx(convergence_via_mge, 1e-3) + assert ell_convergence_2d == pytest.approx(sph_convergence_2d.array, 1.0e-4) + + +# def test__convergence_2d_via_mge_from(): +# mp = ag.mp.SersicCore( +# ell_comps=(0.2, 0.4), +# effective_radius=5.0, +# sersic_index=4.0, +# radius_break=0.01, +# intensity=0.1, +# gamma=1.0, +# alpha=1.0, +# mass_to_light_ratio=1.0, +# ) +# +# convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[0.0, 1.0]])) +# convergence_via_mge = mp.convergence_2d_via_mge_from( +# grid=ag.Grid2DIrregular([[0.0, 1.0]]) +# ) +# +# assert convergence == pytest.approx(convergence_via_mge, 1e-3) diff --git a/test_autogalaxy/profiles/mass/stellar/test_sersic_gradient.py b/test_autogalaxy/profiles/mass/stellar/test_sersic_gradient.py index c16994077..f85156c26 100644 --- a/test_autogalaxy/profiles/mass/stellar/test_sersic_gradient.py +++ b/test_autogalaxy/profiles/mass/stellar/test_sersic_gradient.py @@ -41,25 +41,25 @@ def test__deflections_via_integral_from(): assert deflections[0, 1] == pytest.approx(0.725459334118341, 1e-3) -def test__deflections_2d_via_mge_from(): - mp = ag.mp.SersicGradient( - centre=(-0.4, -0.2), - ell_comps=(-0.07142, -0.085116), - intensity=5.0, - effective_radius=0.2, - sersic_index=2.0, - mass_to_light_ratio=1.0, - mass_to_light_gradient=-1.0, - ) - - deflections_via_integral = mp.deflections_2d_via_integral_from( - grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) - ) - deflections_via_mge = mp.deflections_2d_via_mge_from( - grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) - ) - - assert deflections_via_integral == pytest.approx(deflections_via_mge, 1.0e-3) +# def test__deflections_2d_via_mge_from(): +# mp = ag.mp.SersicGradient( +# centre=(-0.4, -0.2), +# ell_comps=(-0.07142, -0.085116), +# intensity=5.0, +# effective_radius=0.2, +# sersic_index=2.0, +# mass_to_light_ratio=1.0, +# mass_to_light_gradient=-1.0, +# ) +# +# deflections_via_integral = mp.deflections_2d_via_integral_from( +# grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) +# ) +# deflections_via_mge = mp.deflections_2d_via_mge_from( +# grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) +# ) +# +# assert deflections_via_integral == pytest.approx(deflections_via_mge.array, 1.0e-3) def test__deflections_2d_via_cse_from(): @@ -80,7 +80,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) mp = ag.mp.SersicGradient( centre=(-0.4, -0.2), @@ -99,7 +99,7 @@ def test__deflections_2d_via_cse_from(): grid=ag.Grid2DIrregular([[0.1625, 0.1625]]) ) - assert deflections_via_integral == pytest.approx(deflections_via_cse, 1.0e-4) + assert deflections_via_integral == pytest.approx(deflections_via_cse.array, 1.0e-4) def test__deflections_yx_2d_from(): @@ -110,7 +110,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) + assert deflections == pytest.approx(deflections_via_integral.array, 1.0e-4) mp = ag.mp.SersicGradientSph() @@ -119,7 +119,7 @@ def test__deflections_yx_2d_from(): grid=ag.Grid2DIrregular([[1.0, 0.0]]) ) - assert deflections == pytest.approx(deflections_via_integral, 1.0e-4) + assert deflections == pytest.approx(deflections_via_integral.array, 1.0e-4) elliptical = ag.mp.SersicGradient( centre=(0.0, 0.0), @@ -143,7 +143,7 @@ def test__deflections_yx_2d_from(): ell_deflections_yx_2d = elliptical.deflections_yx_2d_from(grid=grid) sph_deflections_yx_2d = spherical.deflections_yx_2d_from(grid=grid) - ell_deflections_yx_2d == pytest.approx(sph_deflections_yx_2d, 1.0e-4) + ell_deflections_yx_2d == pytest.approx(sph_deflections_yx_2d.array, 1.0e-4) def test__convergence_2d_from(): @@ -239,7 +239,7 @@ def test__convergence_2d_from(): ell_convergence_2d = elliptical.convergence_2d_from(grid=grid) sph_convergence_2d = spherical.convergence_2d_from(grid=grid) - assert ell_convergence_2d == pytest.approx(sph_convergence_2d, 1.0e-4) + assert ell_convergence_2d == pytest.approx(sph_convergence_2d.array, 1.0e-4) def test__compare_to_sersic(): @@ -269,11 +269,11 @@ def test__compare_to_sersic(): ) assert sersic_deflections[0, 0] == pytest.approx( - exponential_deflections[0, 0], 1e-3 + exponential_deflections.array[0, 0], 1e-3 ) assert sersic_deflections[0, 0] == pytest.approx(0.90493, 1e-3) assert sersic_deflections[0, 1] == pytest.approx( - exponential_deflections[0, 1], 1e-3 + exponential_deflections.array[0, 1], 1e-3 ) assert sersic_deflections[0, 1] == pytest.approx(0.62569, 1e-3) @@ -333,10 +333,10 @@ def test__compare_to_sersic(): ) assert sersic_deflections[0, 0] == pytest.approx( - sersic_grad_deflections[0, 0], 1e-3 + sersic_grad_deflections.array[0, 0], 1e-3 ) assert sersic_deflections[0, 0] == pytest.approx(1.1446, 1e-3) assert sersic_deflections[0, 1] == pytest.approx( - sersic_grad_deflections[0, 1], 1e-3 + sersic_grad_deflections.array[0, 1], 1e-3 ) assert sersic_deflections[0, 1] == pytest.approx(0.79374, 1e-3) diff --git a/test_autogalaxy/profiles/mass/total/test_decorators.py b/test_autogalaxy/profiles/mass/total/test_decorators.py deleted file mode 100644 index 091ed1158..000000000 --- a/test_autogalaxy/profiles/mass/total/test_decorators.py +++ /dev/null @@ -1,127 +0,0 @@ -import numpy as np - -import autogalaxy as ag - -grid = ag.Grid2DIrregular([[1.0, 1.0], [2.0, 2.0], [3.0, 3.0], [2.0, 4.0]]) - - -def test__mass_quantity_functions__output_is_autoarray_structure(): - grid = ag.Grid2D.uniform(shape_native=(2, 2), pixel_scales=1.0) - - point_mass = ag.mp.PointMass() - deflections = point_mass.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - cored_power_law = ag.mp.PowerLawBroken() - - convergence = cored_power_law.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - deflections = cored_power_law.deflections_yx_2d_from(grid=grid) - assert deflections.shape_native == (2, 2) - - cored_power_law = ag.mp.PowerLawBrokenSph() - - convergence = cored_power_law.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - deflections = cored_power_law.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - cored_power_law = ag.mp.PowerLawCore() - - convergence = cored_power_law.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = cored_power_law.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = cored_power_law.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - cored_power_law = ag.mp.PowerLawCoreSph() - - convergence = cored_power_law.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = cored_power_law.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = cored_power_law.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - power_law = ag.mp.PowerLaw() - - convergence = power_law.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = power_law.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = power_law.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - power_law = ag.mp.PowerLawSph() - - convergence = power_law.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = power_law.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = power_law.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - cored_isothermal = ag.mp.IsothermalCore() - - convergence = cored_isothermal.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = cored_isothermal.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = cored_isothermal.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - cored_isothermal = ag.mp.IsothermalCoreSph() - - convergence = cored_isothermal.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = cored_isothermal.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = cored_isothermal.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - isothermal = ag.mp.Isothermal() - - convergence = isothermal.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = isothermal.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = isothermal.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) - - isothermal = ag.mp.IsothermalSph() - - convergence = isothermal.convergence_2d_from(grid=grid) - assert convergence.shape_native == (2, 2) - - potential = isothermal.potential_2d_from(grid=grid) - assert potential.shape_native == (2, 2) - - deflections = isothermal.deflections_yx_2d_from(grid=grid) - assert isinstance(deflections, ag.VectorYX2D) - assert deflections.shape_native == (2, 2) diff --git a/test_autogalaxy/profiles/mass/total/test_dual_pseudo_isothermal.py b/test_autogalaxy/profiles/mass/total/test_dual_pseudo_isothermal.py index 76d587934..0bc7d06ed 100644 --- a/test_autogalaxy/profiles/mass/total/test_dual_pseudo_isothermal.py +++ b/test_autogalaxy/profiles/mass/total/test_dual_pseudo_isothermal.py @@ -87,6 +87,6 @@ def test__convergence_2d_from(): ) spherical = ag.mp.dPIESph(centre=(1.1, 1.1), kappa_scale=3.0, ra=2.0, rs=3.0) - assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1e-4 + assert elliptical.convergence_2d_from(grid=grid).array == pytest.approx( + spherical.convergence_2d_from(grid=grid).array, 1e-4 ) diff --git a/test_autogalaxy/profiles/mass/total/test_isothermal.py b/test_autogalaxy/profiles/mass/total/test_isothermal.py index 21c315a4f..22605bb1b 100644 --- a/test_autogalaxy/profiles/mass/total/test_isothermal.py +++ b/test_autogalaxy/profiles/mass/total/test_isothermal.py @@ -40,7 +40,7 @@ def test__deflections_yx_2d_from(): spherical = ag.mp.IsothermalSph(centre=(1.1, 1.1), einstein_radius=3.0) assert elliptical.deflections_yx_2d_from(grid=grid) == pytest.approx( - spherical.deflections_yx_2d_from(grid=grid), 1e-4 + spherical.deflections_yx_2d_from(grid=grid).array, 1e-4 ) @@ -79,8 +79,8 @@ def test__convergence_2d_from(): ) spherical = ag.mp.IsothermalSph(centre=(1.1, 1.1), einstein_radius=3.0) - assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1e-4 + assert elliptical.convergence_2d_from(grid=grid).array == pytest.approx( + spherical.convergence_2d_from(grid=grid).array, 1e-4 ) @@ -107,7 +107,7 @@ def test__potential_2d_from(): spherical = ag.mp.IsothermalSph(centre=(1.1, 1.1), einstein_radius=3.0) assert elliptical.potential_2d_from(grid=grid) == pytest.approx( - spherical.potential_2d_from(grid=grid), 1e-4 + spherical.potential_2d_from(grid=grid).array, 1e-4 ) @@ -119,19 +119,19 @@ def test__shear_yx_2d_from(): shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 1.0]])) assert shear[0, 0] == pytest.approx(0.0, 1e-4) - assert shear[0, 1] == pytest.approx(-convergence, 1e-4) + assert shear[0, 1] == pytest.approx(-convergence.array[0], 1e-4) convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[2.0, 1.0]])) shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[2.0, 1.0]])) - assert shear[0, 0] == pytest.approx(-(4.0 / 5.0) * convergence, 1e-4) - assert shear[0, 1] == pytest.approx((3.0 / 5.0) * convergence, 1e-4) + assert shear[0, 0] == pytest.approx(-(4.0 / 5.0) * convergence.array[0], 1e-4) + assert shear[0, 1] == pytest.approx((3.0 / 5.0) * convergence.array[0], 1e-4) convergence = mp.convergence_2d_from(grid=ag.Grid2DIrregular([[3.0, 5.0]])) shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[3.0, 5.0]])) - assert shear[0, 0] == pytest.approx(-(30.0 / 34.0) * convergence, 1e-4) - assert shear[0, 1] == pytest.approx(-(16.0 / 34.0) * convergence, 1e-4) + assert shear[0, 0] == pytest.approx(-(30.0 / 34.0) * convergence.array[0], 1e-4) + assert shear[0, 1] == pytest.approx(-(16.0 / 34.0) * convergence.array[0], 1e-4) mp = ag.mp.Isothermal(centre=(0.0, 0.0), ell_comps=(0.0, 0.0), einstein_radius=2.0) @@ -140,36 +140,11 @@ def test__shear_yx_2d_from(): shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 1.0]])) assert shear[0, 0] == pytest.approx(0.0, 1e-4) - assert shear[0, 1] == pytest.approx(-convergence, 1e-4) + assert shear[0, 1] == pytest.approx(-convergence.array[0], 1e-4) mp = ag.mp.Isothermal(centre=(0.0, 0.0), ell_comps=(0.3, 0.4), einstein_radius=2.0) shear = mp.shear_yx_2d_from(grid=ag.Grid2DIrregular([[0.0, 1.0]])) - assert shear[0, 0] == pytest.approx(0.0, 1e-4) + assert shear[0, 0] == pytest.approx(0.0, abs=1e-4) assert shear[0, 1] == pytest.approx(-1.11803398874, 1e-4) - - -def test__compare_to_cored_power_law(): - isothermal = ag.mp.Isothermal( - centre=(0.0, 0.0), ell_comps=(0.333333, 0.0), einstein_radius=1.0 - ) - cored_power_law = ag.mp.PowerLawCore( - centre=(0.0, 0.0), - ell_comps=(0.333333, 0.0), - einstein_radius=1.0, - core_radius=0.0, - ) - - assert isothermal.potential_2d_from(grid=grid) == pytest.approx( - cored_power_law.potential_2d_from(grid=grid), 1e-3 - ) - assert isothermal.potential_2d_from(grid=grid) == pytest.approx( - cored_power_law.potential_2d_from(grid=grid), 1e-3 - ) - assert isothermal.deflections_yx_2d_from(grid=grid) == pytest.approx( - cored_power_law.deflections_yx_2d_from(grid=grid), 1e-3 - ) - assert isothermal.deflections_yx_2d_from(grid=grid) == pytest.approx( - cored_power_law.deflections_yx_2d_from(grid=grid), 1e-3 - ) diff --git a/test_autogalaxy/profiles/mass/total/test_isothermal_cored.py b/test_autogalaxy/profiles/mass/total/test_isothermal_cored.py index 25341ec72..143a1d294 100644 --- a/test_autogalaxy/profiles/mass/total/test_isothermal_cored.py +++ b/test_autogalaxy/profiles/mass/total/test_isothermal_cored.py @@ -60,7 +60,7 @@ def test__deflections_yx_2d_from(): ) assert elliptical.deflections_yx_2d_from(grid=grid) == pytest.approx( - spherical.deflections_yx_2d_from(grid=grid), 1e-4 + spherical.deflections_yx_2d_from(grid=grid).array, 1e-4 ) @@ -150,8 +150,8 @@ def test__convergence_2d_from(): centre=(1.1, 1.1), einstein_radius=3.0, core_radius=1.0 ) - assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1e-4 + assert elliptical.convergence_2d_from(grid=grid).array == pytest.approx( + spherical.convergence_2d_from(grid=grid).array, 1e-4 ) @@ -205,35 +205,5 @@ def test__potential_2d_from(): ) assert elliptical.potential_2d_from(grid=grid) == pytest.approx( - spherical.potential_2d_from(grid=grid), 1e-4 - ) - - -def test__compare_to_cored_power_law(): - power_law = ag.mp.IsothermalCore( - centre=(0.0, 0.0), - ell_comps=(0.333333, 0.0), - einstein_radius=1.0, - core_radius=0.1, - ) - - cored_power_law = ag.mp.PowerLawCore( - centre=(0.0, 0.0), - ell_comps=(0.333333, 0.0), - einstein_radius=1.0, - slope=2.0, - core_radius=0.1, - ) - - assert power_law.potential_2d_from(grid=grid) == pytest.approx( - cored_power_law.potential_2d_from(grid=grid), 1e-3 - ) - assert power_law.potential_2d_from(grid=grid) == pytest.approx( - cored_power_law.potential_2d_from(grid=grid), 1e-3 - ) - assert power_law.deflections_yx_2d_from(grid=grid) == pytest.approx( - cored_power_law.deflections_yx_2d_from(grid=grid), 1e-3 - ) - assert power_law.deflections_yx_2d_from(grid=grid) == pytest.approx( - cored_power_law.deflections_yx_2d_from(grid=grid), 1e-3 + spherical.potential_2d_from(grid=grid).array, 1e-4 ) diff --git a/test_autogalaxy/profiles/mass/total/test_power_law.py b/test_autogalaxy/profiles/mass/total/test_power_law.py index 5faaa6ec5..856340d1e 100644 --- a/test_autogalaxy/profiles/mass/total/test_power_law.py +++ b/test_autogalaxy/profiles/mass/total/test_power_law.py @@ -86,7 +86,7 @@ def test__deflections_yx_2d_from(): spherical = ag.mp.PowerLawSph(centre=(1.1, 1.1), einstein_radius=3.0, slope=2.4) assert elliptical.deflections_yx_2d_from(grid=grid) == pytest.approx( - spherical.deflections_yx_2d_from(grid=grid), 1e-4 + spherical.deflections_yx_2d_from(grid=grid).array, 1e-4 ) @@ -140,8 +140,8 @@ def test__convergence_2d_from(): spherical = ag.mp.PowerLawSph(centre=(1.1, 1.1), einstein_radius=3.0, slope=2.4) - assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1e-4 + assert elliptical.convergence_2d_from(grid=grid).array == pytest.approx( + spherical.convergence_2d_from(grid=grid).array, 1e-4 ) @@ -190,35 +190,5 @@ def test__potential_2d_from(): spherical = ag.mp.PowerLawSph(centre=(1.1, 1.1), einstein_radius=3.0, slope=2.4) assert elliptical.potential_2d_from(grid=grid) == pytest.approx( - spherical.potential_2d_from(grid=grid), 1e-4 - ) - - -def test__compare_to_cored_power_law(): - power_law = ag.mp.PowerLaw( - centre=(0.0, 0.0), - ell_comps=(0.333333, 0.0), - einstein_radius=1.0, - slope=2.3, - ) - - cored_power_law = ag.mp.PowerLawCore( - centre=(0.0, 0.0), - ell_comps=(0.333333, 0.0), - einstein_radius=1.0, - slope=2.3, - core_radius=0.0, - ) - - assert power_law.potential_2d_from(grid=grid) == pytest.approx( - cored_power_law.potential_2d_from(grid=grid), 1e-3 - ) - assert power_law.potential_2d_from(grid=grid) == pytest.approx( - cored_power_law.potential_2d_from(grid=grid), 1e-3 - ) - assert power_law.deflections_yx_2d_from(grid=grid) == pytest.approx( - cored_power_law.deflections_yx_2d_from(grid=grid), 1e-3 - ) - assert power_law.deflections_yx_2d_from(grid=grid) == pytest.approx( - cored_power_law.deflections_yx_2d_from(grid=grid), 1e-3 + spherical.potential_2d_from(grid=grid).array, 1e-4 ) diff --git a/test_autogalaxy/profiles/mass/total/test_power_law_broken.py b/test_autogalaxy/profiles/mass/total/test_power_law_broken.py index d9859a0e3..ea27bc8de 100644 --- a/test_autogalaxy/profiles/mass/total/test_power_law_broken.py +++ b/test_autogalaxy/profiles/mass/total/test_power_law_broken.py @@ -179,7 +179,7 @@ def test__deflections_yx_2d_from__compare_to_power_law(): power_law_yx_ratio = deflections[0, 0] / deflections[0, 1] - assert broken_yx_ratio == pytest.approx(power_law_yx_ratio, 1.0e-4) + assert broken_yx_ratio == pytest.approx(power_law_yx_ratio.array, 1.0e-4) mp = ag.mp.PowerLawBrokenSph( centre=(0, 0), @@ -201,4 +201,4 @@ def test__deflections_yx_2d_from__compare_to_power_law(): power_law_yx_ratio = deflections[0, 0] / deflections[0, 1] - assert broken_yx_ratio == pytest.approx(power_law_yx_ratio, 1.0e-4) + assert broken_yx_ratio == pytest.approx(power_law_yx_ratio.array, 1.0e-4) diff --git a/test_autogalaxy/profiles/mass/total/test_power_law_cored.py b/test_autogalaxy/profiles/mass/total/test_power_law_cored.py index 5c102804b..5c4efa896 100644 --- a/test_autogalaxy/profiles/mass/total/test_power_law_cored.py +++ b/test_autogalaxy/profiles/mass/total/test_power_law_cored.py @@ -66,7 +66,7 @@ def test__deflections_yx_2d_from(): ) assert elliptical.deflections_yx_2d_from(grid=grid) == pytest.approx( - spherical.deflections_yx_2d_from(grid=grid), 1e-4 + spherical.deflections_yx_2d_from(grid=grid).array, 1e-4 ) @@ -114,8 +114,8 @@ def test__convergence_2d_from(): centre=(1.1, 1.1), einstein_radius=3.0, slope=2.2, core_radius=0.1 ) - assert elliptical.convergence_2d_from(grid=grid) == pytest.approx( - spherical.convergence_2d_from(grid=grid), 1e-4 + assert elliptical.convergence_2d_from(grid=grid).array == pytest.approx( + spherical.convergence_2d_from(grid=grid).array, 1e-4 ) @@ -176,5 +176,5 @@ def test__potential_2d_from(): ) assert elliptical.potential_2d_from(grid=grid) == pytest.approx( - spherical.potential_2d_from(grid=grid), 1e-4 + spherical.potential_2d_from(grid=grid).array, 1e-4 ) diff --git a/test_autogalaxy/profiles/plot/test_light_profile_plotters.py b/test_autogalaxy/profiles/plot/test_light_profile_plotters.py index d843bb896..e39e6cf77 100644 --- a/test_autogalaxy/profiles/plot/test_light_profile_plotters.py +++ b/test_autogalaxy/profiles/plot/test_light_profile_plotters.py @@ -20,7 +20,6 @@ def test__figures_1d__all_are_output( lp_1, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_1d_all, plot_path, plot_patch, ): @@ -33,7 +32,6 @@ def test__figures_1d__all_are_output( light_profile_plotter = aplt.LightProfilePlotter( light_profile=lp_0, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, ) @@ -48,7 +46,6 @@ def test__figures_1d__all_are_output( light_profile_plotter = aplt.LightProfilePDFPlotter( light_profile_pdf_list=[lp_0, lp_1, lp_0, lp_1, lp_0, lp_offset_centre], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, sigma=2.0, ) @@ -62,14 +59,12 @@ def test__figures_2d__all_are_output( lp_0, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): light_profile_plotter = aplt.LightProfilePlotter( light_profile=lp_0, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) diff --git a/test_autogalaxy/profiles/plot/test_mass_profile_plotters.py b/test_autogalaxy/profiles/plot/test_mass_profile_plotters.py index 847752268..2b1b9bbe5 100644 --- a/test_autogalaxy/profiles/plot/test_mass_profile_plotters.py +++ b/test_autogalaxy/profiles/plot/test_mass_profile_plotters.py @@ -19,7 +19,6 @@ def test__figures_1d__all_are_output( mp_1, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_1d_all, plot_path, plot_patch, ): @@ -32,7 +31,6 @@ def test__figures_1d__all_are_output( mass_profile_plotter = aplt.MassProfilePlotter( mass_profile=mp_0, grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, ) @@ -48,7 +46,6 @@ def test__figures_1d__all_are_output( mass_profile_plotter = aplt.MassProfilePDFPlotter( mass_profile_pdf_list=[mp_0, mp_1, mp_0, mp_1, mp_0, mp_offset_centre], grid=grid_2d_7x7, - include_1d=include_1d_all, mat_plot_1d=mat_plot_1d, ) @@ -62,14 +59,12 @@ def test__figures_2d__all_are_output( mp_0, grid_2d_7x7, grid_2d_irregular_7x7_list, - include_2d_all, plot_path, plot_patch, ): mass_profile_plotter = aplt.MassProfilePlotter( mass_profile=mp_0, grid=grid_2d_7x7, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) mass_profile_plotter.figures_2d( diff --git a/test_autogalaxy/profiles/test_basis.py b/test_autogalaxy/profiles/test_basis.py index 3739ebf28..40a6250cd 100644 --- a/test_autogalaxy/profiles/test_basis.py +++ b/test_autogalaxy/profiles/test_basis.py @@ -86,4 +86,6 @@ def test__mass_profile_quantities(grid_2d_7x7, mp_0, mp_1): convergence_2d = basis.convergence_2d_from(grid=grid_2d_7x7) - assert convergence_2d == pytest.approx(convergence_2d_0 + convergence_2d_1, 1.0e-4) + assert convergence_2d.array == pytest.approx( + convergence_2d_0.array + convergence_2d_1.array, 1.0e-4 + ) diff --git a/test_autogalaxy/profiles/test_dict.py b/test_autogalaxy/profiles/test_dict.py index cf55fc14d..53b4fad06 100644 --- a/test_autogalaxy/profiles/test_dict.py +++ b/test_autogalaxy/profiles/test_dict.py @@ -1,34 +1,34 @@ -import pytest -from autoconf.dictable import to_dict, from_dict - -import autogalaxy as ag -from autogalaxy.profiles.geometry_profiles import GeometryProfile - - -@pytest.fixture(name="ell_sersic") -def make_ell_sersic(): - return ag.mp.Sersic() - - -@pytest.fixture(name="ell_sersic_dict") -def make_ell_sersic_dict(): - return { - "type": "instance", - "class_path": "autogalaxy.profiles.mass.stellar.sersic.Sersic", - "arguments": { - "centre": {"type": "tuple", "values": [0.0, 0.0]}, - "ell_comps": {"type": "tuple", "values": [0.0, 0.0]}, - "intensity": 0.1, - "effective_radius": 0.6, - "sersic_index": 0.6, - "mass_to_light_ratio": 1.0, - }, - } - - -def test__to_dict(ell_sersic, ell_sersic_dict): - assert to_dict(ell_sersic) == ell_sersic_dict - - -def test__from_dict(ell_sersic, ell_sersic_dict): - assert ell_sersic == from_dict(ell_sersic_dict) +import pytest +from autoconf.dictable import to_dict, from_dict + +import autogalaxy as ag +from autogalaxy.profiles.geometry_profiles import GeometryProfile + + +@pytest.fixture(name="ell_sersic") +def make_ell_sersic(): + return ag.mp.Sersic() + + +@pytest.fixture(name="ell_sersic_dict") +def make_ell_sersic_dict(): + return { + "type": "instance", + "class_path": "autogalaxy.profiles.mass.stellar.sersic.Sersic", + "arguments": { + "centre": {"type": "tuple", "values": [0.0, 0.0]}, + "ell_comps": {"type": "tuple", "values": [0.0, 0.0]}, + "intensity": 0.1, + "effective_radius": 0.6, + "sersic_index": 0.6, + "mass_to_light_ratio": 1.0, + }, + } + + +def test__to_dict(ell_sersic, ell_sersic_dict): + assert to_dict(ell_sersic) == ell_sersic_dict + + +def test__from_dict(ell_sersic, ell_sersic_dict): + assert ell_sersic == from_dict(ell_sersic_dict) diff --git a/test_autogalaxy/profiles/test_light_and_mass_profiles.py b/test_autogalaxy/profiles/test_light_and_mass_profiles.py index 19c17aa6e..8f68fabab 100644 --- a/test_autogalaxy/profiles/test_light_and_mass_profiles.py +++ b/test_autogalaxy/profiles/test_light_and_mass_profiles.py @@ -20,14 +20,16 @@ def test__gaussian(): mass_to_light_ratio=2.0, ) - assert (lp.image_2d_from(grid=grid) == lmp.image_2d_from(grid=grid)).all() - assert ( - mp.convergence_2d_from(grid=grid) == lmp.convergence_2d_from(grid=grid) - ).all() + assert lp.image_2d_from(grid=grid) == pytest.approx( + lmp.image_2d_from(grid=grid).array, 1.0e-4 + ) + assert mp.convergence_2d_from(grid=grid) == pytest.approx( + lmp.convergence_2d_from(grid=grid).array, 1.0e-4 + ) # assert (mp.potential_2d_from(grid=grid) == lmp.potential_2d_from(grid=grid)).all() - assert ( - mp.deflections_yx_2d_from(grid=grid) == lmp.deflections_yx_2d_from(grid=grid) - ).all() + assert mp.deflections_yx_2d_from(grid=grid) == pytest.approx( + lmp.deflections_yx_2d_from(grid=grid).array, 1.0e-4 + ) def test__gaussian_gradient(): @@ -49,14 +51,16 @@ def test__gaussian_gradient(): mass_to_light_radius=1.0, ) - assert (lp.image_2d_from(grid=grid) == lmp.image_2d_from(grid=grid)).all() - assert ( - mp.convergence_2d_from(grid=grid) == lmp.convergence_2d_from(grid=grid) - ).all() + assert lp.image_2d_from(grid=grid) == pytest.approx( + lmp.image_2d_from(grid=grid).array, 1.0e-4 + ) + assert mp.convergence_2d_from(grid=grid) == pytest.approx( + lmp.convergence_2d_from(grid=grid).array, 1.0e-4 + ) # assert (mp.potential_2d_from(grid=grid) == lmp.potential_2d_from(grid=grid)).all() - assert ( - mp.deflections_yx_2d_from(grid=grid) == lmp.deflections_yx_2d_from(grid=grid) - ).all() + assert mp.deflections_yx_2d_from(grid=grid) == pytest.approx( + lmp.deflections_yx_2d_from(grid=grid).array, 1.0e-4 + ) def test__sersic(): @@ -81,14 +85,16 @@ def test__sersic(): mass_to_light_ratio=2.0, ) - assert (lp.image_2d_from(grid=grid) == lmp.image_2d_from(grid=grid)).all() - assert ( - mp.convergence_2d_from(grid=grid) == lmp.convergence_2d_from(grid=grid) - ).all() + assert lp.image_2d_from(grid=grid) == pytest.approx( + lmp.image_2d_from(grid=grid).array, 1.0e-4 + ) + assert mp.convergence_2d_from(grid=grid) == pytest.approx( + lmp.convergence_2d_from(grid=grid).array, 1.0e-4 + ) # assert (mp.potential_2d_from(grid=grid) == lmp.potential_2d_from(grid=grid)).all() - assert ( - mp.deflections_yx_2d_from(grid=grid) == lmp.deflections_yx_2d_from(grid=grid) - ).all() + assert mp.deflections_yx_2d_from(grid=grid) == pytest.approx( + lmp.deflections_yx_2d_from(grid=grid).array, 1.0e-4 + ) def test__exponential(): @@ -106,14 +112,16 @@ def test__exponential(): mass_to_light_ratio=2.0, ) - assert (lp.image_2d_from(grid=grid) == lmp.image_2d_from(grid=grid)).all() - assert ( - mp.convergence_2d_from(grid=grid) == lmp.convergence_2d_from(grid=grid) - ).all() + assert lp.image_2d_from(grid=grid) == pytest.approx( + lmp.image_2d_from(grid=grid).array, 1.0e-4 + ) + assert mp.convergence_2d_from(grid=grid) == pytest.approx( + lmp.convergence_2d_from(grid=grid).array, 1.0e-4 + ) # assert (mp.potential_2d_from(grid=grid) == lmp.potential_2d_from(grid=grid)).all() - assert ( - mp.deflections_yx_2d_from(grid=grid) == lmp.deflections_yx_2d_from(grid=grid) - ).all() + assert mp.deflections_yx_2d_from(grid=grid) == pytest.approx( + lmp.deflections_yx_2d_from(grid=grid).array, 1.0e-4 + ) def test__dev_vaucouleurs(): @@ -133,14 +141,16 @@ def test__dev_vaucouleurs(): mass_to_light_ratio=2.0, ) - assert (lp.image_2d_from(grid=grid) == lmp.image_2d_from(grid=grid)).all() - assert ( - mp.convergence_2d_from(grid=grid) == lmp.convergence_2d_from(grid=grid) - ).all() + assert lp.image_2d_from(grid=grid) == pytest.approx( + lmp.image_2d_from(grid=grid).array, 1.0e-4 + ) + assert mp.convergence_2d_from(grid=grid) == pytest.approx( + lmp.convergence_2d_from(grid=grid).array, 1.0e-4 + ) # assert (mp.potential_2d_from(grid=grid) == lmp.potential_2d_from(grid=grid)).all() - assert ( - mp.deflections_yx_2d_from(grid=grid) == lmp.deflections_yx_2d_from(grid=grid) - ).all() + assert mp.deflections_yx_2d_from(grid=grid) == pytest.approx( + lmp.deflections_yx_2d_from(grid=grid).array, 1.0e-4 + ) def test__sersic_gradient(): @@ -197,14 +207,14 @@ def test__sersic_gradient(): ) assert lp.image_2d_from(grid=grid) == pytest.approx( - lmp.image_2d_from(grid=grid), 1.0e-4 + lmp.image_2d_from(grid=grid).array, 1.0e-4 ) assert mp.convergence_2d_from(grid=grid) == pytest.approx( - lmp.convergence_2d_from(grid=grid), 1.0e-4 + lmp.convergence_2d_from(grid=grid).array, 1.0e-4 ) # assert (mp.potential_2d_from(grid=grid) == lmp.potential_2d_from(grid=grid)).all() assert mp.deflections_yx_2d_from(grid=grid) == pytest.approx( - lmp.deflections_yx_2d_from(grid=grid), 1.0e-4 + lmp.deflections_yx_2d_from(grid=grid).array, 1.0e-4 ) diff --git a/test_autogalaxy/profiles/test_radial_minima.py b/test_autogalaxy/profiles/test_radial_minima.py deleted file mode 100644 index 6aef7f2a1..000000000 --- a/test_autogalaxy/profiles/test_radial_minima.py +++ /dev/null @@ -1,70 +0,0 @@ -from __future__ import division, print_function - -from os import path -import autogalaxy as ag - -import pytest - -directory = path.dirname(path.realpath(__file__)) - - -def test__grid_2d__moves_radial_coordinates__does_not_double_transform(): - grid_2d = ag.Grid2D.no_mask(values=[[[0.0, 0.0]]], pixel_scales=1.0) - grid_2d_offset = ag.Grid2D.no_mask(values=[[[0.0001, 0.0001]]], pixel_scales=1.0) - - isothermal = ag.mp.Isothermal(centre=(0.0, 0.0), einstein_radius=1.0) - - convergence_1 = isothermal.convergence_2d_from(grid=grid_2d) - convergence_0 = isothermal.convergence_2d_from(grid=grid_2d_offset) - - assert convergence_0 == pytest.approx(convergence_1, 1.0e-8) - - grid_2d = ag.Grid2D.no_mask( - values=[[[0.5, 0.5]]], pixel_scales=1.0, origin=(0.5, 0.5) - ) - grid_2d_offset = ag.Grid2D.no_mask( - values=[[[0.5001, 0.5001]]], pixel_scales=1.0, origin=(0.5001, 0.5001) - ) - - isothermal = ag.mp.Isothermal(centre=(0.0, 0.0), einstein_radius=1.0) - - convergence_1 = isothermal.convergence_2d_from(grid=grid_2d) - convergence_0 = isothermal.convergence_2d_from(grid=grid_2d_offset) - - assert convergence_0 != pytest.approx(convergence_1, 1.0e-8) - - isothermal = ag.mp.Isothermal(centre=(0.5, 0.5), einstein_radius=1.0) - - convergence_1 = isothermal.convergence_2d_from(grid=grid_2d) - convergence_0 = isothermal.convergence_2d_from(grid=grid_2d_offset) - - assert convergence_0 == pytest.approx(convergence_1, 1.0e-5) - - -def test__grid_2d_irrergular__moves_radial_coordinates__does_not_double_transform(): - grid_2d_irregular = ag.Grid2DIrregular(values=[[0.0, 0.0]]) - grid_2d_irregular_offset = ag.Grid2DIrregular(values=[[0.0001, 0.0001]]) - - isothermal = ag.mp.Isothermal(centre=(0.0, 0.0), einstein_radius=1.0) - - convergence_1 = isothermal.convergence_2d_from(grid=grid_2d_irregular) - convergence_0 = isothermal.convergence_2d_from(grid=grid_2d_irregular_offset) - - assert convergence_0 == pytest.approx(convergence_1, 1.0e-8) - - grid_2d_irregular = ag.Grid2DIrregular(values=[[0.5, 0.5]]) - grid_2d_irregular_offset = ag.Grid2DIrregular(values=[[0.5001, 0.5001]]) - - isothermal = ag.mp.Isothermal(centre=(0.0, 0.0), einstein_radius=1.0) - - convergence_1 = isothermal.convergence_2d_from(grid=grid_2d_irregular) - convergence_0 = isothermal.convergence_2d_from(grid=grid_2d_irregular_offset) - - assert convergence_0 != pytest.approx(convergence_1, 1.0e-8) - - isothermal = ag.mp.Isothermal(centre=(0.5, 0.5), einstein_radius=1.0) - - convergence_1 = isothermal.convergence_2d_from(grid=grid_2d_irregular) - convergence_0 = isothermal.convergence_2d_from(grid=grid_2d_irregular_offset) - - assert convergence_0 == pytest.approx(convergence_1, 1.0e-8) diff --git a/test_autogalaxy/quantity/model/test_plotter_interface_quantity.py b/test_autogalaxy/quantity/model/test_plotter_interface_quantity.py index eeb52afc5..eae1a139b 100644 --- a/test_autogalaxy/quantity/model/test_plotter_interface_quantity.py +++ b/test_autogalaxy/quantity/model/test_plotter_interface_quantity.py @@ -16,7 +16,6 @@ def make_plotter_interface_plotter_setup(): def test__dataset( dataset_quantity_7x7_array_2d, - include_2d_all, plot_path, plot_patch, ): @@ -37,7 +36,6 @@ def test__dataset( def test__fit_quantity( fit_quantity_7x7_array_2d, fit_quantity_7x7_vector_yx_2d, - include_2d_all, plot_path, plot_patch, ): diff --git a/test_autogalaxy/quantity/plot/test_fit_quantity_plotters.py b/test_autogalaxy/quantity/plot/test_fit_quantity_plotters.py index 84f5bb3b2..94265e502 100644 --- a/test_autogalaxy/quantity/plot/test_fit_quantity_plotters.py +++ b/test_autogalaxy/quantity/plot/test_fit_quantity_plotters.py @@ -20,13 +20,11 @@ def make_galaxy_fit_plotter_setup(): def test__fit_individuals__source_and_galaxy__dependent_on_input( fit_quantity_7x7_array_2d, fit_quantity_7x7_vector_yx_2d, - include_2d_all, plot_path, plot_patch, ): fit_quantity_plotter = aplt.FitQuantityPlotter( fit=fit_quantity_7x7_array_2d, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -39,7 +37,6 @@ def test__fit_individuals__source_and_galaxy__dependent_on_input( fit_quantity_plotter = aplt.FitQuantityPlotter( fit=fit_quantity_7x7_vector_yx_2d, - include_2d=include_2d_all, mat_plot_2d=aplt.MatPlot2D(output=aplt.Output(plot_path, format="png")), ) @@ -58,7 +55,6 @@ def test__fit_individuals__source_and_galaxy__dependent_on_input( def test__fit_sub_plot__all_types_of_fit( fit_quantity_7x7_array_2d, fit_quantity_7x7_vector_yx_2d, - include_2d_all, plot_patch, plot_path, ): diff --git a/test_autogalaxy/quantity/test_dataset_quantity.py b/test_autogalaxy/quantity/test_dataset_quantity.py index 94b1cf15b..63af2b0d0 100644 --- a/test_autogalaxy/quantity/test_dataset_quantity.py +++ b/test_autogalaxy/quantity/test_dataset_quantity.py @@ -106,11 +106,15 @@ def test__vector_data__y_x(): assert isinstance(dataset_quantity.y, ag.DatasetQuantity) assert (dataset_quantity.y.data.slim == np.array([1.0, 2.0, 3.0, 4.0])).all() - assert (dataset_quantity.y.noise_map.slim == np.array([1.1, 2.1, 3.1, 4.1])).all() + assert dataset_quantity.y.noise_map.slim == pytest.approx( + np.array([1.1, 2.1, 3.1, 4.1]), 1.0e-4 + ) assert isinstance(dataset_quantity.y, ag.DatasetQuantity) assert (dataset_quantity.x.data.slim == np.array([5.0, 6.0, 7.0, 8.0])).all() - assert (dataset_quantity.x.noise_map.slim == np.array([5.1, 6.1, 7.1, 8.1])).all() + assert dataset_quantity.x.noise_map.slim == pytest.approx( + np.array([5.1, 6.1, 7.1, 8.1]), 1.0e-4 + ) @pytest.fixture(name="test_data_path") diff --git a/test_autogalaxy/test_convert.py b/test_autogalaxy/test_convert.py index e88b88714..5250864e0 100644 --- a/test_autogalaxy/test_convert.py +++ b/test_autogalaxy/test_convert.py @@ -6,71 +6,71 @@ def test__ell_comps_from(): ell_comps = ag.convert.ell_comps_from(axis_ratio=0.00050025012, angle=0.0) - assert ell_comps == pytest.approx((0.0, 0.999), 1.0e-4) + assert ell_comps == pytest.approx((0.0, 0.999), abs=1.0e-4) def test__axis_ratio_and_angle_from(): axis_ratio, angle = ag.convert.axis_ratio_and_angle_from(ell_comps=(0.0, 1.0)) - assert axis_ratio == pytest.approx(0.00050025012, 1.0e-4) - assert angle == pytest.approx(0.0, 1.0e-4) + assert axis_ratio == pytest.approx(0.00050025012, abs=1.0e-4) + assert angle == pytest.approx(0.0, abs=1.0e-4) axis_ratio, angle = ag.convert.axis_ratio_and_angle_from(ell_comps=(1.0, 0.0)) - assert axis_ratio == pytest.approx(0.00050025012, 1.0e-4) - assert angle == pytest.approx(45.0, 1.0e-4) + assert axis_ratio == pytest.approx(0.00050025012, abs=1.0e-4) + assert angle == pytest.approx(45.0, abs=1.0e-4) axis_ratio, angle = ag.convert.axis_ratio_and_angle_from(ell_comps=(0.0, -1.0)) - assert axis_ratio == pytest.approx(0.00050025012, 1.0e-4) - assert angle == pytest.approx(90.0, 1.0e-4) + assert axis_ratio == pytest.approx(0.00050025012, abs=1.0e-4) + assert angle == pytest.approx(90.0, abs=1.0e-4) axis_ratio, angle = ag.convert.axis_ratio_and_angle_from(ell_comps=(-1.0, 0.0)) - assert axis_ratio == pytest.approx(0.00050025012, 1.0e-4) - assert angle == pytest.approx(-45.0, 1.0e-4) + assert axis_ratio == pytest.approx(0.00050025012, abs=1.0e-4) + assert angle == pytest.approx(-45.0, abs=1.0e-4) axis_ratio, angle = ag.convert.axis_ratio_and_angle_from(ell_comps=(-1.0, -1.0)) - assert axis_ratio == pytest.approx(0.00050025012, 1.0e-4) - assert angle == pytest.approx(112.5, 1.0e-4) + assert axis_ratio == pytest.approx(0.00050025012, abs=1.0e-4) + assert angle == pytest.approx(112.5, abs=1.0e-4) def test__shear_gamma_1_2_from(): gamma_1, gamma_2 = ag.convert.shear_gamma_1_2_from(magnitude=0.05, angle=0.0) - assert gamma_1 == pytest.approx(0.05, 1.0e-4) - assert gamma_2 == pytest.approx(0.0, 1.0e-4) + assert gamma_1 == pytest.approx(0.05, abs=1.0e-4) + assert gamma_2 == pytest.approx(0.0, abs=1.0e-4) gamma_1, gamma_2 = ag.convert.shear_gamma_1_2_from(magnitude=0.05, angle=45.0) - assert gamma_1 == pytest.approx(0.0, 1.0e-4) - assert gamma_2 == pytest.approx(0.05, 1.0e-4) + assert gamma_1 == pytest.approx(0.0, abs=1.0e-4) + assert gamma_2 == pytest.approx(0.05, abs=1.0e-4) gamma_1, gamma_2 = ag.convert.shear_gamma_1_2_from(magnitude=0.05, angle=90.0) - assert gamma_1 == pytest.approx(-0.05, 1.0e-4) - assert gamma_2 == pytest.approx(0.0, 1.0e-4) + assert gamma_1 == pytest.approx(-0.05, abs=1.0e-4) + assert gamma_2 == pytest.approx(0.0, abs=1.0e-4) gamma_1, gamma_2 = ag.convert.shear_gamma_1_2_from(magnitude=0.05, angle=135.0) - assert gamma_1 == pytest.approx(0.0, 1.0e-4) - assert gamma_2 == pytest.approx(-0.05, 1.0e-4) + assert gamma_1 == pytest.approx(0.0, abs=1.0e-4) + assert gamma_2 == pytest.approx(-0.05, abs=1.0e-4) gamma_1, gamma_2 = ag.convert.shear_gamma_1_2_from(magnitude=0.05, angle=180.0) - assert gamma_1 == pytest.approx(0.05, 1.0e-4) - assert gamma_2 == pytest.approx(0.0, 1.0e-4) + assert gamma_1 == pytest.approx(0.05, abs=1.0e-4) + assert gamma_2 == pytest.approx(0.0, abs=1.0e-4) gamma_1, gamma_2 = ag.convert.shear_gamma_1_2_from(magnitude=0.05, angle=225.0) - assert gamma_1 == pytest.approx(0.0, 1.0e-4) - assert gamma_2 == pytest.approx(0.05, 1.0e-4) + assert gamma_1 == pytest.approx(0.0, abs=1.0e-4) + assert gamma_2 == pytest.approx(0.05, abs=1.0e-4) gamma_1, gamma_2 = ag.convert.shear_gamma_1_2_from(magnitude=0.05, angle=-45.0) - assert gamma_1 == pytest.approx(0.0, 1.0e-4) - assert gamma_2 == pytest.approx(-0.05, 1.0e-4) + assert gamma_1 == pytest.approx(0.0, abs=1.0e-4) + assert gamma_2 == pytest.approx(-0.05, abs=1.0e-4) def test__shear_magnitude_and_angle_from(): @@ -78,95 +78,95 @@ def test__shear_magnitude_and_angle_from(): gamma_1=0.05, gamma_2=0.0 ) - assert magnitude == pytest.approx(0.05, 1.0e-4) - assert angle == pytest.approx(0.0, 1.0e-4) + assert magnitude == pytest.approx(0.05, abs=1.0e-4) + assert angle == pytest.approx(0.0, abs=1.0e-4) magnitude, angle = ag.convert.shear_magnitude_and_angle_from( gamma_1=0.0, gamma_2=0.05 ) - assert magnitude == pytest.approx(0.05, 1.0e-4) - assert angle == pytest.approx(45.0, 1.0e-4) + assert magnitude == pytest.approx(0.05, abs=1.0e-4) + assert angle == pytest.approx(45.0, abs=1.0e-4) magnitude, angle = ag.convert.shear_magnitude_and_angle_from( gamma_1=-0.05, gamma_2=0.0 ) - assert magnitude == pytest.approx(0.05, 1.0e-4) - assert angle == pytest.approx(90.0, 1.0e-4) + assert magnitude == pytest.approx(0.05, abs=1.0e-4) + assert angle == pytest.approx(90.0, abs=1.0e-4) magnitude, angle = ag.convert.shear_magnitude_and_angle_from( gamma_1=0.0, gamma_2=-0.05 ) - assert magnitude == pytest.approx(0.05, 1.0e-4) - assert angle == pytest.approx(135.0, 1.0e-4) + assert magnitude == pytest.approx(0.05, abs=1.0e-4) + assert angle == pytest.approx(135.0, abs=1.0e-4) magnitude, angle = ag.convert.shear_magnitude_and_angle_from( gamma_1=0.05, gamma_2=0.0 ) - assert magnitude == pytest.approx(0.05, 1.0e-4) - assert angle == pytest.approx(0.0, 1.0e-4) + assert magnitude == pytest.approx(0.05, abs=1.0e-4) + assert angle == pytest.approx(0.0, abs=1.0e-4) magnitude, angle = ag.convert.shear_magnitude_and_angle_from( gamma_1=0.0, gamma_2=0.05 ) - assert magnitude == pytest.approx(0.05, 1.0e-4) - assert angle == pytest.approx(45.0, 1.0e-4) + assert magnitude == pytest.approx(0.05, abs=1.0e-4) + assert angle == pytest.approx(45.0, abs=1.0e-4) magnitude, angle = ag.convert.shear_magnitude_and_angle_from( gamma_1=0.05, gamma_2=0.0 ) - assert magnitude == pytest.approx(0.05, 1.0e-4) + assert magnitude == pytest.approx(0.05, abs=1.0e-4) magnitude, angle = ag.convert.shear_magnitude_and_angle_from( gamma_1=0.05, gamma_2=-0.05 ) - assert magnitude == pytest.approx(0.07071067811865, 1.0e-4) - assert angle == pytest.approx(-22.5, 1.0e-4) + assert magnitude == pytest.approx(0.07071067811865, abs=1.0e-4) + assert angle == pytest.approx(-22.5, abs=1.0e-4) def test__multipole_k_m_and_phi_m_from(): k_m, phi = ag.convert.multipole_k_m_and_phi_m_from(multipole_comps=(0.1, 0.0), m=1) - assert k_m == pytest.approx(0.1, 1e-3) - assert phi == pytest.approx(90.0, 1e-3) + assert k_m == pytest.approx(0.1, abs=1e-3) + assert phi == pytest.approx(90.0, abs=1e-3) k_m, phi = ag.convert.multipole_k_m_and_phi_m_from(multipole_comps=(0.0, 0.1), m=1) - assert k_m == pytest.approx(0.1, 1e-3) - assert phi == pytest.approx(0.0, 1e-3) + assert k_m == pytest.approx(0.1, abs=1e-3) + assert phi == pytest.approx(0.0, abs=1e-3) k_m, phi = ag.convert.multipole_k_m_and_phi_m_from(multipole_comps=(0.1, 0.0), m=2) - assert k_m == pytest.approx(0.1, 1e-3) - assert phi == pytest.approx(45.0, 1e-3) + assert k_m == pytest.approx(0.1, abs=1e-3) + assert phi == pytest.approx(45.0, abs=1e-3) k_m, phi = ag.convert.multipole_k_m_and_phi_m_from( multipole_comps=(-0.1, -0.1), m=2 ) - assert k_m == pytest.approx(0.14142135, 1e-3) - assert phi == pytest.approx(112.5, 1e-3) + assert k_m == pytest.approx(0.14142135, abs=1e-3) + assert phi == pytest.approx(112.5, abs=1e-3) def test__multipole_comps_from(): multipole_comps = ag.convert.multipole_comps_from(k_m=0.1, phi_m=90.0, m=1) - assert multipole_comps == pytest.approx((0.1, 0.0), 1e-3) + assert multipole_comps == pytest.approx((0.1, 0.0), abs=1e-3) multipole_comps = ag.convert.multipole_comps_from(k_m=0.1, phi_m=0.0, m=1) - assert multipole_comps == pytest.approx((0.0, 0.1), 1e-3) + assert multipole_comps == pytest.approx((0.0, 0.1), abs=1e-3) multipole_comps = ag.convert.multipole_comps_from(k_m=0.1, phi_m=45.0, m=2) - assert multipole_comps == pytest.approx((0.1, 0.0), 1e-3) + assert multipole_comps == pytest.approx((0.1, 0.0), abs=1e-3) multipole_comps = ag.convert.multipole_comps_from(k_m=0.14142135, phi_m=112.5, m=2) - assert multipole_comps == pytest.approx((-0.1, -0.1), 1e-3) + assert multipole_comps == pytest.approx((-0.1, -0.1), abs=1e-3) diff --git a/test_autogalaxy/test_regression.py b/test_autogalaxy/test_regression.py index 2f4bb5c54..a3466f95e 100644 --- a/test_autogalaxy/test_regression.py +++ b/test_autogalaxy/test_regression.py @@ -1,76 +1,76 @@ -import pytest - -from autogalaxy import Galaxy -from autogalaxy.abstract_fit import AbstractFitInversion -import autofit as af -import autoarray as aa -from autogalaxy.profiles.light.linear import LightProfileLinear, Sersic - - -class FitInversion(AbstractFitInversion): - def __init__( - self, model_obj, settings_inversion: aa.SettingsInversion, light_profiles - ): - super().__init__(model_obj=model_obj, settings_inversion=settings_inversion) - self.light_profiles = light_profiles - - @property - def linear_light_profile_intensity_dict(self): - return {light_profile: 1.0 for light_profile in self.light_profiles} - - -@pytest.fixture(name="light_profile") -def make_light_profile(): - return Sersic() - - -def test_no_modify_state(light_profile): - model_obj = af.ModelInstance( - { - "galaxies": af.ModelInstance( - { - "galaxy": Galaxy( - redshift=0.5, - light_profile=light_profile, - ) - } - ) - } - ) - - fit_inversion = FitInversion( - model_obj=model_obj, - settings_inversion=aa.SettingsInversion(use_linear_operators=True), - light_profiles=[light_profile], - ) - result = fit_inversion.model_obj_linear_light_profiles_to_light_profiles - - assert result.galaxies.galaxy.light_profile is not light_profile - assert model_obj.galaxies.galaxy.light_profile is light_profile - - -@pytest.fixture(name="path") -def make_path(): - return "galaxies", 0, "light_profile" - - -@pytest.fixture(name="model_obj") -def make_model_obj(light_profile): - return af.ModelInstance( - { - "galaxies": [ - Galaxy( - redshift=0.5, - light_profile=light_profile, - ) - ] - } - ) - - -def test_list_galaxies(model_obj, path): - assert model_obj.path_instance_tuples_for_class((LightProfileLinear,))[0][0] == path - - -def test_object_from_path(model_obj, path, light_profile): - assert model_obj.object_for_path(path) == light_profile +import pytest + +from autogalaxy import Galaxy +from autogalaxy.abstract_fit import AbstractFitInversion +import autofit as af +import autoarray as aa +from autogalaxy.profiles.light.linear import LightProfileLinear, Sersic + + +class FitInversion(AbstractFitInversion): + def __init__( + self, model_obj, settings_inversion: aa.SettingsInversion, light_profiles + ): + super().__init__(model_obj=model_obj, settings_inversion=settings_inversion) + self.light_profiles = light_profiles + + @property + def linear_light_profile_intensity_dict(self): + return {light_profile: 1.0 for light_profile in self.light_profiles} + + +@pytest.fixture(name="light_profile") +def make_light_profile(): + return Sersic() + + +def test_no_modify_state(light_profile): + model_obj = af.ModelInstance( + { + "galaxies": af.ModelInstance( + { + "galaxy": Galaxy( + redshift=0.5, + light_profile=light_profile, + ) + } + ) + } + ) + + fit_inversion = FitInversion( + model_obj=model_obj, + settings_inversion=aa.SettingsInversion(use_linear_operators=True), + light_profiles=[light_profile], + ) + result = fit_inversion.model_obj_linear_light_profiles_to_light_profiles + + assert result.galaxies.galaxy.light_profile is not light_profile + assert model_obj.galaxies.galaxy.light_profile is light_profile + + +@pytest.fixture(name="path") +def make_path(): + return "galaxies", 0, "light_profile" + + +@pytest.fixture(name="model_obj") +def make_model_obj(light_profile): + return af.ModelInstance( + { + "galaxies": [ + Galaxy( + redshift=0.5, + light_profile=light_profile, + ) + ] + } + ) + + +def test_list_galaxies(model_obj, path): + assert model_obj.path_instance_tuples_for_class((LightProfileLinear,))[0][0] == path + + +def test_object_from_path(model_obj, path, light_profile): + assert model_obj.object_for_path(path) == light_profile