imap_processing.mag.l1a.mag_l1a_data.MagL1a#
- class imap_processing.mag.l1a.mag_l1a_data.MagL1a(is_mago: bool, is_active: int, shcoarse: int, starting_vectors: InitVar[np.ndarray], starting_packet: InitVar[MagL1aPacketProperties], missing_sequences: list[int] = <factory>, _compression_flags_list: list = <factory>)#
Data class for MAG Level 1A data.
One MAG L1A object corresponds to part of one MAG L0 packet, which corresponds to one packet of data from the MAG instrument. Each L0 packet consists of data from two sensors, MAGO (outboard) and MAGI (inboard). One of these sensors is designated as the primary sensor (first part of data stream), and one as the secondary.
We expect the primary sensor to be MAGO, and the secondary to be MAGI, but this is not guaranteed. Each MagL1A object contains data from one sensor. The primary/secondary construct is only used to sort the vectors into MAGo and MAGi data, and therefore is not used at higher levels.
- starting_vectors#
Initvar to create the first entry in the vector list. This is to preserve the external API of creating the object with the first set of vectors. This cannot be accessed from an instance of the class. Instead, vectors should be used.
- Type:
InitVar[numpy.ndarray]
- starting_packet#
The packet properties for the first packet in the day. As an InitVar, this cannot be accessed from an instance of the class. Instead, packet_definitions should be used.
- Type:
InitVar[MagL1aPacketProperties]
- vectors#
List of magnetic vector samples, starting at start_time. [x, y, z, range, time], where time is numpy.datetime64[ns]. This is a property that concatenates the internal vector list on demand.
- Type:
- compression_flags#
Array of flags to indicate compression and width for all timestamps in the L1A file. Shaped like (n, 2) where n is the number of vectors. First value is a boolean for compressed/uncompressed, second vector is a number between 0-20 if the data is compressed, which is the width in bits of the compressed data. This is a property that concatenates the internal compression flags list.
- Type:
- packet_definitions#
Dictionary of packet properties for each packet in the day. The key is the start time of the packet, and the value is a dataclass of packet properties.
- start_time#
Start time of the day, in ns since J2000 epoch
- Type:
numpy.int64
- _compression_flags_list#
Array of flags to indication compression and width for all timestamps in the L1A file. Shaped like (n, 2) where n is the number of vectors. First value is a boolean for compressed/uncompressed, second vector is a number between 0-20 if the data is compressed, which is the width in bits of the compressed data. Transformed into a numpy array upon retrieval.
- Type:
np.ndarray
- _vector_list#
Internal list of vectors, used to build the final vectors attribute. This is a list of numpy arrays, each with shape (n, 5) where n is the number of vectors in that packet, and each vector is (x, y, z, range, time).
- Type:
- _vector_cache#
A cache of the concatenated vector list. This is None until the vectors property is accessed, at which point it is created and stored here for future access.
- Type:
numpy.ndarray | None
- append_vectors()#
- calculate_vector_time()#
- convert_diffs_to_vectors()#
- process_vector_data()#
- process_uncompressed_vectors()#
- process_compressed_vectors()#
- process_range_data_section()#
- _process_vector_section()#
- unpack_one_vector()#
- decode_fib_zig_zag()#
- twos_complement()#
- update_compression_array()#
- vectors_per_second_attribute()#
- all_vectors_primary()#
- __init__(is_mago: bool, is_active: int, shcoarse: int, starting_vectors: InitVar[np.ndarray], starting_packet: InitVar[MagL1aPacketProperties], missing_sequences: list[int] = <factory>, _compression_flags_list: list = <factory>) None#
Methods
__init__(is_mago, is_active, shcoarse, ...)Check if all vectors in the file are from the primary sensor.
append_vectors(additional_vectors, ...)Append additional vectors to the current vectors array.
calculate_vector_time(vectors, ...)Add timestamps to the vector list, turning the shape from (n, 4) to (n, 5).
convert_diffs_to_vectors(first_vector, ...)Given a list of differences and the first vector, return calculated vectors.
decode_fib_zig_zag(code)Decode a fibonacci and zig-zag encoded value.
process_compressed_vectors(vector_data, ...)Given raw compressed packet data, process into Vectors.
process_range_data_section(range_data, vectors)Given a range data section and vectors, return an updated vector array.
process_uncompressed_vectors(vector_data, ...)Given raw uncompressed packet data, process into Vectors.
process_vector_data(vector_data, ...)Transform raw vector data into Vectors.
twos_complement(value, bits)Compute the two's complement of an integer.
unpack_one_vector(vector_data, width, has_range)Unpack a single vector from the vector data.
update_compression_array(packet_properties, ...)Create or update compression_flags with 1 flag per timestamp.
Generate a string describing the vectors per second.
Attributes
Return the compression flags array.
Concatenate the internal vector list into a numpy array.