ArrayWFrame#

class ArrayWFrame(array: ArrayWUnits | ndarray | float, units_or_frame: Units | Frame, frame: Frame = None)#

Bases: object

Defines a a value or values with associated units and reference frame.

Accepts two calling conventions:

  • ArrayWFrame(awu, frame) — wrap an existing ArrayWUnits in a frame.

  • ArrayWFrame(array, units, frame) — wrap a raw array with units and frame.

Parameters:
arrayArrayWUnits

Value or values with associated units to be defined in the given reference frame.

units_or_frameUnits or Frame

Units or Frame objects to be linked with the object.

frameFrame, optional

Frame object to be linked with the ArrayWFrame. Defaults to None.

Attributes:
frame

The associated frame of the ArrayWFrame.

quantity

The quantity or quantities linked to the Frame.

shape

The shape of the ArrayWFrame.

Methods

T()

Same as self.transpose()

append(other[, axis])

Append another ArrayWFrame to this one along the given axis.

convert_to(frame_target[, epoch])

Convert an entire AWF from its current frame to a target frame at given epochs.

cos()

Trigonometric cosine operator for ArrayWFrame objects.

cross(other)

Cross product operation between two ArrayWFrame objects.

exp()

Exponential operator for ArrayWFrame objects.

exp2()

Exponential base 2 operator for ArrayWFrame objects.

inverse()

Inverse operator for ArrayWFrame objects.

log()

Natural log operator for ArrayWFrame objects.

log10()

Log base 10 operator for ArrayWFrame objects.

log2()

Log base 2 operator for ArrayWFrame objects.

norm()

Matrix or vector norm operator for ArrayWFrame objects.

pseudo_inverse()

Pseudo-inverse operator for ArrayWFrame objects.

sin()

Trigonometric sine operator for ArrayWFrame objects.

summation()

Sum all elements in the ArrayWFrame object, if units allow.

tan()

Trigonometric tangent operator for ArrayWFrame objects.

transpose()

Transpose operator for ArrayWFrame objects.

unitary()

Converts a given ArrayWFrame vector into a unit vector with the same units.

See also

scarabaeus.Frame

define a Frame object that carry information about a SPICE-defined frame with origin and orientation

scarabaeus.Units

define Units to be attached to numpy arrays

scarabaeus.ArrayWUnits

define an ArrayWUnits that carry information about numpy arrays and units linked to their content

Examples

Create an ArrayWFrame by assigning a Frame to an ArrayWUnits:

>>> import scarabaeus as scb
>>> from pathlib import Path
>>> mk_path = Path('path/to/example_mk.tm')
>>> scb.SpiceManager.load_kernel_from_mkfile(str(mk_path))  # furnish metakernel
>>> km = scb.Units.get_units('km')  # define units
>>> J2000 = scb.Frame('J2000')  # define reference frame
>>> pos_vec = scb.ArrayWUnits([1, 2, 3], km)    # define position
>>> pos_J2000 = scb.ArrayWFrame(pos_vec, J2000) # define position in J2000
T() → Self#

Same as self.transpose()

append(other: Self, axis: int = None) → Self#

Append another ArrayWFrame to this one along the given axis.

Parameters:
otherArrayWFrame

The ArrayWFrame to append. Must share the same reference frame.

axisint, optional

Axis along which to append. Passed directly to ArrayWUnits.append(). Defaults to None (flatten).

Returns:
outArrayWFrame

A new ArrayWFrame containing the concatenated values in the same frame.

convert_to(frame_target: Frame, epoch: EpochArray = None) → None#

Convert an entire AWF from its current frame to a target frame at given epochs.

Parameters:
frame_targetFrame

The target frame to convert to.

epochEpochArray, optional

Given an array of ET at which the transformations hold. Required if the AWF has time-dependent data.

Raises:
ValueError

If the transformation requirements are not met (shape mismatch, incompatible frames, etc.).

cos() → Self#

Trigonometric cosine operator for ArrayWFrame objects.

cross(other: Self) → Self#

Cross product operation between two ArrayWFrame objects.

exp() → Self#

Exponential operator for ArrayWFrame objects.

exp2() → Self#

Exponential base 2 operator for ArrayWFrame objects.

inverse() → Self#

Inverse operator for ArrayWFrame objects.

Only valid for square matrices.

log() → Self#

Natural log operator for ArrayWFrame objects.

log10() → Self#

Log base 10 operator for ArrayWFrame objects.

log2() → Self#

Log base 2 operator for ArrayWFrame objects.

norm() → ArrayWUnits#

Matrix or vector norm operator for ArrayWFrame objects.

Returns an ArrayWUnits, not an ArrayWFrame: a norm is a magnitude with no direction, so there is no frame for it to be expressed in. Rotating the input leaves it unchanged, which is precisely what makes a frame label meaningless here — unlike unitary() or transpose(), whose results do live in the frame and so keep it.

pseudo_inverse() → Self#

Pseudo-inverse operator for ArrayWFrame objects.

sin() → Self#

Trigonometric sine operator for ArrayWFrame objects.

summation() → Self#

Sum all elements in the ArrayWFrame object, if units allow.

tan() → Self#

Trigonometric tangent operator for ArrayWFrame objects.

transpose() → Self#

Transpose operator for ArrayWFrame objects.

unitary() → Self#

Converts a given ArrayWFrame vector into a unit vector with the same units.

Only valid for vectorial ArrayWFrame.

property frame: Frame#

The associated frame of the ArrayWFrame.

property quantity: ArrayWUnits#

The quantity or quantities linked to the Frame.

property shape: ndarray#

The shape of the ArrayWFrame.