How to use autofit - 10 common examples

To help you get started, we’ve selected a few autofit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jammy2211 / PyAutoLens / test / pipeline / test_phase_property.py View on Github external
import os

import pytest
from autofit import conf
from autofit.core import model_mapper as mm
from autofit.core import non_linear

from autolens.model.galaxy import galaxy as g, galaxy_model as gp
from autolens.pipeline import phase as ph
from autolens.pipeline import phase_property

directory = os.path.dirname(os.path.realpath(__file__))

conf.instance = conf.Config("{}/../../workspace/config".format(directory),
                            "{}/../../workspace/output/".format(directory))


class NLO(non_linear.NonLinearOptimizer):
    def fit(self, analysis):
        class Fitness(object):
            def __init__(self, instance_from_physical_vector, constant):
                self.result = None
                self.instance_from_physical_vector = instance_from_physical_vector
                self.constant = constant

            def __call__(self, vector):
                instance = self.instance_from_physical_vector(vector)
                for key, value in self.constant.__dict__.items():
                    setattr(instance, key, value)
github Jammy2211 / PyAutoLens / test / unit / model / profiles / test_geometry_profiles.py View on Github external
def do_something():
    af.conf.instance = af.conf.Config(
        config_path="{}/../../test_files/config/radial_min".format(directory)
    )
github Jammy2211 / PyAutoLens / test_autolens / unit / model / profiles / test_light_profiles.py View on Github external
def reset_config():
    """
    Use configuration from the default path. You may want to change this to set a specific path.
    """
    af.conf.instance = af.conf.default
github Jammy2211 / PyAutoLens / test / unit / model / galaxy / test_galaxy_model.py View on Github external
def do_something():
    af.conf.instance = af.conf.Config(
        "{}/../../test_files/config/galaxy_model".format(
            os.path.dirname(os.path.realpath(__file__))
        )
github Jammy2211 / PyAutoLens / test / unit / pipeline / phase / test_phase_imaging.py View on Github external
def do_something():
    af.conf.instance = af.conf.Config(
        "{}/../test_files/config/phase_imaging_7x7".format(directory)
    )
github Jammy2211 / PyAutoLens / test_autolens / unit / plot / test_fit_imaging_plots.py View on Github external
def set_config_path():
    conf.instance = conf.Config(
        path.join(directory, "files/plotter"), path.join(directory, "output")
    )
github Jammy2211 / PyAutoLens / test / unit / pipeline / phase / test_phase_imaging.py View on Github external
def clean_images():
    try:
        os.remove("{}/source_lens_phase/source_image_0.fits".format(directory))
        os.remove("{}/source_lens_phase/lens_image_0.fits".format(directory))
        os.remove("{}/source_lens_phase/model_image_0.fits".format(directory))
    except FileNotFoundError:
        pass
    af.conf.instance.data_path = directory
github Jammy2211 / PyAutoLens / test / unit / pipeline / phase / test_phase.py View on Github external
def do_something():
    af.conf.instance = af.conf.Config(
        "{}/../test_files/config/phase_imaging_7x7".format(directory)
    )
github Jammy2211 / PyAutoLens / test_autolens / unit / model / profiles / test_geometry_profiles.py View on Github external
def do_something():
    af.conf.instance = af.conf.Config(
        config_path="{}/../../test_files/config/radial_min".format(directory)
    )
github Jammy2211 / PyAutoLens / test / unit / model / galaxy / test_galaxy_model.py View on Github external
mass_profile=al.mass_profiles.SphericalIsothermal,
        )

        redshift_prior = af.GaussianPrior(1, 1)
        einstein_radius_prior = af.GaussianPrior(4, 1)
        intensity_prior = af.GaussianPrior(7, 1)

        arguments = {
            galaxy_model.redshift.redshift: redshift_prior,
            galaxy_model.mass_profile.mask_centre.centre_0: af.GaussianPrior(2, 1),
            galaxy_model.mass_profile.mask_centre.centre_1: af.GaussianPrior(3, 1),
            galaxy_model.mass_profile.einstein_radius.value: einstein_radius_prior,
            galaxy_model.light_profile.axis_ratio: af.GaussianPrior(5, 1),
            galaxy_model.light_profile.phi: af.GaussianPrior(6, 1),
            galaxy_model.light_profile.intensity.value: intensity_prior,
            galaxy_model.light_profile.effective_radius.value: af.GaussianPrior(8, 1),
            galaxy_model.light_profile.sersic_index: af.GaussianPrior(9, 1),
        }

        gaussian_galaxy_model_model = galaxy_model.gaussian_prior_model_for_arguments(
            arguments
        )

        assert gaussian_galaxy_model_model.redshift.redshift == redshift_prior
        assert (
            gaussian_galaxy_model_model.mass_profile.einstein_radius.value
            == einstein_radius_prior
        )
        assert (
            gaussian_galaxy_model_model.light_profile.intensity.value == intensity_prior
        )