Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/point smbh #98

Merged
merged 10 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions autogalaxy/aggregator/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/aggregator/fit_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -99,15 +99,15 @@ 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.

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.

Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/aggregator/fit_interferometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -95,15 +95,15 @@ 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.

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.

Expand Down
8 changes: 4 additions & 4 deletions autogalaxy/aggregator/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ 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).

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")
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/aggregator/interferometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/aggregator/plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -62,15 +62,15 @@ 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.

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.

Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions autogalaxy/analysis/model_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/analysis/preloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/config/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions autogalaxy/config/grids.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions autogalaxy/config/notation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,6 +58,7 @@ label:
ExternalShear: ext
Mesh: mesh
Point: point
SMBH: smbh
Redshift: z
Regularization: reg
HyperBackgroundNoise: hyper
Expand Down
55 changes: 55 additions & 0 deletions autogalaxy/config/priors/mass/point/smbh.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions autogalaxy/cosmology/lensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/imaging/model/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:

Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/interferometer/model/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:

Expand Down
Loading