Skip to content

Commit 12d4310

Browse files
committed
Update metadata for rotations. Create helper tool for WCS matrix.
1 parent 953b370 commit 12d4310

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

suncet_processing_pipeline/make_level1.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ def __coarse_rotate(self, data, telemetry):
199199
# Determining the number of 90 deg rotations to keep solar north approximately on the top of the matrix
200200
k = np.round(angle_deg / 90)
201201

202-
# TODO: update self.metadata rotation to indicate the number of rotations
202+
self.metadata.coord_sys_rotation = k * 90.
203+
self.metadata.wcs_rot_pc11, self.metadata.wcs_rot_pc12, self.metadata.wcs_rot_pc21, self.metadata.wcs_rot_pc22 = \
204+
(utilities.CROTA_2_WCSrotation_matrix(k * 90.))
203205

204206
return np.rot90(data, k)
205207

suncet_processing_pipeline/suncet_utility.py

+15
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,18 @@ def detector_angle(telemetry, degrees=True):
9595
suncet_angle = angle_rad
9696

9797
return suncet_angle
98+
99+
def CROTA_2_WCSrotation_matrix(crota2, decimals=6):
100+
"""
101+
converts from the Rotation of the horizontal and vertical axes in the xy-plane to WCS coordinate rotation matrix.
102+
:param crota2: degree rotation of the xy coordinate plane
103+
:param decimals: Number of decimals to keep for finite precision
104+
:return: pc1_1, pc1_2, pc2_1, pc2_2
105+
"""
106+
107+
pc1_1 = np.round(np.cos(np.deg2rad(crota2)), decimals=decimals)
108+
pc1_2 = np.round(-1 * np.sin(np.deg2rad(crota2)), decimals=decimals)
109+
pc2_1 = np.round(np.sin(np.deg2rad(crota2)), decimals=decimals)
110+
pc2_2 = np.round(np.cos(np.deg2rad(crota2)), decimals=decimals)
111+
112+
return pc1_1, pc1_2, pc2_1, pc2_2

0 commit comments

Comments
 (0)