-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfit_interferometer_plots.py
More file actions
197 lines (180 loc) · 5.14 KB
/
fit_interferometer_plots.py
File metadata and controls
197 lines (180 loc) · 5.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import numpy as np
from typing import Optional
import matplotlib.pyplot as plt
from autoarray.plot.array import plot_array
from autoarray.plot.yx import plot_yx
from autoarray.plot.utils import subplot_save, symmetric_vmin_vmax, hide_unused_axes
def subplot_fit_interferometer(
fit,
output_path: Optional[str] = None,
output_filename: str = "subplot_fit",
output_format: str = "png",
colormap=None,
use_log10: bool = False,
residuals_symmetric_cmap: bool = True,
):
"""
2×3 subplot of ``FitInterferometer`` residuals in UV-plane.
Panels (real then imaginary): Residual Map | Norm Residual Map | Chi-Squared Map
Parameters
----------
fit
A ``FitInterferometer`` instance.
output_path
Directory to save the figure. ``None`` calls ``plt.show()``.
output_filename
Base filename without extension.
output_format
File format.
colormap
Matplotlib colormap name.
use_log10
Apply log10 normalisation.
residuals_symmetric_cmap
Not used here (UV-plane residuals are scatter plots); kept for API
consistency.
"""
fig, axes = plt.subplots(2, 3, figsize=(21, 14))
axes = axes.flatten()
uv = fit.dataset.uv_distances / 10**3.0
plot_yx(
np.real(fit.residual_map),
uv,
ax=axes[0],
title="Residual vs UV-Distance (real)",
xlabel="k$\\lambda$",
plot_axis_type="scatter",
)
plot_yx(
np.real(fit.normalized_residual_map),
uv,
ax=axes[1],
title="Norm Residual vs UV-Distance (real)",
ylabel="$\\sigma$",
xlabel="k$\\lambda$",
plot_axis_type="scatter",
)
plot_yx(
np.real(fit.chi_squared_map),
uv,
ax=axes[2],
title="Chi-Squared vs UV-Distance (real)",
ylabel="$\\chi^2$",
xlabel="k$\\lambda$",
plot_axis_type="scatter",
)
plot_yx(
np.imag(fit.residual_map),
uv,
ax=axes[3],
title="Residual vs UV-Distance (imag)",
xlabel="k$\\lambda$",
plot_axis_type="scatter",
)
plot_yx(
np.imag(fit.normalized_residual_map),
uv,
ax=axes[4],
title="Norm Residual vs UV-Distance (imag)",
ylabel="$\\sigma$",
xlabel="k$\\lambda$",
plot_axis_type="scatter",
)
plot_yx(
np.imag(fit.chi_squared_map),
uv,
ax=axes[5],
title="Chi-Squared vs UV-Distance (imag)",
ylabel="$\\chi^2$",
xlabel="k$\\lambda$",
plot_axis_type="scatter",
)
hide_unused_axes(axes)
plt.tight_layout()
subplot_save(fig, output_path, output_filename, output_format)
def subplot_fit_interferometer_dirty_images(
fit,
output_path: Optional[str] = None,
output_filename: str = "subplot_fit_dirty_images",
output_format: str = "png",
colormap=None,
use_log10: bool = False,
residuals_symmetric_cmap: bool = True,
):
"""
2×3 subplot of ``FitInterferometer`` dirty-image components.
Panels: Dirty Image | Dirty S/N Map | Dirty Model Image |
Dirty Residual Map | Dirty Norm Residual Map | Dirty Chi-Squared Map
Parameters
----------
fit
A ``FitInterferometer`` instance.
output_path
Directory to save the figure. ``None`` calls ``plt.show()``.
output_filename
Base filename without extension.
output_format
File format.
colormap
Matplotlib colormap name.
use_log10
Apply log10 normalisation to non-residual panels.
residuals_symmetric_cmap
Centre residual colour scale symmetrically around zero.
"""
fig, axes = plt.subplots(2, 3, figsize=(21, 14))
axes = axes.flatten()
plot_array(
fit.dirty_image,
ax=axes[0],
title="Dirty Image",
colormap=colormap,
use_log10=use_log10,
)
plot_array(
fit.dirty_signal_to_noise_map,
ax=axes[1],
title="Dirty Signal-To-Noise Map",
colormap=colormap,
use_log10=use_log10,
)
plot_array(
fit.dirty_model_image,
ax=axes[2],
title="Dirty Model Image",
colormap=colormap,
use_log10=use_log10,
)
if residuals_symmetric_cmap:
vmin_r, vmax_r = symmetric_vmin_vmax(fit.dirty_residual_map)
vmin_n, vmax_n = symmetric_vmin_vmax(fit.dirty_normalized_residual_map)
else:
vmin_r = vmax_r = vmin_n = vmax_n = None
plot_array(
fit.dirty_residual_map,
ax=axes[3],
title="Dirty Residual Map",
colormap=colormap,
use_log10=False,
vmin=vmin_r,
vmax=vmax_r,
)
plot_array(
fit.dirty_normalized_residual_map,
ax=axes[4],
title="Dirty Normalized Residual Map",
colormap=colormap,
use_log10=False,
vmin=vmin_n,
vmax=vmax_n,
)
plot_array(
fit.dirty_chi_squared_map,
ax=axes[5],
title="Dirty Chi-Squared Map",
colormap=colormap,
use_log10=use_log10,
)
hide_unused_axes(axes)
plt.tight_layout()
subplot_save(fig, output_path, output_filename, output_format)