diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m index 4f82c2cd3ebec1b380f77836b4d232b91db7f9d9..fcd7772b6dc55615ee24f92ea8e2d3823b3e4ddb 100644 --- a/+PlotID/Publish.m +++ b/+PlotID/Publish.m @@ -69,27 +69,12 @@ else end disp(['publishing of ', ID, ' started']); -%% Create a Copy of the script, config and user functions(optional) +%% Create a Copy of the script and user functions(optional) % script PlotID.createFileCopy({[DataPaths.script,'.m']},folderName,storPath,ID, 'script'); -% config -[fList,pList] = matlab.codetools.requiredFilesAndProducts(DataPaths.script); -if ~configError %config File must exist - % copy config file - configPath = PlotID.createFileCopy('config.json',folderName,... - storPath,ID, 'data'); - % add Metadata - config.MatlabVersion = version; - % TODO Add Toolboxes - %write config - fid = fopen(char(configPath),'w'); - txt = jsonencode(config,'PrettyPrint',true); - fprintf(fid,txt); - fclose(fid); -end - % user functions +[fList,pList] = matlab.codetools.requiredFilesAndProducts(DataPaths.script); if options.CopyUserFCN fList = fList(~ismember(fList,[DataPaths.script,'.m'])); % rmv script from list fList = fList(~contains(fList,'config.json')); % rmv config.json from list @@ -146,6 +131,32 @@ switch options.Method % Create a copy of the research data PlotID.createFileCopy(DataPaths.rdata,folderName,storPath,ID, 'data'); end +%% Write Config File + +if ~configError %config File must exist + % copy config file + configPath = PlotID.createFileCopy('config.json',folderName,... + storPath,ID, 'data'); +else + configPath = fullpath(storPath,folderName, 'config.json'); + config = struct(); + if ispc + config.author = getenv('USERNAME'); + end +end +% add further Metadata +config.ProjectID = ID; +config.CreationDate = datestr(now); +config.MatlabVersion = version; +config.ToolboxVersions = pList; + +%write config +fid = fopen(char(configPath),'w'); +txt = jsonencode(config,'PrettyPrint',true); +fprintf(fid,txt); +fclose(fid); + + %% Export the Plot try PlotName = [ID,'_plot']; % plotname diff --git a/example-config.json b/example-config.json index c0bd9719ec0d2d48a805b9118189dbe11b2ecc20..9df3f40d142af73340a15197d7787e9485809211 100644 --- a/example-config.json +++ b/example-config.json @@ -1,4 +1,5 @@ -{ +{ + "Author": "Example Author" "ProjectID": "AB01", "ServerPath": "\\\\Server\\path\\folder" } \ No newline at end of file diff --git a/example.m b/example.m index 492711c999d27bc475e8439b1fc2a284091f774c..04aa8c11aebc102d0810c7e23681ad1ba473d943 100644 --- a/example.m +++ b/example.m @@ -43,7 +43,7 @@ h5write(fpath, "/y1", y1) % Place for post-processing of the data, or additional related code. % example_fcn is a dummy function to show the functionality a = 1; a = example_fcn(a); -%p = betacdf(0.5,1,1); % to test toolboxes +p = betacdf(0.5,1,1); % to test toolboxes %% Plotting % This is still part of a normal script to produce plots.