Skip to content

Commit

Permalink
improve linear exceptipon
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Nov 17, 2023
1 parent fe8edcf commit d6e9f99
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
36 changes: 27 additions & 9 deletions autogalaxy/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
"""
)
2 changes: 1 addition & 1 deletion autogalaxy/galaxy/plot/galaxy_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/plane/plot/plane_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/profiles/plot/light_profile_plotters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d6e9f99

Please sign in to comment.