Esempio n. 1
0
def make_label_config():

    print(directory, "config")

    config = conf.Config(path.join(directory, "config"),
                         output_path=path.join(directory, "output"))

    return config["notation"]["label"]
Esempio n. 2
0
def run(
    module, test_name=None, search=af.DynestyStatic(), config_folder="config", mask=None
):

    test_name = test_name or module.test_name
    test_path = "{}/../..".format(os.path.dirname(os.path.realpath(__file__)))
    output_path = f"{test_path}/output/imaging"
    config_path = f"{test_path}/{config_folder}"
    conf.instance = conf.Config(config_path=config_path, output_path=output_path)

    imaging = instrument_util.load_test_imaging(
        data_name=module.data_name, instrument=module.instrument
    )

    if mask is None:
        mask = al.Mask.circular(
            shape_2d=imaging.shape_2d, pixel_scales=imaging.pixel_scales, radius=3.0
        )

    info = {"Test": 100}

    module.make_pipeline(
        name=test_name, folders=[module.test_type, test_name], search=search
    ).run(dataset=imaging, mask=mask, info=info)
Esempio n. 3
0
# %%
from pyprojroot import here

workspace_path = str(here())
print("Workspace Path: ", workspace_path)

# %%
"""
Use this path to explicitly set the config path and output path.
"""

# %%
from autoconf import conf

conf.instance = conf.Config(
    config_path=f"{workspace_path}/config", output_path=f"{workspace_path}/output"
)

# %%
"""
__Data__

First, lets get data of a 1D Gaussian + 1D Exponential, by importing the 'autofit_workspace/complex/simulator.py' 
module, which  simulates the noisy data we fit (check it out to see how we simulate the data).
"""

# %%
from autofit_workspace.examples.complex import simulator

data = simulator.data
noise_map = simulator.noise_map
Esempio n. 4
0
extra 5-7, parameters. If there are 4 components, or multiple _Galaxy_'s we're quickly entering the somewhat nasty
regime of 30-40+ parameters in our non-linear search. Even with a pipeline, that is a lot of parameters to fit!
"""

# %%
""" AUTOFIT + CONFIG SETUP """

# %%
from autoconf import conf
from pyprojroot import here

workspace_path = str(here())
print("Workspace Path: ", workspace_path)

conf.instance = conf.Config(
    config_path=f"{workspace_path}/howtolens/config",
    output_path=f"{workspace_path}/howtolens/output",
)

# %%
#%matplotlib inline

import autolens as al
import autolens.plot as aplt

# %%
"""
We'll use new strong lensing data, where:

 - The lens galaxy's light is omitted.
 - The lens galaxy's _MassProfile_ is an _EllipticalIsothermal_.
 - The source galaxy's _LightProfile_ is four _EllipticalSersic_'s.
Esempio n. 5
0
def make_config(files_directory):
    return conf.Config(
        files_directory / "config",
        files_directory / "default",
    )
"""

# %%
#%matplotlib inline

from autoconf import conf
import autofit as af
from pyprojroot import here

workspace_path = str(here())
print("Workspace Path: ", workspace_path)


# %%
conf.instance = conf.Config(
    config_path=f"{workspace_path}/howtofit/config",
    output_path=f"{workspace_path}/howtofit/output",  # <- This sets up where the non-linear search's outputs go.
)

# %%
"""
First, checkout the file 

 'autofit_workspace/howtofit/chapter_1_introduction/tutorial_4_source_code/src/__init__.py

Here, we have added imports to this file allowing us to import the entire project in one go, which we do below,
importing it as 'htf'. 

Many software projects tend not to do this, instead relying on the user explicitly importing every module in the 
project that need, for example:

 from tutorial_4_source_code.src.dataset.dataset import Dataset
print("Workspace Path: ", workspace_path)

# %%
"""
You're going to see a line like the one below (with 'conf.instance =') in every tutorial this chapter. This sets the
following property:

 - The path to the configuration files used by PyAutoFit. You need to give the path to your autofit_workspace, so 
 the configuration files in the workspace are used (e.g. '/path/to/autolens_workspace/config'). 

(These will work autommatically if the WORKSPACE environment variable was set up correctly during installation. 
Nevertheless, setting the paths explicitly within the code is good practise.
"""

# %%
conf.instance = conf.Config(config_path=f"{workspace_path}/howtofit/config")

# %%
"""
Below, you'll notice the command:

 'from autofit_workspace.howtofit.simulators.chapter_1.gaussian_x1'

This will crop up in nearly every tutorial from here on. This imports a module that simulates the dataset we plot in
this tutorialt. Feel free to check out the simulator scripts to see how this is done!

 - The data is a 1D numpy array of values corresponding to the observed counts of the Gaussian.
 - The noise-map corresponds to the expected noise in every data point.
"""

# %%
Esempio n. 8
0
def set_config_path():
    conf.instance = conf.Config(
        path.join(directory, "..", "config"),
        path.join(directory, "..", "pipeline", "output"),
    )
    return conf.instance
Esempio n. 9
0
def set_config_path():
    conf.instance = conf.Config(config_path=path.join(directory, "config"), )
Esempio n. 10
0
def make_label_config():

    config = conf.Config(path.join(directory, "config"),
                         path.join(directory, "default"))

    return config["notation"]["label"]
Esempio n. 11
0
It takes a while to correct a full image, so a small patch far from the readout 
register (where CTI has the most effect) is used for this example.
"""

import arcticpy as ac
import os
from autoconf import conf
import matplotlib.pyplot as plt
import numpy as np

# Path to this file
path = os.path.dirname(os.path.realpath(__file__))

# Set up some configuration options for the automatic fits dataset loading
conf.instance = conf.Config(config_path=f"{path}/config")

# Load the HST ACS dataset
path += "/acs"
name = "jc0a01h8q_raw"
frame = ac.acs.FrameACS.from_fits(file_path=f"{path}/{name}.fits",
                                  quadrant_letter="A")

# Extract an example patch of a few rows and columns, offset far from readout
row_start, row_end, column_start, column_end = -70, -40, -205, -190
row_offset = len(frame) + row_start
frame = frame[row_start:row_end, column_start:column_end]
frame.mask = frame.mask[row_start:row_end, column_start:column_end]

# Plot the initial image
plt.figure()
Esempio n. 12
0
def set_config_path():
    conf.instance = conf.Config(path.join(directory, "unit/config"),
                                path.join(directory, "output"))
cosma_output_path = path.join(cosma_path, "output")

# %%
"""In contrast to the dataset and output folders, our workspace path is in your COSMA home directory.."""
workspace_path = "/cosma/home/dp004/cosma_username/autolens_workspace/"

"""Use this to set the path to the cosma config files in your COSMA home directory.r"""
config_path = f"cosma/config"

# %%
"""Set the config and output paths using autoconf, as you would for a laptop run."""

# %%
from autoconf import conf

conf.instance = conf.Config(config_path=f"config", output_path=f"output")

"""
Cosma submissions require a`batch script`, which tells Cosma the PyAutoLens runners you want it to execute and 
distributes them to nodes and CPUs. Lets look at the batch script 

 `autolens_workspace/cosma/batch/example
    
The following options are worth noting:

 `#SBATCH -N 1` - The number of nodes we require, where 1 node contains 28 CPUs.
 `#SBATCH --ntasks=16` - The total number of task we are submitting.
 `#SBATCH --cpus-per-task=1` - The number of tasks per CPU, this should always be 1 for PyAutoLens use.
 `#SBATCH -J example` - The name of the job, which is how it`ll appear on cosma when you inspect it.
 `#SBATCH -o output/output.%A.out` - Python interpreter output is placed in a file in the `output` folder.
 `#SBATCH -o error/error.%A.out` - Python interpreter errors are placed in a file in the `error` folder.
Esempio n. 14
0
def set_config_path():
    conf.instance = conf.Config(
        path.join(directory, "config"), path.join(directory, "pipeline/output")
    )
Esempio n. 15
0
dataset_name = "_".join((
    str(sersic_elliptical_comps),
    str(NFW_mass),
    str(einstein_radius),
    str(source_centre),
    str(source_elliptical_comps),
    str(source_radius),
))

save_path = (
    "/home/matthew/Durham2020/MyScripts/autolens_tools/ExampleData/NFW_sersic/"
    + dataset_name + "/")

conf.instance = conf.Config(
    config_path=f"{workspace_path}config/",
    output_path=save_path,
)

if not os.path.exists(save_path):
    os.makedirs(save_path)

# Script
import autolens as al
import autolens.plot as aplt
import datetime
from scipy.optimize import fsolve

print("Generating:")
print(datetime.datetime.now())

redshift_lens = 0.5
Esempio n. 16
0
def set_config_path():
    conf.instance = conf.Config(
        os.path.join(directory, "files/plotter"), os.path.join(directory, "output")
    )
Esempio n. 17
0
def test_missing_logging_config(files_directory):
    config = conf.Config(files_directory / "no_logging", )
    config.push(new_path=files_directory / "no_logging")