diff --git a/autogalaxy/aggregator/abstract.py b/autogalaxy/aggregator/abstract.py index 0871fb07b..c42a250d7 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 9eb782078..44a47a151 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. @@ -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. @@ -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..ac191003a 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. @@ -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. @@ -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..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). @@ -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") @@ -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. @@ -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..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, @@ -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..75e4b3bca 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. @@ -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. @@ -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/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/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/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 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/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..8d871d0eb --- /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: 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 + upper: inf \ No newline at end of file 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/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/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 new file mode 100644 index 000000000..b94b0850f --- /dev/null +++ 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/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/autogalaxy/profiles/mass/point/smbh.py b/autogalaxy/profiles/mass/point/smbh.py new file mode 100644 index 000000000..0a92246bb --- /dev/null +++ b/autogalaxy/profiles/mass/point/smbh.py @@ -0,0 +1,50 @@ +import numpy as np +from typing import Tuple + +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/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: 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/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 diff --git a/test_autogalaxy/legacy/test_model_util.py b/test_autogalaxy/legacy/test_model_util.py index 56d223e74..4d3c393b6 100644 --- a/test_autogalaxy/legacy/test_model_util.py +++ b/test_autogalaxy/legacy/test_model_util.py @@ -126,213 +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 - - -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, - ) 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 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)