diff --git a/autoarray/__init__.py b/autoarray/__init__.py index 9722a5d45..7ca26e4b9 100644 --- a/autoarray/__init__.py +++ b/autoarray/__init__.py @@ -10,10 +10,10 @@ from .dataset.abstract.settings import AbstractSettingsDataset from .dataset.abstract.w_tilde import AbstractWTilde from .dataset.imaging.settings import SettingsImaging -from .dataset.imaging.imaging import Imaging +from .dataset.imaging.dataset import Imaging from .dataset.imaging.simulator import SimulatorImaging from .dataset.imaging.w_tilde import WTildeImaging -from .dataset.interferometer.interferometer import Interferometer +from .dataset.interferometer.dataset import Interferometer from .dataset.interferometer.settings import SettingsInterferometer from .dataset.interferometer.simulator import SimulatorInterferometer from .dataset.interferometer.w_tilde import WTildeInterferometer diff --git a/autoarray/dataset/imaging/imaging.py b/autoarray/dataset/imaging/dataset.py similarity index 100% rename from autoarray/dataset/imaging/imaging.py rename to autoarray/dataset/imaging/dataset.py diff --git a/autoarray/dataset/imaging/simulator.py b/autoarray/dataset/imaging/simulator.py index 7cb41a597..9edf0eda6 100644 --- a/autoarray/dataset/imaging/simulator.py +++ b/autoarray/dataset/imaging/simulator.py @@ -1,7 +1,7 @@ import logging import numpy as np -from autoarray.dataset.imaging.imaging import Imaging +from autoarray.dataset.imaging.dataset import Imaging from autoarray.structures.arrays.uniform_2d import Array2D from autoarray.structures.arrays.kernel_2d import Kernel2D from autoarray.mask.mask_2d import Mask2D @@ -19,28 +19,38 @@ def __init__( background_sky_level: float = 0.0, psf: Kernel2D = None, normalize_psf: bool = True, - read_noise: float = None, add_poisson_noise: bool = True, noise_if_add_noise_false: float = 0.1, noise_seed: int = -1, ): """ - A class representing a Imaging observation, using the shape of the image, the pixel scale, - psf, exposure time, etc. + Simulations observations of imaging data, including simulation of the image, noise-map, PSF, etc. as + an `Imaging` object. + + The simulation of an `Imaging` dataset uses the following steps: + + 1) Receive as input the raw image which is simulated via the steps below. + 2) Convolve the image with the Point Spread Function of the simulated dataset. + 3) Use input values of the background sky level in every pixel of the image to add the background sky to + the PSF convolved image. + 4) Add Poisson noise to the image, which represents noise due to whether photons hits the CCD and are converted + to photo-electrons which are succcessfully detected by the CCD and converted to counts. + 5) Subtract the background sky from the image, so that the returned simulated dataset is background sky + subtracted. + + The inputs of the `SimulatorImaging` object can toggle these steps on and off, for example if `psf=None` the + PSF convolution step is omitted. Parameters ---------- - psf : Kernel2D - An arrays describing the PSF kernel of the image. exposure_time The exposure time of the simulated imaging. background_sky_level The level of the background sky of the simulated imaging. + psf + An array describing the PSF kernel of the image. normalize_psf If `True`, the PSF kernel is normalized so all values sum to 1.0. - read_noise - The level of read-noise added to the simulated imaging by drawing from a Gaussian distribution with - sigma equal to the value `read_noise`. add_poisson_noise Whether Poisson noise corresponding to photon count statistics on the imaging observation is added. noise_if_add_noise_false @@ -60,19 +70,21 @@ def __init__( self.exposure_time = exposure_time self.background_sky_level = background_sky_level - self.read_noise = read_noise self.add_poisson_noise = add_poisson_noise self.noise_if_add_noise_false = noise_if_add_noise_false self.noise_seed = noise_seed - def via_image_from(self, image: Array2D): + def via_image_from(self, image: Array2D) -> Imaging: """ - Returns a realistic simulated image by applying effects to a plain simulated image. + Simulate an `Imaging` dataset from an input image. + + The steps of the `SimulatorImaging` simulation process (e.g. PSF convolution, noise addition) are + described in the `SimulatorImaging` `__init__` method docstring. Parameters ---------- image - The image before simulating which has noise added, PSF convolution, etc performed to it. + The 2D image from which the Imaging dataset is simulated. """ exposure_time_map = Array2D.full( diff --git a/autoarray/dataset/interferometer/interferometer.py b/autoarray/dataset/interferometer/dataset.py similarity index 100% rename from autoarray/dataset/interferometer/interferometer.py rename to autoarray/dataset/interferometer/dataset.py diff --git a/autoarray/dataset/interferometer/simulator.py b/autoarray/dataset/interferometer/simulator.py index ccea2d869..396cbfaca 100644 --- a/autoarray/dataset/interferometer/simulator.py +++ b/autoarray/dataset/interferometer/simulator.py @@ -1,6 +1,6 @@ import numpy as np -from autoarray.dataset.interferometer.interferometer import Interferometer +from autoarray.dataset.interferometer.dataset import Interferometer from autoarray.operators.transformer import TransformerDFT from autoarray.structures.visibilities import VisibilitiesNoiseMap diff --git a/autoarray/dataset/plot/imaging_plotters.py b/autoarray/dataset/plot/imaging_plotters.py index b7dab6f6a..ff4661453 100644 --- a/autoarray/dataset/plot/imaging_plotters.py +++ b/autoarray/dataset/plot/imaging_plotters.py @@ -5,7 +5,7 @@ from autoarray.plot.mat_plot.two_d import MatPlot2D from autoarray.plot.auto_labels import AutoLabels from autoarray.plot.abstract_plotters import Plotter -from autoarray.dataset.imaging.imaging import Imaging +from autoarray.dataset.imaging.dataset import Imaging class ImagingPlotterMeta(Plotter): diff --git a/autoarray/dataset/plot/interferometer_plotters.py b/autoarray/dataset/plot/interferometer_plotters.py index 3c57cc97c..f41c27758 100644 --- a/autoarray/dataset/plot/interferometer_plotters.py +++ b/autoarray/dataset/plot/interferometer_plotters.py @@ -6,7 +6,7 @@ from autoarray.plot.mat_plot.one_d import MatPlot1D from autoarray.plot.mat_plot.two_d import MatPlot2D from autoarray.plot.auto_labels import AutoLabels -from autoarray.dataset.interferometer.interferometer import Interferometer +from autoarray.dataset.interferometer.dataset import Interferometer from autoarray.structures.grids.irregular_2d import Grid2DIrregular diff --git a/autoarray/fit/fit_imaging.py b/autoarray/fit/fit_imaging.py index 7a189b2d4..145fe9e95 100644 --- a/autoarray/fit/fit_imaging.py +++ b/autoarray/fit/fit_imaging.py @@ -1,6 +1,6 @@ from typing import Dict, Optional -from autoarray.dataset.imaging.imaging import Imaging +from autoarray.dataset.imaging.dataset import Imaging from autoarray.fit.fit_dataset import FitDataset from autoarray.mask.mask_2d import Mask2D from autoarray.structures.arrays.uniform_2d import Array2D diff --git a/autoarray/fit/fit_interferometer.py b/autoarray/fit/fit_interferometer.py index c9964ddf1..20f21b0c9 100644 --- a/autoarray/fit/fit_interferometer.py +++ b/autoarray/fit/fit_interferometer.py @@ -1,7 +1,7 @@ import numpy as np from typing import Dict, Optional, Union -from autoarray.dataset.interferometer.interferometer import Interferometer +from autoarray.dataset.interferometer.dataset import Interferometer from autoarray.structures.arrays.uniform_2d import Array2D from autoarray.structures.visibilities import Visibilities from autoarray.fit.fit_dataset import FitDataset diff --git a/autoarray/inversion/inversion/factory.py b/autoarray/inversion/inversion/factory.py index 0cc666ea2..10e4b470a 100644 --- a/autoarray/inversion/inversion/factory.py +++ b/autoarray/inversion/inversion/factory.py @@ -1,6 +1,6 @@ from typing import Dict, List, Optional, Union -from autoarray.dataset.imaging.imaging import Imaging +from autoarray.dataset.imaging.dataset import Imaging from autoarray.dataset.imaging.w_tilde import WTildeImaging from autoarray.dataset.interferometer.w_tilde import WTildeInterferometer from autoarray.structures.arrays.uniform_2d import Array2D diff --git a/autoarray/plot/wrap/base/ticks.py b/autoarray/plot/wrap/base/ticks.py index 70a208428..869fd343c 100644 --- a/autoarray/plot/wrap/base/ticks.py +++ b/autoarray/plot/wrap/base/ticks.py @@ -387,10 +387,7 @@ def set( ) if is_log10: - if not is_log10: - plt.ylim(min_value, max_value) - else: - plt.ylim(max(min_value, 1e-3), max_value) + plt.ylim(max(min_value, 1e-3), max_value) if not is_for_1d_plot and not units.use_scaled: labels = reversed(labels) diff --git a/autoarray/plot/wrap/one_d/yx_plot.py b/autoarray/plot/wrap/one_d/yx_plot.py index 8adc8243a..a2352e11a 100644 --- a/autoarray/plot/wrap/one_d/yx_plot.py +++ b/autoarray/plot/wrap/one_d/yx_plot.py @@ -73,8 +73,6 @@ def plot_y_vs_x( # ls=ls_errorbar, **self.config_dict ) - if y_extra is not None: - plt.plot(x, y_extra, c="r") if plot_axis_type == "errorbar_logy": plt.yscale("log") else: @@ -82,3 +80,6 @@ def plot_y_vs_x( "The plot_axis_type supplied to the plotter is not a valid string (must be linear " "{semilogy, loglog})" ) + + if y_extra is not None: + plt.plot(x, y_extra, c="r") \ No newline at end of file