Skip to content

Commit

Permalink
mag corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
daralynnrhode committed Jul 30, 2024
1 parent 6c76f76 commit 67f91b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions imap_processing/mag/l0/mag_l0_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ def __post_init__(self) -> None:
"""
# Convert string output from space_packet_parser to numpy array of
# big-endian bytes
self.VECTORS = np.frombuffer(
int(self.VECTORS, 2).to_bytes(len(self.VECTORS) // 8, "big"),
dtype=np.dtype(">b"),
)
if isinstance(self.VECTORS, str):
self.VECTORS = np.frombuffer(
int(self.VECTORS, 2).to_bytes(len(self.VECTORS) // 8, "big"),
dtype=np.dtype(">b"),
)

# Remove buffer from end of vectors. Vector data needs to be in 50 bit chunks,
# and may have an extra byte at the end from CCSDS padding.
Expand Down
14 changes: 8 additions & 6 deletions imap_processing/mag/l1a/mag_l1a_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class MagL1a:
is_mago: bool
is_active: int
shcoarse: int
vectors: np.array
vectors: np.ndarray
starting_packet: InitVar[MagL1aPacketProperties]
packet_definitions: dict[np.datetime64, MagL1aPacketProperties] = field(init=False)
most_recent_sequence: int = field(init=False)
Expand All @@ -216,14 +216,14 @@ def __post_init__(self, starting_packet: MagL1aPacketProperties) -> None:
self.most_recent_sequence = starting_packet.src_seq_ctr

def append_vectors(
self, additional_vectors: np.array, packet_properties: MagL1aPacketProperties
self, additional_vectors: np.ndarray, packet_properties: MagL1aPacketProperties
) -> None:
"""
Append additional vectors to the current vectors array.
Parameters
----------
additional_vectors : numpy.array
additional_vectors : numpy.ndarray
New vectors to append.
packet_properties : MagL1aPacketProperties
Additional vector definition to add to the l0_packets dictionary.
Expand All @@ -244,7 +244,7 @@ def append_vectors(
@staticmethod
def calculate_vector_time(
vectors: np.ndarray, vectors_per_sec: int, start_time: TimeTuple
) -> np.array:
) -> np.ndarray:
"""
Add timestamps to the vector list, turning the shape from (n, 4) to (n, 5).
Expand All @@ -253,7 +253,7 @@ def calculate_vector_time(
Parameters
----------
vectors : numpy.array
vectors : numpy.ndarray
List of magnetic vector samples, starting at start_time. Shape of (n, 4).
vectors_per_sec : int
Number of vectors per second.
Expand Down Expand Up @@ -281,7 +281,9 @@ def calculate_vector_time(
),
(vectors.shape[0], -1),
)
vector_objects = np.concatenate([vectors, times], axis=1, dtype=np.int64)
vector_objects: np.ndarray = np.concatenate(
[vectors, times], axis=1, dtype=np.int64
)
return vector_objects

@staticmethod
Expand Down

0 comments on commit 67f91b3

Please sign in to comment.