Skip to content

Commit

Permalink
Update metadata for rotations. Create helper tool for WCS matrix.
Browse files Browse the repository at this point in the history
  • Loading branch information
MSKirk committed Jan 17, 2025
1 parent 953b370 commit 12d4310
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion suncet_processing_pipeline/make_level1.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ def __coarse_rotate(self, data, telemetry):
# Determining the number of 90 deg rotations to keep solar north approximately on the top of the matrix
k = np.round(angle_deg / 90)

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

return np.rot90(data, k)

Expand Down
15 changes: 15 additions & 0 deletions suncet_processing_pipeline/suncet_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,18 @@ def detector_angle(telemetry, degrees=True):
suncet_angle = angle_rad

return suncet_angle

def CROTA_2_WCSrotation_matrix(crota2, decimals=6):
"""
converts from the Rotation of the horizontal and vertical axes in the xy-plane to WCS coordinate rotation matrix.
:param crota2: degree rotation of the xy coordinate plane
:param decimals: Number of decimals to keep for finite precision
:return: pc1_1, pc1_2, pc2_1, pc2_2
"""

pc1_1 = np.round(np.cos(np.deg2rad(crota2)), decimals=decimals)
pc1_2 = np.round(-1 * np.sin(np.deg2rad(crota2)), decimals=decimals)
pc2_1 = np.round(np.sin(np.deg2rad(crota2)), decimals=decimals)
pc2_2 = np.round(np.cos(np.deg2rad(crota2)), decimals=decimals)

return pc1_1, pc1_2, pc2_1, pc2_2

0 comments on commit 12d4310

Please sign in to comment.