diff --git a/README.md b/README.md index b08bd07..803ee5c 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/RadClass/RadClass.py b/RadClass/Processor.py similarity index 99% rename from RadClass/RadClass.py rename to RadClass/Processor.py index d5f73ff..a3afe92 100644 --- a/RadClass/RadClass.py +++ b/RadClass/Processor.py @@ -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. diff --git a/images/RadClass_workflow.png b/images/RadClass_workflow.png index 718a2d9..e82db98 100644 Binary files a/images/RadClass_workflow.png and b/images/RadClass_workflow.png differ diff --git a/tests/test_BackgroundEstimator.py b/tests/test_BackgroundEstimator.py index 2d10c89..1b67781 100644 --- a/tests/test_BackgroundEstimator.py +++ b/tests/test_BackgroundEstimator.py @@ -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 @@ -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() @@ -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' diff --git a/tests/test_DiffSpectra.py b/tests/test_DiffSpectra.py index 8f584ed..7276364 100644 --- a/tests/test_DiffSpectra.py +++ b/tests/test_DiffSpectra.py @@ -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 @@ -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 @@ -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) diff --git a/tests/test_H0.py b/tests/test_H0.py index 6c1669d..0c7ce8a 100644 --- a/tests/test_H0.py +++ b/tests/test_H0.py @@ -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 @@ -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] @@ -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] @@ -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) @@ -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) diff --git a/tests/test_RadClass.py b/tests/test_RadClass.py index 7825b33..be5b626 100644 --- a/tests/test_RadClass.py +++ b/tests/test_RadClass.py @@ -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 @@ -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) @@ -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) @@ -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: @@ -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: @@ -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: @@ -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) @@ -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) - @@ -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)) * @@ -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: @@ -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() @@ -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()