From fac603636475fbd1699b6e4fcafa721336192fb1 Mon Sep 17 00:00:00 2001 From: charlydelta Date: Sat, 16 Dec 2017 19:40:17 +0100 Subject: [PATCH 1/3] Octave-compatible changes --- src/file/ImportAgilent.m | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) mode change 100755 => 100644 src/file/ImportAgilent.m diff --git a/src/file/ImportAgilent.m b/src/file/ImportAgilent.m old mode 100755 new mode 100644 index bd1577f..a396a31 --- a/src/file/ImportAgilent.m +++ b/src/file/ImportAgilent.m @@ -102,20 +102,25 @@ % --------------------------------------- p = inputParser; -addParameter(p, 'file', default.file); -addParameter(p, 'depth', default.depth); -addParameter(p, 'content', default.content, @ischar); -addParameter(p, 'verbose', default.verbose, @ischar); +% CHANGE REASON: addParameter is undefined as of Octave 4.0.1, which is what I am using. It may have changed in more recent versions + +%addParameter(p, 'file', default.file); +%addParameter(p, 'depth', default.depth); +%addParameter(p, 'content', default.content, @ischar); +%addParameter(p, 'verbose', default.verbose, @ischar); parse(p, varargin{:}); % --------------------------------------- % Options % --------------------------------------- -option.file = p.Results.file; -option.depth = p.Results.depth; -option.content = p.Results.content; -option.verbose = p.Results.verbose; + +% CHANGE REASON: p would be uninitialised because of the prior change otherwise, which lead to more errors. This is just a 'short-circuit' + +option.file = default.file; +option.depth = default.depth; +option.content = default.content; +option.verbose = default.verbose; % --------------------------------------- % Validate @@ -346,7 +351,11 @@ function status(varargin) end % JFileChooser (Java) -fc = javax.swing.JFileChooser(java.io.File(pwd)); + +% CHANGE REASON: This is the Octave way of initialising an Java object. According to this source [1] it looks like it also works with MATLAB +% [1] http://www.ece.northwestern.edu/local-apps/matlabhelp/techdoc/ref/javaobject.html + +fc = javaObject("javax.swing.JFileChooser"); % Options fc.setFileSelectionMode(fc.FILES_AND_DIRECTORIES); @@ -354,13 +363,16 @@ function status(varargin) fc.setAcceptAllFileFilterUsed(false); % Filter: Agilent (.D, .MS, .CH, .UV) -agilent = com.mathworks.hg.util.dFilter; -agilent.setDescription('Agilent files (*.D, *.MS, *.CH, *.UV)'); -agilent.addExtension('d'); -agilent.addExtension('ms'); -agilent.addExtension('ch'); -agilent.addExtension('uv'); +% CHANGE REASON: The com.mathworks.* Java package does of course not exist in Octave. Since this merely filters the UI I disabled it completely, but the following changes replicate the functionality using standard Java classes + +allowedFileExtensions = javaArray ("java.lang.String", 4); +allowedFileExtensions(1) = "d" +allowedFileExtensions(2) = "ms" +allowedFileExtensions(3) = "ch" +allowedFileExtensions(4) = "uv" + +agilent = javaObject("javax.swing.filechooser.FileNameExtensionFilter", "Agilent files (*.D, *.MS, *.CH, *.UV)", allowedFileExtensions); fc.addChoosableFileFilter(agilent); From ba6aa01e2dfa10b2e07ea51c11dbc30f3798e1bb Mon Sep 17 00:00:00 2001 From: charlydelta Date: Sat, 16 Dec 2017 19:41:48 +0100 Subject: [PATCH 2/3] Fix quotes --- src/file/ImportAgilent.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/file/ImportAgilent.m b/src/file/ImportAgilent.m index a396a31..3bb734c 100644 --- a/src/file/ImportAgilent.m +++ b/src/file/ImportAgilent.m @@ -355,7 +355,7 @@ function status(varargin) % CHANGE REASON: This is the Octave way of initialising an Java object. According to this source [1] it looks like it also works with MATLAB % [1] http://www.ece.northwestern.edu/local-apps/matlabhelp/techdoc/ref/javaobject.html -fc = javaObject("javax.swing.JFileChooser"); +fc = javaObject('javax.swing.JFileChooser'); % Options fc.setFileSelectionMode(fc.FILES_AND_DIRECTORIES); @@ -366,13 +366,13 @@ function status(varargin) % CHANGE REASON: The com.mathworks.* Java package does of course not exist in Octave. Since this merely filters the UI I disabled it completely, but the following changes replicate the functionality using standard Java classes -allowedFileExtensions = javaArray ("java.lang.String", 4); -allowedFileExtensions(1) = "d" -allowedFileExtensions(2) = "ms" -allowedFileExtensions(3) = "ch" -allowedFileExtensions(4) = "uv" +allowedFileExtensions = javaArray ('java.lang.String', 4); +allowedFileExtensions(1) = 'd' +allowedFileExtensions(2) = 'ms' +allowedFileExtensions(3) = 'ch' +allowedFileExtensions(4) = 'uv' -agilent = javaObject("javax.swing.filechooser.FileNameExtensionFilter", "Agilent files (*.D, *.MS, *.CH, *.UV)", allowedFileExtensions); +agilent = javaObject('javax.swing.filechooser.FileNameExtensionFilter', 'Agilent files (*.D, *.MS, *.CH, *.UV)', allowedFileExtensions); fc.addChoosableFileFilter(agilent); From 6bfc73774e27f0bc194df739826546864feb2b65 Mon Sep 17 00:00:00 2001 From: charlydelta Date: Sat, 16 Dec 2017 20:42:55 +0100 Subject: [PATCH 3/3] Add python plot script and example data --- python-plots/plot.py | 71 + python-plots/raw-data-a.csv | 3001 +++++++++++++++++++++++++++++++++++ 2 files changed, 3072 insertions(+) create mode 100644 python-plots/plot.py create mode 100644 python-plots/raw-data-a.csv diff --git a/python-plots/plot.py b/python-plots/plot.py new file mode 100644 index 0000000..23d15b6 --- /dev/null +++ b/python-plots/plot.py @@ -0,0 +1,71 @@ +import matplotlib +import matplotlib.pyplot as plt +import scipy.integrate as integrate +from scipy.interpolate import interp1d +import csv +import math + +# Config for the plot +font = {'family' : 'Roboto', + 'weight' : 'normal', + 'size' : 20} +matplotlib.rc('font', **font) + +# Constants +PEAK_START_TIME = 150 # !HARDCODED! Time when peak starts (manually derived, [s]) +PEAK_END_TIME = 300 # !HARDCODED! Time when peak ends (manually derived, [s]) + +# Variables +baseline = math.inf + +x_vals = [] +y_vals = [] + +peak_x_vals = [] +peak_y_vals = [] + +# Read data !HARDCODED! Path to CSV data +with open('raw-data-a.csv', newline='') as csvfile: # File must be formatted as: