-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsample_export.m
More file actions
49 lines (40 loc) · 1.68 KB
/
Copy pathsample_export.m
File metadata and controls
49 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
%% load Nexus client
connectorFolderPath = fullfile(tempdir, 'nexus');
[~, ~] = mkdir(connectorFolderPath);
url = 'https://raw.githubusercontent.com/nexus-main/nexus/master/src/clients/matlab/NexusClient.m';
websave(fullfile(connectorFolderPath, 'NexusClient.m'), url);
addpath(connectorFolderPath)
%% Create client and authenticate
% You get this token in the user settings menu of Nexus.
accessToken = '<token>';
baseUrl = 'http://localhost:5000';
client = NexusClient(baseUrl);
client.signIn(accessToken)
%% Export data from sample catalog /SAMPLE/LOCAL
dateTimeBegin = datetime(2020, 01, 01, 0, 0, 0, 'TimeZone', 'UTC');
dateTimeEnd = datetime(2020, 01, 02, 0, 0, 0, 'TimeZone', 'UTC');
T1 = '/SAMPLE/LOCAL/T1/1_s';
V1 = '/SAMPLE/LOCAL/V1/1_s';
resourcePaths = { ...
T1
V1
};
% Use a file period of zero to write all data into a single file.
filePeriod = duration(0, 0, 0);
% The following writers are currently supported:
% 'Nexus.Writers.Csv' | 'Nexus.Writers.Hdf5' | 'Nexus.Writers.Mat73' | 'Nexus.Writers.Famos'
fileFormat = 'Nexus.Writers.Csv';
% Nexus.Writers.Csv supports the following optional request configuration parameters:
% https://github.com/nexus-main/nexus/blob/master/src/Nexus/Extensions/Writers/README.md
configuration = containers.Map;
configuration('significant-figures') = '4';
configuration('row-index-format') = 'iso-8601';
client.export(...
dateTimeBegin, ...
dateTimeEnd, ...
filePeriod, ...
fileFormat, ...
resourcePaths, ...
configuration, ...
'data', ... % target folder
@(progress, message) fprintf('%3.0f %%: %s\n', progress * 100, message));