From be3d9cca1add09ddc7984c9a3d4d072dac1ed556 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Wed, 10 May 2023 12:50:11 +0100 Subject: [PATCH 01/10] visualization refactoring --- autogalaxy/aggregator/abstract.py | 33 +++++++++++---------- autogalaxy/aggregator/fit_imaging.py | 4 +-- autogalaxy/aggregator/fit_interferometer.py | 4 +-- autogalaxy/aggregator/imaging.py | 4 +-- autogalaxy/aggregator/interferometer.py | 2 +- autogalaxy/aggregator/plane.py | 4 +-- autogalaxy/analysis/analysis.py | 2 +- autogalaxy/analysis/preloads.py | 2 +- autogalaxy/config/README.rst | 2 +- autogalaxy/cosmology/lensing.py | 4 +-- autogalaxy/imaging/model/analysis.py | 6 ++-- autogalaxy/interferometer/model/analysis.py | 6 ++-- autogalaxy/quantity/model/analysis.py | 2 +- 13 files changed, 38 insertions(+), 37 deletions(-) diff --git a/autogalaxy/aggregator/abstract.py b/autogalaxy/aggregator/abstract.py index 0871fb07b..694db9ccf 100644 --- a/autogalaxy/aggregator/abstract.py +++ b/autogalaxy/aggregator/abstract.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, List, Generator if TYPE_CHECKING: - from autogalaxy.galaxy.galaxy import Galaxy + from autocti.model.model_util import AbstractCTI import autofit as af @@ -15,8 +15,9 @@ def __init__(self, aggregator: af.Aggregator): An abstract aggregator wrapper, which makes it straight forward to compute generators of objects from specific samples of a non-linear search. - For example, in **PyAutoLens**, this makes it straight forward to create generators of `Plane`'s drawn from + For example, in **PyAutoCTI**, this makes it straight forward to create generators of `CTI`'s drawn from the PDF estimated by a non-linear for efficient error calculation of derived quantities. + Parameters ---------- aggregator @@ -25,17 +26,17 @@ def __init__(self, aggregator: af.Aggregator): self.aggregator = aggregator @abstractmethod - def make_object_for_gen(self, fit: af.Fit, galaxies: List[Galaxy]) -> object: + def make_object_for_gen(self, fit: af.Fit, cti: AbstractCTI) -> object: """ - For example, in the `PlaneAgg` object, this function is overwritten such that it creates a `Plane` from a - `ModelInstance` that contains the galaxies of a sample from a non-linear search. + For example, in the `CTIAgg` object, this function is overwritten such that it creates a `CTI` from a + `ModelInstance` that contains the cti model of a sample from a non-linear search. Parameters ---------- fit - A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits. - galaxies - A list of galaxies corresponding to a sample of a non-linear search and model-fit. + A PyAutoFit database Fit object containing the generators of the results of model-fits. + cti + A cti model corresponding to a sample of a non-linear search and model-fit. Returns ------- @@ -49,13 +50,13 @@ def max_log_likelihood_gen_from(self) -> Generator: This generator creates a list containing the maximum log instance of every result loaded in the aggregator. - For example, in **PyAutoLens**, by overwriting the `make_gen_from` method this returns a generator - of `Plane` objects from a PyAutoFit aggregator. This generator then generates a list of the maximum log - likelihood `Plane` objects for all aggregator results. + For example, in **PyAutoCTI**, by overwriting the `make_gen_from` method this returns a generator + of `CTI` objects from a PyAutoFit aggregator. This generator then generates a list of the maximum log + likelihood `CTI` objects for all aggregator results. """ def func_gen(fit: af.Fit) -> Generator: - return self.make_object_for_gen(fit=fit, galaxies=fit.instance.galaxies) + return self.make_object_for_gen(fit=fit, cti=fit.instance.cti) return self.aggregator.map(func=func_gen) @@ -117,7 +118,7 @@ def func_gen(fit: af.Fit, minimum_weight: float) -> List[object]: instance = sample.instance_for_model(model=samples.model) all_above_weight_list.append( - self.make_object_for_gen(fit=fit, galaxies=instance.galaxies) + self.make_object_for_gen(fit=fit, cti=instance.cti) ) return all_above_weight_list @@ -136,8 +137,8 @@ def randomly_drawn_via_pdf_gen_from(self, total_samples: int): entries will be returned, where each entry in this list contains 100 object's paired with non-linear samples randomly drawn from the PDF. - For example, in **PyAutoLens**, by overwriting the `make_gen_from` method this returns a generator - of `Plane` objects from a PyAutoFit aggregator. This generator then generates lists of `Plane` objects + For example, in **PyAutoCTI**, by overwriting the `make_gen_from` method this returns a generator + of `CTI` objects from a PyAutoFit aggregator. This generator then generates lists of `CTI` objects corresponding to non-linear search samples randomly drawn from the PDF. Parameters @@ -152,7 +153,7 @@ def func_gen(fit: af.Fit, total_samples: int) -> List[object]: return [ self.make_object_for_gen( fit=fit, - galaxies=samples.draw_randomly_via_pdf().galaxies, + cti=samples.draw_randomly_via_pdf().cti, ) for i in range(total_samples) ] diff --git a/autogalaxy/aggregator/fit_imaging.py b/autogalaxy/aggregator/fit_imaging.py index 9eb782078..a332a73c7 100644 --- a/autogalaxy/aggregator/fit_imaging.py +++ b/autogalaxy/aggregator/fit_imaging.py @@ -32,7 +32,7 @@ def _fit_imaging_from( Parameters ---------- fit - A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits. + A PyAutoFit database Fit object containing the generators of the results of model-fits. galaxies A list of galaxies corresponding to a sample of a non-linear search and model-fit. @@ -107,7 +107,7 @@ def make_object_for_gen(self, fit, galaxies) -> FItImaging: Parameters ---------- fit - A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits. + A PyAutoFit database Fit object containing the generators of the results of model-fits. galaxies A list of galaxies corresponding to a sample of a non-linear search and model-fit. diff --git a/autogalaxy/aggregator/fit_interferometer.py b/autogalaxy/aggregator/fit_interferometer.py index 3950ce28d..ac5ff2a66 100644 --- a/autogalaxy/aggregator/fit_interferometer.py +++ b/autogalaxy/aggregator/fit_interferometer.py @@ -33,7 +33,7 @@ def _fit_interferometer_from( Parameters ---------- fit - A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits. + A PyAutoFit database Fit object containing the generators of the results of model-fits. galaxies A list of galaxies corresponding to a sample of a non-linear search and model-fit. @@ -103,7 +103,7 @@ def make_object_for_gen(self, fit, galaxies) -> FitInterferometer: Parameters ---------- fit - A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits. + A PyAutoFit database Fit object containing the generators of the results of model-fits. galaxies A list of galaxies corresponding to a sample of a non-linear search and model-fit. diff --git a/autogalaxy/aggregator/imaging.py b/autogalaxy/aggregator/imaging.py index 9ea5e6372..848cf373d 100644 --- a/autogalaxy/aggregator/imaging.py +++ b/autogalaxy/aggregator/imaging.py @@ -17,7 +17,7 @@ def _imaging_from(fit: af.Fit, settings_imaging: Optional[aa.SettingsImaging] = Parameters ---------- fit - A PyAutoFit aggregator's SearchOutput object containing the generators of the results of PyAutoGalaxy model-fits. + A PyAutoFit aggregator's SearchOutput object containing the generators of the results of model-fits. """ data = fit.value(name="data") @@ -64,7 +64,7 @@ def imaging_gen_from(self, settings_imaging: Optional[aa.SettingsImaging] = None Parameters ---------- aggregator - A PyAutoFit aggregator object containing the results of PyAutoGalaxy model-fits. + A PyAutoFit aggregator object containing the results of model-fits. """ func = partial(_imaging_from, settings_imaging=settings_imaging) diff --git a/autogalaxy/aggregator/interferometer.py b/autogalaxy/aggregator/interferometer.py index 8e99a66e4..6e48f1ee7 100644 --- a/autogalaxy/aggregator/interferometer.py +++ b/autogalaxy/aggregator/interferometer.py @@ -67,7 +67,7 @@ def interferometer_gen_from( Parameters ---------- aggregator : ImaginAggregator - A PyAutoFit aggregator object containing the results of PyAutoGalaxy model-fits. + A PyAutoFit aggregator object containing the results of model-fits. """ func = partial( diff --git a/autogalaxy/aggregator/plane.py b/autogalaxy/aggregator/plane.py index f557efba0..c9a425c37 100644 --- a/autogalaxy/aggregator/plane.py +++ b/autogalaxy/aggregator/plane.py @@ -21,7 +21,7 @@ def _plane_from(fit: af.Fit, galaxies: List[Galaxy]) -> Plane: Parameters ---------- fit - A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits. + A PyAutoFit database Fit object containing the generators of the results of model-fits. galaxies A list of galaxies corresponding to a sample of a non-linear search and model-fit. @@ -70,7 +70,7 @@ def make_object_for_gen(self, fit, galaxies) -> Plane: Parameters ---------- fit - A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits. + A PyAutoFit database Fit object containing the generators of the results of model-fits. galaxies A list of galaxies corresponding to a sample of a non-linear search and model-fit. diff --git a/autogalaxy/analysis/analysis.py b/autogalaxy/analysis/analysis.py index 48b94b9f3..1015842e6 100644 --- a/autogalaxy/analysis/analysis.py +++ b/autogalaxy/analysis/analysis.py @@ -324,7 +324,7 @@ def instance_with_associated_adapt_images_from( def save_attributes_for_aggregator(self, paths: af.DirectoryPaths): """ Before the model-fit via the non-linear search begins, this routine saves attributes of the `Analysis` object - to the `pickles` folder such that they can be load after the analysis using PyAutoFit's database and aggregator + to the `pickles` folder such that they can be loaded after the analysis using PyAutoFit's database and aggregator tools. For this analysis the following are output: diff --git a/autogalaxy/analysis/preloads.py b/autogalaxy/analysis/preloads.py index e27950911..cf98cd161 100644 --- a/autogalaxy/analysis/preloads.py +++ b/autogalaxy/analysis/preloads.py @@ -46,7 +46,7 @@ def __init__( Parameters ---------- blurred_image - The preloaded array of values containing the blurred image of a lens model fit (e.g. that light profile of + 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 diff --git a/autogalaxy/config/README.rst b/autogalaxy/config/README.rst index 1d5b5b506..c6dd5c196 100644 --- a/autogalaxy/config/README.rst +++ b/autogalaxy/config/README.rst @@ -3,7 +3,7 @@ The ``config`` folder contains configuration files which customize default **PyA Folders ------- -- ``priors``: Configs defining default priors assumed on every lens model component and set of parameters. +- ``priors``: Configs defining default priors assumed on every model component and set of parameters. - ``visualize``: Configs defining what images are output by a lens model fit. Files diff --git a/autogalaxy/cosmology/lensing.py b/autogalaxy/cosmology/lensing.py index 1ad1fa7d4..7192ce210 100644 --- a/autogalaxy/cosmology/lensing.py +++ b/autogalaxy/cosmology/lensing.py @@ -140,7 +140,7 @@ def critical_surface_density_between_redshifts_from( D_l = angular_diameter_distance_of_lens_redshift_to_earth This function returns the critical surface density in units of solar masses, which are convenient units for - converting the inferred masses of a lens model from angular units (e.g. dimensionless units inferred from + converting the inferred masses of a model from angular units (e.g. dimensionless units inferred from data in arcseconds) to solar masses. Parameters @@ -177,7 +177,7 @@ def critical_surface_density_between_redshifts_solar_mass_per_kpc2_from( 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 lens model from angular units (e.g. dimensionless units inferred + 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 diff --git a/autogalaxy/imaging/model/analysis.py b/autogalaxy/imaging/model/analysis.py index e3c8cbf85..fed75785a 100644 --- a/autogalaxy/imaging/model/analysis.py +++ b/autogalaxy/imaging/model/analysis.py @@ -247,7 +247,7 @@ def visualize_before_fit(self, paths: af.DirectoryPaths, model: af.Collection): The PyAutoFit model object, which includes model components representing the galaxies that are fitted to the imaging data. """ - if paths.is_complete or os.environ.get("PYAUTOFIT_TEST_MODE") == "1": + if not self.should_visualize(paths=paths): return visualizer = VisualizerImaging(visualize_path=paths.image_path) @@ -295,7 +295,7 @@ def visualize( which may change which images are output. """ - if os.environ.get("PYAUTOFIT_TEST_MODE") == "1": + if not self.should_visualize(paths=paths): return instance = self.instance_with_associated_adapt_images_from(instance=instance) @@ -374,7 +374,7 @@ def make_result( def save_attributes_for_aggregator(self, paths: af.DirectoryPaths): """ Before the non-linear search begins, this routine saves attributes of the `Analysis` object to the `pickles` - folder such that they can be load after the analysis using PyAutoFit's database and aggregator tools. + folder such that they can be loaded after the analysis using PyAutoFit's database and aggregator tools. For this analysis, it uses the `AnalysisDataset` object's method to output the following: diff --git a/autogalaxy/interferometer/model/analysis.py b/autogalaxy/interferometer/model/analysis.py index 284fa09b0..e4b8d5c8c 100644 --- a/autogalaxy/interferometer/model/analysis.py +++ b/autogalaxy/interferometer/model/analysis.py @@ -318,7 +318,7 @@ def visualize_before_fit(self, paths: af.DirectoryPaths, model: af.Collection): the imaging data. """ - if paths.is_complete or os.environ.get("PYAUTOFIT_TEST_MODE") == "1": + if not self.should_visualize(paths=paths): return visualizer = VisualizerInterferometer(visualize_path=paths.image_path) @@ -364,7 +364,7 @@ def visualize(self, paths: af.DirectoryPaths, instance, during_analysis): which may change which images are output. """ - if os.environ.get("PYAUTOFIT_TEST_MODE") == "1": + if not self.should_visualize(paths=paths): return instance = self.instance_with_associated_adapt_images_from(instance=instance) @@ -449,7 +449,7 @@ def make_result( def save_attributes_for_aggregator(self, paths: af.DirectoryPaths): """ Before the model-fit begins, this routine saves attributes of the `Analysis` object to the `pickles` folder - such that they can be load after the analysis using PyAutoFit's database and aggregator tools. + such that they can be loaded after the analysis using PyAutoFit's database and aggregator tools. For this analysis, it uses the `AnalysisDataset` object's method to output the following: diff --git a/autogalaxy/quantity/model/analysis.py b/autogalaxy/quantity/model/analysis.py index 9436d4e1d..4ee1cc503 100644 --- a/autogalaxy/quantity/model/analysis.py +++ b/autogalaxy/quantity/model/analysis.py @@ -201,7 +201,7 @@ def make_result( def save_attributes_for_aggregator(self, paths: af.DirectoryPaths): """ Before the non-linear search begins, this routine saves attributes of the `Analysis` object to the `pickles` - folder such that they can be load after the analysis using PyAutoFit's database and aggregator tools. + folder such that they can be loaded after the analysis using PyAutoFit's database and aggregator tools. For this analysis, it uses the `AnalysisDataset` object's method to output the following: From f475b1c2e7ca2ed0bff82efe8e19a3291bc63c35 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Wed, 10 May 2023 18:33:20 +0100 Subject: [PATCH 02/10] fix aggregator abstract --- autogalaxy/aggregator/abstract.py | 35 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/autogalaxy/aggregator/abstract.py b/autogalaxy/aggregator/abstract.py index 694db9ccf..64d129b53 100644 --- a/autogalaxy/aggregator/abstract.py +++ b/autogalaxy/aggregator/abstract.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, List, Generator if TYPE_CHECKING: - from autocti.model.model_util import AbstractCTI + from autogalaxy.galaxy.galaxy import Galaxy import autofit as af @@ -15,9 +15,8 @@ def __init__(self, aggregator: af.Aggregator): An abstract aggregator wrapper, which makes it straight forward to compute generators of objects from specific samples of a non-linear search. - For example, in **PyAutoCTI**, this makes it straight forward to create generators of `CTI`'s drawn from + For example, in **PyAutoLens**, this makes it straight forward to create generators of `Plane`'s drawn from the PDF estimated by a non-linear for efficient error calculation of derived quantities. - Parameters ---------- aggregator @@ -26,17 +25,17 @@ def __init__(self, aggregator: af.Aggregator): self.aggregator = aggregator @abstractmethod - def make_object_for_gen(self, fit: af.Fit, cti: AbstractCTI) -> object: + def make_object_for_gen(self, fit: af.Fit, galaxies: List[Galaxy]) -> object: """ - For example, in the `CTIAgg` object, this function is overwritten such that it creates a `CTI` from a - `ModelInstance` that contains the cti model of a sample from a non-linear search. + For example, in the `PlaneAgg` object, this function is overwritten such that it creates a `Plane` from a + `ModelInstance` that contains the galaxies of a sample from a non-linear search. Parameters ---------- fit - A PyAutoFit database Fit object containing the generators of the results of model-fits. - cti - A cti model corresponding to a sample of a non-linear search and model-fit. + A PyAutoFit database Fit object containing the generators of the results of PyAutoGalaxy model-fits. + galaxies + A list of galaxies corresponding to a sample of a non-linear search and model-fit. Returns ------- @@ -50,13 +49,13 @@ def max_log_likelihood_gen_from(self) -> Generator: This generator creates a list containing the maximum log instance of every result loaded in the aggregator. - For example, in **PyAutoCTI**, by overwriting the `make_gen_from` method this returns a generator - of `CTI` objects from a PyAutoFit aggregator. This generator then generates a list of the maximum log - likelihood `CTI` objects for all aggregator results. + For example, in **PyAutoLens**, by overwriting the `make_gen_from` method this returns a generator + of `Plane` objects from a PyAutoFit aggregator. This generator then generates a list of the maximum log + likelihood `Plane` objects for all aggregator results. """ def func_gen(fit: af.Fit) -> Generator: - return self.make_object_for_gen(fit=fit, cti=fit.instance.cti) + return self.make_object_for_gen(fit=fit, galaxies=fit.instance.galaxies) return self.aggregator.map(func=func_gen) @@ -118,7 +117,7 @@ def func_gen(fit: af.Fit, minimum_weight: float) -> List[object]: instance = sample.instance_for_model(model=samples.model) all_above_weight_list.append( - self.make_object_for_gen(fit=fit, cti=instance.cti) + self.make_object_for_gen(fit=fit, galaxies=instance.galaxies) ) return all_above_weight_list @@ -137,8 +136,8 @@ def randomly_drawn_via_pdf_gen_from(self, total_samples: int): entries will be returned, where each entry in this list contains 100 object's paired with non-linear samples randomly drawn from the PDF. - For example, in **PyAutoCTI**, by overwriting the `make_gen_from` method this returns a generator - of `CTI` objects from a PyAutoFit aggregator. This generator then generates lists of `CTI` objects + For example, in **PyAutoLens**, by overwriting the `make_gen_from` method this returns a generator + of `Plane` objects from a PyAutoFit aggregator. This generator then generates lists of `Plane` objects corresponding to non-linear search samples randomly drawn from the PDF. Parameters @@ -153,11 +152,11 @@ def func_gen(fit: af.Fit, total_samples: int) -> List[object]: return [ self.make_object_for_gen( fit=fit, - cti=samples.draw_randomly_via_pdf().cti, + galaxies=samples.draw_randomly_via_pdf().galaxies, ) for i in range(total_samples) ] func = partial(func_gen, total_samples=total_samples) - return self.aggregator.map(func=func) + return self.aggregator.map(func=func) \ No newline at end of file From c0176a92bc2524393ed89133a7f05faf0c2354c4 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 12 May 2023 19:02:42 +0100 Subject: [PATCH 03/10] remove another legacy test --- autogalaxy/aggregator/abstract.py | 8 +- autogalaxy/aggregator/fit_imaging.py | 2 +- autogalaxy/aggregator/fit_interferometer.py | 2 +- autogalaxy/aggregator/imaging.py | 4 +- autogalaxy/aggregator/interferometer.py | 4 +- autogalaxy/aggregator/plane.py | 2 +- autogalaxy/analysis/model_util.py | 8 +- autogalaxy/legacy/model_util.py | 8 +- docs/general/workspace.rst | 4 +- docs/howtogalaxy/howtogalaxy.rst | 4 +- docs/installation/numba.rst | 2 +- docs/installation/overview.rst | 2 +- docs/installation/source.rst | 2 +- docs/overview/overview_3_modeling.rst | 2 +- docs/overview/overview_5_pixelizations.rst | 2 +- .../aggregator/test_aggregator_imaging.py | 2 +- .../test_aggregator_interferometer.py | 2 +- test_autogalaxy/analysis/test_model_util.py | 6 +- test_autogalaxy/legacy/test_model_util.py | 209 ------------------ 19 files changed, 33 insertions(+), 242 deletions(-) diff --git a/autogalaxy/aggregator/abstract.py b/autogalaxy/aggregator/abstract.py index 64d129b53..6dbdd110b 100644 --- a/autogalaxy/aggregator/abstract.py +++ b/autogalaxy/aggregator/abstract.py @@ -25,7 +25,7 @@ def __init__(self, aggregator: af.Aggregator): self.aggregator = aggregator @abstractmethod - def make_object_for_gen(self, fit: af.Fit, galaxies: List[Galaxy]) -> object: + def object_via_gen_from(self, fit: af.Fit, galaxies: List[Galaxy]) -> object: """ For example, in the `PlaneAgg` object, this function is overwritten such that it creates a `Plane` from a `ModelInstance` that contains the galaxies of a sample from a non-linear search. @@ -55,7 +55,7 @@ def max_log_likelihood_gen_from(self) -> Generator: """ def func_gen(fit: af.Fit) -> Generator: - return self.make_object_for_gen(fit=fit, galaxies=fit.instance.galaxies) + return self.object_via_gen_from(fit=fit, galaxies=fit.instance.galaxies) return self.aggregator.map(func=func_gen) @@ -117,7 +117,7 @@ def func_gen(fit: af.Fit, minimum_weight: float) -> List[object]: instance = sample.instance_for_model(model=samples.model) all_above_weight_list.append( - self.make_object_for_gen(fit=fit, galaxies=instance.galaxies) + self.object_via_gen_from(fit=fit, galaxies=instance.galaxies) ) return all_above_weight_list @@ -150,7 +150,7 @@ def func_gen(fit: af.Fit, total_samples: int) -> List[object]: samples = fit.value(name="samples") return [ - self.make_object_for_gen( + self.object_via_gen_from( fit=fit, galaxies=samples.draw_randomly_via_pdf().galaxies, ) diff --git a/autogalaxy/aggregator/fit_imaging.py b/autogalaxy/aggregator/fit_imaging.py index a332a73c7..44a47a151 100644 --- a/autogalaxy/aggregator/fit_imaging.py +++ b/autogalaxy/aggregator/fit_imaging.py @@ -99,7 +99,7 @@ def __init__( self.settings_inversion = settings_inversion self.use_preloaded_grid = use_preloaded_grid - def make_object_for_gen(self, fit, galaxies) -> FItImaging: + def object_via_gen_from(self, fit, galaxies) -> FItImaging: """ Creates a `FitImaging` object from a `ModelInstance` that contains the galaxies of a sample from a non-linear search. diff --git a/autogalaxy/aggregator/fit_interferometer.py b/autogalaxy/aggregator/fit_interferometer.py index ac5ff2a66..ac191003a 100644 --- a/autogalaxy/aggregator/fit_interferometer.py +++ b/autogalaxy/aggregator/fit_interferometer.py @@ -95,7 +95,7 @@ def __init__( self.use_preloaded_grid = use_preloaded_grid self.real_space_mask = real_space_mask - def make_object_for_gen(self, fit, galaxies) -> FitInterferometer: + def object_via_gen_from(self, fit, galaxies) -> FitInterferometer: """ Creates a `FitInterferometer` object from a `ModelInstance` that contains the galaxies of a sample from a non-linear search. diff --git a/autogalaxy/aggregator/imaging.py b/autogalaxy/aggregator/imaging.py index 848cf373d..54514298d 100644 --- a/autogalaxy/aggregator/imaging.py +++ b/autogalaxy/aggregator/imaging.py @@ -9,7 +9,7 @@ def _imaging_from(fit: af.Fit, settings_imaging: Optional[aa.SettingsImaging] = """ Returns a `Imaging` object from an aggregator's `SearchOutput` class, which we call an 'agg_obj' to describe that it acts as the aggregator object for one result in the `Aggregator`. This uses the aggregator's generator - outputs such that the function can use the `Aggregator`'s map function to to create a `Imaging` generator. + outputs such that the function can use the `Aggregator`'s map function to create a `Imaging` generator. The `Imaging` is created following the same method as the PyAutoGalaxy `Search` classes, including using the `SettingsImaging` instance output by the Search to load inputs of the `Imaging` (e.g. psf_shape_2d). @@ -52,7 +52,7 @@ class ImagingAgg: def __init__(self, aggregator: af.Aggregator): self.aggregator = aggregator - def imaging_gen_from(self, settings_imaging: Optional[aa.SettingsImaging] = None): + def dataset_gen_from(self, settings_imaging: Optional[aa.SettingsImaging] = None): """ Returns a generator of `Imaging` objects from an input aggregator, which generates a list of the `Imaging` objects for every set of results loaded in the aggregator. diff --git a/autogalaxy/aggregator/interferometer.py b/autogalaxy/aggregator/interferometer.py index 6e48f1ee7..182d0ab34 100644 --- a/autogalaxy/aggregator/interferometer.py +++ b/autogalaxy/aggregator/interferometer.py @@ -13,7 +13,7 @@ def _interferometer_from( """ Returns a `Interferometer` object from an aggregator's `SearchOutput` class, which we call an 'agg_obj' to describe that it acts as the aggregator object for one result in the `Aggregator`. This uses the aggregator's - generator outputs such that the function can use the `Aggregator`'s map function to to create a + generator outputs such that the function can use the `Aggregator`'s map function to create a `Interferometer` generator. The `Interferometer` is created following the same method as the PyAutoGalaxy `Search` classes, including @@ -51,7 +51,7 @@ class InterferometerAgg: def __init__(self, aggregator: af.Aggregator): self.aggregator = aggregator - def interferometer_gen_from( + def dataset_gen_from( self, real_space_mask: Optional[aa.Mask2D] = None, settings_interferometer: Optional[aa.SettingsInterferometer] = None, diff --git a/autogalaxy/aggregator/plane.py b/autogalaxy/aggregator/plane.py index c9a425c37..75e4b3bca 100644 --- a/autogalaxy/aggregator/plane.py +++ b/autogalaxy/aggregator/plane.py @@ -62,7 +62,7 @@ class PlaneAgg(AbstractAgg): search model-fit. """ - def make_object_for_gen(self, fit, galaxies) -> Plane: + def object_via_gen_from(self, fit, galaxies) -> Plane: """ Creates a `Plane` object from a `ModelInstance` that contains the galaxies of a sample from a non-linear search. diff --git a/autogalaxy/analysis/model_util.py b/autogalaxy/analysis/model_util.py index bac23c3c8..9ab3553c4 100644 --- a/autogalaxy/analysis/model_util.py +++ b/autogalaxy/analysis/model_util.py @@ -158,7 +158,7 @@ def clean_model_of_adapt_images(model): return model -def hyper_model_from( +def adapt_model_from( setup_adapt, result: af.Result, pixelization_overwrite=None, @@ -231,7 +231,7 @@ def adapt_fit( "The analysis class does not have a adapt_model_image attribute, which is required for hyper fitting." ) - hyper_model_pix = hyper_model_from( + adapt_model_pix = adapt_model_from( setup_adapt=setup_adapt, result=result, ) @@ -245,10 +245,10 @@ def adapt_fit( ) set_upper_limit_of_pixelization_pixels_prior( - model=hyper_model_pix, pixels_in_mask=result.mask.pixels_in_mask + model=adapt_model_pix, pixels_in_mask=result.mask.pixels_in_mask ) - adapt_result = search.fit(model=hyper_model_pix, analysis=analysis) + adapt_result = search.fit(model=adapt_model_pix, analysis=analysis) result.adapt = adapt_result diff --git a/autogalaxy/legacy/model_util.py b/autogalaxy/legacy/model_util.py index e5e951ef4..924b7fde4 100644 --- a/autogalaxy/legacy/model_util.py +++ b/autogalaxy/legacy/model_util.py @@ -194,13 +194,13 @@ def adapt_fit_no_noise( if use_positive_only_solver: analysis.settings_inversion.use_positive_only_solver = True - hyper_model_pix = hyper_pix_model_from( + adapt_model_pix = hyper_pix_model_from( setup_adapt=setup_adapt, result=result, include_hyper_image_sky=include_hyper_image_sky, ) - if hyper_model_pix is None: + if adapt_model_pix is None: return result search = setup_adapt.search_pix_cls( @@ -211,7 +211,7 @@ def adapt_fit_no_noise( **setup_adapt.search_pix_dict, ) - hyper_pix_result = search.fit(model=hyper_model_pix, analysis=analysis) + hyper_pix_result = search.fit(model=adapt_model_pix, analysis=analysis) result.adapt = hyper_pix_result @@ -332,7 +332,7 @@ def adapt_fit( return result -def hyper_model_from( +def adapt_model_from( setup_adapt, result: af.Result, include_hyper_image_sky: bool = False ) -> af.Collection: """ diff --git a/docs/general/workspace.rst b/docs/general/workspace.rst index c8156f3ad..09909ff83 100644 --- a/docs/general/workspace.rst +++ b/docs/general/workspace.rst @@ -35,7 +35,7 @@ the `autogalaxy workspace GitHub page `_ or using `PyPI `_ to ``pip install`` **PyAutoGalaxy** into your Python distribution. -We recommend Anaconda as it manages the installation of many major libraries used by **PyAutoGalaxy** (e.g. numpy, scipy, +We recommend Anaconda as it manages the installation of many major libraries (e.g. numpy, scipy, matplotlib, etc.) making installation more straight forward. Windows users must use Anaconda. The installation guide for both approaches can be found at: diff --git a/docs/installation/source.rst b/docs/installation/source.rst index 0cdc9e868..e4cd49647 100644 --- a/docs/installation/source.rst +++ b/docs/installation/source.rst @@ -13,7 +13,7 @@ A large amount of **PyAutoGalaxy** functionality is contained in its parent proj **PyAutoArray** https://github.com/Jammy2211/PyAutoArray -If you wish to build from source all code used by **PyAutoGalaxy** you may need to build from source these 3 additional +If you wish to build from source all code you may need to build from source these 3 additional projects. We include below instructions for building just **PyAutoGalaxy** from source or building all projects. Building Only PyAutoGalaxy diff --git a/docs/overview/overview_3_modeling.rst b/docs/overview/overview_3_modeling.rst index fad920dcc..2c65a682f 100644 --- a/docs/overview/overview_3_modeling.rst +++ b/docs/overview/overview_3_modeling.rst @@ -18,7 +18,7 @@ The task of finding these ``LightProfiles``'is called *modeling*. PyAutoFit --------- -Modeling with **PyAutoGalaxy** uses the probabilistic programming language +Modeling uses the probabilistic programming language `PyAutoFit `_, an open-source Python framework that allows complex model fitting techniques to be straightforwardly integrated into scientific modeling software. Check it out if you are interested in developing your own software to perform advanced model-fitting! diff --git a/docs/overview/overview_5_pixelizations.rst b/docs/overview/overview_5_pixelizations.rst index 39243099f..dbfcccf38 100644 --- a/docs/overview/overview_5_pixelizations.rst +++ b/docs/overview/overview_5_pixelizations.rst @@ -81,7 +81,7 @@ The workspace contains examples of how to do this, as well as other uses for pix Wrap-Up ------- -This was a brief overview of ``Inverion``'s with **PyAutoGalaxy**. +This was a brief overview of ``Inverion``'s. There is a lot more to using ``Inverion``'s then presented here, which is covered in chapters 4 of the **HowToGalaxy**, specifically: diff --git a/test_autogalaxy/aggregator/test_aggregator_imaging.py b/test_autogalaxy/aggregator/test_aggregator_imaging.py index fef1fe0de..e25744029 100644 --- a/test_autogalaxy/aggregator/test_aggregator_imaging.py +++ b/test_autogalaxy/aggregator/test_aggregator_imaging.py @@ -37,7 +37,7 @@ def test__imaging_generator_from_aggregator(imaging_7x7, mask_2d_7x7, samples, m agg.add_directory(directory=result_path) imaging_agg = ag.agg.ImagingAgg(aggregator=agg) - imaging_gen = imaging_agg.imaging_gen_from() + imaging_gen = imaging_agg.dataset_gen_from() for imaging in imaging_gen: assert (imaging.image == masked_imaging_7x7.image).all() diff --git a/test_autogalaxy/aggregator/test_aggregator_interferometer.py b/test_autogalaxy/aggregator/test_aggregator_interferometer.py index 675d2baf1..e5d84f8fb 100644 --- a/test_autogalaxy/aggregator/test_aggregator_interferometer.py +++ b/test_autogalaxy/aggregator/test_aggregator_interferometer.py @@ -47,7 +47,7 @@ def test__interferometer_generator_from_aggregator( agg.add_directory(directory=result_path) interferometer_agg = ag.agg.InterferometerAgg(aggregator=agg) - interferometer_gen = interferometer_agg.interferometer_gen_from() + interferometer_gen = interferometer_agg.dataset_gen_from() for interferometer in interferometer_gen: assert (interferometer.visibilities == interferometer_7.visibilities).all() diff --git a/test_autogalaxy/analysis/test_model_util.py b/test_autogalaxy/analysis/test_model_util.py index 86e99f63d..b9c172358 100644 --- a/test_autogalaxy/analysis/test_model_util.py +++ b/test_autogalaxy/analysis/test_model_util.py @@ -122,7 +122,7 @@ def test__set_upper_limit_of_pixelization_pixels_prior(): # ) -def test__hyper_model_from(): +def test__adapt_model_from(): pixelization = af.Model(ag.Pixelization, mesh=ag.mesh.Rectangular) model = af.Collection( @@ -136,7 +136,7 @@ def test__hyper_model_from(): result = ag.m.MockResult(instance=instance) - model = ag.util.model.hyper_model_from(setup_adapt=ag.SetupAdapt(), result=result) + model = ag.util.model.adapt_model_from(setup_adapt=ag.SetupAdapt(), result=result) assert isinstance(model.galaxies.galaxy.pixelization.mesh, af.Model) @@ -154,6 +154,6 @@ def test__hyper_model_from(): result = ag.m.MockResult(instance=instance) - model = ag.util.model.hyper_model_from(result=result, setup_adapt=ag.SetupAdapt()) + model = ag.util.model.adapt_model_from(result=result, setup_adapt=ag.SetupAdapt()) assert model == None diff --git a/test_autogalaxy/legacy/test_model_util.py b/test_autogalaxy/legacy/test_model_util.py index 56d223e74..2089fe37b 100644 --- a/test_autogalaxy/legacy/test_model_util.py +++ b/test_autogalaxy/legacy/test_model_util.py @@ -127,212 +127,3 @@ def test__hyper_model_noise_from__adds_hyper_galaxies(): assert model.galaxies.galaxy_1.redshift == 1.0 assert model.galaxies.galaxy_1.hyper_galaxy.cls is ag.legacy.HyperGalaxy - -def test__hyper_model_inversion_from(): - pixelization = af.Model(ag.Pixelization, mesh=ag.mesh.Rectangular) - - model = af.Collection( - galaxies=af.Collection( - galaxy=af.Model(ag.legacy.Galaxy, redshift=0.5, pixelization=pixelization), - galaxy_1=af.Model(ag.legacy.Galaxy, redshift=1.0, bulge=ag.lp.Sersic), - ) - ) - - instance = model.instance_from_prior_medians() - - result = ag.m.MockResult(instance=instance) - - model = ag.util.model_legacy.adapt_model_from( - setup_adapt=ag.legacy.SetupAdapt(), result=result - ) - - assert isinstance(model.galaxies.galaxy.pixelization.mesh, af.Model) - - assert model.galaxies.galaxy.pixelization.mesh.cls is ag.mesh.Rectangular - assert model.galaxies.galaxy_1.bulge.intensity == pytest.approx(1.0, 1.0e-4) - - assert model.hyper_image_sky is None - assert model.hyper_background_noise is None - - model = ag.util.model_legacy.adapt_model_from(result=result, setup_adapt=None) - - assert model == None - - model = ag.util.model_legacy.adapt_model_from( - setup_adapt=ag.legacy.SetupAdapt( - hyper_image_sky=ag.legacy.hyper_data.HyperImageSky, - hyper_background_noise=ag.legacy.hyper_data.HyperBackgroundNoise, - ), - result=result, - include_hyper_image_sky=True, - ) - - assert isinstance(model.galaxies.galaxy.pixelization.mesh, af.Model) - assert isinstance(model.hyper_image_sky, af.Model) - - assert model.hyper_background_noise is None - - assert model.hyper_image_sky.cls == ag.legacy.hyper_data.HyperImageSky - - model = af.Collection( - galaxies=af.Collection( - galaxy=af.Model(ag.legacy.Galaxy, redshift=0.5), - galaxy_1=af.Model(ag.legacy.Galaxy, redshift=1.0, bulge=ag.lp.Sersic), - ) - ) - - instance = model.instance_from_prior_medians() - - result = ag.m.MockResult(instance=instance) - - model = ag.util.model_legacy.adapt_model_from( - result=result, setup_adapt=ag.legacy.SetupAdapt() - ) - - assert model == None - - -def test__hyper_model_inversion_from__adds_hyper_galaxies(): - pixelization = af.Model(ag.Pixelization, mesh=ag.mesh.Rectangular) - - model = af.Collection( - galaxies=af.Collection( - galaxy_0=af.Model(ag.legacy.Galaxy, redshift=0.5), - galaxy_1=af.Model( - ag.legacy.Galaxy, - redshift=1.0, - bulge=ag.lp.Sersic, - pixelization=pixelization, - ), - ) - ) - - instance = model.instance_from_prior_medians() - - path_galaxy_tuples = [ - ( - ("galaxies", "galaxy_0"), - ag.legacy.Galaxy( - redshift=0.5, hyper_galaxy=ag.legacy.HyperGalaxy(contribution_factor=1) - ), - ), - ( - ("galaxies", "galaxy_1"), - ag.legacy.Galaxy( - redshift=1.0, hyper_galaxy=ag.legacy.HyperGalaxy(contribution_factor=2) - ), - ), - ] - - adapt_galaxy_image_path_dict = { - ("galaxies", "galaxy_0"): ag.Array2D.ones( - shape_native=(3, 3), pixel_scales=1.0 - ), - ("galaxies", "galaxy_1"): ag.Array2D.full( - fill_value=2.0, shape_native=(3, 3), pixel_scales=1.0 - ), - } - - result = ag.m.MockResult( - instance=instance, - path_galaxy_tuples=path_galaxy_tuples, - adapt_galaxy_image_path_dict=adapt_galaxy_image_path_dict, - ) - - setup_adapt = ag.legacy.SetupAdapt() - setup_adapt.hyper_galaxy_names = ["galaxy_0"] - - model = ag.util.model_legacy.adapt_model_from( - result=result, setup_adapt=setup_adapt - ) - - assert isinstance(model.galaxies.galaxy_0, af.Model) - assert model.galaxies.galaxy_0.redshift == 0.5 - assert model.galaxies.galaxy_0.hyper_galaxy.contribution_factor == 1 - assert model.galaxies.galaxy_1.hyper_galaxy is None - - setup_adapt = ag.legacy.SetupAdapt() - setup_adapt.hyper_galaxy_names = ["galaxy_0", "galaxy_1"] - - model = ag.util.model_legacy.adapt_model_from( - result=result, setup_adapt=setup_adapt - ) - - assert isinstance(model.galaxies.galaxy_0, af.Model) - assert model.galaxies.galaxy_0.redshift == 0.5 - assert model.galaxies.galaxy_0.hyper_galaxy.contribution_factor == 1 - assert isinstance(model.galaxies.galaxy_1, af.Model) - assert model.galaxies.galaxy_1.redshift == 1.0 - assert model.galaxies.galaxy_1.hyper_galaxy.contribution_factor == 2 - - -def test__stochastic_model_from(): - pixelization = af.Model( - ag.Pixelization, - mesh=ag.mesh.VoronoiBrightnessImage(), - regularization=ag.reg.AdaptiveBrightness(), - ) - - model = af.Collection( - galaxies=af.Collection( - lens=af.Model( - ag.legacy.Galaxy, - redshift=0.5, - light=ag.lp.SersicSph(), - mass=ag.mp.IsothermalSph(), - ), - source=af.Model(ag.legacy.Galaxy, redshift=1.0, pixelization=pixelization), - ) - ) - - instance = model.instance_from_prior_medians() - - model = af.Collection( - galaxies=af.Collection(lens=af.Model(ag.legacy.Galaxy, redshift=0.5)) - ) - - result = ag.m.MockResult(instance=instance, model=model) - - model = ag.util.model_legacy.stochastic_model_from(result=result) - - assert isinstance(model.galaxies.lens.mass.centre, af.TuplePrior) - assert isinstance(model.galaxies.lens.light.intensity, float) - assert isinstance(model.galaxies.source.pixelization.mesh.pixels, int) - assert isinstance( - model.galaxies.source.pixelization.regularization.inner_coefficient, float - ) - - model = ag.util.model_legacy.stochastic_model_from( - result=result, include_lens_light=True - ) - - assert isinstance(model.galaxies.lens.mass.centre, af.TuplePrior) - assert isinstance(model.galaxies.lens.light.intensity, af.LogUniformPrior) - assert isinstance(model.galaxies.source.pixelization.mesh.pixels, int) - assert isinstance( - model.galaxies.source.pixelization.regularization.inner_coefficient, float - ) - - model = ag.util.model_legacy.stochastic_model_from( - result=result, include_pixelization=True - ) - - assert isinstance(model.galaxies.lens.mass.centre, af.TuplePrior) - assert isinstance(model.galaxies.lens.light.intensity, float) - assert isinstance(model.galaxies.source.pixelization.mesh.pixels, af.UniformPrior) - assert not isinstance( - model.galaxies.source.pixelization.regularization.inner_coefficient, - af.LogUniformPrior, - ) - - model = ag.util.model_legacy.stochastic_model_from( - result=result, include_regularization=True - ) - - assert isinstance(model.galaxies.lens.mass.centre, af.TuplePrior) - assert isinstance(model.galaxies.lens.light.intensity, float) - assert isinstance(model.galaxies.source.pixelization.mesh.pixels, int) - assert isinstance( - model.galaxies.source.pixelization.regularization.inner_coefficient, - af.LogUniformPrior, - ) From 15ffed0ee8951835048d3c60bb004c6cd8aec4cb Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 12 May 2023 19:04:34 +0100 Subject: [PATCH 04/10] move point mass to own module --- autogalaxy/profiles/mass/point/__init__.py | 0 autogalaxy/profiles/mass/{total => point}/point.py | 0 test_autogalaxy/profiles/mass/point/__init__.py | 0 test_autogalaxy/profiles/mass/{total => point}/test_point.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 autogalaxy/profiles/mass/point/__init__.py rename autogalaxy/profiles/mass/{total => point}/point.py (100%) create mode 100644 test_autogalaxy/profiles/mass/point/__init__.py rename test_autogalaxy/profiles/mass/{total => point}/test_point.py (100%) diff --git a/autogalaxy/profiles/mass/point/__init__.py b/autogalaxy/profiles/mass/point/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/autogalaxy/profiles/mass/total/point.py b/autogalaxy/profiles/mass/point/point.py similarity index 100% rename from autogalaxy/profiles/mass/total/point.py rename to autogalaxy/profiles/mass/point/point.py diff --git a/test_autogalaxy/profiles/mass/point/__init__.py b/test_autogalaxy/profiles/mass/point/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test_autogalaxy/profiles/mass/total/test_point.py b/test_autogalaxy/profiles/mass/point/test_point.py similarity index 100% rename from test_autogalaxy/profiles/mass/total/test_point.py rename to test_autogalaxy/profiles/mass/point/test_point.py From e089376f15cccacf3a1b5aaffca92e9e6a31e549 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 12 May 2023 19:18:36 +0100 Subject: [PATCH 05/10] SMBH class implemented --- autogalaxy/aggregator/abstract.py | 2 +- autogalaxy/profiles/mass/__init__.py | 2 +- autogalaxy/profiles/mass/point/__init__.py | 2 + autogalaxy/profiles/mass/point/smbh.py | 52 +++++++++++++++++++ autogalaxy/profiles/mass/total/__init__.py | 1 - test_autogalaxy/legacy/test_model_util.py | 1 - .../profiles/mass/point/test_smbh.py | 11 ++++ 7 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 autogalaxy/profiles/mass/point/smbh.py create mode 100644 test_autogalaxy/profiles/mass/point/test_smbh.py diff --git a/autogalaxy/aggregator/abstract.py b/autogalaxy/aggregator/abstract.py index 6dbdd110b..c42a250d7 100644 --- a/autogalaxy/aggregator/abstract.py +++ b/autogalaxy/aggregator/abstract.py @@ -159,4 +159,4 @@ def func_gen(fit: af.Fit, total_samples: int) -> List[object]: func = partial(func_gen, total_samples=total_samples) - return self.aggregator.map(func=func) \ No newline at end of file + return self.aggregator.map(func=func) diff --git a/autogalaxy/profiles/mass/__init__.py b/autogalaxy/profiles/mass/__init__.py index a653242f8..72d6b9d69 100644 --- a/autogalaxy/profiles/mass/__init__.py +++ b/autogalaxy/profiles/mass/__init__.py @@ -1,6 +1,6 @@ from .abstract.abstract import MassProfile +from .point import PointMass, SMBH from .total import ( - PointMass, PowerLawCore, PowerLawCoreSph, PowerLawBroken, diff --git a/autogalaxy/profiles/mass/point/__init__.py b/autogalaxy/profiles/mass/point/__init__.py index e69de29bb..b94b0850f 100644 --- a/autogalaxy/profiles/mass/point/__init__.py +++ b/autogalaxy/profiles/mass/point/__init__.py @@ -0,0 +1,2 @@ +from .point import PointMass +from .smbh import SMBH diff --git a/autogalaxy/profiles/mass/point/smbh.py b/autogalaxy/profiles/mass/point/smbh.py new file mode 100644 index 000000000..9bfd7c64e --- /dev/null +++ b/autogalaxy/profiles/mass/point/smbh.py @@ -0,0 +1,52 @@ +import numpy as np +from typing import Tuple + +import autoarray as aa + +from autogalaxy.cosmology.wrap import Planck15 +from autogalaxy.profiles.mass.point.point import PointMass + + +class SMBH(PointMass): + def __init__( + self, + centre: Tuple[float, float] = (0.0, 0.0), + mass: float = 1e10, + redshift_object: float = 0.5, + redshift_source: float = 1.0, + ): + """ + Represents a supermassive black hole (SMBH). + + This uses the `PointMass` mass profile to represent the SMBH, where the SMBH mass in converted to the + `PointMass` Einstein radius value. + + Parameters + ---------- + centre + The (y,x) arc-second coordinates of the profile centre. + mass + The mass of the SMBH in solar masses. + redshift_object + The redshift of the SMBH, which is used to convert its mass to an Einstein radius. + 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 + + cosmology = Planck15() + + critical_surface_density = ( + cosmology.critical_surface_density_between_redshifts_from( + redshift_0=redshift_object, + redshift_1=redshift_source, + ) + ) + mass_angular = mass / critical_surface_density + einstein_radius = np.sqrt(mass_angular / np.pi) + + super().__init__(centre=centre, einstein_radius=einstein_radius) + + self.redshift_object = redshift_object + self.redshift_source = redshift_source diff --git a/autogalaxy/profiles/mass/total/__init__.py b/autogalaxy/profiles/mass/total/__init__.py index 0b9c51320..05d48dd07 100644 --- a/autogalaxy/profiles/mass/total/__init__.py +++ b/autogalaxy/profiles/mass/total/__init__.py @@ -1,6 +1,5 @@ from .isothermal import Isothermal, IsothermalSph from .isothermal_core import IsothermalCore, IsothermalCoreSph -from .point import PointMass from .power_law import PowerLaw, PowerLawSph from .power_law_broken import PowerLawBroken, PowerLawBrokenSph from .power_law_core import PowerLawCore, PowerLawCoreSph diff --git a/test_autogalaxy/legacy/test_model_util.py b/test_autogalaxy/legacy/test_model_util.py index 2089fe37b..4d3c393b6 100644 --- a/test_autogalaxy/legacy/test_model_util.py +++ b/test_autogalaxy/legacy/test_model_util.py @@ -126,4 +126,3 @@ def test__hyper_model_noise_from__adds_hyper_galaxies(): assert isinstance(model.galaxies.galaxy_1, af.Model) assert model.galaxies.galaxy_1.redshift == 1.0 assert model.galaxies.galaxy_1.hyper_galaxy.cls is ag.legacy.HyperGalaxy - diff --git a/test_autogalaxy/profiles/mass/point/test_smbh.py b/test_autogalaxy/profiles/mass/point/test_smbh.py new file mode 100644 index 000000000..a2983070a --- /dev/null +++ b/test_autogalaxy/profiles/mass/point/test_smbh.py @@ -0,0 +1,11 @@ +import pytest + +import autogalaxy as ag + + +def test__mass_to_einstein_radius_in_init(): + smbh = ag.mp.SMBH( + centre=(0.0, 0.0), mass=0.513e10, redshift_object=0.169, redshift_source=0.451 + ) + + assert smbh.einstein_radius == pytest.approx(0.2014, 1e-3) From b537df353aa40237517a7f0a2574d6e3a2e8f395 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 12 May 2023 19:20:24 +0100 Subject: [PATCH 06/10] SMBH prior config --- .../config/priors/mass/point/__init__.py | 0 .../priors/mass/{total => point}/point.yaml | 0 autogalaxy/config/priors/mass/point/smbh.yaml | 55 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 autogalaxy/config/priors/mass/point/__init__.py rename autogalaxy/config/priors/mass/{total => point}/point.yaml (100%) create mode 100644 autogalaxy/config/priors/mass/point/smbh.yaml diff --git a/autogalaxy/config/priors/mass/point/__init__.py b/autogalaxy/config/priors/mass/point/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/autogalaxy/config/priors/mass/total/point.yaml b/autogalaxy/config/priors/mass/point/point.yaml similarity index 100% rename from autogalaxy/config/priors/mass/total/point.yaml rename to autogalaxy/config/priors/mass/point/point.yaml diff --git a/autogalaxy/config/priors/mass/point/smbh.yaml b/autogalaxy/config/priors/mass/point/smbh.yaml new file mode 100644 index 000000000..8dfb2a1db --- /dev/null +++ b/autogalaxy/config/priors/mass/point/smbh.yaml @@ -0,0 +1,55 @@ +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: 1e6 + upper_limit: 1e13 + 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 + upper: inf \ No newline at end of file From 0e047d4af2b734df83814a8177dc1e01a64e269a Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 12 May 2023 19:22:49 +0100 Subject: [PATCH 07/10] notation configs --- autogalaxy/config/notation.yaml | 2 ++ autogalaxy/profiles/mass/point/smbh.py | 2 -- test_autogalaxy/config/notation.yaml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/autogalaxy/config/notation.yaml b/autogalaxy/config/notation.yaml index 95a182cfe..a1c693c12 100644 --- a/autogalaxy/config/notation.yaml +++ b/autogalaxy/config/notation.yaml @@ -26,6 +26,7 @@ label: intensity: I_{\rm b} kappa: \kappa kappa_s: \kappa_{\rm s} + mass: M mass_at_200: M_{\rm 200} mass_to_light_gradient: \Gamma mass_to_light_ratio: \Psi @@ -57,6 +58,7 @@ label: ExternalShear: ext Mesh: mesh Point: point + SMBH: smbh Redshift: z Regularization: reg HyperBackgroundNoise: hyper diff --git a/autogalaxy/profiles/mass/point/smbh.py b/autogalaxy/profiles/mass/point/smbh.py index 9bfd7c64e..0a92246bb 100644 --- a/autogalaxy/profiles/mass/point/smbh.py +++ b/autogalaxy/profiles/mass/point/smbh.py @@ -1,8 +1,6 @@ import numpy as np from typing import Tuple -import autoarray as aa - from autogalaxy.cosmology.wrap import Planck15 from autogalaxy.profiles.mass.point.point import PointMass diff --git a/test_autogalaxy/config/notation.yaml b/test_autogalaxy/config/notation.yaml index daacf1aa0..d626ed2d7 100644 --- a/test_autogalaxy/config/notation.yaml +++ b/test_autogalaxy/config/notation.yaml @@ -25,6 +25,7 @@ label: intensity: I_{\rm b} kappa: \kappa kappa_s: \kappa_{\rm s} + mass: M mass_at_200: M_{\rm 200} mass_to_light_gradient: \Gamma mass_to_light_ratio: \Psi From e00863aca5e5ab91f1dc88c82c2165902b290bc3 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 12 May 2023 19:23:59 +0100 Subject: [PATCH 08/10] SMBH implemented --- autogalaxy/config/priors/mass/point/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 autogalaxy/config/priors/mass/point/__init__.py diff --git a/autogalaxy/config/priors/mass/point/__init__.py b/autogalaxy/config/priors/mass/point/__init__.py deleted file mode 100644 index e69de29bb..000000000 From 0d51682200e2b1bc2efe88f2aeb85a9492412d4a Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 12 May 2023 21:01:22 +0100 Subject: [PATCH 09/10] fix config prior --- autogalaxy/config/priors/mass/point/smbh.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogalaxy/config/priors/mass/point/smbh.yaml b/autogalaxy/config/priors/mass/point/smbh.yaml index 8dfb2a1db..8d871d0eb 100644 --- a/autogalaxy/config/priors/mass/point/smbh.yaml +++ b/autogalaxy/config/priors/mass/point/smbh.yaml @@ -25,8 +25,8 @@ SMBH: upper: inf mass: type: LogUniform - lower_limit: 1e6 - upper_limit: 1e13 + lower_limit: 1000000.0 + upper_limit: 10000000000000.0 width_modifier: type: Relative value: 0.25 From e67f1f16479af17a4af2f91cde85c6a9b41838f9 Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Sat, 13 May 2023 12:39:07 +0100 Subject: [PATCH 10/10] radiual grid config --- autogalaxy/config/grids.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/autogalaxy/config/grids.yaml b/autogalaxy/config/grids.yaml index 6d0b81683..f2425208c 100644 --- a/autogalaxy/config/grids.yaml +++ b/autogalaxy/config/grids.yaml @@ -56,4 +56,5 @@ radial_minimum: ShapeletPolarEll: 1.0e-8 ShapeletExponential: 1.0e-8 ShapeletExponentialEll: 1.0e-8 + SMBH: 1.0e-8 EllProfile: 1.0e-08