예제 #1
0
def test_array_clear():
    """
    test_array_clear() ascertains that each run of form_matrix() outputs the appropriate files
    This is done by using two different offsets with an n of 1
    This should break if the two offsets load files that are not of identical dimensions, which occurs if you try to load file 7
    """
    n = 1
    offset = 3
    spectrum_file_location = 'radioxenon_ml/test_files/test'
    first_sim_vec, first_exp_vec = mlmc.form_matrix(spectrum_file_location,n,offset)
    offset = 4
    second_sim_vec, second_exp_vec = mlmc.form_matrix(spectrum_file_location,n,offset)
    print(np.shape(first_exp_vec))
    print(np.shape(second_exp_vec))
    assert np.shape(first_sim_vec) == np.shape(second_sim_vec)
    assert np.shape(first_exp_vec) == np.shape(second_exp_vec)
    print("\nNo assertion errors for import sizes; all input files identical")
예제 #2
0
def test_two_matrices():                        #passes is there are two matrices formed
    """
    test_two_matrices() makes sure two matrices have been formed
    spectrum_file_location = file location of the dummy files, size 6x5
    """
    spectrum_file_location = 'radioxenon_ml/test_files/test'
    simulation_vec, experimental_vec = mlmc.form_matrix(spectrum_file_location)
    assert 'experimental_vec' in locals()
    assert 'simulation_vec' in locals()
    
    print("\nBoth the simulation matrix and the measurement matrix exist!")
    return
예제 #3
0
def test_different_n_values():
    """
    test_different_n_values() makes sure that various values of n can be loaded into the file without it breaking
    Checks if the file exists, then loads it in
    n is set to 1 permenantly such that only one file at a time gets loaded
    If offset is 7 or above, an error should occur
    """
    spectrum_file_location = 'radioxenon_ml/test_files/test' 
    n=1
    for offset in range(0,6):
        try:
            first_sim_vec, first_exp_vec = mlmc.form_matrix(spectrum_file_location,n,offset)
        except FileNotFoundError:
            print(n+1+offset)
            assert n==0
예제 #4
0
def matrix_legitimacy():
    """
    matrix_legitimacy() makes sure the matrices are legitimate, i.e.: they've loaded the right data
    spectrum_file_location = file location of the dummy files, size 6x5
    """
    n = 5
    spectrum_file_location = 'radioxenon_ml/test_files/test'
    simulation_vec, experimental_vec = mlmc.form_matrix(n,spectrum_file_location)
    assert simulation_vec[0,0] == 1
    assert simulation_vec[29,0] == 30
    assert simulation_vec[29,4] == 150
    assert simulation_vec.dtype == 'int32'
    assert experimental_vec.shape[0] == 30
    assert experimental_vec[23] == 11
    
    print("\nBoth the simulation matrix and the measurement matrix are of correct dimensions\nand were correctly built!")
    return
예제 #5
0
from radioxenon_ml.read_in import ml_matrix_composition as mlmc
from radioxenon_ml.solve import iterate
import numpy as np
"""
import radioxenon_ml.read_in.ml_matrix_composition
import radioxenon_ml.solve.iterate
import radioxenon_ml.solve.variance
"""
"""the master file for the radioxenon_ml package"""  
parser = argparse.ArgumentParser(description='This is the master file for running the maximum likelihood package.')
parser.add_argument('-o', '--offset', 
                    type=int,
                    default=84,
                    help='where to start the file selection from list of test files'
                    )
args = parser.parse_args(sys.argv[1:])

spectrum_file_location = 'radioxenon_ml/test_files/test'
offset = args.offset
err = 0.01                              #acceptable error in normalized activity
scale_array = np.array([1,1,1,1])       #Should have elements equal to the number of isotopes
#scale_array = np.array([0.561,0.584,0.9,0.372,0.489,0.489,1])   #scaling factor for each simulation file
                                                              #currently taken from (Czyz, 2017)
n = np.shape(scale_array)[0]            #number of simulated spectra

simulation, experiment, totcount = mlmc.form_matrix(spectrum_file_location,scale_array,n,offset);    #known issue: requires UTF-8 encoding
#simulation, experiment = mlmc.scale_matrix(simulation_unscaled,experiment_unscaled,)

A,J,K,q=iterate.iterate(simulation, experiment, err)
print("\n_____________________________________\nTotal activity percents = " + str(A*100))
예제 #6
0
"""
Created on Sun April 22 13:24:00 2018

@author: Steven Czyz
"""
from radioxenon_ml.read_in import ml_matrix_composition as mlmc
"""the master file for the radioxenon_ml package"""

n = 5  #this is a user defined number to state how many simulation spectra we will be using
spectrum_file_location = 'radioxenon_ml/test_files/test'
offset = 0

simulation_vec, experimental_vec = mlmc.form_matrix(spectrum_file_location)
#known issue: requires UTF-8 encoding