Exemplo n.º 1
0
import os
import GMR.InputOutput as io

main_dir = io.config_dir_path()

exp_settings = io.exp_in(main_dir)
print(f'Experiment Settings:\n {exp_settings}\n')

for hs_img in exp_settings['hs_imgs']:
    img_dir = os.path.join(main_dir, hs_img)
    if not os.path.isdir(img_dir):
        continue
    corrected_img_dir = os.path.join(img_dir, 'corrected_imgs')

    data_files = io.extract_files(dir_name=corrected_img_dir,
                                  file_string='corrected_img_')
    print(len(data_files))

    data_cube = []

    print('\nBuilding data cube...')
    for index, file in enumerate(data_files):
        file_path = os.path.join(corrected_img_dir, file)
        corrected_img, file_name = io.array_in(file_path, mode='r')
        data_cube.append(corrected_img)

        io.update_progress(index / len(data_files))

    print('\nSaving data cube...approximately 1min per 100 imgs')
    io.array_out(array_name=data_cube,
                 file_name=f'{hs_img}_datacube',
Exemplo n.º 2
0
import os
import numpy as np
import matplotlib.pyplot as plt
import csv
import shutil

import GMR.InputOutput as io
import GMR.DataPreparation as dprep
import GMR.DataProcessing as dproc

sensor = 'Nanohole_Array'  ## Set this to the photonic crystal used ##

root = io.config_dir_path()

for date_dir in os.listdir(root):
    selected_date = os.path.join(root, date_dir)
    print(f'Looking at: {date_dir}')

    print('Background Calibration')
    bg_dir = os.path.join(selected_date, 'Background')
    bg_datafiles = io.extract_files(dir_name=bg_dir,
                                    file_string='_Background.csv')

    for index, selected_file in enumerate(bg_datafiles):
        file = os.path.join(bg_dir, selected_file)
        zero_file = os.path.join(bg_dir, f'{sensor}_Background.csv')

        wavelength, intensity, file_name = io.csv_in(file)
        wav_naught, int_naught, zero_name = io.csv_in(zero_file)

        fig, ax = plt.subplots(1, 1, figsize=[10, 7])