-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheda_extract_data.m
More file actions
executable file
·52 lines (47 loc) · 2.38 KB
/
Copy patheda_extract_data.m
File metadata and controls
executable file
·52 lines (47 loc) · 2.38 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
50
51
52
%READ
%This function takes in the data, parameter name, and the index of the
%parameter in the list of parameters located in data.raw.scalars
%Because the location of the paramaeter is the same in the listdlg of converted parameter names
%and the original names in data.raw.scalars, this number is used to extract
%the dat/UID files for that parameter.
%Some exceptions are made to this way of extraction,(excess_charge etc.),
%because these are calculated(not raw) parameters
%This function is based on nvn_extract_data
function [uid_vector,prmtr_vector]= eda_extract_data(data_struc,prmtr_extrct_name,index_sort_parameter)
scalar_struc = data_struc.raw.scalars;
switch prmtr_extrct_name
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%Calculating excess charge
case 'excess_charge_USBPM1_DSBPM1'
[US_BPM1_ID,US_BPM1_value]=nvn_extract_data(data_struc,'US_BPM1');
[DS_BPM1_ID,DS_BPM1_value]=nvn_extract_data(data_struc,'DS_BPM1');
%UID Check
assert(sum(DS_BPM1_ID==US_BPM1_ID)==length(US_BPM1_ID))
uid_vector=US_BPM1_ID;
%prmtr_vector=DS_BPM1_value-US_BPM1_value + 3e+09;
prmtr_vector=DS_BPM1_value-US_BPM1_value;
case 'excess_charge_USBPM1_DSBPM2'
[US_BPM1_ID,US_BPM1_value]=nvn_extract_data(data_struc,'US_BPM1');
[DS_BPM2_ID,DS_BPM2_value]=nvn_extract_data(data_struc,'DS_BPM2');
%UID Check
assert(sum(DS_BPM2_ID==US_BPM1_ID)==length(US_BPM1_ID))
uid_vector=US_BPM1_ID;
% prmtr_vector=DS_BPM2_value - US_BPM1_value + 6e+09;
prmtr_vector=DS_BPM2_value - US_BPM1_value;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%Calculating excess charge toro:(US1,DS1)
case 'excess_charge_UStoro1_DStoro1'
[US_toro1_ID,US_toro1_value]=nvn_extract_data(data_struc,'US_toro1');
[DS_toro1_ID,DS_toro1_value]=nvn_extract_data(data_struc,'DS_toro1');
%UID Check
assert(sum(DS_toro1_ID==US_toro1_ID)==length(US_toro1_ID))
uid_vector=US_toro1_ID;
prmtr_vector=DS_toro1_value-US_toro1_value;
otherwise
%extract data method for rest of parameters
scalars=fieldnames(data_struc.raw.scalars);
prmtr_cell = scalars(index_sort_parameter);
prmtr_str = prmtr_cell{1};
uid_vector=scalar_struc.(prmtr_str).UID;
prmtr_vector=scalar_struc.(prmtr_str).dat;
end