From d6e9f99d9f380ef001c9356a82db44afc0fc23df Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Fri, 17 Nov 2023 18:58:53 +0000 Subject: [PATCH] improve linear exceptipon --- autogalaxy/exc.py | 36 ++++++++++++++----- autogalaxy/galaxy/plot/galaxy_plotters.py | 2 +- autogalaxy/plane/plot/plane_plotters.py | 2 +- .../profiles/plot/light_profile_plotters.py | 2 +- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/autogalaxy/exc.py b/autogalaxy/exc.py index 3d4e9b38b..279a569a0 100644 --- a/autogalaxy/exc.py +++ b/autogalaxy/exc.py @@ -83,21 +83,39 @@ def raise_linear_light_profile_in_unmasked(): ) -def raise_linear_light_profile_in_plot(plotter_type: str, model_obj: str): +def raise_linear_light_profile_in_plot( + plotter_type: str, +): raise ProfileException( f""" - A linear light profile (inherits from `LightProfileLinear` class) has - been passed to the `{plotter_type}`. + A linear light profile has been passed to the `{plotter_type}`. Linear light profiles cannot be plotted, because they do not have an intensity value. - Therefore convert all linear light profiles to normal light profiles. + Therefore convert all linear light profiles to normal light profiles + with intensity values. - If you are performing modeling and have access to `FitImaging` - or `FitInterferometer` object, a `{model_obj}` where all - linear light are converted to regular light profiles using the - solved for intensities is available via the attribute - `{model_obj.lower()}_linear_light_profiles_to_light_profiles`. + The easiest way to do this is to create a`FitImaging` + or `FitInterferometer` object. This will contain a property + where all linear light have been converted to regular light profiles + using the solved for intensities. + + If you are using PyAutoLens, you should use the attribute + `fit.tracer_linear_light_profiles_to_light_profiles` to access a + `Tracer` with these converted light profiles. + + If you are using PyAutoGalaxy, you should instead use + `fit.plane_linear_light_profiles_to_light_profiles` to access a + `Plane` with these converted light profiles. + + If you are using database functionality and creating tracers + via the `TracerAgg` object or `PlaneAgg` object, you should + instead use the `FitImagingAgg` object to create `FitImaging` + objects. + + You should then access what you need via + `fit.tracer_linear_light_profiles_to_light_profiles` or + `fit.plane_linear_light_profiles_to_light_profiles`. """ ) diff --git a/autogalaxy/galaxy/plot/galaxy_plotters.py b/autogalaxy/galaxy/plot/galaxy_plotters.py index 654e64917..003f6767f 100644 --- a/autogalaxy/galaxy/plot/galaxy_plotters.py +++ b/autogalaxy/galaxy/plot/galaxy_plotters.py @@ -80,7 +80,7 @@ def __init__( if galaxy is not None: if galaxy.has(cls=LightProfileLinear): raise exc.raise_linear_light_profile_in_plot( - plotter_type=self.__class__.__name__, model_obj="Plane" + plotter_type=self.__class__.__name__, ) super().__init__( diff --git a/autogalaxy/plane/plot/plane_plotters.py b/autogalaxy/plane/plot/plane_plotters.py index ee4b6ad41..2c9cc9559 100644 --- a/autogalaxy/plane/plot/plane_plotters.py +++ b/autogalaxy/plane/plot/plane_plotters.py @@ -68,7 +68,7 @@ def __init__( if plane.has(cls=LightProfileLinear): raise exc.raise_linear_light_profile_in_plot( - plotter_type=self.__class__.__name__, model_obj="Plane" + plotter_type=self.__class__.__name__, ) super().__init__( diff --git a/autogalaxy/profiles/plot/light_profile_plotters.py b/autogalaxy/profiles/plot/light_profile_plotters.py index 97dad602c..f4d37f8f8 100644 --- a/autogalaxy/profiles/plot/light_profile_plotters.py +++ b/autogalaxy/profiles/plot/light_profile_plotters.py @@ -69,7 +69,7 @@ def __init__( if isinstance(light_profile, LightProfileLinear): raise exc.raise_linear_light_profile_in_plot( - plotter_type=self.__class__.__name__, model_obj="Plane" + plotter_type=self.__class__.__name__, ) self.light_profile = light_profile