Skip to content
Snippets Groups Projects

Merge 51 into developmen

Merged Lemmer, Jan requested to merge 51-hilfe-beschreibung-in-publish into development
4 files
+ 66
32
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 45
15
function Publish(DataPaths, ID, figure, options)
%Publishes saves plot, data and measuring script
function Publish(DataPaths,scriptPath, ID, 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
% use a cell array
% 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
%
% Options:
% 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.
@@ -10,7 +18,8 @@ function Publish(DataPaths, ID, figure, options)
% path is used, PlotId will use this path a storagePath
arguments
DataPaths
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
@@ -48,8 +57,8 @@ switch options.Location
storPath = options.ParentFolder;
else
% use the script path as export path
scriptPath = fileparts(DataPaths.script);
storPath = fullfile(scriptPath,options.ParentFolder);
scriptLocation = fileparts(scriptPath);
storPath = fullfile(scriptLocation,options.ParentFolder);
end
case 'server' %from config File
storPath = config.ServerPath;
@@ -71,12 +80,12 @@ disp(['publishing of ', ID, ' started']);
%% Create a Copy of the script and user functions(optional)
% script
PlotID.createFileCopy({[DataPaths.script,'.m']},folderName,storPath,ID, 'script');
PlotID.createFileCopy({scriptPath},folderName,storPath,ID, 'script');
% user functions
[fList,pList] = matlab.codetools.requiredFilesAndProducts(DataPaths.script);
[fList,pList] = matlab.codetools.requiredFilesAndProducts(scriptPath);
if options.CopyUserFCN
fList = fList(~ismember(fList,[DataPaths.script,'.m'])); % rmv script from list
fList = fList(~ismember(fList,scriptPath)); % rmv script from list
fList = fList(~contains(fList,'config.json')); % rmv config.json from list
fList = PlotID.removePltIdFiles(fList); % Do not copy files that are part of plot ID
if ~isempty(fList)
@@ -103,9 +112,9 @@ switch options.Method
% Check if the new plot is based on the original data-set
% copy the data(once)
for i=1:numel(DataPaths.rdata)
for i=1:numel(DataPaths)
% check if identical file exists (status = 1)
[~, idx] = PlotID.fileCompare(DataPaths.rdata{i},fList);
[~, idx] = PlotID.fileCompare(DataPaths{i},fList);
% create Linked HDF5 files for identical files
if any(idx)
fList.path = fullfile(fList.folder,fList.name);
@@ -117,10 +126,10 @@ switch options.Method
end
else % no identical file exists
%Copy the file in data and create the links (if hdf5)
[dataPath] = PlotID.createFileCopy(DataPaths.rdata{i},'data',storPath,ID,'dataCentral');
[dataPath] = PlotID.createFileCopy(DataPaths{i},'data',storPath,ID,'dataCentral');
relativeDataPath = strrep(dataPath,currentPath,'');
%WIP
if contains(DataPaths.rdata{i},{'.h5','.hdf5'}) % Linking only for HDF5
if contains(DataPaths{i},{'.h5','.hdf5'}) % Linking only for HDF5
% and create also linked files in the plot folder
PlotID.createLinkedHDF5(relativeDataPath,storPath,ID);
end %if
@@ -129,7 +138,7 @@ switch options.Method
clear DataFolderName
case 'individual'
% Create a copy of the research data
PlotID.createFileCopy(DataPaths.rdata,folderName,storPath,ID, 'data');
PlotID.createFileCopy(DataPaths,folderName,storPath,ID, 'data');
end
%% Write Config File
@@ -174,8 +183,8 @@ disp(['publishing of ', ID , ' done']);
% CSV EXport
if options.CSV
T = table();
T.research_Data = DataPaths.rdata'; T.PlotID(:) = {ID};
T.Script_Name(:) = {[DataPaths.script,'.m']};
T.research_Data = DataPaths'; T.PlotID(:) = {ID};
T.Script_Name(:) = {scriptPath};
T.Storage_Location(:) = {storPath};
T.Date(:) = {datestr(now)};
T = movevars(T,'PlotID','before',1);
@@ -184,7 +193,28 @@ end
end %function
%% Argument Validation Functions
function tf = mustBeFigure(h)
%checks if input is a figure object
tf = strcmp(get(h, 'type'), 'figure') & isa(h, 'matlab.ui.Figure');
end
function mustBeDataPath(DataPaths)
%checks if input is a valid DataPath object
if iscellstr(DataPaths)
tf = zeros(1,numel(DataPaths));
for i=1:numel(DataPaths)
tf(i) = ~isfile(DataPaths{i});
end
else
tf = ~isfile(DataPaths);
end
if any(tf)
eidType = 'mustBeDataPath:notaValidFilePath';
msgType = 'DataPaths must contain file-path(s)';
throwAsCaller(MException(eidType,msgType))
end
end
Loading