diff --git a/.gitignore b/.gitignore index 06d6bb37630051d2de5c5131286c6fdfeb6df232..3d5fc69ca1e50965038a6e833ed09a2d1a9d32a8 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ export/* # Octave session info octave-workspace +test_data.mat diff --git a/example.m b/example.m index 9686cb452b91b082b8612c709ade0d9f2b11196e..4a775d1ad696f8a1cedee90481c27cd21f67faec 100644 --- a/example.m +++ b/example.m @@ -58,7 +58,7 @@ path.script = mfilename('fullpath'); % filename of the m.script % file name of the data path.rdata = {dataset1,dataset2} ; % don't forget the extension -Publish(path, ID, figs, 'Location', 'local','Method','individual') +Publish(path, ID, figs, 'Location', 'local','Method','centraliced') %% Second Plot with identical data to test centralized method % diff --git a/fcn_core/Publish.m b/fcn_core/Publish.m index 6ab522b164e79cab7c6cc442047f9587a5c6ad4e..75473df7bdd13f006753b225ce2b19b41c60c392 100644 --- a/fcn_core/Publish.m +++ b/fcn_core/Publish.m @@ -95,43 +95,6 @@ disp(['publishing of ', ID , ' done']); end %function -function [] = createFileCopy(filePaths,folderName,storPath,ID,type) -% Creates a copy of the files (can used for multiple paths in a cell array) -% folderName is the name of the exporting folder - disp(['start to copy ', type]); - -% try - for i = 1:numel(filePaths) - FileNameAndLocation = filePaths{i}; - [~,name,ext] = fileparts(filePaths{i}); % get the extension - - switch type - case 'data' - sufix = '_data'; - newfile = sprintf([ID, sufix, '_' , num2str(i) ,ext]); - case 'dataCentral' - %keep original name - newfile = sprintf([name,ext]); - case 'script' - sufix = '_script'; - newfile = sprintf([ID, sufix ,ext]); - case 'userFcn' - %keep original name - newfile = sprintf([name,ext]); - otherwise - error([type,' is not a valid type for createFileCopy']) - end %switch - - % Write the file - RemotePath = fullfile(storPath,folderName, newfile); - copyfile(FileNameAndLocation,RemotePath); - end - disp([type, ' sucessfully published']); -% catch -% warning([type,' export was not sucessful']) -% end %try -end - function tf = mustBeFigure(h) %checks if input is a figure object tf = strcmp(get(h, 'type'), 'figure') & isa(h, 'matlab.ui.Figure'); diff --git a/fcn_core/TagPlot.m b/fcn_core/TagPlot.m index 3c426266624a4a9dd64e93d970428c2fe08837a0..4fac128393edd75b1b7877cee7ce29eb517f54c1 100644 --- a/fcn_core/TagPlot.m +++ b/fcn_core/TagPlot.m @@ -1,16 +1,50 @@ -function [figs, ID] = TagPlot(figs, prefix) +function [figs, ID] = TagPlot(figs, prefix, options) %TagPlot adds IDs to figures % The ID is placed visual on the figure window and as Tag (Property of figure) % TagPlot can tag multiple figures at once +% prefix is the project number (string or char) +% +% The ID is placed on the 'east' per default, if you want it somwhere +% else, use the 'Location' option. 'north','east','south','west' are +% predefined, otherwise use the 'custom' option and provide the desired +% 'Position' (relative to your x- and y-axis limits) arguments figs (1,:) {mustBeFigure} prefix (1,:) {mustBeText}= '' + options.Fontsize (1,1) {mustBeInteger} = 8 + options.Location (1,:) {mustBeText} = 'east' + options.Position (1,2) {mustBeVector} = [1,0.4] % default for east + options.Rotation (1,1) {mustBeInteger} = 0 end if isempty(prefix) warning('no project prefix defined') end +switch options.Location + case 'north' + options.Position = [0.4,0.95]; + options.Rotation = 0; + case 'east' + options.Position = [1,0.4]; + options.Rotation = 90; + case 'south' + options.Position = [0.4,.02]; + options.Rotation = 0; + case 'west' + options.Position = [.05,0.4]; + options.Rotation = 90; + case 'custom' + % Check if Position is valid + if ~all(0 <= options.Position & options.Position <= 1) + options.Position = [1,0.4]; + warning('options.Position is not valid, TagPlot default values instead'); + end + otherwise % set default position + warning([options.Location, ' is not a defined location, TagPlot uses location east instead']); + options.Location = 'east'; options.Position = [1,0.4]; +end + for n = 1:numel(figs) ID = CreateID; % Create ID ID = [prefix,'-',ID]; % add Prefix @@ -19,8 +53,10 @@ for n = 1:numel(figs) ylim =get(axes,'YLim'); xlim =get(axes,'XLim'); %ID - text(axes,xlim(2),0.4*ylim(2), ID,'Fontsize',8,'Rotation',90,'VerticalAlignment','bottom',... - 'Color', 0.65*[1 1 1],'BackgroundColor','w'); + position = [options.Position(1)*xlim(2), options.Position(2)*ylim(2)]; + text(axes,position(1),position(2), ID,'Fontsize',options.Fontsize,... + 'Rotation',options.Rotation, 'VerticalAlignment','bottom','Color',... + 0.65*[1 1 1],'BackgroundColor','w'); set(figs(n),'Tag', ID); end diff --git a/fcn_help/createFileCopy.m b/fcn_help/createFileCopy.m new file mode 100644 index 0000000000000000000000000000000000000000..67b16204ff7463ac32d3c69b4f1d31da0442c2ef --- /dev/null +++ b/fcn_help/createFileCopy.m @@ -0,0 +1,47 @@ +function [] = createFileCopy(filePaths,folderName,storPath,ID,type) +% Creates a copy of the files (can used for multiple paths in a cell array) +% folderName is the name of the exporting folder + disp(['start to copy ', type]); + +% try + for i = 1:numel(filePaths) + FileNameAndLocation = filePaths{i}; + [~,name,ext] = fileparts(filePaths{i}); % get the extension + + switch type + case 'data' + sufix = '_data'; + newfile = sprintf([ID, sufix, '_' , num2str(i) ,ext]); + case 'dataCentral' + %keep original name + newfile = sprintf([name,ext]); + case 'script' + sufix = '_script'; + newfile = sprintf([ID, sufix ,ext]); + case 'userFcn' + %keep original name + newfile = sprintf([name,ext]); + otherwise + error([type,' is not a valid type for createFileCopy']) + end %switch + + % Write the file + RemotePath = fullfile(storPath,folderName, newfile); + + % Check if remote file already exists (not working) +% count = 0; +% while isfile(RemotePath) && ismember(type,{'data','dataCentral'}) +% % Add a Sufix number to file name +% count = count + 1; +% [~,name,ext] = fileparts(RemotePath); +% RemotePath = fullfile(storPath,folderName,... +% [name,'_',num2str(count),ext]); +% end + copyfile(FileNameAndLocation,RemotePath); + end + disp([type, ' sucessfully published']); +% catch +% warning([type,' export was not sucessful']) +% end %try +end + diff --git a/test123_data.h5 b/test123_data.h5 deleted file mode 100644 index c85a96e642cca94a1b7fc824f2b0014fab90c50e..0000000000000000000000000000000000000000 Binary files a/test123_data.h5 and /dev/null differ diff --git a/test_data.mat b/test_data.mat deleted file mode 100644 index 33fbe1ef1a97e81ad944afeb8bcf68356d7d626a..0000000000000000000000000000000000000000 Binary files a/test_data.mat and /dev/null differ diff --git a/testdata_2.h5 b/testdata_2.h5 deleted file mode 100644 index 8415c693f833bd3db2dc2ca3c7e614efdbc98080..0000000000000000000000000000000000000000 Binary files a/testdata_2.h5 and /dev/null differ