Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ RadClass is designed to be modular, allowing a user to use analysis modules as n
![RadClass Workflow](/images/RadClass_workflow.png)

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.
`RadClass` then uses `DataSet` and the user specified `AnalysisParameters` to run, storing the results for use by the user.
To see examples of how a user can initialize and run `RadClass`, review /tests/.
`Processor` then uses `DataSet` and the user specified `AnalysisParameters` to run, storing the results for use by the user.
To see examples of how a user can initialize and run `Processor`, review /tests/.

## Data Format

`RadClass` expects a data structure as follows:
`RadClass.Processor` expects a data structure as follows:

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

Expand Down
2 changes: 1 addition & 1 deletion RadClass/RadClass.py → RadClass/Processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import RadClass.DataSet as ds


class RadClass:
class Processor:
'''
Bulk handler class. Contains most functions needed for processing data
stream files and pass along to an analysis object.
Expand Down
Binary file modified images/RadClass_workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions tests/test_BackgroundEstimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from datetime import datetime, timedelta

from RadClass.RadClass import RadClass
from RadClass.Processor import Processor
from RadClass.BackgroundEstimator import BackgroundEstimator
import tests.test_data as test_data

Expand Down Expand Up @@ -40,8 +40,8 @@ def test_estimation():
confidence = 0.8
bckg = BackgroundEstimator(confidence=confidence)
# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, store_data=True, analysis=bckg)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, store_data=True, analysis=bckg)
classifier.run_all()

bckg.estimate()
Expand Down Expand Up @@ -69,8 +69,8 @@ def test_write():
confidence = 0.8
bckg = BackgroundEstimator(confidence=confidence)
# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, store_data=True, analysis=bckg)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, store_data=True, analysis=bckg)
classifier.run_all()

ofilename = 'bckg_test'
Expand Down
14 changes: 7 additions & 7 deletions tests/test_DiffSpectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from datetime import datetime, timedelta

from RadClass.RadClass import RadClass
from RadClass.Processor import Processor
from RadClass.DiffSpectra import DiffSpectra
import tests.test_data as test_data

Expand Down Expand Up @@ -34,9 +34,9 @@ def test_difference():
# small stride since there are less data samples in test_data
diff_stride = 2
post_analysis = DiffSpectra(stride=diff_stride)
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, post_analysis=post_analysis,
store_data=True)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, post_analysis=post_analysis,
store_data=True)
classifier.run_all()

diff_spectra = post_analysis.diff_spectra
Expand Down Expand Up @@ -81,9 +81,9 @@ def test_write():
# small stride since there are less data samples in test_data
diff_stride = 2
post_analysis = DiffSpectra(stride=diff_stride)
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, post_analysis=post_analysis,
store_data=True)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, post_analysis=post_analysis,
store_data=True)
classifier.run_all()
post_analysis.write(filename)

Expand Down
18 changes: 9 additions & 9 deletions tests/test_H0.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from datetime import datetime, timedelta

from RadClass.RadClass import RadClass
from RadClass.Processor import Processor
from RadClass.H0 import H0
import tests.test_data as test_data

Expand Down Expand Up @@ -49,8 +49,8 @@ def test_gross():

# run handler script with analysis parameter
analysis = H0()
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, analysis=analysis)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, analysis=analysis)
classifier.run_all()

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

# run handler script with analysis parameter
analysis = H0(gross=False, energy_bins=test_data.energy_bins)
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, analysis=analysis)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, analysis=analysis)
classifier.run_all()

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

# run handler script with analysis parameter
analysis = H0()
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, analysis=analysis)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, analysis=analysis)
classifier.run_all()
analysis.write(filename)

Expand All @@ -115,8 +115,8 @@ def test_write_channel():

# run handler script with analysis parameter
analysis = H0(gross=False, energy_bins=test_data.energy_bins)
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, analysis=analysis)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, analysis=analysis)
classifier.run_all()
analysis.write(filename)

Expand Down
75 changes: 37 additions & 38 deletions tests/test_RadClass.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from multiprocessing.sharedctypes import Value
import numpy as np
import h5py
import pytest
import os
from datetime import datetime, timedelta

from RadClass.RadClass import RadClass
from RadClass.Processor import Processor
import tests.test_data as test_data

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

# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, analysis=NullAnalysis(),
store_data=False)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, analysis=NullAnalysis(),
store_data=False)
classifier.run_all()

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

classifier = RadClass(stride=stride, integration=integration,
datapath=test_data.datapath,
filename=test_data.filename, store_data=store_data,
cache_size=cache_size, stop_time=stop_time,
labels=test_data.labels)
classifier = Processor(stride=stride, integration=integration,
datapath=test_data.datapath,
filename=test_data.filename, store_data=store_data,
cache_size=cache_size, stop_time=stop_time,
labels=test_data.labels)

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

# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, store_data=True)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, store_data=True)
classifier.run_all()

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

# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, store_data=True,
cache_size=cache_size)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, store_data=True,
cache_size=cache_size)
classifier.run_all()

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

# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename)
classifier.run_all()

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

# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename)
classifier.run_all()
classifier.write(filename)

Expand Down Expand Up @@ -184,9 +183,9 @@ def test_start():
start_time = timestamps[integration]

# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, store_data=True,
cache_size=cache_size, start_time=start_time)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, store_data=True,
cache_size=cache_size, start_time=start_time)
classifier.run_all()

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

# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, store_data=True,
cache_size=cache_size, stop_time=stop_time)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, store_data=True,
cache_size=cache_size, stop_time=stop_time)
classifier.run_all()

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

# run handler script
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, store_data=True,
stop_time=stop_time)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, store_data=True,
stop_time=stop_time)
classifier.run_all()

# the resulting 1-hour observation should be:
Expand All @@ -259,23 +258,23 @@ def test_bad_start_stop():
# Checks if start_time > stop_time
start_time = timestamps[1]
stop_time = timestamps[0]
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, start_time=start_time,
stop_time=stop_time)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, start_time=start_time,
stop_time=stop_time)
with pytest.raises(ValueError):
classifier.queue_file()

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

# checks if stop_time < first timestamp
stop_time = timestamps[0] - 1000.0
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, stop_time=stop_time)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, stop_time=stop_time)
with pytest.raises(ValueError):
classifier.queue_file()

Expand All @@ -287,8 +286,8 @@ def test_equal_start_stop():
# Checks if start_time = stop_time
start_time = timestamps[0]
stop_time = timestamps[0]
classifier = RadClass(stride, integration, test_data.datapath,
test_data.filename, start_time=start_time,
stop_time=stop_time)
classifier = Processor(stride, integration, test_data.datapath,
test_data.filename, start_time=start_time,
stop_time=stop_time)
with pytest.raises(RuntimeWarning):
classifier.queue_file()