Skip to content

Commit 086dbea

Browse files
committed
- Major API refactor, creating structures for arrays as well as data.
Merge branch 'release/0.3.0'
2 parents 632ff22 + 3fc7b69 commit 086dbea

120 files changed

Lines changed: 8497 additions & 4583 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

autoarray/__init__.py

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,28 @@
1-
from autoarray.mask.mask import Mask as mask
2-
from autoarray.structures.arrays import Array as array, MaskedArray as masked_array
3-
from autoarray.structures.grids import (
4-
Grid as grid,
5-
MaskedGrid as masked_grid,
6-
IrregularGrid as irregular_grid,
7-
)
8-
from autoarray.structures.kernel import Kernel as kernel
9-
from autoarray.structures.visibilities import Visibilities as visibilities
101
from autoarray import conf
2+
from autoarray import exc
3+
from autoarray import masked
114
from autoarray import plotters as plot
5+
from autoarray import simulator
126
from autoarray import util
13-
from autoarray.data import data_converter
14-
from autoarray.data.imaging import Imaging as imaging
15-
from autoarray.data.imaging import SimulatedImaging
16-
from autoarray.data.interferometer import Interferometer as interferometer
17-
from autoarray.fit.fit import (
18-
DataFit as fit,
19-
ImagingFit as fit_imaging,
20-
InterferometerFit as fit_interferometer,
21-
)
22-
from autoarray.fit.masked_data import (
23-
MaskedImaging as masked_imaging,
24-
MaskedInterferometer as masked_interferometer,
25-
)
7+
from autoarray.dataset import data_converter
8+
from autoarray.dataset.imaging import Imaging as imaging
9+
from autoarray.dataset.interferometer import Interferometer as interferometer
10+
from autoarray.fit.fit import fit
2611
from autoarray.mask.mask import Mask as mask
27-
from autoarray.operators.convolution import Convolver as convolver
28-
from autoarray.operators.fourier_transform import Transformer as transformer
29-
from autoarray.operators.inversion import (
30-
pixelization_grids as pix_grid,
31-
pixelizations as pix,
32-
regularization as reg,
33-
mappers,
34-
inversions,
12+
from autoarray.operators.convolver import Convolver as convolver
13+
from autoarray.operators.inversion import pixelizations as pix, regularization as reg
14+
from autoarray.operators.inversion.inversions import inversion
15+
from autoarray.operators.inversion.mappers import mapper
16+
from autoarray.operators.transformer import Transformer as transformer
17+
from autoarray.structures.arrays import Array as array
18+
from autoarray.structures.grids import (
19+
Grid as grid,
20+
GridIrregular as grid_irregular,
21+
GridRectangular as grid_rectangular,
22+
GridVoronoi as grid_voronoi,
23+
Positions as positions,
3524
)
36-
from autoarray.structures.arrays import Array as array, MaskedArray as masked_array
37-
from autoarray.structures.grids import Grid as grid, MaskedGrid as masked_grid
3825
from autoarray.structures.kernel import Kernel as kernel
26+
from autoarray.structures.visibilities import Visibilities as visibilities
3927

40-
__version__ = '0.2.2'
28+
__version__ = '0.3.0'

autoarray/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
from copy import deepcopy
44

55

6+
def get_matplotlib_backend():
7+
try:
8+
return instance.visualize.get("figures", "backend", str)
9+
except Exception:
10+
return "TKAgg"
11+
12+
613
def family(current_class):
714
yield current_class
815
for next_class in current_class.__bases__:
Lines changed: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
import ast
21
import numpy as np
32

43
from autoarray.structures import arrays
54
from autoarray import exc
65

76

8-
class AbstractData(object):
7+
class AbstractDataset(object):
98
def __init__(self, data, noise_map, exposure_time_map=None):
109
"""A collection of abstract 2D for different data_type classes (an image, pixel-scale, noise-map, etc.)
1110
1211
Parameters
1312
----------
1413
data : arrays.Array
15-
The array of the image data_type, in units of electrons per second.
14+
The array of the image data_type, in unit_label of electrons per second.
1615
pixel_scales : float
1716
The size of each pixel in arc seconds.
1817
psf : PSF
1918
An array describing the PSF kernel of the image.
2019
noise_map : NoiseMap | float | ndarray
21-
An array describing the RMS standard deviation error in each pixel, preferably in units of electrons per
20+
An array describing the RMS standard deviation error in each pixel, preferably in unit_label of electrons per
2221
second.
2322
background_noise_map : NoiseMap
2423
An array describing the RMS standard deviation error in each pixel due to the background sky noise_map,
25-
preferably in units of electrons per second.
24+
preferably in unit_label of electrons per second.
2625
poisson_noise_map : NoiseMap
2726
An array describing the RMS standard deviation error in each pixel due to the Poisson counts of the source,
28-
preferably in units of electrons per second.
27+
preferably in unit_label of electrons per second.
2928
exposure_time_map : arrays.Array
3029
An array describing the effective exposure time in each imaging pixel.
3130
background_sky_map : aa.Scaled
@@ -82,7 +81,7 @@ def potential_chi_squared_max(self):
8281

8382
def array_from_electrons_per_second_to_counts(self, array):
8483
"""
85-
For an array (in electrons per second) and an exposure time mappers, return an array in units counts.
84+
For an array (in electrons per second) and an exposure time mappers, return an array in unit_label counts.
8685
8786
Parameters
8887
----------
@@ -93,7 +92,7 @@ def array_from_electrons_per_second_to_counts(self, array):
9392

9493
def array_from_counts_to_electrons_per_second(self, array):
9594
"""
96-
For an array (in counts) and an exposure time mappers, convert the array to units electrons per second
95+
For an array (in counts) and an exposure time mappers, convert the array to unit_label electrons per second
9796
9897
Parameters
9998
----------
@@ -107,7 +106,7 @@ def array_from_counts_to_electrons_per_second(self, array):
107106

108107
def array_from_adus_to_electrons_per_second(self, array, gain):
109108
"""
110-
For an array (in counts) and an exposure time mappers, convert the array to units electrons per second
109+
For an array (in counts) and an exposure time mappers, convert the array to unit_label electrons per second
111110
112111
Parameters
113112
----------
@@ -121,7 +120,7 @@ def array_from_adus_to_electrons_per_second(self, array, gain):
121120

122121
@property
123122
def image_counts(self):
124-
"""The image in units of counts."""
123+
"""The image in unit_label of counts."""
125124
return self.array_from_electrons_per_second_to_counts(self.data)
126125

127126

@@ -209,54 +208,3 @@ def load_exposure_time_map(
209208
return ExposureTimeMap.from_exposure_time_and_inverse_noise_map(
210209
exposure_time=exposure_time, inverse_noise_map=inverse_noise_map
211210
)
212-
213-
214-
def load_positions(positions_path):
215-
"""Load the positions of an image.
216-
217-
Positions correspond to a set of pixels in the lensed source galaxy that are anticipated to come from the same \
218-
multiply-imaged region of the source-plane. Mass models which do not trace the pixels within a threshold value of \
219-
one another are resampled during the non-linear search.
220-
221-
Positions are stored in a .dat file, where each line of the file gives a list of list of (y,x) positions which \
222-
correspond to the same region of the source-plane. Thus, multiple source-plane regions can be input over multiple \
223-
lines of the same positions file.
224-
225-
Parameters
226-
----------
227-
positions_path : str
228-
The path to the positions .dat file containing the positions (e.g. '/path/to/positions.dat')
229-
"""
230-
with open(positions_path) as f:
231-
position_string = f.readlines()
232-
233-
positions = []
234-
235-
for line in position_string:
236-
position_list = ast.literal_eval(line)
237-
positions.append(position_list)
238-
239-
return positions
240-
241-
242-
def output_positions(positions, positions_path):
243-
"""Output the positions of an image to a positions.dat file.
244-
245-
Positions correspond to a set of pixels in the lensed source galaxy that are anticipated to come from the same \
246-
multiply-imaged region of the source-plane. Mass models which do not trace the pixels within a threshold value of \
247-
one another are resampled during the non-linear search.
248-
249-
Positions are stored in a .dat file, where each line of the file gives a list of list of (y,x) positions which \
250-
correspond to the same region of the source-plane. Thus, multiple source-plane regions can be input over multiple \
251-
lines of the same positions file.
252-
253-
Parameters
254-
----------
255-
positions : [[[]]]
256-
The lists of positions (e.g. [[[1.0, 1.0], [2.0, 2.0]], [[3.0, 3.0], [4.0, 4.0]]])
257-
positions_path : str
258-
The path to the positions .dat file containing the positions (e.g. '/path/to/positions.dat')
259-
"""
260-
with open(positions_path, "w") as f:
261-
for position in positions:
262-
f.write("%s\n" % position)

0 commit comments

Comments
 (0)