Skip to content
Snippets Groups Projects
Select Git revision
  • c20cc78e99c18753d5756bed2b301dbb9df3f105
  • master default protected
  • gitkeep
  • development protected
  • QRCode/Size
  • sync-link-hdf5
  • feature/multi-scriptpaths
  • dev/plotID_Class
  • doc
  • V1.0.1
  • V1.0
  • V1.0-RC1
  • V0.2.2
  • V0.2.1
  • V0.2-RC1
  • V0.1
16 results

example.m

Blame
  • Jan Lemmer's avatar
    Fixes #21, Fixes Error when trying to export the same ID again
    Lemmer, Jan authored
    bd3d59df
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    example.m 2.85 KiB
    %% Example Script
    % This Script is meant to demonstrate the capabilities of the PlotID tool.
    
    %% Clear Environment
    clear; clc; close all;
    addpath('fcn_core','fcn_help');
    addpath('CI_files'); % Test scripts
    
    try
        delete testdata_2.h5;
    end
    
    
    %% Set ProjectID
    % ProjectID 
    
    % TODO:  decide how projectID and optionally ORCID will be implemented
    % ORCID placed on startup (alternative?) - projectID as persistent
    % otherwise dialogue?
    ProjectID = 'JL01';
    
    
    
    %% Data
    % Creating Random Data to use as data-file
    
    x = linspace(0,7);
    y = rand(1,100)+2;
    dataset1 = 'test_data.mat';
    save('test_data.mat','x','y');
    
    
    % some data as .h5
    x1 = linspace(0,2*pi);
    y1 = sin(x1)+2;
    
    % define file path & name
    fpath = "./testdata_2.h5";
    dataset2 = 'testdata_2.h5';
    
    % create hdf5 file and dataset > write data to hdf5 file / dataset
    h5create(fpath, "/x1", size(x1), "Datatype", class(x1))
    h5create(fpath, "/y1", size(y1), "Datatype", class(y1))
    h5write(fpath, "/x1", x1)
    h5write(fpath, "/y1", y1)
    
    %% function calls
    % Place for post-processing of the data, or additional related code.
    a = 1;
    % example_fcn is a dummy function to show the functionality
    a = example_fcn(a); 
    
    %% Plotting
    % This is still part of a normal script to produce plots.
    % Make sure to save each figure in a variable to pass to PlotID-functions.
    fig(1) = figure;
    plot(x,y,'-k');
    box off; hold on;
    plot(x1,y1,'-r');
    set(gca, 'TickDir', 'out', 'YLim', [0,4]);
    
    %% Example 1: single plot based on two data-sets
    
    %% Tag the plot
    % PlotID Implementation starts here.
    % TagPlot adds a visible ID to the figure(s) and to the figures property
    % 'Tag'
    [fig, ID] = TagPlot(fig, ProjectID);
    
    %% Publishing
    % Second part of plotID 
    % The functions needs the file location, the location of the data and the
    % figure and can take several options.
    % TODO add explanations for Options
    
    path.script = mfilename('fullpath'); % filename of the m.script
    % file names of the datasets
    path.rdata =  {dataset1,dataset2} ; % don't forget the extension
    
    Publish(path, ID, fig(1), 'Location', 'local','Method','centraliced')
    
    %% Example 2 : multiple plots plot, all based on two data-set2
    % for individual data-sets, use an appropriate array
    
    fig(2) = figure;
    plot(x,y,'-b');
    box off; hold on;
    plot(x1,y1,'--k');
    set(gca, 'TickDir', 'out', 'YLim', [0,4]);
    
    % tag both plots 
    [fig, IDs] = TagPlot(fig, ProjectID);
    
    % data locations
    path.script = mfilename('fullpath'); % filename of the m.script
    % file names of the datasets
    path.rdata =  {dataset2} ; % don't forget the extension
    
    % publsihing via for-loop
    for i=1: numel(fig)
        disp(string(i));
        Publish(path, IDs{i}, fig(i), 'Location', 'local','Method','centraliced');
    end
    
    %% Second Plot with identical data to test centralized method
    % ToDO Add better description
    
    fig2 =figure;
    plot(x,y,'-k');
    hold on
    plot(x1,y1,'-r');
    
    [fig2, ID] = TagPlot(fig2, ProjectID);
    
    Publish(path, ID, fig2, 'Location', 'local','Method','centraliced')