Example #1
0
import csv
import numpy as np
import pandas as pd
from data_loader import load_file
from scipy.io import savemat
import glob

for idx in range(15, 16):
    fname = glob.glob(f"data/19_04_2021/*_{idx}.bin*")[0]
    table, range_res, vel_res = load_file(fname)
    table = np.average(table, 1)
    table = table.reshape((table.shape[0], table.shape[1]))

    # pd.DataFrame(table).to_csv(fname.replace(".bin", ".csv"))
    savemat(fname.replace(".bin", ".mat"), {"radar": table})
# Set plot params
plt.rc('font', size=14)  # controls default text sizes
plt.rc('axes', titlesize=14)  # fontsize of the axes title
plt.rc('axes', labelsize=16)  # fontsize of the x and y labels
plt.rc('xtick', labelsize=14)  # fontsize of the tick labels
plt.rc('ytick', labelsize=14)  # fontsize of the tick labels
plt.rc('legend', fontsize=14)  # legend fontsize

# Specify files to load
ag_file = 'Ag_200nm_10pt'
au_file = 'Au_200nm_10pt'
pd_file = 'Pd_200nm_10pt'
lamp_file = 'CRS_700nm'

# Load lamp spectra
lamp_data, _ = load_file(lamp_file)
lamp_spectra = lamp_data["spectra_0"]

# Define dict
spectra_dict = {
    "Ag": {
        "file": ag_file,
        "wvl": [],
        "avg_spectra": np.zeros((1024)),
        "peak_pos": 0,
        "color": "slategray"
    },
    "Au": {
        "file": au_file,
        "wvl": [],
        "avg_spectra": np.zeros((1024)),
# Set plot params
plt.rcParams["font.family"] = "Times New Roman"
plt.rc('font', size=14)          # controls default text sizes
plt.rc('axes', titlesize=14)     # fontsize of the axes title
plt.rc('axes', labelsize=16)    # fontsize of the x and y labels
plt.rc('xtick', labelsize=14)    # fontsize of the tick labels
plt.rc('ytick', labelsize=14)    # fontsize of the tick labels
plt.rc('legend', fontsize=14)    # legend fontsize

# Load the data
filename = 'Ag_200nm_10pt'
lamp_spectrum_file = 'CRS_700nm'
background_spectra = 0

# Size of sensor is 1024x256
data, nbr_particles = load_file(filename)
lamp_data, s = load_file(lamp_spectrum_file)

# Plot the data
fig, ax = plt.subplots(figsize=(10,6))
ax = fig.gca(projection='3d')
wvl = data["lambda"]
background = data["spectra_" + str(background_spectra)]
lamp_spectra = lamp_data["spectra_0"]

peak_guesses = [540+i*20 for i in range(nbr_particles)]
#peak_guesses.reverse()
peak_positions = []
for i in range(0,nbr_particles):
    spectra = data[f'spectra_{i}']
    if not i == background_spectra:
Example #4
0
plt.rc('font', size=14)  # controls default text sizes
plt.rc('axes', titlesize=14)  # fontsize of the axes title
plt.rc('axes', labelsize=14)  # fontsize of the x and y labels
plt.rc('xtick', labelsize=14)  # fontsize of the tick labels
plt.rc('ytick', labelsize=14)  # fontsize of the tick labels
plt.rc('legend', fontsize=14)  # legend fontsize

# Files
filename = 'Pd_diskrod_200nm_15pt_pulse2'
lamp_file = 'CRS_700nm_glas'
gas_file = 'Lab_TIF295_ArH2_pulses_Pd_2'
nbr_particles = 15
samples_to_plot = [12, 14]

# Load lamp spectra
lamp_data, _ = load_file(lamp_file)
lamp_spectra = lamp_data["spectra_0"]

# Load gas data - ndarray [t,h2]
gas_data = read_gas_file(gas_file)
#fig_gas, ax_gas = plt.subplots()
#ax_gas.plot(gas_data[0], gas_data[1])

# Load data
measurements = read_timeseries(filename, nbr_particles)
#print(measurements)

peak_guess = 750  # About 750 nm is a good guess for Pd

# Loop over all measurements at different times t
peak_positions = [[] for i in range(nbr_particles)]
Example #5
0
from data_loader import load_file
from k_means import Kmeans
from dbscan import DBSCAN
from random import shuffle
from utils import calculate_accuracy
from sklearn.cluster import KMeans
from utils import euclidean_distance
import pry

raw_data = load_file('iris.data')
classes = set([x[-1] for x in raw_data])
class_dict = {}
test_data = {}
train_data = []
for kelas in classes:
    class_dict[kelas] = list(filter(lambda x: x[-1] == kelas, raw_data))
    shuffle(class_dict[kelas])

    test_data[kelas] = [x[:-1] for x in class_dict[kelas][:10]]
    train_data += [x[:-1] for x in class_dict[kelas][10:]]

db_scan = DBSCAN(1, 0.5)
pry()
db_scan.fit(train_data[:10])
db_scan.clusters
Example #6
0
                n_slice = len(glob.glob('{0}/rawdata*.mat'.format(subject_id)))

                output = []
                target = []
                input0 = []
                normalization = []

                for i in range(1, n_slice + 1):

                    raw = '{0}/rawdata{1}.mat'.format(subject_id, i)
                    sen = '{0}/espirit{1}.mat'.format(subject_id, i)
                    mask = '{0}/{1}'.format(which_view, dataset['mask'])

                    rawdata = sio.loadmat(raw)['rawdata']
                    if dataset['name'] == 'axial_t2':
                        coil_sensitivities = load_file(sen)
                        coil_sensitivities = data2complex(
                            coil_sensitivities['sensitivities']).transpose(
                                2, 1, 0)
                    else:
                        coil_sensitivities = np.complex64(
                            sio.loadmat(sen)['sensitivities'])

                    mask_func = MaskFunc(center_fractions=[center_fract],
                                         accelerations=[acc])
                    img_und, img_gt, rawdata_und, masks, sensitivity = data_for_training(
                        rawdata, coil_sensitivities, mask_func)

                    # add batch dimension
                    batch_img_und = img_und.unsqueeze(0).to(device)
                    batch_rawdata_und = rawdata_und.unsqueeze(0).to(device)
Example #7
0
# t_frames = t_sample[::]
# print(len(t_sample))
# v_sample = _mixing_func(t_sample)

table = np.zeros((n_r, n_s), dtype=np.complex)

for chirp_nr in range(n_r):
    t_start = chirp_nr * (1 / f_chirp)
    t_frame = np.linspace(t_start, t_start + T_r, n_s)
    v_sample = _mixing_func(t_frame)
    table[chirp_nr, :] = v_sample

# plt.plot(get_all_ranges(np.linspace(0,50,))[0])
# plt.show()

table = load_file(all_data["exp5_2_3"])[0]
# table -= np.average(table, axis=0)

# table, range_res, vel_res = load_file("data/18032021/empty_2lane_Raw_0.bin")

# table = np.average(table, axis=1)

chirp0_samples = table[0, :]
chirp0_magnitude = np.abs(fft(chirp0_samples))
frequencies = np.arange(0, n_s // 2) * f_s / n_s

# plt.scatter(np.linspace(0,200,200),chirp0_magnitude)
# plt.show()


def freq_to_range(f):