Skip to content

Commit cfd0818

Browse files
authored
Merge pull request #23 from simonsobs/trajectory
Trajectory
2 parents 0b44833 + d056f48 commit cfd0818

File tree

117 files changed

+24052
-230
lines changed

Some content is hidden

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

117 files changed

+24052
-230
lines changed

lat_alignment/adjustments.py

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@
1313

1414

1515
def rotate(
16-
point: NDArray[np.float32],
17-
end_point1: NDArray[np.float32],
18-
end_point2: NDArray[np.float32],
19-
theta: np.float32,
20-
) -> NDArray[np.float32]:
16+
point: NDArray[np.float64],
17+
end_point1: NDArray[np.float64],
18+
end_point2: NDArray[np.float64],
19+
theta: np.float64,
20+
) -> NDArray[np.float64]:
2121
"""
2222
Rotate a point about an axis
2323
2424
Parameters
2525
----------
26-
point : NDArray[np.float32]
26+
point : NDArray[np.float64]
2727
The point to rotate
28-
end_point1 : NDArray[np.float32]
28+
end_point1 : NDArray[np.float64]
2929
A point on the axis of rotation
30-
end_point2 : NDArray[np.float32]
30+
end_point2 : NDArray[np.float64]
3131
Another point on the axis of rotation
32-
theta: NDArray[np.float32]
32+
theta: NDArray[np.float64]
3333
Angle in radians to rotate by
3434
3535
Returns
3636
-------
37-
point : NDArray[np.float32]
37+
point : NDArray[np.float64]
3838
The rotated point
3939
"""
4040
origin = np.mean((end_point1, end_point2))
@@ -46,34 +46,34 @@ def rotate(
4646

4747

4848
def rotate_panel(
49-
points: NDArray[np.float32],
50-
adjustors: NDArray[np.float32],
51-
thetha_0: np.float32,
52-
thetha_1: np.float32,
53-
) -> Tuple[NDArray[np.float32], NDArray[np.float32]]:
49+
points: NDArray[np.float64],
50+
adjustors: NDArray[np.float64],
51+
thetha_0: np.float64,
52+
thetha_1: np.float64,
53+
) -> Tuple[NDArray[np.float64], NDArray[np.float64]]:
5454
"""
5555
Rotate panel about axes created by adjustors.
5656
5757
Parameters
5858
----------
59-
points : NDArray[np.float32]
59+
points : NDArray[np.float64]
6060
Points on panel to rotate.
61-
adjustors : NDArray[np.float32]
61+
adjustors : NDArray[np.float64]
6262
Adjustor positions.
63-
thetha_0 : np.float32
63+
thetha_0 : np.float64
6464
Angle to rotate about first adjustor axis
65-
thetha_1 : np.float32.
65+
thetha_1 : np.float64.
6666
Angle to rotate about second adjustor axis
6767
6868
Returns
6969
-------
70-
rot_points : NDArray[np.float32]
70+
rot_points : NDArray[np.float64]
7171
The rotated points.
72-
rot_adjustors : NDArray[np.float32]
72+
rot_adjustors : NDArray[np.float64]
7373
The rotated adjustors.
7474
"""
75-
rot_points = np.zeros(points.shape, np.float32)
76-
rot_adjustors = np.zeros(adjustors.shape, np.float32)
75+
rot_points = np.zeros(points.shape, np.float64)
76+
rot_adjustors = np.zeros(adjustors.shape, np.float64)
7777

7878
n_points = len(points)
7979
n_adjustors = len(adjustors)
@@ -90,51 +90,51 @@ def rotate_panel(
9090

9191

9292
def translate_panel(
93-
points: NDArray[np.float32],
94-
adjustors: NDArray[np.float32],
95-
dx: np.float32,
96-
dy: np.float32,
97-
dz: np.float32,
98-
) -> Tuple[NDArray[np.float32], NDArray[np.float32]]:
93+
points: NDArray[np.float64],
94+
adjustors: NDArray[np.float64],
95+
dx: np.float64,
96+
dy: np.float64,
97+
dz: np.float64,
98+
) -> Tuple[NDArray[np.float64], NDArray[np.float64]]:
9999
"""
100100
Translate a panel.
101101
102102
Parameters
103103
----------
104-
points : NDArray[np.float32]
104+
points : NDArray[np.float64]
105105
The points on panel to translate.
106-
adjustors : NDArray[np.float32]
106+
adjustors : NDArray[np.float64]
107107
Adjustor positions.
108-
dx : np.float32
108+
dx : np.float64
109109
Translation in x.
110-
dy : np.float32
110+
dy : np.float64
111111
Translation in y.
112-
dz : np.float32
112+
dz : np.float64
113113
Translation in z.
114114
115115
Returns
116116
-------
117-
points : NDArray[np.float32]
117+
points : NDArray[np.float64]
118118
The translated points.
119-
adjustors : NDArray[np.float32]
119+
adjustors : NDArray[np.float64]
120120
The translated adjustors.
121121
"""
122122
translation = np.array((dx, dy, dz))
123123
return points + translation, adjustors + translation
124124

125125

126126
def adjustment_fit_func(
127-
pars: NDArray[np.float32],
128-
can_points: NDArray[np.float32],
129-
points: NDArray[np.float32],
130-
adjustors: NDArray[np.float32],
131-
) -> np.float32:
127+
pars: NDArray[np.float64],
128+
can_points: NDArray[np.float64],
129+
points: NDArray[np.float64],
130+
adjustors: NDArray[np.float64],
131+
) -> np.float64:
132132
r"""
133133
Function to minimize when calculating adjustments.
134134
135135
Parameters
136136
----------
137-
pars : NDArray[np.float32]
137+
pars : NDArray[np.float64]
138138
The parameters to fit for:
139139
140140
* dx: Translation in x
@@ -143,16 +143,16 @@ def adjustment_fit_func(
143143
* thetha_0: Angle to rotate about first adjustor axis
144144
* thetha_1: Angle to rotate about second adjustor axis
145145
* z_t: Additional translation to tension the center point
146-
can_points : NDArray[np.float32]
146+
can_points : NDArray[np.float64]
147147
The cannonical positions of the points to align.
148-
points : NDArray[np.float32]
148+
points : NDArray[np.float64]
149149
The measured positions of the points to align.
150-
adjustors : NDArray[np.float32]
150+
adjustors : NDArray[np.float64]
151151
The measured positions of the adjustors.
152152
153153
Returns
154154
-------
155-
norm : np.float32
155+
norm : np.float64
156156
The norm of $cannonical_positions - transformed_positions$.
157157
"""
158158
dx, dy, dz, thetha_0, thetha_1, z_t = pars
@@ -163,43 +163,43 @@ def adjustment_fit_func(
163163

164164

165165
def calc_adjustments(
166-
can_points: NDArray[np.float32],
167-
points: NDArray[np.float32],
168-
adjustors: NDArray[np.float32],
166+
can_points: NDArray[np.float64],
167+
points: NDArray[np.float64],
168+
adjustors: NDArray[np.float64],
169169
**kwargs,
170170
) -> Tuple[
171-
np.float32,
172-
np.float32,
173-
NDArray[np.float32],
174-
np.float32,
175-
np.float32,
176-
NDArray[np.float32],
171+
np.float64,
172+
np.float64,
173+
NDArray[np.float64],
174+
np.float64,
175+
np.float64,
176+
NDArray[np.float64],
177177
]:
178178
"""
179179
Calculate adjustments needed to align panel.
180180
181181
Parameters
182182
----------
183-
can_points : NDArray[np.float32]
183+
can_points : NDArray[np.float64]
184184
The cannonical position of the points to align.
185-
points : NDArray[np.float32]
185+
points : NDArray[np.float64]
186186
The measured positions of the points to align.
187-
adjustors : NDArray[np.float32]
187+
adjustors : NDArray[np.float64]
188188
The measured positions of the adjustors.
189189
**kwargs
190190
Arguments to be passed to `scipy.optimize.minimize`.
191191
192-
dx : np.float32
192+
dx : np.float64
193193
The required translation of panel in x.
194-
dy : np.float32
194+
dy : np.float64
195195
The required translation of panel in y.
196-
d_adj : NDArray[np.float32]
196+
d_adj : NDArray[np.float64]
197197
The amount to move each adjustor.
198-
dx_err : np.float32
198+
dx_err : np.float64
199199
The error in the fit for `dx`.
200-
dy_err : np.float32
200+
dy_err : np.float64
201201
The error in the fit for `dy`.
202-
d_adj_err : NDArray[np.float32]
202+
d_adj_err : NDArray[np.float64]
203203
The error in the fit for `d_adj`.
204204
"""
205205
res = opt.minimize(

lat_alignment/alignment.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def log_alignment(alignment, logger):
3838

3939
def adjust_panel(
4040
panel: mir.Panel, mnum: int, fit: bool, cfg: dict
41-
) -> NDArray[np.float32]:
41+
) -> NDArray[np.float64]:
4242
"""
4343
Helper function to get the adjustments for a single panel.
4444
@@ -57,12 +57,12 @@ def adjust_panel(
5757
5858
Returns
5959
-------
60-
adjustments : NDArray[np.float32]
60+
adjustments : NDArray[np.float64]
6161
The adjustments to make for the panel.
6262
This is a 17 element array with the following structure:
6363
`[mnum, panel_row, panel_col, dx, dy, d_adj1, ..., d_adj5, dx_err, dy_err, d_adj1_err, ..., d_adj5_err]`.
6464
"""
65-
adjustments = np.zeros(17, np.float32)
65+
adjustments = np.zeros(17, np.float64)
6666
adjustments[0] = mnum
6767
adjustments[1] = panel.row
6868
adjustments[2] = panel.col
@@ -245,7 +245,7 @@ def main():
245245
# Load data and compute the transformation to align with the model
246246
# We want to put all the transformations into opt_global
247247
elements = {} # {element_name : full_alignment}
248-
identity = (np.eye(3, dtype=np.float32), np.zeros(3, dtype=np.float32))
248+
identity = (np.eye(3, dtype=np.float64), np.zeros(3, dtype=np.float64))
249249
try:
250250
meas, alignment = pg.align_photo(
251251
dataset.copy(), reference, True, "primary", **cfg.get("align_photo", {})
@@ -276,7 +276,7 @@ def main():
276276
)
277277
full_alignment = mt.compose_transform(*common_mode_2, *full_alignment)
278278
full_alignment = tf.affine_basis_transform(
279-
full_alignment[0], full_alignment[1], "opt_primary", "opt_global", False
279+
full_alignment[0], full_alignment[1], "opt_primary", "opt_global"
280280
)
281281
log_alignment(full_alignment, logger)
282282
except Exception as e:
@@ -325,11 +325,7 @@ def main():
325325
)
326326
full_alignment = mt.compose_transform(*common_mode_2, *full_alignment)
327327
full_alignment = tf.affine_basis_transform(
328-
full_alignment[0],
329-
full_alignment[1],
330-
"opt_secondary",
331-
"opt_global",
332-
False,
328+
full_alignment[0], full_alignment[1], "opt_secondary", "opt_global"
333329
)
334330
log_alignment(full_alignment, logger)
335331
except Exception as e:

lat_alignment/bearing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
def partition_points(
3535
dataset: Dataset,
36-
) -> tuple[Dataset, Dataset, NDArray[np.float32], NDArray[np.float32]]:
36+
) -> tuple[Dataset, Dataset, NDArray[np.float64], NDArray[np.float64]]:
3737
"""
3838
Split up dataset into points on the bearing reference surface and inner surface.
3939
Also pulls out the bearing zero points.
@@ -52,10 +52,10 @@ def partition_points(
5252
face_points : Dataset
5353
Points on face of the bearing that we use as a reference surface.
5454
Only includes targets, codes are removed.
55-
zero_point : NDArray[np.float32]
55+
zero_point : NDArray[np.float64]
5656
Array of size (3,) that gives the coordinates of the target we treat
5757
as the bearing's zero point.
58-
zero_code: NDArray[np.float32]
58+
zero_code: NDArray[np.float64]
5959
Array of size (3,) that gives the coordinates of the coded target we use
6060
to identify the bearing's zero point.
6161
@@ -111,7 +111,7 @@ def partition_points(
111111

112112
def cylinder_fit(
113113
dataset: Dataset,
114-
) -> tuple[Dataset, tuple[NDArray[np.float32], NDArray[np.float32]]]:
114+
) -> tuple[Dataset, tuple[NDArray[np.float64], NDArray[np.float64]]]:
115115
"""
116116
Fit for the bearing's position by fitting a cylinder to the bearing surface.
117117
This acts as a correction on top of the alignment to reference points.
@@ -127,7 +127,7 @@ def cylinder_fit(
127127
inside_points : Dataset
128128
Points on the inner surface of the bearing with alignment applied.
129129
Only includes targets, codes are removed.
130-
alignment : tuple[NDArray[np.float32], NDArray[np.float32]]
130+
alignment : tuple[NDArray[np.float64], NDArray[np.float64]]
131131
The transformation that aligned the bearing.
132132
The first element is a rotation matrix and
133133
the second is the shift.
@@ -159,7 +159,7 @@ def cylinder_fit(
159159
logger.info("\t\tError on bearing axis alignment: %f", err)
160160

161161
shift = rot.apply(shift)
162-
rot = np.array(rot.as_matrix(), dtype=np.float32).T
162+
rot = np.array(rot.as_matrix(), dtype=np.float64).T
163163
logger.debug("\t\tShift is %s mm", str(shift))
164164
logger.debug("\t\tRotation is %s deg", str(np.rad2deg(decompose_rotation(rot))))
165165

0 commit comments

Comments
 (0)