forked from IMAP-Science-Operations-Center/imap_processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathccsds_data.py
More file actions
51 lines (43 loc) · 1.17 KB
/
ccsds_data.py
File metadata and controls
51 lines (43 loc) · 1.17 KB
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
"""Contain a data class for CCSDS data."""
from dataclasses import dataclass, fields
@dataclass
class CcsdsData:
"""
Data class for CCSDS header.
Parameters
----------
packet_header : dict
Dictionary of packet headers.
Attributes
----------
VERSION: int
CCSDS Packet Version Number.
TYPE: int
CCSDS Packet Type Indicator.
SEC_HDR_FLG: int
CCSDS Packet Secondary Header Flag.
PKT_APID: int
CCSDS Packet Application Process ID.
SEQ_FLGS: int
CCSDS Packet Grouping Flags.
SRC_SEQ_CTR: int
CCSDS Packet Sequence Count.
PKT_LEN: int
CCSDS Packet Length.
"""
VERSION: int
TYPE: int
SEC_HDR_FLG: int
PKT_APID: int
SEQ_FLGS: int
SRC_SEQ_CTR: int
PKT_LEN: int
def __init__(self, packet_header: dict):
attributes = [field.name for field in fields(self)]
for key, value in packet_header.items():
if key in attributes:
setattr(self, key, value)
else:
raise KeyError(
f"Did not find matching attribute in Histogram data class for {key}"
)