From 01af896726e8ef55cebcb10ed33bc7c7a1a8dcf0 Mon Sep 17 00:00:00 2001 From: "M. Hock" <martin.hock@fst.tu-darmstadt.de> Date: Thu, 23 Sep 2021 16:18:23 +0200 Subject: [PATCH] (Old) bugfix for hdf5 linking removed config.json from index (might be deleted on pull) added workaround if no config file was created and no projectID defined changed filepaths to absolute paths in example and Demo --- +PlotID/Publish.m | 2 +- +PlotID/TagPlot.m | 14 +++++++++++--- PlotID_Demo.m | 9 ++++++--- config.json | 4 ---- example.m | 9 ++++++--- 5 files changed, 24 insertions(+), 14 deletions(-) delete mode 100644 config.json diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m index 1843f8d..91e8cae 100644 --- a/+PlotID/Publish.m +++ b/+PlotID/Publish.m @@ -94,7 +94,7 @@ switch options.Method if any(idx) sourcePath = fList{idx,'name'}; % If there are multiple copies already, this only picks the last entry if contains(sourcePath,{'.h5','.hdf5'}) % Linking only for HDF5 - PlotID.createLinkedHDF5(sourcePath,storPath,ID); + PlotID.createLinkedHDF5(sourcePath{1,1},storPath,ID); end else % no identical file exists %Copy the file in data diff --git a/+PlotID/TagPlot.m b/+PlotID/TagPlot.m index 26aee3e..bcf84b9 100644 --- a/+PlotID/TagPlot.m +++ b/+PlotID/TagPlot.m @@ -21,8 +21,16 @@ arguments end if isempty(options.ProjectID) - txt = fileread('config.json'); - config = jsondecode(txt); + try + txt = fileread('config.json'); + config = jsondecode(txt); + catch + config =struct; + config.ProjectID = ''; + warning("No ProjectID was definded and no config.json could be found"); + + end + if ~isempty(config.ProjectID) options.ProjectID = config.ProjectID; else @@ -47,7 +55,7 @@ switch options.Location % 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'); + warning('options.Position is not valid, TagPlot uses default values instead'); end otherwise % set default position warning([options.Location, ' is not a defined location, TagPlot uses location east instead']); diff --git a/PlotID_Demo.m b/PlotID_Demo.m index 961afc7..ac720c0 100644 --- a/PlotID_Demo.m +++ b/PlotID_Demo.m @@ -18,15 +18,18 @@ ProjectID = 'FST01'; x = linspace(0,7); y = rand(1,100)+2; dataset1 = 'test_data.mat'; -save('test_data.mat','x','y'); +% use absolute paths for good practise +dataset1 = fullfile(pwd, dataset1); +save(dataset1,'x','y'); % some data as .h5 x1 = linspace(0,2*pi); y1 = sin(x1)+.5*sin(2*x1)+2; % define file path & name -fpath = "./testdata_2.h5"; -dataset2 = 'testdata_2.h5'; + +fpath = fullefile(pwd,"./testdata_2.h5"); +dataset2 = fullfile(pwd,'testdata_2.h5'); % create hdf5 file and dataset > write data to hdf5 file / dataset h5create(fpath, "/x1", size(x1), "Datatype", class(x1)) diff --git a/config.json b/config.json deleted file mode 100644 index 23a100c..0000000 --- a/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "ProjectID": "JL01", - "ServerPath": "\\\\FST-220\\Jans-50GB-SMB\\Lemmer" -} \ No newline at end of file diff --git a/example.m b/example.m index dfc42f2..c73c83a 100644 --- a/example.m +++ b/example.m @@ -27,7 +27,9 @@ ProjectID = ''; x = linspace(0,7); y = rand(1,100)+2; dataset1 = 'test_data.mat'; -save('test_data.mat','x','y'); +% Use absolute paths for good practise +dataset1 = fullfile(pwd,dataset1); +save(dataset1,'x','y'); % some data as .h5 @@ -35,8 +37,9 @@ x1 = linspace(0,2*pi); y1 = sin(x1)+2; % define file path & name -fpath = "./testdata_2.h5"; dataset2 = 'testdata_2.h5'; +dataset2 = fullfile(pwd,dataset2); +fpath = dataset2; % create hdf5 file and dataset > write data to hdf5 file / dataset h5create(fpath, "/x1", size(x1), "Datatype", class(x1)) @@ -77,7 +80,7 @@ path.script = mfilename('fullpath'); % filename of the m.script % file names of the datasets path.rdata = {dataset1,dataset2} ; % don't forget the extension -PlotID.Publish(path, ID, fig(1), 'Location', 'server' ,'Method','centralized') +PlotID.Publish(path, ID, fig(1), 'Location', 'local' ,'Method','centralized') %% Example 2: multiple plots plot, all based on data-set2 (hdf5) % for individual data-sets, use an appropriate array -- GitLab