get_rotation_matrix#

sunpy.coordinates.spice.get_rotation_matrix(source_frame, target_frame, from_time, to_time=None)[source]#

Get the rotation matrix between the orientations of two SPICE frames.

Parameters:
Returns:

ndarray – A 3x3 rotation matrix for the change in orientation.

Examples

>>> from sunpy.coordinates.spice import get_rotation_matrix
>>> source_frame = "J2000"
>>> target_frame = "Galactic"
>>> from_time = '2001-01-01T00:00:00'
>>> rotation_matrix = get_rotation_matrix(source_frame, target_frame, from_time)
>>> rotation_matrix
array([[-0.05487554, -0.8734371 , -0.48383499],
       [ 0.49410945, -0.44482959,  0.74698225],
       [-0.86766614, -0.19807639,  0.45598379]])

This rotation matrix can be used to re-orient a vector (field), e.g.:

>>> vec_components = [1, 0, 0] * u.T
>>> transformed_matrix = rotation_matrix @ vec_components
>>> transformed_matrix
<Quantity [-0.05487554, 0.49410945, -0.86766614] T>