-
Notifications
You must be signed in to change notification settings - Fork 0
/
fgs2tofgs1_calibration.py
60 lines (45 loc) · 1.38 KB
/
fgs2tofgs1_calibration.py
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
#!/usr/bin/env python
"""Determine the FGS2 to FGS1 matrix given two sets of SIAF parameters.
Authors
-------
Tony Sohn
Notes
-----
This is the FGS2 to FGS1 matrix calculation code based on the
pysiaf.utils.tools.jwst_fgs_to_fgs_matrix. The pysiaf tool is not
able to take inputs, but instead only provides the FGS2_to_FGS1
matrix as stored in the LoadsPRD.
"""
import sys
import numpy as np
from pysiaf.utils.rotations import rotate
def fgs2tofgs1_matrix(fgs1_siaf_params, fgs2_siaf_params):
"""
Parameters
----------
fgs1_siaf_params: array (or tuple) or V2Ref, V3Ref, V3IdlYAngle for FGS1
fgs2_siaf_params: array (or tuple) or V2Ref, V3Ref, V3IdlYAngle for FGS2
Returns
-------
R_BtoA: ndarray, FGS2 to FGS1 rotation matrix
"""
FGS1V2 = fgs1_siaf_params[0]
FGS1V3 = fgs1_siaf_params[1]
FGS1pa = fgs1_siaf_params[2]
FGS2V2 = fgs2_siaf_params[0]
FGS2V3 = fgs2_siaf_params[1]
FGS2pa = fgs2_siaf_params[2]
# Form RA = R3.R2.R1
R1 = rotate(1, -FGS1pa)
R2 = rotate(2, -FGS1V3 / 3600.0)
R3 = rotate(3, FGS1V2 / 3600.0)
RA = np.dot(R2, R1)
RA = np.dot(R3, RA)
# Form RB = R6.R5.R4
R4 = rotate(1, -FGS2pa)
R5 = rotate(2, -FGS2V3 / 3600.0)
R6 = rotate(3, FGS2V2 / 3600.0)
RB = np.dot(R5, R4)
RB = np.dot(R6, RB)
R_BtoA = np.dot(np.transpose(RA), RB)
return R_BtoA