chandra_maneuver

class chandra_maneuver.maneuver.ManeuverProfile(duration: float, max_ang_accel: float, max_ang_vel: float, time_max_ang_vel: float, quat: ndarray, angle: float)

Parameters for a spacecraft maneuver.

Attributes

durationfloat

Duration of maneuver in seconds

max_ang_accelfloat

Maximum angular acceleration in rad/sec**3 (MAYBE)

max_ang_velfloat

Maximum angular velocity in rad/sec (MAYBE)

time_max_ang_velfloat

Time at which maximum angular velocity occurs in seconds (MAYBE)

quatnp.ndarray

4-element ndarray representing q_final / q_init which defines the maneuver quaternion

anglefloat

Maneuver angle in degrees

angle: float

Alias for field number 5

duration: float

Alias for field number 0

max_ang_accel: float

Alias for field number 1

max_ang_vel: float

Alias for field number 2

quat: ndarray

Alias for field number 4

time_max_ang_vel: float

Alias for field number 3

chandra_maneuver.maneuver.NSM_attitude(att, time) Quat

Calculate the closest NSM attitude for 90 deg pitch from starting attitude.

This function is DEPRECATED. Use ska_sun.get_nsm_attitude() instead.

Parameters

attQuat

Attitude that can initialize a Quat().

timeCxoTimeLike

Time in a valid Chandra.Time format.

Returns

Quat

NSM attitude quaternion.

chandra_maneuver.maneuver.attitudes(att1, att2, step=300, tstart=0, exact_steps=False)

Determine attitudes in a maneuver from att1 to att2.

This calculate the maneuver profile of the spacecraft and returns time, attitude quaternions, and sun pitch.

By default the time steps are calculated to be the closest possible to the specified step while maintaining an even spacing between the start and end of the maneuver. If exact_steps is True then the time steps are exactly as specified and there will be one uneven step at the end.

Parameters

att1QuatLike

Initial attitude (Quat, 3 element RA,Dec,Roll, or 4 element quaternion)

att2QuatLike

Final attitude (Quat, 3 element RA,Dec,Roll, or 4 element quaternion)

stepfloat, optional

Time separation of returned attitudes (seconds), by default 300

tstartCxoTimeLike, optional

Maneuver start time (CxoTime compatible), by default 0

exact_stepsbool, optional

Use the exact time step, by default False

Returns

numpy.recarray

Record array with fields: time, q1, q2, q3, q4, pitch, off_nom_roll

Examples

>>> import chandra_maneuver
>>> atts = chandra_maneuver.attitudes((0,0,0), (10,20,30))
>>> atts.pitch
array([ 79.64483   ,  81.90894478,  89.10262574,  95.10617367,  96.57590726])
>>> atts.q1
array([ 0.        ,  0.03083816,  0.13619809,  0.23923962,  0.26853582])
chandra_maneuver.maneuver.duration(att1, att2)

Calculate the duration of a maneuver.

This is a thin wrapper around the get_maneuver_profile function which is preferred for application code. This function is provided for backward compatibility.

Parameters

att1QuatLike

Initial attitude (Quat, 3 element RA,Dec,Roll, or 4 element quaternion)

att2QuatLike

Final attitude (Quat, 3 element RA,Dec,Roll, or 4 element quaternion)

Returns

float

Duration of maneuver in seconds

Examples

>>> import chandra_maneuver
>>> chandra_maneuver.duration((0,0,0), (20,20,20))
1141.4469982300088
chandra_maneuver.maneuver.get_aberration_correction(q1, q2, time, use_cheta_ephem=False, definitive_ephem=False, include_chandra=False)

Calculate the aberration correction of the maneuver from q1 to q2 starting at time.

In the FOT matlab tools, this is called aberration error. The matlab code to calculate these values uses only the Sun/Earth ephemeris (equivalent to include_chandra=False) and the calculated values from the FOT matlab tools are included in the products ManErr file in the columns aber-X, aber-Y, and aber-Z.

This method includes an option to use either the DE432 ephemeris or cheta ephemeris data (the use_cheta_ephem kwarg). Use of the cheta ephemeris data also allows the user to include Chandra’s velocity (via the include_chandra kwarg). Calculating the aberration correction without including Chandra’s velocity is less accurate at a level of around 25%.

With regard to signs, the Ska centroid_report code applies a “correction” for aberration to the one shot values by subtracting the pitch and yaw aber values from the kadi maneuver event one shot pitch and yaw values - that is:

one_shot_pitch_aberr_corrected = manvr_event.one_shot_pitch - aber.pitch
one_shot_yaw_aberr_corrected = manvr_event.one_shot_yaw - aber.yaw

Parameters

q1array or Quat

Quaternion representing the initial attitude.

q2array or Quat

Quaternion representing the final attitude.

timeCxoTimeLike

Start time of the maneuver.

use_cheta_ephembool

If True, use the Cheta ephemeris data. If False, use the chandra_aca copy of the DE432 ephemeris. Default is False.

definitive_ephembool

If True, use the definitive cheta ephemeris data. If False, use the predictive cheta ephemeris data. Default is False.

include_chandra: bool

If True, include Chandra velocity in the aberration calculation. Default is False. Note that this may only be set to True if use_cheta_ephem is also True. And note that the calculation without including Chandra’s velocity is less accurate at a level of around 25%.

Returns

aberration_correctionNamedTuple

Aberration correction with fields roll, pitch, and yaw in arcseconds.

chandra_maneuver.maneuver.get_eigenaxis(A)

Calculate the rotation eigenaxis from first three components of quaternion A.

Parameters

Anumpy.ndarray

Quaternion as a 4 element numpy array.

Returns

numpy.ndarray

3 element numpy array.

chandra_maneuver.maneuver.get_maneuver_profile(att1: Quat | Annotated[List[float], 4] | Annotated[List[float], 3] | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], att2: Quat | Annotated[List[float], 4] | Annotated[List[float], 3] | Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ManeuverProfile

Calculate maneuver parameters/profile for initial and final attitude quaternions.

Parameters

att1QuatLike

Initial attitude (Quat, 3 element RA,Dec,Roll, or 4 element quaternion)

att2QuatLike

Final attitude (Quat, 3 element RA,Dec,Roll, or 4 element quaternion)

Returns

ManeuverProfile

Named tuple containing maneuver parameters: - duration: Duration of maneuver in seconds - max_ang_accel: Maximum angular acceleration in rad/sec**3 - max_ang_vel: Maximum angular velocity in rad/sec - time_max_ang_vel: Time at which maximum angular velocity occurs in seconds - quat: 4-element ndarray representing q_final / q_init - angle: Maneuver angle in degrees

chandra_maneuver.maneuver.get_quaternions(atts)

Get a list of quaternions from the specified atts attitudes.

Parameters

attsnumpy.recarray

Recarray of the attitudes, times and pitches

Returns

list

List of corresponding Quat objects

chandra_maneuver.maneuver.inject_errors(atts, att_err, bias_err)

Inject errors into atts.

Inject errors into atts corresponding to an initial attitude error att_err and bias error bias_err.

The bias_err input can have shape (3, len(atts)) to allow for a time varying bias error.

Parameters

attsnumpy.recarray

Recarray of the attitudes, times and pitches

att_errarray_like

Initial attitude error (roll, pitch, yaw in arcsec)

bias_errarray_like

Bias error (roll, pitch, yaw in arcsec/sec)

Returns

numpy.recarray

Recarray array of the attitudes, times and pitches

chandra_maneuver.maneuver.make_phi_dphi(delta, J, eps, tau, s)

Calculate the maneuver phi and dphi and the segments of a maneuver.

Given a time array, the maneuver parameters, and a unit vector, calculate the maneuver phi and dphi in the different segments of the maneuver

Parameters

deltafloat

Maneuver parameter delta

Jfloat

Maneuver parameter J

epsfloat

Maneuver parameter eps

taufloat

Maneuver parameter tau

snumpy.ndarray

Time array

Returns

tuple

Tuple containing (phi, dphi, d2phi)

chandra_maneuver.maneuver.profile(q_init, q_final)

Calculate maneuver parameters/profile for initial and final attitude quaternions.

This is for internal use only. Application code should use the get_maneuver_profile function instead.

Parameters

q_initQuat, 3 element RA,Dec,Roll, or 4 element quaternion

Initial quaternion

q_finalQuat, 3 element RA,Dec,Roll, or 4 element quaternion

Final quaternion

Returns

Tmfloat

Duration of maneuver in seconds

Jfloat

Maximum angular acceleration in rad/sec**3 (MAYBE)

epsfloat

Maximum angular velocity in rad/sec (MAYBE)

taufloat

Time at which maximum angular velocity occurs in seconds (MAYBE)

manvr_quat4-element ndarray

q_final / q_init which defines the maneuver quaternion

chandra_maneuver.maneuver.velocity_earth_wrt_sun(time)

Get the velocity of the Earth with respect to the Sun at a given time.

The velocity is returned in km/s.

Parameters

time: CxoTimeLike

Time in a valid Cxotime format

Returns

vel_km_snp.array

Vector velocity of the Earth with respect to the Sun in km/s.

chandra_maneuver.maneuver.velocity_wrt_sun_cheta(time, definitive=False, include_chandra=True)

Get the velocity with respect to the Sun at a given time.

This uses the Cheta ephemeris data.

Parameters

timeCxoTimeLike

Time in a valid CxoTime format.

definitivebool

If True, use the definitive ephemeris data. If False, use the predictive ephemeris data. Default is False.

include_chandrabool

If True, include the Chandra orbit ephemeris data. If False, do not include the Chandra orbit ephemeris. Default is True.

Returns

vel_km_snp.array

x, y, z velocity with respect to the Sun in km/s. If include_chandra is True, this includes the Chandra orbit velocity otherwise it is just the Earth velocity with respect to the Sun.