-
Notifications
You must be signed in to change notification settings - Fork 1
/
Preferences.py
281 lines (199 loc) · 11.9 KB
/
Preferences.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
from PyQt5.QtCore import QSettings, QSize, QPoint
from Constants import Constants
class Preferences(QSettings):
# The following are the preferences available
# How should frames be combined? Stored as an integer corresponding to one of
# the COMBINE_xxx constants in the Constants class
MASTER_COMBINE_METHOD = "master_combine_method"
# If the Min-Max method is used, how many points are dropped from each end (min and max)
# before the remaining points are Mean-combined? Returns an integer > 0.
MIN_MAX_NUMBER_CLIPPED_PER_END = "min_max_number_clipped_per_end"
# If Sigma-Clip method is used, what is the threshold sigma score?
# Data farther than this many standard deviations from the sample mean are rejected,
# the the remaining points are mean-combined. Floating point number > 0.
SIGMA_CLIP_THRESHOLD = "sigma_clip_threshold"
# What do we do with the input files after a successful combine?
# Gives an integer from the constants class DISPOSITION_xxx
INPUT_FILE_DISPOSITION = "input_file_disposition"
# Folder name to move input files if DISPOSITION is SUBFOLDER
DISPOSITION_SUBFOLDER_NAME = "disposition_subfolder_name"
# Main window size and position - so last window move or resizing is remembered
MAIN_WINDOW_SIZE = "main_window_size"
MAIN_WINDOW_POSITION = "main_window_position"
# Console window size
CONSOLE_WINDOW_SIZE = "console_window_size"
CONSOLE_WINDOW_POSITION = "console_window_position"
# What kind of precalibration is done to images before combining
# Gives an integer from the constants class CALIBRATION_
IMAGE_PRE_CALIBRATION = "image_pre_calibration"
# Pedestal value if pedestal option chosen
PRE_CALIBRATION_PEDESTAL = "pre_calibration_pedestal"
# File path if bias/dark file is to be subtracted
PRE_CALIBRATION_FILE = "pre_calibration_file"
# File path to auto bias directory
PRE_CALIBRATION_AUTO_DIRECTORY = "pre_calibration_auto_directory"
# Should auto-directory (for bias) recursively search sub-directories too?
AUTO_DIRECTORY_RECURSIVE = "auto_directory_recursive"
# Should auto-directory restrict files considered to only BIAS files?
AUTO_DIRECTORY_BIAS_ONLY = "auto_directory_bias_only"
DISPLAY_AUTO_SELECT_RESULTS = "display_auto_select_results"
# Are we processing multiple file sets at once using grouping?
GROUP_BY_SIZE = "group_by_size"
GROUP_BY_TEMPERATURE = "group_by_temperature"
GROUP_BY_FILTER = "group_by_filter"
# How much, as a percentage, can temperatures vary before being considered a different group?
TEMPERATURE_GROUP_BANDWIDTH = "temperature_group_bandwidth"
# Should we ignore small groups (probably haven't finished collecting them yet)? How small
IGNORE_GROUPS_FEWER_THAN = "ignore_groups_fewer_than"
MINIMUM_GROUP_SIZE = "minimum_group_size"
# Should ADU values for FITS files be displayed in the main window (slows down processing
# since every file has to be read in its entirety to populate the window)
DISPLAY_AVERAGE_ADUS = "display_average_adus"
def __init__(self):
QSettings.__init__(self, "EarwigHavenObservatory.com", "MasterFlatMaker_b")
# print(f"Preferences file path: {self.fileName()}")
# Getters and setters for preferences values
# How should frames be combined? Stored as an integer corresponding to one of
# the COMBINE_xxx constants in the Constants class
def get_master_combine_method(self) -> int:
result = int(self.value(self.MASTER_COMBINE_METHOD, defaultValue=Constants.COMBINE_SIGMA_CLIP))
assert (result == Constants.COMBINE_SIGMA_CLIP) \
or (result == Constants.COMBINE_MINMAX) \
or (result == Constants.COMBINE_MEDIAN) \
or (result == Constants.COMBINE_MEAN)
return result
def set_master_combine_method(self, value: int):
assert (value == Constants.COMBINE_SIGMA_CLIP) or (value == Constants.COMBINE_MINMAX) \
or (value == Constants.COMBINE_MEDIAN) or (value == Constants.COMBINE_MEAN)
self.setValue(self.MASTER_COMBINE_METHOD, value)
# If the Min-Max method is used, how many points are dropped from each end (min and max)
# before the remaining points are Mean-combined? Returns an integer > 0.
def get_min_max_number_clipped_per_end(self) -> int:
result = int(self.value(self.MIN_MAX_NUMBER_CLIPPED_PER_END, defaultValue=2))
assert result > 0
return result
def set_min_max_number_clipped_per_end(self, value: int):
assert value > 0
self.setValue(self.MIN_MAX_NUMBER_CLIPPED_PER_END, value)
# If Sigma-Clip method is used, what is the threshold sigma score?
# Data farther than this many sigmas (ratio of value and std deviation of set) from the sample mean
# are rejected, the the remaining points are mean-combined. Floating point number > 0.
def get_sigma_clip_threshold(self) -> float:
result = float(self.value(self.SIGMA_CLIP_THRESHOLD, defaultValue=2.0))
assert result > 0.0
return result
def set_sigma_clip_threshold(self, value: float):
assert value > 0.0
self.setValue(self.SIGMA_CLIP_THRESHOLD, value)
# What to do with input files after a successful combine
def get_input_file_disposition(self):
result = int(self.value(self.INPUT_FILE_DISPOSITION, defaultValue=Constants.INPUT_DISPOSITION_NOTHING))
assert (result == Constants.INPUT_DISPOSITION_NOTHING) or (result == Constants.INPUT_DISPOSITION_SUBFOLDER)
return result
def set_input_file_disposition(self, value: int):
assert (value == Constants.INPUT_DISPOSITION_NOTHING) or (value == Constants.INPUT_DISPOSITION_SUBFOLDER)
self.setValue(self.INPUT_FILE_DISPOSITION, value)
# Where to move input files if disposition "subfolder" is chosen
def get_disposition_subfolder_name(self):
return self.value(self.DISPOSITION_SUBFOLDER_NAME, defaultValue="originals-%d-%t")
def set_disposition_subfolder_name(self, value: str):
self.setValue(self.DISPOSITION_SUBFOLDER_NAME, value)
# Main window size when resized
def get_main_window_size(self) -> QSize:
return self.value(self.MAIN_WINDOW_SIZE, defaultValue=None)
def set_main_window_size(self, size: QSize):
self.setValue(self.MAIN_WINDOW_SIZE, size)
# Main window position when moved
def get_main_window_position(self) -> QPoint:
return self.value(self.MAIN_WINDOW_POSITION, defaultValue=None)
def set_main_window_position(self, position: QPoint):
self.setValue(self.MAIN_WINDOW_POSITION, position)
# Console window size when resized
def get_console_window_size(self) -> QSize:
return self.value(self.CONSOLE_WINDOW_SIZE, defaultValue=None)
def set_console_window_size(self, size: QSize):
self.setValue(self.CONSOLE_WINDOW_SIZE, size)
# Console window position when moved
def get_console_window_position(self) -> QPoint:
return self.value(self.CONSOLE_WINDOW_POSITION, defaultValue=None)
def set_console_window_position(self, position: QPoint):
self.setValue(self.CONSOLE_WINDOW_POSITION, position)
# Pre-calibration method
def get_precalibration_type(self) -> int:
result = int(self.value(self.IMAGE_PRE_CALIBRATION, defaultValue=Constants.CALIBRATION_NONE))
assert (result == Constants.CALIBRATION_NONE) \
or (result == Constants.CALIBRATION_FIXED_FILE) \
or (result == Constants.CALIBRATION_AUTO_DIRECTORY) \
or (result == Constants.CALIBRATION_PEDESTAL)
return result
def set_precalibration_type(self, value: int):
assert (value == Constants.CALIBRATION_NONE) \
or (value == Constants.CALIBRATION_FIXED_FILE) \
or (value == Constants.CALIBRATION_AUTO_DIRECTORY) \
or (value == Constants.CALIBRATION_PEDESTAL)
self.setValue(self.IMAGE_PRE_CALIBRATION, value)
# Pedestal value used if pre-calibration option "pedestal" is chosen
def get_precalibration_pedestal(self) -> int:
return int(self.value(self.PRE_CALIBRATION_PEDESTAL, defaultValue=Constants.DEFAULT_CALIBRATION_PEDESTAL))
def set_precalibration_pedestal(self, value: int):
self.setValue(self.PRE_CALIBRATION_PEDESTAL, value)
# File path if fixed bias/dark file is to be subtracted
def get_precalibration_fixed_path(self) -> str:
return str(self.value(self.PRE_CALIBRATION_FILE, defaultValue=""))
def set_precalibration_fixed_path(self, path: str):
self.setValue(self.PRE_CALIBRATION_FILE, path)
# Directory path if automatic selection of bias from directory is used
def get_precalibration_auto_directory(self) -> str:
return str(self.value(self.PRE_CALIBRATION_AUTO_DIRECTORY, defaultValue=""))
def set_precalibration_auto_directory(self, path: str):
self.setValue(self.PRE_CALIBRATION_AUTO_DIRECTORY, path)
# Should auto-directory (for bias) recursively search sub-directories too?
def get_auto_directory_recursive(self) -> bool:
return self.value(self.AUTO_DIRECTORY_RECURSIVE, defaultValue=True)
def set_auto_directory_recursive(self, path: bool):
self.setValue(self.AUTO_DIRECTORY_RECURSIVE, path)
# Should auto-directory restrict files considered to only BIAS files?
def get_auto_directory_bias_only(self) -> bool:
return self.value(self.AUTO_DIRECTORY_BIAS_ONLY, defaultValue=True)
def set_auto_directory_bias_only(self, path: bool):
self.setValue(self.AUTO_DIRECTORY_BIAS_ONLY, path)
# Are we processing multiple file sets at once using grouping?
def get_group_by_size(self) -> bool:
return bool(self.value(self.GROUP_BY_SIZE, defaultValue=False))
def set_group_by_size(self, is_grouped: bool):
self.setValue(self.GROUP_BY_SIZE, is_grouped)
def get_group_by_temperature(self) -> bool:
return bool(self.value(self.GROUP_BY_TEMPERATURE, defaultValue=False))
def set_group_by_temperature(self, is_grouped: bool):
self.setValue(self.GROUP_BY_TEMPERATURE, is_grouped)
def get_group_by_filter(self) -> bool:
return bool(self.value(self.GROUP_BY_FILTER, defaultValue=False))
def set_group_by_filter(self, is_grouped: bool):
self.setValue(self.GROUP_BY_FILTER, is_grouped)
def get_display_auto_select_results(self) -> bool:
return bool(self.value(self.DISPLAY_AUTO_SELECT_RESULTS, defaultValue=True))
def set_display_auto_select_results(self, display: bool):
self.setValue(self.DISPLAY_AUTO_SELECT_RESULTS, display)
# Bandwidth to use for clustering temperatures into groups
def get_temperature_group_bandwidth(self) -> float:
bandwidth: float = float(self.value(self.TEMPERATURE_GROUP_BANDWIDTH, defaultValue=1.0))
assert 0.1 <= bandwidth <= 50.0
return bandwidth
def set_temperature_group_bandwidth(self, bandwidth: float):
assert 0.1 <= bandwidth <= 50.0
self.setValue(self.TEMPERATURE_GROUP_BANDWIDTH, bandwidth)
# Should we ignore small groups (probably haven't finished collecting them yet)? How small?
def get_ignore_groups_fewer_than(self) -> bool:
return bool(self.value(self.IGNORE_GROUPS_FEWER_THAN, defaultValue=False))
def set_ignore_groups_fewer_than(self, ignore: bool):
self.setValue(self.IGNORE_GROUPS_FEWER_THAN, ignore)
def get_minimum_group_size(self) -> int:
return int(self.value(self.MINIMUM_GROUP_SIZE, defaultValue=32))
def set_minimum_group_size(self, value: int):
self.setValue(self.MINIMUM_GROUP_SIZE, value)
# Should ADU values for FITS files be displayed in the main window (slows down processing
# since every file has to be read in its entirety to populate the window)
def get_display_average_adus(self) -> bool:
return bool(self.value(self.DISPLAY_AVERAGE_ADUS, defaultValue=False))
def set_display_average_adus(self, display: bool):
self.setValue(self.DISPLAY_AVERAGE_ADUS, display)