Merge branch 'dev' into 'main'

Added CSV file support, scrolling to allow for more data, and implemented first row secs option.

See merge request sta-git/propulsion/stahr/plotting-tool!2
This commit is contained in:
Max Heckmann 2023-01-17 21:35:45 +00:00
commit fa59c5522b
7 changed files with 115 additions and 22 deletions

Binary file not shown.

View File

@ -9,7 +9,7 @@ This is an attempt to standardize data plotting in Space Team Aachen, or at leas
Currently, the plotting tool covers the following functionalities:
- Process “tdms” files
- Process "tdms" and "csv" files
- Process multiple files at once
- generate time values with increment
- Automatically creates a folder-structure for the results
@ -114,15 +114,14 @@ One last disclaimer: If there is a mistake in the data set, if you use a comma i
There are numerous functionalities still missing. The following list provides an overview of all important functions, that should be added as soon as possible (more or less). The order of precedence represents the priority.
1. Implement the “first row secs” functionality as described before
2. Support the file formats CSV and TXT
3. Merge plots (more than one data set in a single plot) Maybe another tool for that?
4. Select/ Unselect all checkboxes in one column with a button
5. “Set all” button for start and end time
6. Choose the order of the move mean filter
7. Add a custom x-axis label
8. Add the option for a derivation plot
9. Allow multiple loads (Load different folder in one session)
10. Add try and catch statements around every user input
1. Support the file format TXT
2. Merge plots (more than one data set in a single plot) Maybe another tool for that?
3. Select/ Unselect all checkboxes in one column with a button
4. “Set all” button for start and end time
5. Choose the order of the move mean filter
6. Add a custom x-axis label
7. Add the option for a derivation plot
8. Allow multiple loads (Load different folder in one session)
9. Add try and catch statements around every user input
You are very welcome to help develop this tool further. If you are planning to do so, please send me a message (Max Heckmann) and I give you a short introduction in the already existing code. This probably saves you some time.

View File

@ -14,17 +14,44 @@ function fourierPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, chan
if fileSettings{2}.Value == 0
[timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel);
else
%TO DO
if ending == 0
timeArray = data(:,1);
yData = data(:, channel);
else
timeIndex = 1;
while data(timeIndex,1) < str2double(start{channel}.Value)
timeIndex = timeIndex + 1;
end
startIndex = timeIndex;
while data(timeIndex, 1) <= str2double(stop{channel}.Value) || timeIndex >= length(data)
timeArray(timeIndex - startIndex + 1) = data(timeIndex,1);
timeIndex = timeIndex + 1;
end
endIndex = timeIndex;
for timeIndex = startIndex:endIndex - 1
yData(timeIndex - startIndex + 1) = data(timeIndex, channel);
end
end
end
fs = 1 / fileSettings{3}.Value;
if length(yData) < 1024
Nspec = length(yData) - 1;
else
Nspec = 1024;
end
wspec = hamming(Nspec);
Noverlap = Nspec/2;
hold on
figure(channel)
spectrogram(yData, wspec, Noverlap, Nspec, fs, 'yaxis');
title(channels{channel});

View File

@ -14,7 +14,30 @@ function graphPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, channe
if fileSettings{2}.Value == 0
[timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel);
else
%TO DO
if ending == 0
timeArray = data(:,1);
yData = data(:, channel);
else
timeIndex = 1;
while data(timeIndex,1) < str2double(start{channel}.Value)
timeIndex = timeIndex + 1;
end
startIndex = timeIndex;
while data(timeIndex, 1) <= str2double(stop{channel}.Value) || timeIndex >= length(data)
timeArray(timeIndex - startIndex + 1) = data(timeIndex,1);
timeIndex = timeIndex + 1;
end
endIndex = timeIndex;
for timeIndex = startIndex:endIndex - 1
yData(timeIndex - startIndex + 1) = data(timeIndex, channel);
end
end
end

View File

@ -1,11 +1,20 @@
function [channels] = loadChannels(path, filenames)
function [channels] = loadChannels(path, filenamesTDMS, filenamesCSV)
channels = {};
for i = 1:length(filenames)
channel = tdmsinfo(append(path, '\', filenames(i).name)).ChannelList;
% read TDMS file headers
for i = 1:length(filenamesTDMS)
channel = tdmsinfo(append(path, '\', filenamesTDMS(i).name)).ChannelList;
channel = channel{:, "ChannelName"};
channels{i} = channel;
end
% read CSV file headers
for i = length(filenamesTDMS) + 1:length(filenamesCSV) + length(filenamesTDMS)
channel = readtable(strcat(path, '\', filenamesCSV(i - length(filenamesTDMS)).name), ...
'VariableNamingRule','preserve');
channel = channel.Properties.VariableNames;
channel = string(channel);
channels{i} = channel.';
end
end

View File

@ -1,18 +1,31 @@
function [dataListTable] = loadData(tdmsFileList)
function [dataListTable] = loadData(tdmsFileList, csvFileList)
%Convert struct to cell for easy access
tdmsFileList = struct2cell(tdmsFileList);
if width(tdmsFileList) > 0
path = tdmsFileList{2, 1};
else
path = csvFileList(1).folder;
end
%load TDMS files
for i = 1:width(tdmsFileList)
%Read files and save them as a table in a list
data = tdmsread(strcat(tdmsFileList{2, i}, '\', tdmsFileList{1, i}));
data = tdmsread(strcat(path, '\', tdmsFileList{1, i}));
%Take the table out of an 1x1 cell array and convert it in a cell array.
dataListTable{i} = table2array(data{1,1});
end
%load CSV files
for i = width(tdmsFileList) + 1: length(csvFileList) + width(tdmsFileList)
%Read CSV files
dataListTable{i} = readmatrix(strcat(path, '\', csvFileList(i - width(tdmsFileList)).name));
end
end

View File

@ -14,7 +14,29 @@ function meanPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, channel
if fileSettings{2}.Value == 0
[timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel);
else
%TO DO
if ending == 0
timeArray = data(:,1);
yData = data(:, channel);
else
timeIndex = 1;
while data(timeIndex,1) < str2double(start{channel}.Value)
timeIndex = timeIndex + 1;
end
startIndex = timeIndex;
while data(timeIndex, 1) <= str2double(stop{channel}.Value) || timeIndex >= length(data)
timeArray(timeIndex - startIndex + 1) = data(timeIndex,1);
timeIndex = timeIndex + 1;
end
endIndex = timeIndex;
for timeIndex = startIndex:endIndex - 1
yData(timeIndex - startIndex + 1) = data(timeIndex, channel);
end
end
end