-
Notifications
You must be signed in to change notification settings - Fork 1
/
DataModel.py
214 lines (161 loc) · 8.79 KB
/
DataModel.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
#
# Data model for this program, storing the information for one combination session.
# (As opposed to the Preferences object which permanently stores default settings that will
# be used for future sessions.)
#
# This data model is displayed and edited on the main window when using the GUI, or
# modified by command-line flags when using the command line. It is initialized when
# created from values in the Preferences object
#
from Constants import Constants
from Preferences import Preferences
class DataModel:
def __init__(self, preferences: Preferences):
"""
Create data model from given preferences object. This also lists all the fetch/settable values
:param preferences: Program preferences to establish model's default values
"""
self._master_combine_method: int = preferences.get_master_combine_method()
self._min_max_number_clipped_per_end: int = preferences.get_min_max_number_clipped_per_end()
self._sigma_clip_threshold: float = preferences.get_sigma_clip_threshold()
self._input_file_disposition: int = preferences.get_input_file_disposition()
self._disposition_subfolder_name: str = preferences.get_disposition_subfolder_name()
self._precalibration_type: int = preferences.get_precalibration_type()
self._precalibration_pedestal: int = preferences.get_precalibration_pedestal()
self._precalibration_fixed_path: str = preferences.get_precalibration_fixed_path()
self._precalibration_auto_directory: str = preferences.get_precalibration_auto_directory()
self._auto_directory_recursive: bool = preferences.get_auto_directory_recursive()
self._auto_directory_bias_only: bool = preferences.get_auto_directory_bias_only()
self._group_by_size: bool = preferences.get_group_by_size()
self._group_by_temperature: bool = preferences.get_group_by_temperature()
self._group_by_filter: bool = preferences.get_group_by_filter()
self._temperature_group_bandwidth: float = preferences.get_temperature_group_bandwidth()
self._ignore_file_type: bool = False
self._ignore_groups_fewer_than: bool = preferences.get_ignore_groups_fewer_than()
self._minimum_group_size: int = preferences.get_minimum_group_size()
self._display_average_adus: bool = preferences.get_display_average_adus()
self._display_auto_select_results: bool = preferences.get_display_auto_select_results()
def get_master_combine_method(self) -> int:
result = self._master_combine_method
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._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 = self._min_max_number_clipped_per_end
assert result > 0
return result
def set_min_max_number_clipped_per_end(self, value: int):
assert value > 0
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 = self._sigma_clip_threshold
assert result > 0.0
return result
def set_sigma_clip_threshold(self, value: float):
assert value > 0.0
self._sigma_clip_threshold = value
# What to do with input files after a successful combine
def get_input_file_disposition(self):
result = self._input_file_disposition
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._input_file_disposition = value
# Where to move input files if disposition "subfolder" is chosen
def get_disposition_subfolder_name(self):
return self._disposition_subfolder_name
def set_disposition_subfolder_name(self, value: str):
self._disposition_subfolder_name = value
# Pre-calibration method
def get_precalibration_type(self) -> int:
result = self._precalibration_type
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._precalibration_type = value
# Pedestal value used if pre-calibration option "pedestal" is chosen
def get_precalibration_pedestal(self) -> int:
result = self._precalibration_pedestal
assert 0 <= result <= 0xffff
return result
def set_precalibration_pedestal(self, value: int):
assert 0 <= value <= 0xffff
self._precalibration_pedestal = value
# File path if fixed bias/dark file is to be subtracted
def get_precalibration_fixed_path(self) -> str:
return self._precalibration_fixed_path
def set_precalibration_fixed_path(self, path: str):
self._precalibration_fixed_path = path
# Directory path if automatic selection of bias from directory is used
def get_precalibration_auto_directory(self) -> str:
return self._precalibration_auto_directory
def set_precalibration_auto_directory(self, path: str):
self._precalibration_auto_directory = path
# Are we processing multiple file sets at once using grouping?
def get_group_by_size(self) -> bool:
return self._group_by_size
def set_group_by_size(self, is_grouped: bool):
self._group_by_size = is_grouped
def get_group_by_temperature(self) -> bool:
return self._group_by_temperature
def set_group_by_temperature(self, is_grouped: bool):
self._group_by_temperature = is_grouped
def get_group_by_filter(self) -> bool:
return self._group_by_filter
def set_group_by_filter(self, is_grouped: bool):
self._group_by_filter = is_grouped
def get_auto_directory_recursive(self) -> bool:
return self._auto_directory_recursive
def set_auto_directory_recursive(self, is_recursive: bool):
self._auto_directory_recursive = is_recursive
def get_auto_directory_bias_only(self) -> bool:
return self._auto_directory_bias_only
def set_auto_directory_bias_only(self, bias_only: bool):
self._auto_directory_bias_only = bias_only
def get_display_auto_select_results(self) -> bool:
return self._display_auto_select_results
def set_display_auto_select_results(self, display: bool):
self._display_auto_select_results = display
# How much, as a percentage, can temperatures vary before being considered a different group?
def get_temperature_group_bandwidth(self) -> float:
bandwidth: float = self._temperature_group_bandwidth
assert 0.1 <= bandwidth <= 50
return bandwidth
def set_temperature_group_bandwidth(self, bandwidth: float):
assert 0.1 <= bandwidth <= 50
self._temperature_group_bandwidth = bandwidth
def get_ignore_file_type(self) -> bool:
return self._ignore_file_type
def set_ignore_file_type(self, ignore: bool):
self._ignore_file_type = ignore
def get_ignore_groups_fewer_than(self) -> bool:
return self._ignore_groups_fewer_than
def set_ignore_groups_fewer_than(self, ignore: bool):
self._ignore_groups_fewer_than = ignore
def get_minimum_group_size(self) -> int:
return self._minimum_group_size
def set_minimum_group_size(self, minimum: int):
self._minimum_group_size = minimum
def get_display_average_adus(self) -> bool:
return self._display_average_adus
def set_display_average_adus(self, display: bool):
self._display_average_adus = display