import matplotlib.pyplot as plt
from src.model.qacd_project import QACDProject

filename = 'test_data/test_data.quack'

project = QACDProject()
project.load_file(filename)
print('State:', project.state)
print('Elements:', project.elements)
print('Ratios:', project.ratios)
print('Presets:', project.get_valid_preset_ratios())

if len(project.ratios) == 0:
    project.create_ratio_map('Mg#', preset='Mg#')
    project.create_ratio_map('Example',
                             elements=('Ca', 'Na'),
                             correction_model='pyroxene')
    print('Ratios:', project.ratios)
else:
    names = ['Mg#', 'Example']
    for i, name in enumerate(names):
        ratio, stats = project.get_ratio(name, want_stats=True)
        plt.subplot(len(names), 1, i + 1)
        plt.imshow(ratio)
        plt.colorbar()
        plt.title('{} = {}'.format(stats['name'], stats['formula']))
    plt.show()
Beispiel #2
0
if 0:
    project.import_raw_csv_files('test_data')
    #project.import_raw_csv_files('/home/iant/Desktop/Johan_Lissenberg_Xmas2015',
    #                             ['Ca K series.csv', 'Mg K series.csv'])
else:
    project.import_raw_csv_files(
        'test_data', ['Ca K series.csv', 'Na K series.csv', 'Mg K series.csv'])

project.filter(pixel_totals=True, median=True)
project.normalise()
project.create_h_factor()
project.create_ratio_map('some ratio',
                         elements=['Mg', 'Ca'],
                         correction_model='pyroxene')
project.create_ratio_map('Anorthite', preset='anorthite')
print(project.get_valid_preset_ratios())
print(project.ratios)
#project.write_debug()

kmin = 5
kmax = 10
project.k_means_clustering(kmin, kmax, want_all_elements=True)

if 1:
    # Plot k-means clustering.
    for k in range(kmin, kmax + 1):
        plt.subplot(2, 3, k + 1 - kmin)
        labels, stats = project.get_cluster_indices(k, want_stats=True)
        print(k, stats)
        if 1:
            cmap = cm.get_cmap('rainbow', k)  # k discrete levels