irfpy.pep.pep_attitude

A PEP attitude module.

Note

Can be generalized for the future use.

The JUICE attitude is not very clear, however, I have implemented more generally as a NadirLookingSc class. This represents the nadir looking spacecraft and its fixed coordinate system to any Cartesian reference frame.

irfpy.pep.pep_attitude.unitvector(s)

Return unit vector

class irfpy.pep.pep_attitude.NadirLookingSc[source]

Bases: object

A conversion between the frames of nadir-looking spacecraft and a user-selected reference frame.

Note

This is used for the preparation during PEP proposal (2011). It is no longer usable, because of clearer definition of the spacecraft attitude. Use JuiceNominal or other related classes.

The use case is as follows.

>>> sc = NadirLookingSc()

The planetary body should be first placed at the origin, i.e. (0, 0, 0). Set the position and velocity of the spacecraft at a time of interest. The coordinate system of the position and velocity is arbitrary, but should be consistent (for example, you may use JSE, J2000, IAU_GANYMEDE or whatever). The used coordinate system is considered as a reference corrdinate system from now on.

Sample: JUICE is at the position of (2500, 0, 0) with velocity (0, 0, -1.5) in the IAU_GANYMEDE frame, you can set them as

>>> sc.set_posvel([2500., 0, 0], [0, 0, -1.5])

Then, the object sc can convert the frames between the nadir-looking-spacecraft (NSC) frame and the reference frame. Here, the nadir-looking-spacecraft (NSC) coordinate system is defined as follows.

  • Center: The spacecraft

  • z-axis: Nadir direction, i.e. Spacecraft to the origin of the body.

  • y-axis: y-z plane should be the same as position-velocity vector plane.

    Angle between plus y and velocity vector should be less than 90 degrees. This means that the y component of velocity in the NSC coordinate should be positive.

  • x-axis: Completes the right hand system.

Now, you can convert in between by the methods convert_to_nsc() and convert_to_ref().

The class may be used for

  • Ganymede orbiting phase

  • Jupiter pointing

  • Sun pointing

  • Earth pointing

set_posvel(pos, vel)[source]

Set the spacecraft position and velocity.

The following specifies the spacecraft position and velocity in arbitrary coordinate system.

>>> sc = NadirLookingSc()
>>> sc.set_posvel([2500., 0, 0], [0, 0, -1.5])
convert_to_ref(nscvecs)[source]

Convert nsc vectors to ref.

Parameters

nscvecs – (3, X) shaped array.

>>> sc = NadirLookingSc()
>>> sc.set_posvel([2500., 1800, -3000], [1., 3, 0])

The z-axis in NSC frame should be the antiparallel direction of the spacecraft position in the reference frame.

>>> zref = sc.convert_to_ref([0, 0, 1])
>>> print(zref)
[-0.58139535 -0.41860465  0.69767442]

If you want to convert 5 vectors as (0, 0, 1), (1, 2, 3), (2, 3, 4), (3, 4, 5), and (4, 5, 6), you can instance np.array object as follows.

>>> nscvecs = np.array([[0, 1, 2, 3, 4],
...     [0, 2, 3, 4, 5],
...     [1, 3, 4, 5, 6]])
>>> print(nscvecs.shape)
(3, 5)

Then convert.

>>> refvecs = sc.convert_to_ref(nscvecs)
>>> refvecs.shape
(3, 5)

The converted values can be referred like

>>> print(refvecs[:, 0])  # Corresponding to (0, 0, 1)
[-0.58139535 -0.41860465  0.69767442]
convert_to_nsc(refvecs)[source]
get_matrix_nsc2ref()[source]

Return the 3x3 np.array converting NSC frame to the reference frame

>>> sc = NadirLookingSc()
>>> sc.set_posvel([2500., 1800, -3000], [1., 3, 0])

The z-axis of the NSC frame should be parallel to (-2500, -1800, +3000), meaning (-0.5814, -0.4186, 6977)

>>> z = np.array([0, 0, 1])
>>> z_ref = sc.get_matrix_nsc2ref().dot(z)
>>> print('%.4f %.4f %.4f' % (z_ref[0], z_ref[1], z_ref[2]))
-0.5814 -0.4186 0.6977
get_matrix_ref2nsc()[source]

Return the 3x3 np.array converting the reference frame to NSC frame

class irfpy.pep.pep_attitude.NadirLookingYawSteeringSc[source]

Bases: object

Nadir looking spacecraft with yaw steering support.

Note

This is used for the preparation during PEP proposal (2011). It is no longer usable, because of clearer definition of the spacecraft attitude. Use JuiceMoonYaw class.

You can set yaw steering angle in set_posvel() method.

The yaw steering is considered by the JUICE project (Yaw steerling impact).

The reference frame is referred by the name “ysc”.

Sample follows.

Consider the spacecraft at the position of (100, 100, 0) in a certain coordinate system (reference frame) with the velocity of (0, 50, 50).

Then, the nadir point spacecraft NSC and its yaw steering enabled YSC can be instance as follows

>>> nsc = NadirLookingSc()
>>> nsc.set_posvel([100, 100, 0], [0, 50, 50])
>>> ysc = NadirLookingYawSteeringSc()
>>> ysc.set_posvel([100, 100, 0], [0, 50, 50], 90)

For yaw-steering YSC, the yaw steering angle is here defined as 90 degrees.

The z-axis in the NSC and YSC should be the same in the reference frame.

>>> zn = nsc.convert_to_ref([0, 0, 1])
>>> zy = ysc.convert_to_ref([0, 0, 1])
>>> print((zn == zy).all())
True

Indeed, the component-wise,

>>> print(zy)
[-0.70710678 -0.70710678  0.        ]

However, the x and y axis should be different. For NSC, the x axis is (0.707, 0, 0.707) and the y axis is (-0.577, 0.577, 0.577).

>>> xn = nsc.convert_to_ref([1, 0, 0])
>>> print(xn)
[ 0.57735027 -0.57735027  0.57735027]
>>> yn = nsc.convert_to_ref([0, 1, 0])
>>> print(yn)
[-0.40824829  0.40824829  0.81649658]

On the other hand, for the YSC frame, the 90 degrees yaw steering is considered, so that the +x(YSC) axis is the same as +y(NSC) and +y(YSC) is the same as -x(NSC).

>>> xy = ysc.convert_to_ref([1, 0, 0])
>>> print(np.linalg.norm(xy - yn) < 1e-10)
True
>>> print(xy)
[-0.40824829  0.40824829  0.81649658]
>>> yy = ysc.convert_to_ref([0, 1, 0])
>>> print(np.linalg.norm(yy + xn) < 1e-10)
True
>>> print(yy)
[-0.57735027  0.57735027 -0.57735027]
set_posvel(pos, vel, yawangle_deg)[source]

Set the position and velocity with yawangle_deg.

The yaw angle is defined referring to z axis, nadir direction. This means that the positive yaw is as the spacecraft rotates toward the right seeing from space. It is equivalent to the x axis is toward y axis.

convert_to_ref(yscvecs)[source]

Convert ysc vectors to ref.

Parameters

yscvecs – (3, X) shaped array.

>>> sc = NadirLookingYawSteeringSc()
>>> sc.set_posvel([2500., 1800, -3000], [1., 3, 0], 30.)
convert_to_ysc(refvecs)[source]
get_matrix_ysc2nsc()[source]
get_matrix_nsc2ysc()[source]
get_matrix_nsc2ref()[source]
get_matrix_ref2nsc()[source]
get_matrix_ysc2ref()[source]

Return the 3x3 np.array converting NSC frame to the reference frame

>>> sc = NadirLookingSc()
>>> sc.set_posvel([2500., 1800, -3000], [1., 3, 0])

The z-axis of the NSC frame should be parallel to (-2500, -1800, +3000), meaning (-0.5814, -0.4186, 6977)

>>> z = np.array([0, 0, 1])
>>> z_ref = sc.get_matrix_nsc2ref().dot(z)
>>> print('%.4f %.4f %.4f' % (z_ref[0], z_ref[1], z_ref[2]))
-0.5814 -0.4186 0.6977
get_matrix_ref2ysc()[source]

Return the 3x3 np.array converting the reference frame to YSC frame