Skip to content
Snippets Groups Projects
Commit bffd379d authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

Merge branch 'dev/example' into 'development'

Dev/example

See merge request !38
parents 57366050 abfaee4b
No related branches found
No related tags found
2 merge requests!43Implements #73, cleans up example file,,!38Dev/example
Pipeline #596999 failed
classdef config < handle classdef config < handle
%CONFIG class handles methoths and attributes related to the config %CONFIG class handles methods and attributes related to the config
%file %file
% Detailed explanation goes here %handle class used for dynamicy property updates
% handle class used for dynamicy property updates
properties (SetAccess = private) properties (SetAccess = private)
mandatoryFields = {'Author', 'ProjectID'} mandatoryFields = {'Author', 'ProjectID'}
...@@ -19,7 +18,8 @@ classdef config < handle ...@@ -19,7 +18,8 @@ classdef config < handle
methods methods
function obj = config(configFileName) function obj = config(configFileName)
%CONFIG Construct an instance of this class %CONFIG Construct an instance of this class
% Detailed explanation goes here % reads config data from config file, if an error occurs the
% wizard is started by the catch block
obj.configFileName = configFileName; obj.configFileName = configFileName;
try try
txt = fileread(obj.configFileName); txt = fileread(obj.configFileName);
...@@ -62,18 +62,12 @@ classdef config < handle ...@@ -62,18 +62,12 @@ classdef config < handle
end end
function configData = addPublishOptions(obj,mode) function configData = addPublishOptions(obj,mode)
%writeConfig writes the config file to path %addPublishOptions adds the publsih options to the config
% TODo; %object depending on the mode
obj.configData.options = obj.plotID_options(mode); obj.configData.options = obj.plotID_options(mode);
cpath = fileparts(obj.configPath); cpath = fileparts(obj.configPath);
obj.writeConfig(cpath); obj.writeConfig(cpath);
end end
function outputArg = method1(obj,inputArg)
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
outputArg = obj.Property1 + inputArg;
end
end end
......
function [options] = plotID_options(input) function [options] = plotID_options(input)
%PLOTID_OPTIONS Summary of this function goes here %PLOTID_OPTIONS gives you a struct with all the options defined in publish
% Detailed explanation goes here % Two modes are implemented default and debug
options = struct(); options = struct();
switch input switch input
......
...@@ -38,8 +38,7 @@ classdef userDLG ...@@ -38,8 +38,7 @@ classdef userDLG
end end
function obj = set.msg(obj,message) function obj = set.msg(obj,message)
%setmsg Summary of this method goes here %setmsg sets a message text
% Detailed explanation goes here
obj.msg = message; obj.msg = message;
end end
...@@ -83,12 +82,6 @@ classdef userDLG ...@@ -83,12 +82,6 @@ classdef userDLG
error(message); error(message);
end end
end end
function outputArg = method1(obj,inputArg)
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
outputArg = obj.Property1 + inputArg;
end
end end
end end
...@@ -16,3 +16,4 @@ authors: ...@@ -16,3 +16,4 @@ authors:
family-names: Hock family-names: Hock
email: martin.hock@fst.tu-darmstadt.de email: martin.hock@fst.tu-darmstadt.de
affiliation: 'Chair of Fluid Systems, TU Darmstadt' affiliation: 'Chair of Fluid Systems, TU Darmstadt'
orcid: ' https://orcid.org/0000-0001-9917-3152'
function [x,y, fpath] = createExampleData(option) function [x,y, fpath] = createExampleData(option)
%CREATEEXAMPLEDATA creates x,y Data needed for all PlotID Examples %CREATEEXAMPLEDATA creates x,y data needed for the PlotID examples
% fpath contains the file path of the example data % fpath contains the file path of the example data
% there are two options, the option 'matlab' creates a matlab file and the
% hdf option a hdf5 file
switch option switch option
case 'hdf' case 'hdf'
...@@ -22,7 +24,7 @@ switch option ...@@ -22,7 +24,7 @@ switch option
h5write(fpath, "/x", x) h5write(fpath, "/x", x)
h5write(fpath, "/y", y) h5write(fpath, "/y", y)
case 'matlab' case 'matlab'
% Creating Random Data to use as data-file % Creating random data to use as data-file
x = linspace(0,7); y = rand(1,100)+2; x = linspace(0,7); y = rand(1,100)+2;
dataset = 'test_data.mat'; dataset = 'test_data.mat';
% Use absolute paths for good practise % Use absolute paths for good practise
......
%% Example Script %% Example Script
% This Script is meant to demonstrate the capabilities of the PlotID tool. % This Script is ment to demonstrate the capabilities of the PlotID tool.
% please run Initilisation.m before first time usage % please run Initilisation.m before first time use
%% Clear an set Environment %% Clear and set Environment
clear; clc; close all; clear; clc; close all;
addpath('Examples'); addpath('Examples');
...@@ -55,7 +55,7 @@ fig2 = figure; plot(x,y,'-k'); box off; set(gca, 'TickDir', 'out', 'YLim', [0,4] ...@@ -55,7 +55,7 @@ fig2 = figure; plot(x,y,'-k'); box off; set(gca, 'TickDir', 'out', 'YLim', [0,4]
scriptPath = [mfilename('fullpath'),'.m']; scriptPath = [mfilename('fullpath'),'.m'];
% file paths of the datasets used for the plot (don't forget the extension) % file paths of the datasets used for the plot (don't forget the extension)
% datapath = test_data.mat % datapath = 'test_data.mat';
locations = datapath; locations = datapath;
%call publish %call publish
...@@ -66,7 +66,7 @@ PlotID.Publish(locations,scriptPath, fig2) ...@@ -66,7 +66,7 @@ PlotID.Publish(locations,scriptPath, fig2)
%% Further examples and help %% Further examples and help
% You find more examples in the Examples folder: % You find more examples in the Examples folder:
% Advanced Usage % Advanced usage
% Working with HDF5-files % Working with HDF5-files
% Using a central data folder % Using a central data folder
% How to use advanced config-files % How to use advanced config-files
\ No newline at end of file
**PlotID** **PlotID**
`PlotID` is a toolkit that labels your plots and figures and copies all associated data (research data, plotting script, user-functions and a copy of the figure) to the desired location. `PlotID` is a toolkit that labels your plots and figures and copies all associated data (research data, plotting script, user-functions and a copy of the figure) to the desired location.\
This version of `PlotID` is build for `MATLAB`. \
This version of `PlotID` is build for `MATLAB`.
`PlotID` provides two core functions **TagPlot** and **Publish** which are described in detail below. `PlotID` provides two core functions **TagPlot** and **Publish** which are described in detail below.
Feel free to give feedback and feature requests or to take part in the development process. Feel free to give feedback and feature requests or to take part in the development process.
...@@ -13,19 +11,25 @@ Feel free to give feedback and feature requests or to take part in the developme ...@@ -13,19 +11,25 @@ Feel free to give feedback and feature requests or to take part in the developme
# Quick User Guide # Quick User Guide
**Requirements:** MATLAB R2021a or newer **Requirements:** MATLAB R2021a or newer
`PlotID` works in two Steps: **First use:**
1. Put your PlotID folder in you [userpath](https://uk.mathworks.com/help/matlab/ref/userpath.html) on Windows this is
`C:\Users\USERNAME\Documents\MATLAB`. \
When using a diffrent folder, make sure the folder is on your [search path](https://uk.mathworks.com/help/matlab/matlab_env/add-remove-or-reorder-folders-on-the-search-path.html).
1. tagging the plot 2. Run `Initialisation.m` and follow the command line instructions.\
`[figs, IDs] = plotId.TagPlot(figs, options)` The **ProjectID** is your custom project number, it well be the prefix of the ID created by `PlotID` (e.g. JL-001). Save your config file.
You should either set a ProjectID in the config.json (copy & rename the 'example-config.json' to 'config.json'), or pass it as option 'ProjectID' to the TagPlot function.
2. publish the plot and the associated data **Intended use:**\
`plotID.Publish(DataPaths,scriptPath, figure, options)` `PlotID` works in two Steps:
1. Tag the plot
`[figs, IDs] = PlotId.TagPlot(figs, options)`
`scriptPath` contains the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']`, note that 2. Publish the plot and the associated data
**the extension is mandatory.** `PlotID.Publish(DataPaths,scriptPath, figure, options)`
`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell arrays (they must be at the path). `scriptPath` contains the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']` \
`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell arrays (they must be at the path). \
`figure` is the figure that should be published. `figure` is the figure that should be published.
...@@ -102,15 +106,55 @@ fileCompare checks if file1 is (binary) identical to a file in filelist, it retu ...@@ -102,15 +106,55 @@ fileCompare checks if file1 is (binary) identical to a file in filelist, it retu
removePltIdFiles removes functions that are part of PlotID out of flist. removePltIdFiles removes functions that are part of PlotID out of flist.
# How to use the .config file # How to use the .config file
The config file is a JSON-File. At the moment two options can be set in the config file, the project ID and the remote Path. The config file is a JSON-File. The config file stores user data and options of `PlotID`. It will be created when you use PlotID for the first time. Follow the Instructions to create the file. _Note:_ for basic usage no manual changes on the config file are required. \
**Note:** If you mess up your config-file simply delete it, PlotID will create a new one the next time you use it.
## Define an export path
If you define an export path in the config.json this path is used as location for the exported data.
## Store custom options for Publish
**add custom publish options to the config file** \
you can define your custom options for publish in the config file. **Important:** They will always have priority against Name-Value pairs!
```
configFileName = 'config.json';
configObj = PlotID.config(configFileName);
```
This method adds the default config to your config file
```
configObj.addPublishOptions('default');
```
You can change the options in the json file, but be carefull no argumentValidation will be done on options from the config file!
## Working with multiple (project dependend) config files
<details><summary> Expand </summary>
It is possible to use individual config files for each project (configP1.json, configP2.json, ...) \
1. Create a new config file programatically
```
customConfigFileName = 'configP1.json';
configObj = PlotID.config(customConfigFileName);
configObj.addPublishOptions('default');
```
2. Use the custom Config
you need to provide the name of your custom config file to tagplot as well as to publish by using the Name-Value Pair:
` 'ConfigFileName','YOURNAME.json'` :
``` ```
{ [figs, IDs] = PlotID.TagPlot(figs, 'ConfigFileName','configP1.json');
"ProjectID": "your ProjectID", Publish(DataPaths,scriptPath, 'ConfigFileName','configP1.json')
"ServerPath": "\\\\Server\\Folder1\\Subfolder"
}
``` ```
</details>
# Aknowledgements
The authors would like to thank the Federal Government and the Heads of Government of the Länder, as well as the Joint Science Conference (GWK), for their funding and support within the framework of the NFDI4Ing consortium. Funded by the German Research Foundation (DFG) - project number 442146713.
# Known Issues # Known Issues
# FAQs # FAQs
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment