-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathconstants.py
More file actions
114 lines (93 loc) · 3.13 KB
/
constants.py
File metadata and controls
114 lines (93 loc) · 3.13 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"""Module for constants and useful shared classes used in GLOWS."""
from dataclasses import dataclass
import numpy as np
@dataclass(frozen=True)
class TimeTuple:
"""
Spacecraft clock time, a float divided into seconds and subseconds.
Attributes
----------
seconds: int
Seconds of clock, integer
subseconds: int
Subseconds of clock, defined as 1/SUB_SECOND_LIMIT th of a second. Will
always be less than SUB_SECOND_LIMIT. If the class is initialized with a
subsecond value above SUB_SECOND_LIMIT, the subseconds above the limit will be
converted to seconds.
"""
seconds: int
subseconds: int
def __post_init__(self) -> None:
"""Add any subseconds over the limit into the seconds field."""
final_seconds = self.seconds
final_subseconds = self.subseconds
if final_subseconds >= GlowsConstants.SUBSECOND_LIMIT:
final_seconds += self.subseconds // GlowsConstants.SUBSECOND_LIMIT
final_subseconds = self.subseconds % GlowsConstants.SUBSECOND_LIMIT
object.__setattr__(self, "seconds", final_seconds)
object.__setattr__(self, "subseconds", final_subseconds)
def to_seconds(self) -> np.double:
"""
Convert the TimeTuple to seconds.
Returns
-------
np.single
TimeTuple in seconds.
"""
return np.double(
self.seconds + self.subseconds / GlowsConstants.SUBSECOND_LIMIT
)
@dataclass(frozen=True)
class GlowsConstants:
"""
Constants for GLOWS which can be used across different levels or classes.
Attributes
----------
SUBSECOND_LIMIT: int
subsecond limit for GLOWS clock (and consequently also onboard-interpolated
IMAP clock)
SCAN_CIRCLE_ANGULAR_RADIUS: float
angular radius of IMAP/GLOWS scanning circle [deg]
HISTOGRAM_FILLVAL: int
Fill value for histogram bins (65535 for uint16)
STANDARD_BIN_COUNT: int
Standard number of bins per histogram (3600)
IS_NIGHT_FLAG_IDX: int
Index of the is_night flag in the bad-time flags array (0-indexed)
"""
SUBSECOND_LIMIT: int = 2_000_000
SCAN_CIRCLE_ANGULAR_RADIUS: float = 75.0
HISTOGRAM_FILLVAL: int = 65535
STANDARD_BIN_COUNT: int = 3600
IS_NIGHT_FLAG_IDX: int = 6
@dataclass
class DirectEvent:
"""
DirectEvent() class for IMAP/GLOWS.
Authors: Marek Strumik, maro@cbk.waw.pl, Maxine Hartnett
Attributes
----------
timestamp: TimeTuple
Timestamp for the direct event
impulse_length: int
Direct event data
multi_event: bool
If the event was a multi event. Defaults to False.
"""
timestamp: TimeTuple
impulse_length: int
multi_event: bool = False
def to_list(self) -> list:
"""
Convert object to list [seconds, subseconds, impulse length, multievent].
Returns
-------
list
Converted object to list.
"""
return [
self.timestamp.seconds,
self.timestamp.subseconds,
self.impulse_length,
self.multi_event,
]