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

Merge branch '48-implement-usage-of-figure-property-id' into 'development'

Fixes #48

See merge request !21
parents 0bea01b9 c38120f5
No related branches found
No related tags found
2 merge requests!30Fix CI,!21Fixes #48
Pipeline #573272 passed
function Publish(DataPaths,scriptPath, ID, figure, options) function Publish(DataPaths,scriptPath, figure, options)
%%Publish(DataPaths,scriptPath, ID, figure, options) saves plot, data and measuring script %%Publish(DataPaths,scriptPath, ID, figure, options) saves plot, data and measuring script
% %
% DataPaths contains the path(s) to the research data, for multiple files % DataPaths contains the path(s) to the research data, for multiple files
...@@ -20,7 +20,6 @@ function Publish(DataPaths,scriptPath, ID, figure, options) ...@@ -20,7 +20,6 @@ function Publish(DataPaths,scriptPath, ID, figure, options)
arguments arguments
DataPaths {mustBeDataPath} % location of the data-file(s) DataPaths {mustBeDataPath} % location of the data-file(s)
scriptPath (1,:) {mustBeFile} % location of the matlab script scriptPath (1,:) {mustBeFile} % location of the matlab script
ID (1,:) {mustBeNonzeroLengthText} % ID must be provided
figure (1,:) {mustBeFigure} % Checks if figure is a figure object figure (1,:) {mustBeFigure} % Checks if figure is a figure object
options.Location {mustBeMember(options.Location ,{'local','server','manual','CI-Test'})} = 'local' % storage path options.Location {mustBeMember(options.Location ,{'local','server','manual','CI-Test'})} = 'local' % storage path
options.Method {mustBeMember(options.Method ,{'individual','centralized'})} = 'individual' options.Method {mustBeMember(options.Method ,{'individual','centralized'})} = 'individual'
...@@ -29,6 +28,7 @@ arguments ...@@ -29,6 +28,7 @@ arguments
options.CSV (1,1) {mustBeNumericOrLogical} = false options.CSV (1,1) {mustBeNumericOrLogical} = false
end end
%% argument validation
%catch multiple figures in fig %catch multiple figures in fig
if numel(figure) > 1 if numel(figure) > 1
figure = figure(1); figure = figure(1);
...@@ -38,6 +38,20 @@ if numel(figure) > 1 ...@@ -38,6 +38,20 @@ if numel(figure) > 1
warning(msg); warning(msg);
end end
%get ID from Figure
ID = figure.Tag;
if isempty(ID)
% no ID found, User dialog for Folder name
ID = inputdlg(['No ID defined- ' newline,...
'Please enter a folder name to continue:'],'Please enter a folder name');
ID = ID{1};
msg = ['No ID found - consider to use the TagPlot function before ',...
'you publish ', newline, 'your files will be stored in ' , ID];
warning(msg);
end
%% read config file %% read config file
try try
txt = fileread('config.json'); txt = fileread('config.json');
......
...@@ -56,7 +56,7 @@ try ...@@ -56,7 +56,7 @@ try
% file name of the data % file name of the data
rdata = {dataset1,dataset2} ; % don't forget the extension rdata = {dataset1,dataset2} ; % don't forget the extension
PlotID.Publish(rdata,script, ID, figs, 'Location', 'CI-Test') PlotID.Publish(rdata,script, figs, 'Location', 'CI-Test')
result = true; result = true;
% clean up % clean up
......
...@@ -15,17 +15,17 @@ Feel free to give feedback and feature requests or to take part in the developme ...@@ -15,17 +15,17 @@ Feel free to give feedback and feature requests or to take part in the developme
1. tagging the plot 1. tagging the plot
`[figs, IDs] = plotId.TagPlot(figs, options)` `[figs, IDs] = plotId.TagPlot(figs, options)`
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
2. publishing the plot and the associated data `plotID.Publish(DataPaths,scriptPath, figure, options)`
`plotID.Publish(DataPaths,scriptPath, ID, figure, options)`
`scriptPath` contains the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']`, note that `scriptPath` contains the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']`, note that
**the extension is mandatory.** **the extension is mandatory.**
`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell arrays (they must be at the path). `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.
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.
# PlotID.TagPlot() # PlotID.TagPlot()
`[figs, IDs] = TagPlot(figs, options)` `[figs, IDs] = TagPlot(figs, options)`
...@@ -64,7 +64,7 @@ FriendlyID Changes the Hex Number to a human friendly *datetime* and *dateStr*. ...@@ -64,7 +64,7 @@ FriendlyID Changes the Hex Number to a human friendly *datetime* and *dateStr*.
# PlotID.Publish() # PlotID.Publish()
`Publish(DataPaths,scriptPath, ID, figure, options)` \ `Publish(DataPaths,scriptPath, figure, options)` \
Publishes saves plot, data and measuring script Publishes saves plot, data and measuring script
Location sets the storage location. 'local' sets the storage location to the current folder (an export folder will be created), 'server' is a remote path, that is defined in the config file. Two Methods are implemented 'individual' stores the data for each plot while 'centralized' uses a data folder and uses reference links to the original data (hdf5 only). ParentFolder is the folder Name where the exported data is stored if a path is used, PlotId will use this path a storagePath Location sets the storage location. 'local' sets the storage location to the current folder (an export folder will be created), 'server' is a remote path, that is defined in the config file. Two Methods are implemented 'individual' stores the data for each plot while 'centralized' uses a data folder and uses reference links to the original data (hdf5 only). ParentFolder is the folder Name where the exported data is stored if a path is used, PlotId will use this path a storagePath
......
...@@ -78,7 +78,7 @@ locations = {dataset1,dataset2} ; % don't forget the extension ...@@ -78,7 +78,7 @@ locations = {dataset1,dataset2} ; % don't forget the extension
%locations = {'test_data.mat', 'falsch'}; %locations = {'test_data.mat', 'falsch'};
%call publishing %call publishing
PlotID.Publish(locations,scriptPath, ID, fig(1), 'Location', 'local' ,'Method','individual') PlotID.Publish(locations,scriptPath, fig(1), 'Location', 'local' ,'Method','individual')
%% Example 2: multiple plots plot, all based on dataset2 (hdf5) %% Example 2: multiple plots plot, all based on dataset2 (hdf5)
% for individual data-sets, use an appropriate array % for individual data-sets, use an appropriate array
...@@ -99,7 +99,7 @@ rdata = dataset2 ; % don't forget the extension ...@@ -99,7 +99,7 @@ rdata = dataset2 ; % don't forget the extension
% publsihing via a for-loop % publsihing via a for-loop
for i=1: numel(fig) for i=1: numel(fig)
PlotID.Publish(rdata, script, IDs{i}, fig(i), 'Location', 'local',... PlotID.Publish(rdata, script, fig(i), 'Location', 'local',...
'Method','individual'); 'Method','individual');
end end
...@@ -117,4 +117,4 @@ plot(x1,y1,'-r'); ...@@ -117,4 +117,4 @@ plot(x1,y1,'-r');
[fig2, ID] = PlotID.TagPlot(fig2,'ProjectID', ProjectID); [fig2, ID] = PlotID.TagPlot(fig2,'ProjectID', ProjectID);
PlotID.Publish(locations,scriptPath, ID, fig2, 'Location', 'local','Method','centralized') PlotID.Publish(locations,scriptPath, fig2, 'Location', 'local','Method','centralized')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment