irfpy.cena.frame

A frame definition. CENA frame and SC frame is supported.

CENA frame and SC frame conversion is supported. Since they are rigidly related, implementation is simple.

  • Xcena = Zsc

  • Ycena = Xsc

  • Zcena = Ysc

There is also a definition of angles: \(\theta\) and \(\phi\). This is based on the CENA calibration report. The method cena2angles and angles2cena will convert them each other.

irfpy.cena.frame.cena2sc(vec)[source]

Conversion from CENA frame to Spacecraft frame.

Input is a Vector3d instance or array-like. Return is Vector3d or numpy.array.

>>> vcena = Vector3d(1,2,3)   # v is in the CENA frame
>>> vsc = cena2sc(vcena)
>>> print(vsc.x, vsc.y, vsc.z)
2 3 1
>>> vcena = [-1, -2, -3]
>>> vsc = cena2sc(vcena)   # Return is numpy.array
>>> print(vsc.shape)
(3,)
>>> print(vsc)
[-2 -3 -1]
irfpy.cena.frame.sc2cena(vec)[source]

Conversion from SC frame to CENA frame.

Input is a Vector3d instance or array-like. Return is Vector3d or numpy.array.

>>> vsc = Vector3d(1,2,3)
>>> vcena = sc2cena(vsc)
>>> print(vcena.x, vcena.y, vcena.z)
3 1 2
>>> vsc = [-1, -2, -3]
>>> vcena = sc2cena(vsc)   # Return is numpy.array
>>> print(vcena.shape)
(3,)
>>> print(vcena)
[-3 -1 -2]
irfpy.cena.frame.get_sc2cena_matrix()[source]
>>> vsc = [-1, -2, -3]
>>> m = get_sc2cena_matrix()
>>> print(m.dot(vsc))
[-3 -1 -2]
irfpy.cena.frame.cena2angles2(xarr, yarr, zarr)[source]

Return the CENA-angle from vector

See definition of angle in cena2angles().

Parameters
  • xarr – X cooridnates (array also acceptable)

  • yarr – Y cooridnates (array also acceptable)

  • zarr – Z cooridnates (array also acceptable)

>>> theta, phi = cena2angles2([1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, -1])
>>> theta = np.rad2deg(theta)
>>> phi = np.rad2deg(phi)
>>> print('%.2f %.2f %.2f %.2f' % (theta[0], theta[1], theta[2], theta[3]))
0.00 0.00 -90.00 90.00
>>> print('%.2f %.2f %.2f %.2f' % (phi[0], phi[1], phi[2], phi[3]))
90.00 0.00 0.00 0.00
irfpy.cena.frame.cena2angles(vec, degrees=False)[source]

Conversion in CENA frame from a vector to SC frame in angles.

Angles are defined in Figure 1.1 in CENA calibration report.

The input is array-like or Vector3d instance. The output is a pair of the angle, (\(\theta\), \(\phi\)), defined as follows. The unit is the radian unless degrees argument is set.

\(\theta\) is defined as follows: \(\theta\) =0 is in x-y plane of CENA frame and positive for negative Z. \(\phi\) is define as follows: +y is 0, and +x is 90 degrees.

>>> cena2angles([1, 0, 0], degrees=True)
(0.0, 90.0)
>>> cena2angles([0, 1, 0], degrees=True)
(0.0, 0.0)
>>> cena2angles([0, 0, 1], degrees=True)
(-90.0, 0.0)
>>> cena2angles([0, 0, -1], degrees=True)
(90.0, 0.0)
irfpy.cena.frame.angles2cena(theta, phi, degrees=False, vector3d=False)[source]

Conversion from angles to vectors for CENA frame.

See cena2angles() for definition of angles.

Input is two angles. If degrees is set, the given angles are considered as in degrees. Otherwise, they are considered as radians.

Output is the instance of numpy.array for default, or irfpy.util.vector3d.Vector3d if vector3d option is set.

>>> v = angles2cena(0, 90, degrees=True, vector3d=True)
>>> v_exp = Vector3d(1, 0, 0)
>>> v_exp.sub(v)
>>> print(v_exp.length() < 1e-5)
True
>>> v = angles2cena(0, 0, degrees=True, vector3d=True)
>>> v_exp = Vector3d(0, 1, 0)
>>> v_exp.sub(v)
>>> print(v_exp.length() < 1e-5)
True
>>> v = angles2cena(-90, 0, degrees=True, vector3d=True)
>>> v_exp = Vector3d(0, 0, 1)
>>> v_exp.sub(v)
>>> print(v_exp.length() < 1e-5)
True
>>> v = angles2cena(90, 0, degrees=True, vector3d=True)
>>> v_exp = Vector3d(0, 0, -1)
>>> v_exp.sub(v)
>>> print(v_exp.length() < 1e-5)
True