Processing

This module performs various processing tasks on the orbit data described above, including downsampling, interpolation, and reshaping.

Resampling

Downsample


source

downsample_3d_array

 downsample_3d_array (data:numpy.ndarray, axis:int, hop:int=None,
                      target_size:int=None)

Downsample a 3D numpy array along a specified axis by keeping only every hop-th element or to a target size.

Type Default Details
data ndarray The original 3D array to be downsampled.
axis int The axis along which to perform the downsampling.
hop int None The interval at which to keep elements.
target_size int None The target size for the specified axis.
Returns ndarray

Interpolation


source

resample_3d_array

 resample_3d_array (data:numpy.ndarray, axis:int, target_size:int)

Resample a 3D numpy array along a specified axis using linear interpolation.

Type Details
data ndarray The original 3D array to be resampled.
axis int The axis along which to perform the interpolation.
target_size int The new size of the axis after resampling.
Returns ndarray

Average


source

average_downsample_3d_array

 average_downsample_3d_array (data:numpy.ndarray, axis:int,
                              target_size:int)

Downsample a 3D numpy array along a specified axis using averaging.

Type Details
data ndarray The original 3D array to be downsampled.
axis int The axis along which to perform the downsampling (0, 1, or 2).
target_size int The desired size of the specified axis after downsampling.
Returns ndarray

Reorder Orbit with Time


source

reorder_orbits

 reorder_orbits (orbit_dataset:numpy.ndarray)

Reorders the time steps of each orbit in the dataset such that the time values are always incrementally increasing. Returns the reordered dataset, a 2D array of metric values for each orbit, and a list of metric labels.

Type Details
orbit_dataset ndarray
Returns Tuple 3D numpy array of reordered orbits.

Reshaping Arrays


source

pad_and_convert_to_3d

 pad_and_convert_to_3d (orbits:Dict[int,numpy.ndarray], timesteps:int)

Truncate and pad each orbit to a uniform length and convert to a 3D numpy array.

Type Details
orbits Dict Dictionary of orbits with numerical keys.
timesteps int Desired number of timesteps.
Returns ndarray 3D numpy array of padded orbits.

source

segment_and_convert_to_3d

 segment_and_convert_to_3d (orbits:Dict[int,numpy.ndarray],
                            segment_length:int)

Divide each orbit into segments of a given length and convert to a 3D numpy array.

Type Details
orbits Dict Dictionary of orbits with numerical keys.
segment_length int Desired length of each segment.
Returns Tuple 3D numpy array of segments.
orbits = {
    1: np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
                    [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],
                    [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],
                    [37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48],
                    [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],
                    [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72]]),
    2: np.array([[73, 74, 75, 76, 77, 78, 79],
                    [81, 82, 83, 84, 85, 86, 87],
                    [89, 90, 91, 92, 93, 94, 95],
                    [97, 98, 99, 100, 101, 102, 103],
                    [105, 106, 107, 108, 109, 110, 111],
                    [113, 114, 115, 116, 117, 118, 119]])
}
segment_length = 4

# Expected segments and IDs
expected_segments = np.array([
    [[1, 2, 3, 4], [13, 14, 15, 16], [25, 26, 27, 28], [37, 38, 39, 40], [49, 50, 51, 52], [61, 62, 63, 64]],
    [[5, 6, 7, 8], [17, 18, 19, 20], [29, 30, 31, 32], [41, 42, 43, 44], [53, 54, 55, 56], [65, 66, 67, 68]],
    [[9, 10, 11, 12], [21, 22, 23, 24], [33, 34, 35, 36], [45, 46, 47, 48], [57, 58, 59, 60], [69, 70, 71, 72]],
    [[73, 74, 75, 76], [81, 82, 83, 84], [89, 90, 91, 92], [97, 98, 99, 100], [105, 106, 107, 108], [113, 114, 115, 116]]
])
expected_ids = [1, 1, 1, 2]

# Call the function
segments_3d, segment_ids = segment_and_convert_to_3d(orbits, segment_length)

# Use test_eq to check the results
test_eq(segments_3d.tolist(), expected_segments.tolist())
test_eq(segment_ids, expected_ids)

Add Time Vector


source

add_time_vector_to_orbits

 add_time_vector_to_orbits (orbits:Dict[int,numpy.ndarray],
                            propagated_periods:List[float],
                            periods:List[float])

Add a time vector to each orbit in the dictionary.

Type Details
orbits Dict Dictionary of orbits with numerical keys.
propagated_periods List List of propagated periods for each orbit.
periods List List of periods for each orbit.
Returns Dict Dictionary of updated orbits with time vectors added.

Interpolating Equal Times


source

interpolate_equal_times

 interpolate_equal_times (orbit_dataset:numpy.ndarray)
# Testing with dummy data that has equal time values at the beginning
test_data = np.array([
    [0, 0, 0, 0, 0, 0, 0, 0, 1, 2],
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
])

# Reshape to 3D array (1 orbit with 3 scalars and 10 timesteps)
test_data = test_data.reshape(1, 3, 10)

output = interpolate_equal_times(test_data)
print(output[:,0])
[[0.    0.125 0.25  0.375 0.5   0.625 0.75  0.875 1.    2.   ]]