Skip to content

Commit 61bc511

Browse files
committed
merge
2 parents 64d16b6 + bb30c04 commit 61bc511

36 files changed

Lines changed: 2183 additions & 1162 deletions

autoarray/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@
8888
from .structures.visibilities import VisibilitiesNoiseMap
8989

9090
from autoconf import conf
91+
from autoconf.fitsable import ndarray_via_hdu_from
92+
from autoconf.fitsable import ndarray_via_fits_from
93+
from autoconf.fitsable import header_obj_from
94+
from autoconf.fitsable import output_to_fits
95+
from autoconf.fitsable import hdu_list_for_output_from
9196

9297
conf.instance.register(__file__)
9398

autoarray/abstract_ndarray.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
from abc import ABC
66
from abc import abstractmethod
77

8+
from autoconf.fitsable import output_to_fits
9+
810
from autoarray.numpy_wrapper import np, register_pytree_node, Array
911

1012
from typing import TYPE_CHECKING
1113

1214
if TYPE_CHECKING:
1315
from autoarray.structures.abstract_structure import Structure
1416

15-
from autoarray.structures.arrays import array_2d_util
1617
from autoconf import conf
1718

1819

@@ -279,8 +280,11 @@ def output_to_fits(self, file_path: str, overwrite: bool = False):
279280
overwrite
280281
If a file already exists at the path, if overwrite=True it is overwritten else an error is raised.
281282
"""
282-
array_2d_util.numpy_array_2d_to_fits(
283-
array_2d=self.native.array, file_path=file_path, overwrite=overwrite
283+
output_to_fits(
284+
values=self.native.array,
285+
file_path=file_path,
286+
overwrite=overwrite,
287+
header_dict=self.mask.header_dict,
284288
)
285289

286290
@property

autoarray/dataset/imaging/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def __init__(
108108
kernel_shape=psf.shape_native, mask_pad_value=1
109109
)
110110
)
111-
print(over_sample_size_lp.shape_native)
111+
112112
over_sample_size_pixelization = (
113113
over_sample_util.over_sample_size_convert_to_array_2d_from(
114114
over_sample_size=over_sample_size_pixelization, mask=data.mask

autoarray/dataset/interferometer/dataset.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
from astropy.io import fits
12
import logging
23
import numpy as np
3-
from typing import Optional
4+
from pathlib import Path
45

56
from autoconf import cached_property
7+
from autoconf.fitsable import ndarray_via_fits_from, output_to_fits
68

79
from autoarray.dataset.abstract.dataset import AbstractDataset
810
from autoarray.dataset.interferometer.w_tilde import WTildeInterferometer
@@ -12,7 +14,7 @@
1214
from autoarray.structures.visibilities import Visibilities
1315
from autoarray.structures.visibilities import VisibilitiesNoiseMap
1416

15-
from autoarray.structures.arrays import array_2d_util
17+
from autoarray.inversion.inversion.interferometer import inversion_interferometer_util
1618

1719
logger = logging.getLogger(__name__)
1820

@@ -25,6 +27,7 @@ def __init__(
2527
uv_wavelengths: np.ndarray,
2628
real_space_mask,
2729
transformer_class=TransformerNUFFT,
30+
preprocessing_directory=None,
2831
):
2932
"""
3033
An interferometer dataset, containing the visibilities data, noise-map, real-space msk, Fourier transformer and
@@ -86,6 +89,12 @@ def __init__(
8689
uv_wavelengths=uv_wavelengths, real_space_mask=real_space_mask
8790
)
8891

92+
self.preprocessing_directory = (
93+
Path(preprocessing_directory)
94+
if preprocessing_directory is not None
95+
else None
96+
)
97+
8998
@cached_property
9099
def grids(self):
91100
return GridsDataset(
@@ -120,7 +129,7 @@ def from_fits(
120129
file_path=noise_map_path, hdu=noise_map_hdu
121130
)
122131

123-
uv_wavelengths = array_2d_util.numpy_array_2d_via_fits_from(
132+
uv_wavelengths = ndarray_via_fits_from(
124133
file_path=uv_wavelengths_path, hdu=uv_wavelengths_hdu
125134
)
126135

@@ -132,6 +141,23 @@ def from_fits(
132141
transformer_class=transformer_class,
133142
)
134143

144+
def w_tilde_preprocessing(self):
145+
if self.preprocessing_directory.is_dir():
146+
filename = "{}/curvature_preload.fits".format(self.preprocessing_directory)
147+
148+
if not self.preprocessing_directory.isfile(filename):
149+
print("The file {} does not exist".format(filename))
150+
logger.info("INTERFEROMETER - Computing W-Tilde... May take a moment.")
151+
152+
curvature_preload = inversion_interferometer_util.w_tilde_curvature_preload_interferometer_from(
153+
noise_map_real=self.noise_map.real,
154+
uv_wavelengths=self.uv_wavelengths,
155+
shape_masked_pixels_2d=self.transformer.grid.mask.shape_native_masked_pixels,
156+
grid_radians_2d=self.transformer.grid.mask.unmasked_grid_sub_1.in_radians.native,
157+
)
158+
159+
fits.writeto(filename, data=curvature_preload)
160+
135161
@cached_property
136162
def w_tilde(self):
137163
"""
@@ -152,10 +178,8 @@ def w_tilde(self):
152178

153179
logger.info("INTERFEROMETER - Computing W-Tilde... May take a moment.")
154180

155-
from autoarray.inversion.inversion import inversion_util_secret
156-
157181
curvature_preload = (
158-
inversion_util_secret.w_tilde_curvature_preload_interferometer_from(
182+
inversion_interferometer_util.w_tilde_curvature_preload_interferometer_from(
159183
noise_map_real=np.array(self.noise_map.real),
160184
uv_wavelengths=np.array(self.uv_wavelengths),
161185
shape_masked_pixels_2d=np.array(
@@ -167,7 +191,7 @@ def w_tilde(self):
167191
)
168192
)
169193

170-
w_matrix = inversion_util_secret.w_tilde_via_preload_from(
194+
w_matrix = inversion_interferometer_util.w_tilde_via_preload_from(
171195
w_tilde_preload=curvature_preload,
172196
native_index_for_slim_index=self.real_space_mask.derive_indexes.native_for_slim,
173197
)
@@ -245,8 +269,8 @@ def output_to_fits(
245269
self.noise_map.output_to_fits(file_path=noise_map_path, overwrite=overwrite)
246270

247271
if self.uv_wavelengths is not None and uv_wavelengths_path is not None:
248-
array_2d_util.numpy_array_2d_to_fits(
249-
array_2d=self.uv_wavelengths,
272+
output_to_fits(
273+
values=self.uv_wavelengths,
250274
file_path=uv_wavelengths_path,
251275
overwrite=overwrite,
252276
)

autoarray/inversion/inversion/factory.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,6 @@ def inversion_interferometer_from(
186186
-------
187187
An `Inversion` whose type is determined by the input `dataset` and `settings`.
188188
"""
189-
try:
190-
from autoarray.inversion.inversion import inversion_util_secret
191-
except ImportError:
192-
settings.use_w_tilde = False
193-
194189
if any(
195190
isinstance(linear_obj, AbstractLinearObjFuncList)
196191
for linear_obj in linear_obj_list

0 commit comments

Comments
 (0)