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

Fixes #48

parent 0bea01b9
No related branches found
No related tags found
2 merge requests!30Fix CI,!21Fixes #48
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
%
% DataPaths contains the path(s) to the research data, for multiple files
......@@ -20,7 +20,6 @@ function Publish(DataPaths,scriptPath, ID, figure, options)
arguments
DataPaths {mustBeDataPath} % location of the data-file(s)
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
options.Location {mustBeMember(options.Location ,{'local','server','manual','CI-Test'})} = 'local' % storage path
options.Method {mustBeMember(options.Method ,{'individual','centralized'})} = 'individual'
......@@ -29,6 +28,7 @@ arguments
options.CSV (1,1) {mustBeNumericOrLogical} = false
end
%% argument validation
%catch multiple figures in fig
if numel(figure) > 1
figure = figure(1);
......@@ -38,6 +38,20 @@ if numel(figure) > 1
warning(msg);
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
try
txt = fileread('config.json');
......
......@@ -56,7 +56,7 @@ try
% file name of the data
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;
% clean up
......
......@@ -15,17 +15,17 @@ Feel free to give feedback and feature requests or to take part in the developme
1. tagging the plot
`[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. publishing the plot and the associated data
`plotID.Publish(DataPaths,scriptPath, ID, figure, options)`
2. publish the plot and the associated data
`plotID.Publish(DataPaths,scriptPath, figure, options)`
`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.**
`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell arrays (they must be at the path).
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.
`figure` is the figure that should be published.
# PlotID.TagPlot()
`[figs, IDs] = TagPlot(figs, options)`
......@@ -64,7 +64,7 @@ FriendlyID Changes the Hex Number to a human friendly *datetime* and *dateStr*.
# PlotID.Publish()
`Publish(DataPaths,scriptPath, ID, figure, options)` \
`Publish(DataPaths,scriptPath, figure, options)` \
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
......
......@@ -78,7 +78,7 @@ locations = {dataset1,dataset2} ; % don't forget the extension
%locations = {'test_data.mat', 'falsch'};
%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)
% for individual data-sets, use an appropriate array
......@@ -99,7 +99,7 @@ rdata = dataset2 ; % don't forget the extension
% publsihing via a for-loop
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');
end
......@@ -117,4 +117,4 @@ plot(x1,y1,'-r');
[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