-
Notifications
You must be signed in to change notification settings - Fork 0
/
BiasFrameSet.py
54 lines (46 loc) · 1.94 KB
/
BiasFrameSet.py
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
from FrameSet import FrameSet
class BiasFrameSet(FrameSet):
# No additional attributes for Bias Frames
def fieldNumberAsString(self, field_number: int) -> str:
"""Translate column number of frame table to a string, for bias frames"""
result = "invalid"
if field_number == 0:
result = str(self._numberOfFrames)
elif field_number == 1:
result = "Bias"
elif field_number == 2:
result = ""
elif field_number == 3:
result = f"{self._binning} x {self._binning}"
elif field_number == 4:
result = str(self._numberComplete)
else:
print("fieldNumberAsString: invalid field number " + str(field_number))
# print(f"FrameSet {self} field {field_number} returns {result}")
return result
def __str__(self):
return f"BiasFrameSet<{self._numberOfFrames} BIAS {self._binning} x {self._binning}" \
+ f"({str(self._numberComplete)} complete)>"
def encode(self):
"""JSON encode this bias frame set"""
return {
"_type": "BiasFrameSet",
"_value": self.__dict__
}
def type_name_text(self) -> str:
"""Provide printable label for this kind of frame"""
return "Bias"
# The numeric type code for THeSkyX for this kind of image. 2=Bias, 3=Dark
def camera_image_type_code(self) -> int:
"""Return the magic code number that TheSkyX uses for bias frames"""
return 2
@classmethod
def decode(cls, obj):
"""JSON decode given dict into a BiasFrameSet"""
# print(f"BiasFrameSet/decode({obj}")
assert (obj["_type"] == "BiasFrameSet")
value_dict = obj['_value']
new_number_of_frames = value_dict["_numberOfFrames"]
new_binning = value_dict["_binning"]
new_complete = value_dict["_numberComplete"]
return BiasFrameSet(new_number_of_frames, new_binning, new_complete)