Sensor¶
- class missiontools.AbstractSensor(*, condition=None)[source]¶
Bases:
ABCAbstract base class for instruments attached to a spacecraft.
Subclasses must implement
pointing_eci(),fov_spec(), and__repr__(). The concretepointing_lvlh()andpointing_ecef()methods are provided here and delegate topointing_eci()plus a frame transform.- property spacecraft¶
Host spacecraft, or
Noneif not yet attached.
- property condition¶
Optional
AbstractConditioncontrolling when this sensor is active, orNone(always active).
- abstractmethod fov_spec(r_eci, v_eci, t)[source]¶
Return FOV parameters frozen at the given orbital state.
Returns a dict with at minimum:
'fov_type':'conic'or'rectangular''pointing_lvlh':(3,)boresight unit vector in LVLH
Conic specs also include
'cos_half_angle'. Rectangular specs also include'u1_lvlh','u2_lvlh','tan_theta1', and'tan_theta2'.
- pointing_lvlh(r_eci, v_eci, t)[source]¶
Boresight unit vector(s) in the LVLH frame.
- Parameters:
r_eci (
array_like,shape ``(N,3)``or(3,)) – Host spacecraft ECI position(s) (m).v_eci (
array_like,shape ``(N,3)``or(3,)) – Host spacecraft ECI velocity(s) (m s⁻¹).t (
array_likeofdatetime64,shape ``(N,)``orscalar) – Observation epoch(s).
- Returns:
npt.NDArray[np.floating]– Unit boresight vector(s) in LVLH, shape(N, 3)for array inputs or(3,)for scalar inputs.- Parameters:
r_eci (ArrayLike)
v_eci (ArrayLike)
t (ArrayLike)
- Return type:
- pointing_ecef(r_eci, v_eci, t)[source]¶
Boresight unit vector(s) in the ECEF frame.
- Parameters:
r_eci (
array_like,shape ``(N,3)``or(3,)) – Host spacecraft ECI position(s) (m).v_eci (
array_like,shape ``(N,3)``or(3,)) – Host spacecraft ECI velocity(s) (m s⁻¹).t (
array_likeofdatetime64,shape ``(N,)``orscalar) – Observation epoch(s).
- Returns:
npt.NDArray[np.floating]– Unit boresight vector(s) in ECEF, shape(N, 3)for array inputs or(3,)for scalar inputs.- Parameters:
r_eci (ArrayLike)
v_eci (ArrayLike)
t (ArrayLike)
- Return type:
- class missiontools.ConicSensor(half_angle_deg, *, attitude_law=None, body_vector=None, body_euler_deg=None, condition=None)[source]¶
Bases:
AbstractSensorAn instrument attached to a spacecraft with a cone-shaped field of view.
Prefer the keyword arguments to select the pointing mode (see below). The constructor is public and may be called directly when needed.
- Parameters:
half_angle_deg (
float) – Half-angle of the sensor’s conical field of view (degrees). Must satisfy0 < half_angle_deg <= 90.attitude_law (
AbstractAttitudeLaw, optional) – IndependentAbstractAttitudeLawfor this sensor, decoupled from the host spacecraft’s attitude. Mutually exclusive withbody_vectorandbody_euler_deg.body_vector (
array_like,shape (3,), optional) – Boresight direction expressed in the spacecraft body frame. Normalised on input. Mutually exclusive withattitude_lawandbody_euler_deg.body_euler_deg (
(yaw,pitch,roll) tupleoffloat, optional) – ZYX intrinsic Euler angles (degrees) defining the sensor frame relative to the spacecraft body frame. The boresight is the sensor frame’s z-axis expressed in body-frame coordinates. Mutually exclusive withattitude_lawandbody_vector.
- Parameters:
Notes
Body-mounted sensors (
body_vectororbody_euler_deg) require the sensor to be attached to a spacecraft viaadd_sensor()before their pointing methods can be called.Examples
Nadir-pointing sensor, 10° half-angle:
from missiontools import ConicSensor, FixedAttitudeLaw sensor = ConicSensor(10.0, attitude_law=FixedAttitudeLaw.nadir())
Sensor body-mounted along spacecraft body-z (boresight = nadir for a nadir spacecraft), 5° half-angle:
sensor = ConicSensor(5.0, body_vector=[0, 0, 1])
Sensor tilted 30° in pitch from body-z:
sensor = ConicSensor(15.0, body_euler_deg=(0, 30, 0))
- pointing_eci(r_eci, v_eci, t)[source]¶
Boresight unit vector(s) in the ECI frame.
For
body_vector/body_euler_degsensors the host spacecraft’sattitude_lawis used to transform the body-frame boresight to ECI.- Parameters:
r_eci (
array_like,shape ``(N,3)``or(3,)) – Host spacecraft ECI position(s) (m).v_eci (
array_like,shape ``(N,3)``or(3,)) – Host spacecraft ECI velocity(s) (m s⁻¹).t (
array_likeofdatetime64,shape ``(N,)``orscalar) – Observation epoch(s).
- Returns:
npt.NDArray[np.floating]– Unit boresight vector(s) in ECI, shape(N, 3)for array inputs or(3,)for scalar inputs.- Raises:
RuntimeError – If the sensor is in body mode and has not been attached to a spacecraft via
add_sensor().- Parameters:
r_eci (ArrayLike)
v_eci (ArrayLike)
t (ArrayLike)
- Return type:
- fov_spec(r_eci, v_eci, t)[source]¶
Return FOV parameters frozen at the given orbital state.
Returns a dict with at minimum:
'fov_type':'conic'or'rectangular''pointing_lvlh':(3,)boresight unit vector in LVLH
Conic specs also include
'cos_half_angle'. Rectangular specs also include'u1_lvlh','u2_lvlh','tan_theta1', and'tan_theta2'.
- class missiontools.RectangularSensor(theta1_deg, theta2_deg, *, attitude_law=None, body_vector=None, body_euler_deg=None, condition=None)[source]¶
Bases:
AbstractSensorAn instrument with a rectangular (pyramidal) field of view.
The FOV is defined by two half-angles, theta1 and theta2, measured in two orthogonal planes of the sensor frame. Together they describe a rectangular pyramid whose apex is at the sensor.
- Parameters:
theta1_deg (
float) – Half-angle in the sensor x-z plane (degrees). Must satisfy0 < theta1_deg <= 90.theta2_deg (
float) – Half-angle in the sensor y-z plane (degrees). Must satisfy0 < theta2_deg <= 90.attitude_law (
AbstractAttitudeLaw, optional) – IndependentAbstractAttitudeLawfor this sensor, decoupled from the host spacecraft’s attitude. Mutually exclusive withbody_vectorandbody_euler_deg.body_vector (
array_like,shape (3,), optional) – Boresight direction expressed in the spacecraft body frame. Normalised on input. Mutually exclusive withattitude_lawandbody_euler_deg.body_euler_deg (
(yaw,pitch,roll) tupleoffloat, optional) – ZYX intrinsic Euler angles (degrees) defining the sensor frame relative to the spacecraft body frame. The boresight is the sensor frame’s z-axis; the x/y axes define the FOV orientation about the boresight (roll matters for rectangular sensors). Mutually exclusive withattitude_lawandbody_vector.
- Parameters:
Notes
Body-mounted sensors require attachment to a spacecraft via
add_sensor()before their pointing methods can be called.For
body_vectormode the perpendicular axes are derived via Gram-Schmidt orthogonalisation against the body-z direction (falling back to body-x if the boresight is nearly parallel to body-z).Examples
Nadir-pointing rectangular sensor, 10° × 20°:
from missiontools import RectangularSensor, FixedAttitudeLaw sensor = RectangularSensor(10.0, 20.0, attitude_law=FixedAttitudeLaw.nadir())
Body-mounted with Euler angles (roll rotates the FOV about boresight):
sensor = RectangularSensor(5.0, 10.0, body_euler_deg=(0, 30, 45))
- sensor_frame_eci(r_eci, v_eci, t)[source]¶
Sensor frame axes in ECI as columns of a (3, 3) matrix.
Returns
[u1 | u2 | boresight]where each column is a unit vector in ECI.
- sensor_frame_lvlh(r_eci, v_eci, t)[source]¶
Sensor frame axes in LVLH as columns of a (3, 3) matrix.
- fov_spec(r_eci, v_eci, t)[source]¶
Return FOV parameters frozen at the given orbital state.
Returns a dict with at minimum:
'fov_type':'conic'or'rectangular''pointing_lvlh':(3,)boresight unit vector in LVLH
Conic specs also include
'cos_half_angle'. Rectangular specs also include'u1_lvlh','u2_lvlh','tan_theta1', and'tan_theta2'.