Skip to content

Commit ee05b92

Browse files
authored
Merge pull request #39 from stompsjo/rename-RadClass
2 parents 0177640 + 3b022a0 commit ee05b92

7 files changed

Lines changed: 62 additions & 63 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ RadClass is designed to be modular, allowing a user to use analysis modules as n
3838
![RadClass Workflow](/images/RadClass_workflow.png)
3939

4040
An HDF5 data file is specified as input, which is processed by `DataSet`. The user can specify a type of `AnalysisParameters`. For example, `H0` for hypothesis testing, `BackgroundEstimator` for background estimation, etc.
41-
`RadClass` then uses `DataSet` and the user specified `AnalysisParameters` to run, storing the results for use by the user.
42-
To see examples of how a user can initialize and run `RadClass`, review /tests/.
41+
`Processor` then uses `DataSet` and the user specified `AnalysisParameters` to run, storing the results for use by the user.
42+
To see examples of how a user can initialize and run `Processor`, review /tests/.
4343

4444
## Data Format
4545

46-
`RadClass` expects a data structure as follows:
46+
`RadClass.Processor` expects a data structure as follows:
4747

4848
![File Structure](/images/file_structure.png)
4949

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import RadClass.DataSet as ds
88

99

10-
class RadClass:
10+
class Processor:
1111
'''
1212
Bulk handler class. Contains most functions needed for processing data
1313
stream files and pass along to an analysis object.

images/RadClass_workflow.png

-73 Bytes
Loading

tests/test_BackgroundEstimator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
from datetime import datetime, timedelta
55

6-
from RadClass.RadClass import RadClass
6+
from RadClass.Processor import Processor
77
from RadClass.BackgroundEstimator import BackgroundEstimator
88
import tests.test_data as test_data
99

@@ -40,8 +40,8 @@ def test_estimation():
4040
confidence = 0.8
4141
bckg = BackgroundEstimator(confidence=confidence)
4242
# run handler script
43-
classifier = RadClass(stride, integration, test_data.datapath,
44-
test_data.filename, store_data=True, analysis=bckg)
43+
classifier = Processor(stride, integration, test_data.datapath,
44+
test_data.filename, store_data=True, analysis=bckg)
4545
classifier.run_all()
4646

4747
bckg.estimate()
@@ -69,8 +69,8 @@ def test_write():
6969
confidence = 0.8
7070
bckg = BackgroundEstimator(confidence=confidence)
7171
# run handler script
72-
classifier = RadClass(stride, integration, test_data.datapath,
73-
test_data.filename, store_data=True, analysis=bckg)
72+
classifier = Processor(stride, integration, test_data.datapath,
73+
test_data.filename, store_data=True, analysis=bckg)
7474
classifier.run_all()
7575

7676
ofilename = 'bckg_test'

tests/test_DiffSpectra.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
from datetime import datetime, timedelta
55

6-
from RadClass.RadClass import RadClass
6+
from RadClass.Processor import Processor
77
from RadClass.DiffSpectra import DiffSpectra
88
import tests.test_data as test_data
99

@@ -34,9 +34,9 @@ def test_difference():
3434
# small stride since there are less data samples in test_data
3535
diff_stride = 2
3636
post_analysis = DiffSpectra(stride=diff_stride)
37-
classifier = RadClass(stride, integration, test_data.datapath,
38-
test_data.filename, post_analysis=post_analysis,
39-
store_data=True)
37+
classifier = Processor(stride, integration, test_data.datapath,
38+
test_data.filename, post_analysis=post_analysis,
39+
store_data=True)
4040
classifier.run_all()
4141

4242
diff_spectra = post_analysis.diff_spectra
@@ -81,9 +81,9 @@ def test_write():
8181
# small stride since there are less data samples in test_data
8282
diff_stride = 2
8383
post_analysis = DiffSpectra(stride=diff_stride)
84-
classifier = RadClass(stride, integration, test_data.datapath,
85-
test_data.filename, post_analysis=post_analysis,
86-
store_data=True)
84+
classifier = Processor(stride, integration, test_data.datapath,
85+
test_data.filename, post_analysis=post_analysis,
86+
store_data=True)
8787
classifier.run_all()
8888
post_analysis.write(filename)
8989

tests/test_H0.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
from datetime import datetime, timedelta
55

6-
from RadClass.RadClass import RadClass
6+
from RadClass.Processor import Processor
77
from RadClass.H0 import H0
88
import tests.test_data as test_data
99

@@ -49,8 +49,8 @@ def test_gross():
4949

5050
# run handler script with analysis parameter
5151
analysis = H0()
52-
classifier = RadClass(stride, integration, test_data.datapath,
53-
test_data.filename, analysis=analysis)
52+
classifier = Processor(stride, integration, test_data.datapath,
53+
test_data.filename, analysis=analysis)
5454
classifier.run_all()
5555

5656
obs_timestamp = analysis.triggers[0][0]
@@ -69,8 +69,8 @@ def test_channel():
6969

7070
# run handler script with analysis parameter
7171
analysis = H0(gross=False, energy_bins=test_data.energy_bins)
72-
classifier = RadClass(stride, integration, test_data.datapath,
73-
test_data.filename, analysis=analysis)
72+
classifier = Processor(stride, integration, test_data.datapath,
73+
test_data.filename, analysis=analysis)
7474
classifier.run_all()
7575

7676
obs_timestamp = analysis.triggers[0][0]
@@ -94,8 +94,8 @@ def test_write_gross():
9494

9595
# run handler script with analysis parameter
9696
analysis = H0()
97-
classifier = RadClass(stride, integration, test_data.datapath,
98-
test_data.filename, analysis=analysis)
97+
classifier = Processor(stride, integration, test_data.datapath,
98+
test_data.filename, analysis=analysis)
9999
classifier.run_all()
100100
analysis.write(filename)
101101

@@ -115,8 +115,8 @@ def test_write_channel():
115115

116116
# run handler script with analysis parameter
117117
analysis = H0(gross=False, energy_bins=test_data.energy_bins)
118-
classifier = RadClass(stride, integration, test_data.datapath,
119-
test_data.filename, analysis=analysis)
118+
classifier = Processor(stride, integration, test_data.datapath,
119+
test_data.filename, analysis=analysis)
120120
classifier.run_all()
121121
analysis.write(filename)
122122

tests/test_RadClass.py

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from multiprocessing.sharedctypes import Value
21
import numpy as np
32
import h5py
43
import pytest
54
import os
65
from datetime import datetime, timedelta
76

8-
from RadClass.RadClass import RadClass
7+
from RadClass.Processor import Processor
98
import tests.test_data as test_data
109

1110
# initialize sample data
@@ -40,9 +39,9 @@ def test_analysis():
4039
integration = int(test_data.timesteps/10)
4140

4241
# run handler script
43-
classifier = RadClass(stride, integration, test_data.datapath,
44-
test_data.filename, analysis=NullAnalysis(),
45-
store_data=False)
42+
classifier = Processor(stride, integration, test_data.datapath,
43+
test_data.filename, analysis=NullAnalysis(),
44+
store_data=False)
4645
classifier.run_all()
4746

4847
np.testing.assert_equal(True, classifier.analysis.changed)
@@ -55,11 +54,11 @@ def test_init():
5554
cache_size = 10000
5655
stop_time = 2e9
5756

58-
classifier = RadClass(stride=stride, integration=integration,
59-
datapath=test_data.datapath,
60-
filename=test_data.filename, store_data=store_data,
61-
cache_size=cache_size, stop_time=stop_time,
62-
labels=test_data.labels)
57+
classifier = Processor(stride=stride, integration=integration,
58+
datapath=test_data.datapath,
59+
filename=test_data.filename, store_data=store_data,
60+
cache_size=cache_size, stop_time=stop_time,
61+
labels=test_data.labels)
6362

6463
np.testing.assert_equal(stride, classifier.stride)
6564
np.testing.assert_equal(integration, classifier.integration)
@@ -75,8 +74,8 @@ def test_integration():
7574
integration = int(test_data.timesteps/10)
7675

7776
# run handler script
78-
classifier = RadClass(stride, integration, test_data.datapath,
79-
test_data.filename, store_data=True)
77+
classifier = Processor(stride, integration, test_data.datapath,
78+
test_data.filename, store_data=True)
8079
classifier.run_all()
8180

8281
# the resulting 1-hour observation should be:
@@ -94,9 +93,9 @@ def test_cache():
9493
cache_size = 100
9594

9695
# run handler script
97-
classifier = RadClass(stride, integration, test_data.datapath,
98-
test_data.filename, store_data=True,
99-
cache_size=cache_size)
96+
classifier = Processor(stride, integration, test_data.datapath,
97+
test_data.filename, store_data=True,
98+
cache_size=cache_size)
10099
classifier.run_all()
101100

102101
# the resulting 1-hour observation should be:
@@ -113,8 +112,8 @@ def test_stride():
113112
integration = 5
114113

115114
# run handler script
116-
classifier = RadClass(stride, integration, test_data.datapath,
117-
test_data.filename)
115+
classifier = Processor(stride, integration, test_data.datapath,
116+
test_data.filename)
118117
classifier.run_all()
119118

120119
# the resulting 1-hour observation should be:
@@ -137,8 +136,8 @@ def test_write():
137136
filename = 'test_results'
138137

139138
# run handler script
140-
classifier = RadClass(stride, integration, test_data.datapath,
141-
test_data.filename)
139+
classifier = Processor(stride, integration, test_data.datapath,
140+
test_data.filename)
142141
classifier.run_all()
143142
classifier.write(filename)
144143

@@ -184,9 +183,9 @@ def test_start():
184183
start_time = timestamps[integration]
185184

186185
# run handler script
187-
classifier = RadClass(stride, integration, test_data.datapath,
188-
test_data.filename, store_data=True,
189-
cache_size=cache_size, start_time=start_time)
186+
classifier = Processor(stride, integration, test_data.datapath,
187+
test_data.filename, store_data=True,
188+
cache_size=cache_size, start_time=start_time)
190189
classifier.run_all()
191190

192191
integration_val = (((2*integration)*(2*integration-1)/2) -
@@ -212,9 +211,9 @@ def test_stop():
212211
stop_time = timestamps[integration*(periods-1)+1]
213212

214213
# run handler script
215-
classifier = RadClass(stride, integration, test_data.datapath,
216-
test_data.filename, store_data=True,
217-
cache_size=cache_size, stop_time=stop_time)
214+
classifier = Processor(stride, integration, test_data.datapath,
215+
test_data.filename, store_data=True,
216+
cache_size=cache_size, stop_time=stop_time)
218217
classifier.run_all()
219218

220219
integration_val = (((integration*(periods-1)) *
@@ -238,9 +237,9 @@ def test_max_stop():
238237
stop_time = timestamps[-1]+1000.0
239238

240239
# run handler script
241-
classifier = RadClass(stride, integration, test_data.datapath,
242-
test_data.filename, store_data=True,
243-
stop_time=stop_time)
240+
classifier = Processor(stride, integration, test_data.datapath,
241+
test_data.filename, store_data=True,
242+
stop_time=stop_time)
244243
classifier.run_all()
245244

246245
# the resulting 1-hour observation should be:
@@ -259,23 +258,23 @@ def test_bad_start_stop():
259258
# Checks if start_time > stop_time
260259
start_time = timestamps[1]
261260
stop_time = timestamps[0]
262-
classifier = RadClass(stride, integration, test_data.datapath,
263-
test_data.filename, start_time=start_time,
264-
stop_time=stop_time)
261+
classifier = Processor(stride, integration, test_data.datapath,
262+
test_data.filename, start_time=start_time,
263+
stop_time=stop_time)
265264
with pytest.raises(ValueError):
266265
classifier.queue_file()
267266

268267
# checks if start_time > last timestamp
269268
start_time = timestamps[-1] + 1000.0
270-
classifier = RadClass(stride, integration, test_data.datapath,
271-
test_data.filename, start_time=start_time)
269+
classifier = Processor(stride, integration, test_data.datapath,
270+
test_data.filename, start_time=start_time)
272271
with pytest.raises(ValueError):
273272
classifier.queue_file()
274273

275274
# checks if stop_time < first timestamp
276275
stop_time = timestamps[0] - 1000.0
277-
classifier = RadClass(stride, integration, test_data.datapath,
278-
test_data.filename, stop_time=stop_time)
276+
classifier = Processor(stride, integration, test_data.datapath,
277+
test_data.filename, stop_time=stop_time)
279278
with pytest.raises(ValueError):
280279
classifier.queue_file()
281280

@@ -287,8 +286,8 @@ def test_equal_start_stop():
287286
# Checks if start_time = stop_time
288287
start_time = timestamps[0]
289288
stop_time = timestamps[0]
290-
classifier = RadClass(stride, integration, test_data.datapath,
291-
test_data.filename, start_time=start_time,
292-
stop_time=stop_time)
289+
classifier = Processor(stride, integration, test_data.datapath,
290+
test_data.filename, start_time=start_time,
291+
stop_time=stop_time)
293292
with pytest.raises(RuntimeWarning):
294293
classifier.queue_file()

0 commit comments

Comments
 (0)