Skip to content

Commit 6a4bb04

Browse files
committed
saving before updates
1 parent 81ba075 commit 6a4bb04

17 files changed

Lines changed: 1065 additions & 13 deletions

File tree

autogalaxy/analysis/adapt_images/adapt_images.py

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from autoconf import cached_property
77

88
import autoarray as aa
9+
import numpy as np
910

1011
if TYPE_CHECKING:
1112
from autogalaxy.galaxy.galaxy import Galaxy
@@ -147,7 +148,7 @@ def model_image(self) -> aa.Array2D:
147148

148149
return adapt_model_image
149150

150-
def updated_via_instance_from(self, instance, mask=None) -> "AdaptImages":
151+
def updated_via_instance_from(self, instance, dataset_model, xp=np, mask=None) -> "AdaptImages":
151152
"""
152153
Returns adapt-images which have been updated to map galaxy instances instead of galaxy names.
153154
@@ -202,10 +203,60 @@ def updated_via_instance_from(self, instance, mask=None) -> "AdaptImages":
202203
for galaxy_name, galaxy in instance.path_instance_tuples_for_class(Galaxy):
203204
galaxy_name = str(galaxy_name)
204205

206+
#print('grid_offset:', dataset_model.grid_offset)
207+
#print('grid_rotation:', dataset_model.grid_rotation)
208+
205209
if galaxy_name in self.galaxy_name_image_plane_mesh_grid_dict:
206-
galaxy_image_plane_mesh_grid_dict[galaxy] = (
207-
self.galaxy_name_image_plane_mesh_grid_dict[galaxy_name]
208-
)
210+
211+
# print('AdaptImage Here')
212+
213+
# image_plane_mesh_grid = self.galaxy_name_image_plane_mesh_grid_dict[galaxy_name]
214+
# #print('image_plane_mesh_grid:', image_plane_mesh_grid)
215+
216+
# moved_image_plane_mesh_grid = image_plane_mesh_grid.subtracted_and_rotated_from(
217+
# offset=dataset_model.grid_offset,
218+
# angle=dataset_model.grid_rotation,
219+
# xp=xp
220+
# )
221+
222+
# print('moved_image_plane_mesh_grid:', moved_image_plane_mesh_grid)
223+
224+
#galaxy_image_plane_mesh_grid_dict[galaxy] = moved_image_plane_mesh_grid
225+
# print('What is this?')
226+
# print(self.galaxy_name_image_plane_mesh_grid_dict[galaxy_name])
227+
228+
if dataset_model is not None:
229+
galaxy_image_plane_mesh_grid_dict[galaxy] = (
230+
self.galaxy_name_image_plane_mesh_grid_dict[galaxy_name].subtracted_and_rotated_from(
231+
offset=dataset_model.grid_offset,
232+
angle=dataset_model.grid_rotation_angle,
233+
xp=xp
234+
)
235+
)
236+
else:
237+
galaxy_image_plane_mesh_grid_dict[galaxy] = (
238+
self.galaxy_name_image_plane_mesh_grid_dict[galaxy_name]
239+
)
240+
241+
# if self.galaxy_name_image_plane_mesh_grid_dict[galaxy_name] is not None:
242+
# print('Ever here?')
243+
# image_plane_mesh_grid = self.galaxy_name_image_plane_mesh_grid_dict[galaxy_name]
244+
# print('Ever here 1.5?')
245+
# moved_image_plane_mesh_grid = image_plane_mesh_grid.subtracted_and_rotated_from(
246+
# offset=dataset_model.grid_offset,
247+
# angle=dataset_model.grid_rotation_angle,
248+
# xp=xp
249+
# )
250+
# print('Ever here2?')
251+
# print("What is moved_image_plane_mesh_grid?")
252+
# print(moved_image_plane_mesh_grid)
253+
# print("==========")
254+
# galaxy_image_plane_mesh_grid_dict[galaxy] = (moved_image_plane_mesh_grid)
255+
256+
# else:
257+
# galaxy_image_plane_mesh_grid_dict[galaxy] = (
258+
# self.galaxy_name_image_plane_mesh_grid_dict[galaxy_name]
259+
# )
209260

210261
return AdaptImages(
211262
galaxy_image_dict=galaxy_image_dict,

autogalaxy/analysis/analysis/dataset.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def __init__(
5858
)
5959

6060
self.dataset = dataset
61+
62+
#print(dir(adapt_images))
63+
6164
self.adapt_images = adapt_images
6265

6366
self.settings = settings or aa.Settings()
@@ -169,8 +172,8 @@ def save_results(self, paths: af.DirectoryPaths, result: ResultDataset):
169172
except AttributeError:
170173
pass
171174

172-
def adapt_images_via_instance_from(self, instance: af.ModelInstance) -> AdaptImages:
175+
def adapt_images_via_instance_from(self, instance: af.ModelInstance, dataset_model: aa.DatasetModel, xp=np) -> AdaptImages:
173176
try:
174-
return self.adapt_images.updated_via_instance_from(instance=instance)
177+
return self.adapt_images.updated_via_instance_from(instance=instance, dataset_model=dataset_model, xp=xp)
175178
except AttributeError:
176179
pass

autogalaxy/config/notation.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ label:
6767
weight_power: W_{\rm p}
6868
zeroth_coefficient: \lambda_{\rm 0}
6969
zeroth_signal_scale: V
70+
shift_centre_0: shift_{c0}
71+
shift_centre_1: shift_{c1}
72+
shift_angle: shift_{\theta}
73+
rot_ref_centre_0: rot_ref_{c0}
74+
rot_ref_centre_1: rot_ref_{c1}
75+
magnitude: mag
76+
position_angle: \theta_{\rm pos}
7077
superscript:
7178
ExternalShear: ext
7279
Mesh: mesh
@@ -143,4 +150,9 @@ label_format:
143150
virial_mass: '{:.4f}'
144151
virial_overdens: '{:.4f}'
145152
weight_floor: '{:.4f}'
146-
weight_power: '{:.4f}'
153+
weight_power: '{:.4f}'
154+
shift_centre_0: '{:.4f}'
155+
shift_centre_1: '{:.4f}'
156+
shift_angle: '{:.4f}'
157+
magnitude: '{:.4f}'
158+
position_angle: '{:.4f}'

autogalaxy/config/priors/mass/dark/nfw_mcr_scatter.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,114 @@ NFWMCRScatterLudlowSph:
5959
limits:
6060
lower: -inf
6161
upper: inf
62+
NFWMCRScatterLudlowSphMultiBand:
63+
centre_0:
64+
type: Gaussian
65+
mean: 0.0
66+
sigma: 0.1
67+
width_modifier:
68+
type: Absolute
69+
value: 0.05
70+
limits:
71+
lower: -inf
72+
upper: inf
73+
centre_1:
74+
type: Gaussian
75+
mean: 0.0
76+
sigma: 0.1
77+
width_modifier:
78+
type: Absolute
79+
value: 0.05
80+
limits:
81+
lower: -inf
82+
upper: inf
83+
mass_at_200:
84+
type: LogUniform
85+
lower_limit: 100000000.0
86+
upper_limit: 1000000000000000.0
87+
width_modifier:
88+
type: Relative
89+
value: 0.5
90+
limits:
91+
lower: 0.0
92+
upper: inf
93+
redshift_object:
94+
type: Uniform
95+
lower_limit: 0.0
96+
upper_limit: 1.0
97+
width_modifier:
98+
type: Relative
99+
value: 0.5
100+
limits:
101+
lower: 0.0
102+
upper: inf
103+
redshift_source:
104+
type: Uniform
105+
lower_limit: 0.0
106+
upper_limit: 1.0
107+
width_modifier:
108+
type: Relative
109+
value: 0.5
110+
limits:
111+
lower: 0.0
112+
upper: inf
113+
scatter_sigma:
114+
type: Gaussian
115+
mean: 0.0
116+
sigma: 3.0
117+
width_modifier:
118+
type: Absolute
119+
value: 1.0
120+
limits:
121+
lower: -inf
122+
upper: inf
123+
shift_centre_0:
124+
type: Gaussian
125+
mean: 0.0
126+
sigma: 0.1
127+
width_modifier:
128+
type: Absolute
129+
value: 0.05
130+
limits:
131+
lower: -inf
132+
upper: inf
133+
shift_centre_1:
134+
type: Gaussian
135+
mean: 0.0
136+
sigma: 0.1
137+
width_modifier:
138+
type: Absolute
139+
value: 0.05
140+
limits:
141+
lower: -inf
142+
upper: inf
143+
shift_angle:
144+
type: Gaussian
145+
mean: 0.0
146+
sigma: 20.0
147+
width_modifier:
148+
type: Absolute
149+
value: 5.0
150+
limits:
151+
lower: -inf
152+
upper: inf
153+
rot_ref_centre_0:
154+
type: Gaussian
155+
mean: 0.0
156+
sigma: 0.1
157+
width_modifier:
158+
type: Absolute
159+
value: 0.05
160+
limits:
161+
lower: -inf
162+
upper: inf
163+
rot_ref_centre_1:
164+
type: Gaussian
165+
mean: 0.0
166+
sigma: 0.1
167+
width_modifier:
168+
type: Absolute
169+
value: 0.05
170+
limits:
171+
lower: -inf
172+
upper: inf

autogalaxy/config/priors/mass/sheets/external_shear.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,74 @@ ExternalShear:
1919
limits:
2020
lower: -inf
2121
upper: inf
22+
ExternalShearMultiBand:
23+
centre_0:
24+
type: Gaussian
25+
mean: 0.0
26+
sigma: 0.1
27+
width_modifier:
28+
type: Absolute
29+
value: 0.05
30+
limits:
31+
lower: -inf
32+
upper: inf
33+
centre_1:
34+
type: Gaussian
35+
mean: 0.0
36+
sigma: 0.1
37+
width_modifier:
38+
type: Absolute
39+
value: 0.05
40+
limits:
41+
lower: -inf
42+
upper: inf
43+
magnitude:
44+
type: Uniform
45+
lower_limit: 0.0
46+
upper_limit: 1.0
47+
width_modifier:
48+
type: Absolute
49+
value: 0.025
50+
limits:
51+
lower: 0.0
52+
upper: 2.0
53+
position_angle:
54+
type: Uniform
55+
lower_limit: -180.0
56+
upper_limit: 180.0
57+
width_modifier:
58+
type: Absolute
59+
value: 15.0
60+
limits:
61+
lower: -180.0
62+
upper: 180.0
63+
shift_centre_0:
64+
type: Gaussian
65+
mean: 0.0
66+
sigma: 0.1
67+
width_modifier:
68+
type: Absolute
69+
value: 0.05
70+
limits:
71+
lower: -inf
72+
upper: inf
73+
shift_centre_1:
74+
type: Gaussian
75+
mean: 0.0
76+
sigma: 0.1
77+
width_modifier:
78+
type: Absolute
79+
value: 0.05
80+
limits:
81+
lower: -inf
82+
upper: inf
83+
shift_angle:
84+
type: Gaussian
85+
mean: 0.0
86+
sigma: 20.0
87+
width_modifier:
88+
type: Absolute
89+
value: 5.0
90+
limits:
91+
lower: -inf
92+
upper: inf

0 commit comments

Comments
 (0)