diff --git a/brukeropusreader/opus_data.py b/brukeropusreader/opus_data.py index 3407358..fd3e648 100644 --- a/brukeropusreader/opus_data.py +++ b/brukeropusreader/opus_data.py @@ -1,4 +1,3 @@ -import matplotlib.pyplot as plt import csv import numpy as np from numpy import linalg @@ -19,38 +18,12 @@ class OpusData(object): self.interpolated_data = interp self.meta = meta - def plot_raw(self): - plt.plot(self.raw_data[0], self.raw_data[1], 'o', markeredgewidth=1, - markeredgecolor='r', markerfacecolor='None') - plt.show() - - def plot_interpolated(self): - if self.interpolated_data: - plt.plot(self.interpolated_data[0], self.interpolated_data[1], 'o') - plt.show() - else: - raise NoInterpolatedDataException() - - def plot_data(self): - plt.plot(self.raw_data[0], self.raw_data[1], 'bo') - if self.interpolated_data: - plt.plot(self.interpolated_data[0], - self.interpolated_data[1], - 'ro') - plt.show() - def compare_with(self, file_path): with open(file_path, 'rb') as csv_file: csv_reader = csv.reader(csv_file) - x_r = np.array(map(lambda x: float(x[1:]), next(csv_reader)[2:])) y_r = np.array(map(lambda x: float(x), next(csv_reader)[2:])) - dist = linalg.norm(y_r - self.interpolated_data[1], ord=1) - print("L1 distance between rbart and python versions:", dist) - plt.plot(x_r, y_r, 'bo') - plt.plot(self.interpolated_data[0], - self.interpolated_data[1], - 'ro') - plt.show() + dist = linalg.norm(y_r - self.raw_data[1], ord=1) + print("L1 distance between series:", dist) def gen_interp_waves(self, conf): wunit = (conf.wave_start - conf.wave_end) / (float(conf.iwsize - 1)) diff --git a/example.py b/example.py index 1156638..abd1bf6 100644 --- a/example.py +++ b/example.py @@ -1,26 +1,18 @@ from brukeropusreader.opus_reader import opus_reader -from os import walk -import os + import sys +import argparse -def filter_fun(nm): - return (nm[0] != '.') and (nm[-2:] in ('.0', '.1', '.2', '.3')) - - -def main(path_to_opus_files): - i = 0 - all_files = 0 - for path, subdirs, files in walk(path_to_opus_files): - for name in filter(filter_fun, files): - all_files += 1 - try: - od = opus_reader(os.path.join(path, name)) - od.plot_raw() - except Exception as e: - i += 1 - print(i, ":", name, str(e)) +def main(path_to_file): + od = opus_reader(path_to_file) + print(od.raw_data[1]) if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument("opus_path", + help="Path to opus file", + action="store") + args = parser.parse_args() main(sys.argv[1]) diff --git a/requirements.in b/requirements.in index f23634b..6bad103 100644 --- a/requirements.in +++ b/requirements.in @@ -1,3 +1,2 @@ numpy scipy -matplotlib diff --git a/requirements.txt b/requirements.txt index f69a35d..450dea8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,13 +4,5 @@ # # pip-compile --output-file requirements.txt requirements.in # -backports.functools-lru-cache==1.4 # via matplotlib -cycler==0.10.0 # via matplotlib -matplotlib==2.1.0 numpy==1.13.3 -pyparsing==2.2.0 # via matplotlib -python-dateutil==2.6.1 # via matplotlib -pytz==2017.2 # via matplotlib scipy==0.19.1 -six==1.11.0 # via cycler, matplotlib, python-dateutil -subprocess32==3.2.7 # via matplotlib