# Plotting Tool - User Guide

This is an attempt to standardize data plotting in Space Team Aachen, or at least to create a standard tool for it. If you just want to use the tool, read the first two parts of the article. If you want to help to develop the tool, then go to the section “Developer information”. Do you miss some functionalities which aren't listed in the section “Developer information”? Feel free to comment them down below.

<p class="callout warning">The tool is currently in the beta phase. I did some tests and everything should work, but I'm not quite sure that my tests covered all cases. So if problems occur, don't hesitate to write me a message (Max Heckmann).  
</p>

### Functionalities

Currently, the plotting tool covers the following functionalities:

- Process "tdms", "csv" and "txt" files
- Process multiple files at once
- generate time values with increment
- Automatically creates a folder-structure for the results
- Freely selectable start and end time
- Choose custom label for y-axis (x-axis is always time in seconds)
- Generate a normal plot
- Generate a plot of the data processed by a move-mean filter (20th order)
- Generate a spectrogram of the fourier analysis
- Merge the generated .fig files into singular files

### Accessing the tool

First, you're going to need MATLAB. Thankfully, the RWTH provides a free Matlab license for all students. Click [here](https://www.matlab.rwth-aachen.de/cms/matlab/~tjyju/Campuslizenz/) for further information. Next, you need the plotting tool itself. If you already set up your git account and key, just clone the repository. Don't forget to pull before every use, in order to get all the updates.

Don't worry, there is another solution for all mechanical engineers and other people who are not that familiar with “new” technology. With this solution, you still need access to Space Team Aachen GitLab, but you don't have to set up the SSH-Key. Press the download button in the right corner, as you can see in the picture.

[![git.PNG](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/scaled-1680-/git.PNG)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/git.PNG)

Once you have all the files on your PC. Open the file “PlottingTool.mlapp”. (Compare with the picture)

[![filesPlottingTool.PNG](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/scaled-1680-/filesplottingtool.PNG)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/filesplottingtool.PNG)

This probably takes some time. First, Matlab will open up. Then, without doing anything, a smaller window will open which looks like this:

[![UIMatlabPlotter.PNG](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/scaled-1680-/VIDuimatlabplotter.PNG)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/VIDuimatlabplotter.PNG)

### Using the tool

Press “Select Folder” in order to choose the folder which contains the data. Important: Don't select a file – only the folder. The software is able to handle multiple files in a folder. After that, press the “Load” button. This might take some time as well. You can only press the load button ones. Restart the software if you made a mistake. The UI should look similar to this.

[![UILoad.PNG](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/scaled-1680-/uiload.PNG)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/uiload.PNG)

The software generates a row with bold letters for each file. This row provides settings for the whole file. So, in the example above, there were 4 relevant files in the folder. Under each of these file-setting-rows are rows for the different channels, which provide the possibility for specific channel settings. That means, for example, the 03\_AIC.tdms file probably looked like this:

<table border="1" id="bkmrk-n2-valves-n2-purge-n" style="border-collapse: collapse; width: 100%; height: 119.2px;"><colgroup><col style="width: 20%;"></col><col style="width: 20%;"></col><col style="width: 20%;"></col><col style="width: 20%;"></col><col style="width: 20%;"></col></colgroup><tbody><tr style="height: 29.8px;"><td class="align-center" style="height: 29.8px;">**N2 Valves**  
</td><td class="align-center" style="height: 29.8px;">**N2 Purge**  
</td><td class="align-center" style="height: 29.8px;">**N2 Supply**  
</td><td class="align-center" style="height: 29.8px;">**N2O Supply DLR**  
</td><td class="align-center" style="height: 29.8px;">**Injector**  
</td></tr><tr style="height: 29.8px;"><td class="align-center" style="height: 29.8px;">1.23  
</td><td class="align-center" style="height: 29.8px;">24.3  
</td><td class="align-center" style="height: 29.8px;">53.2  
</td><td class="align-center" style="height: 29.8px;">12.2  
</td><td class="align-center" style="height: 29.8px;">12.0  
</td></tr><tr style="height: 29.8px;"><td class="align-center" style="height: 29.8px;">3.0  
</td><td class="align-center" style="height: 29.8px;">22.7  
</td><td class="align-center" style="height: 29.8px;">19.1  
</td><td class="align-center" style="height: 29.8px;">23.8  
</td><td class="align-center" style="height: 29.8px;">2.4  
</td></tr><tr style="height: 29.8px;"><td class="align-center" style="height: 29.8px;">...  
</td><td class="align-center" style="height: 29.8px;">...  
</td><td class="align-center" style="height: 29.8px;">...  
</td><td class="align-center" style="height: 29.8px;">...  
</td><td class="align-center" style="height: 29.8px;">...</td></tr></tbody></table>

You maybe noticed the missing time column in the chart above. This is not a mistake. It's sometimes possible to measure the data in such a constant frequency, that there is no need to measure the time. If so, all the program needs to know is the time difference between each measurement-value – the increment. This is nothing else than the reciprocal of the measurement frequency.

<p class="callout warning">The following paragraph describes the usage of the "First row secs" checkbox, which is a feature, which isn't implemented yet, although it is already visible in the UI.</p>

If you measured the time separately, because the measurement frequency isn't constant, check the box called “First row secs”. If this checkbox is ticked, the software would assume that the file “03\_AIC.tdms” looks like this:

<table border="1" id="bkmrk-time-%5Bs%5D-n2-valves-n" style="border-collapse: collapse; width: 100%; height: 119.2px;"><tbody><tr style="height: 29.8px;"><td class="align-center" style="height: 29.8px; width: 16.6873%;">**Time \[s\]**  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">**N2 Valves**  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">**N2 Purge**  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">**N2 Supply**  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">**N2O Supply DLR**  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">**Injector**  
</td></tr><tr style="height: 29.8px;"><td class="align-center" style="height: 29.8px; width: 16.6873%;">0.1</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">1.23  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">24.3  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">53.2  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">12.2  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">12.0  
</td></tr><tr style="height: 29.8px;"><td class="align-center" style="height: 29.8px; width: 16.6873%;">0.2  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">3.0  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">22.7  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">19.1  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">23.8  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">2.4  
</td></tr><tr style="height: 29.8px;"><td class="align-center" style="height: 29.8px; width: 16.6873%;">...  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">...  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">...  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">...  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">...  
</td><td class="align-center" style="height: 29.8px; width: 16.6873%;">...</td></tr></tbody></table>

The rest of the user interface is self-explanatory. “Graph” generates a normal plot, "Fourier" analyses the spectrum, “movemean” generates a plot of the data processed by a move-mean filter of the 20th order. You have the opportunity to set a start and an end time for the plots (use a period, not a comma). **If the end time is zero, the software plots the data till the end.** You can set a specific y label for each plot. The x label is always time in seconds. Here are some random examples:

[![PreCC.png](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/scaled-1680-/precc.png)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/precc.png)[![PreCC.png](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/scaled-1680-/O5Kprecc.png)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/O5Kprecc.png)



[![Thrust 20kN.png](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/scaled-1680-/JKXthrust-20kn.png)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2022-12/JKXthrust-20kn.png)



Press “Generate Plots” if you're done with the settings. Choose a storage location – I recommend creating a new folder. Press “ok”. Now different figures are popping up and immediately vanish again. Wait till all figures are closed. The plots should now be found in the specified location.

The plots are always saved as png and fig files. If you need a different y-scale for some plots, find specific data points or much more, open the fig file with Matlab. The Matlab figure UI provides such functionalities, as well as the possibility to save the edited plot.

One last disclaimer: If there is a mistake in the data set, if you use a comma instead of a period, if you write words in fields which expect a number and in many other cases, the software will crash. This software isn't made to be used without a brain.

### Merge Tool

To access the merge tool, follow the instructions for the plotting tool, but select the file **"mergeTool.mlapp"** instead.

The merge tool functions very similarly to the main Plotting tool. In the top of the UI there is a "Select File" and "Path" Text field. Use either of these to specify the first file and then press "Add". Repeat this process for every file you wish to use.

[![MergeUILoad.PNG](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-01/18limage.png)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-01/18limage.png)

Now you can use the "X-Axis Label" and "Y-Axis Label" text fields to change the Labels as needed. In the Rows below you should now see all the .fig files you selected with a "Name in Legend" text field, which allows you to change how the extracted data will be labled in the legend.

[![MergeUIConfig.PNG](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-01/i4yimage.png)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-01/i4yimage.png)

Finally hit the "Generate Merged Plot" button and you will be asked to select the location, where the "merged.fig" and "merged.png" files will be placed. You can continue to use the tool and add more .fig files after the generation.

[![MergeUIGenerate.PNG](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-01/lEpimage.png)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-01/lEpimage.png)

**IMPORTANT: The merge tool, will extract only the "main" plot from each file.** I.e. if you merge a Derivative .fig file (which contains both the original function and it's derivative), **only** the derivative will be added to the new merged figure.

#### Merging with subplots

To merge with subplots please consult this guide:

[![MergeUIGenerate.PNG](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-04/subplotguide.png)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-04/subplotguide.png)

For every supported amount of selected files, there are two sublpot Versions A and B. Simply select the one you wish to use in the drop down menu:

[![MergeUIGenerate.PNG](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-04/Mo0image.png)](https://wiki.intern.spaceteamaachen.de/uploads/images/gallery/2023-04/Mo0image.png)

### Developer information

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. Get the custom x-Axis label to work on the fourier plot
2. Add try and catch statements around every user input
3. Add support for merging plots with multiple data entries

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.