[1e781ba] | 1 | import struct
|
---|
| 2 | import numpy as np
|
---|
| 3 | from AmmosIFDataHeader import AmmosIFDataHeader
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | class AmmosExtendedIFDataHeader():
|
---|
| 7 |
|
---|
| 8 | @classmethod
|
---|
| 9 | def from_bytes(cls, bytes):
|
---|
| 10 | standard_header = AmmosIFDataHeader.from_bytes(bytes[0:56])
|
---|
| 11 | extended_header_elements = struct.unpack('QQI', bytes[56:76])
|
---|
| 12 | block_count = standard_header.block_count
|
---|
| 13 | block_length = standard_header.block_length
|
---|
| 14 | timestamp = standard_header.timestamp
|
---|
| 15 | status = standard_header.status
|
---|
| 16 | source_id = standard_header.source_id
|
---|
| 17 | source_state = standard_header.source_state
|
---|
| 18 | frequency = standard_header.frequency
|
---|
| 19 | bandwidth = standard_header.bandwidth
|
---|
| 20 | sample_rate = standard_header.sample_rate
|
---|
| 21 | interpolation = standard_header.interpolation
|
---|
| 22 | decimation = standard_header.decimation
|
---|
| 23 | voltage_ref = standard_header.voltage_ref
|
---|
| 24 | stream_start = np.datetime64(int(extended_header_elements[0]), 'ns')
|
---|
| 25 | sample_counter = extended_header_elements[1]
|
---|
| 26 | antenna_correction = extended_header_elements[2]
|
---|
| 27 | size = len(bytes)
|
---|
| 28 | return AmmosExtendedIFDataHeader(size, block_count, block_length, timestamp, status, source_id,
|
---|
| 29 | source_state, frequency, bandwidth, sample_rate, interpolation,
|
---|
| 30 | decimation, voltage_ref, stream_start, sample_counter,
|
---|
| 31 | antenna_correction)
|
---|
| 32 |
|
---|
| 33 | def __init__(self, size, block_count, block_length, timestamp, status, source_id, source_state, frequency,
|
---|
| 34 | bandwidth, sample_rate, interpolation, decimation, voltage_ref, stream_start, sample_counter,
|
---|
| 35 | antenna_correction):
|
---|
| 36 |
|
---|
| 37 | self.size = size
|
---|
| 38 | self.block_count = block_count
|
---|
| 39 | self.block_length = block_length
|
---|
| 40 | self.timestamp = timestamp
|
---|
| 41 | self.status = status
|
---|
| 42 | self.source_id = source_id
|
---|
| 43 | self.source_state = source_state
|
---|
| 44 | self.frequency = frequency
|
---|
| 45 | self.bandwidth = bandwidth
|
---|
| 46 | self.sample_rate = sample_rate
|
---|
| 47 | self.interpolation = interpolation
|
---|
| 48 | self.decimation = decimation
|
---|
| 49 | self.voltage_ref = voltage_ref
|
---|
| 50 | self.stream_start = stream_start
|
---|
| 51 | self.sample_counter = sample_counter
|
---|
| 52 | self.antenna_correction = antenna_correction
|
---|
| 53 |
|
---|
| 54 | def __str__(self):
|
---|
| 55 | output = (
|
---|
| 56 | "\nGlobal frame body data header\n" +
|
---|
| 57 | "-----------------------------\n" +
|
---|
| 58 | "Block count:" + str(self.block_count) + "\n" +
|
---|
| 59 | "Block length:" + str(self.block_length) + "\n" +
|
---|
| 60 | "Time stamp:" + str(self.timestamp) + "\n" +
|
---|
| 61 | "Frequency:" + str(self.frequency) + "\n" +
|
---|
| 62 | "Bandwidth:" + str(self.bandwidth) + "\n" +
|
---|
| 63 | "Sample rate:" + str(self.sample_rate) + "\n" +
|
---|
| 64 | "Stream start:" + str(self.stream_start) + "\n" +
|
---|
| 65 | "Sample counter:" + str(self.sample_counter) + "\n" +
|
---|
| 66 | "Antenna correction:" + str(self.antenna_correction) + "\n"
|
---|
| 67 | )
|
---|
| 68 |
|
---|
| 69 | return output
|
---|