-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedder_process.m
117 lines (80 loc) · 4.79 KB
/
edder_process.m
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
% process -- grind all ops blocks through the mill
%
%
% Assumes:
% 1. index has been generated and exists in workspace (indexgen.m)
% 2. ops blocks are defined (opsblock.m)
global tabindex;
tabindex = {}; % Set by createTAB.m. Must be cleared first e.g. in case of manual reruns.
sctconv=@sct2obt;
for b = 1:nob % Loop through all ops blocks
% day = datestr(index(obs(b)).t0,'yyyymmdd'); % convert block start time index to time string, convert to yyyymmdd format
ob = obs(b):obe(b); %ob goes from start time index to end time index
% Find sweeps:
p1s = find([index(ob).sweep] & ([index(ob).probe] == 1)); %%returns indices of all sweeps for probe 1 for macro operation block
p2s = find([index(ob).sweep] & ([index(ob).probe] == 2));
% Find E data:
p1el = find([index(ob).lf] & [index(ob).efield] & ([index(ob).probe] == 1));
p2el = find([index(ob).lf] & [index(ob).efield] & ([index(ob).probe] == 2));
p1eh = find([index(ob).hf] & [index(ob).efield] & ([index(ob).probe] == 1));
p2eh = find([index(ob).hf] & [index(ob).efield] & ([index(ob).probe] == 2));
% Find N data:
p1nl = find([index(ob).lf] & ~[index(ob).efield] & ([index(ob).probe] == 1));
p2nl = find([index(ob).lf] & ~[index(ob).efield] & ([index(ob).probe] == 2));
p1nh = find([index(ob).hf] & ~[index(ob).efield] & ([index(ob).probe] == 1));
p2nh = find([index(ob).hf] & ~[index(ob).efield] & ([index(ob).probe] == 2));
%probe 3
% Find E data:
p3el = find([index(ob).lf] & [index(ob).efield] & ([index(ob).probe] == 3));
p3eh = find([index(ob).hf] & [index(ob).efield] & ([index(ob).probe] == 3));
% Find N data:
p3nl = find([index(ob).lf] & ~[index(ob).efield] & ([index(ob).probe] == 3));
p3nh = find([index(ob).hf] & ~[index(ob).efield] & ([index(ob).probe] == 3));
%
% % This does not preserve label indices, but only the new indices. so
% % index(ob) where ob = 6:10, gives results in the range 1:5
%
%
% %Get Sweep measurements times
% obt0temp= cellfun(@(s) s(4:end-1), {index(ob(p1s)).sct0str}, 'uni',false);
% obt1temp= cellfun(@(s) s(4:end-1), {index(ob(p1s)).sct1str}, 'uni',false);
obt0temp= cell2mat(cellfun(@sct2obt, {index(ob(p1s)).sct0str}, 'uni',false));
obt1temp= cell2mat(cellfun(@sct2obt, {index(ob(p1s)).sct1str}, 'uni',false));
sweept1 = [obt0temp;obt1temp];
% sweept1 = [str2double(obt0temp); str2double(obt1temp)];
% clear sct0temp sct1temp
clear obt0temp obt1temp
obt0temp= cell2mat(cellfun(@sct2obt, {index(ob(p2s)).sct0str}, 'uni',false));
obt1temp= cell2mat(cellfun(@sct2obt, {index(ob(p2s)).sct1str}, 'uni',false));
%
% obt0temp= cellfun(@(s) s(4:end-1), {index(ob(p2s)).sct0str}, 'uni',false);
% obt1temp= cellfun(@(s) s(4:end-1), {index(ob(p2s)).sct1str}, 'uni',false);
sweept2 = [obt0temp;obt1temp];
clear obt0temp obt1temp
% sweept1= arrayfun(@sct2obt,sweept1);
% sweept2= arrayfun(@sct2obt,sweept2);
sweept3 = [sweept1,sweept2];
% %%%% Start TAB genesis
%
%
%
%Generate sweep files
%
if(~isempty(p2s)) edder_createTAB(derivedpath,ob(p2s),index,index(obs(b)).t0,'B2S',sweept1); end
if(~isempty(p1s)) edder_createTAB(derivedpath,ob(p1s),index,index(obs(b)).t0,'B1S',sweept1); end
%Generate E data files
if(~isempty(p1el)) edder_createTAB(derivedpath,ob(p1el),index,index(obs(b)).t0,'V1L',sweept1); end
if(~isempty(p2el)) edder_createTAB(derivedpath,ob(p2el),index,index(obs(b)).t0,'V2L',sweept2); end
if(~isempty(p1eh)) edder_createTAB(derivedpath,ob(p1eh),index,index(obs(b)).t0,'V1H',sweept1); end
if(~isempty(p2eh)) edder_createTAB(derivedpath,ob(p2eh),index,index(obs(b)).t0,'V2H',sweept2); end
if(~isempty(p3el)) edder_createTAB(derivedpath,ob(p3el),index,index(obs(b)).t0,'V3L',sweept3); end
if(~isempty(p3eh)) edder_createTAB(derivedpath,ob(p3eh),index,index(obs(b)).t0,'V3H',sweept3); end
%Generate N data files
if(~isempty(p1nl)) edder_createTAB(derivedpath,ob(p1nl),index,index(obs(b)).t0,'I1L',sweept1); end
if(~isempty(p2nl)) edder_createTAB(derivedpath,ob(p2nl),index,index(obs(b)).t0,'I2L',sweept2); end
if(~isempty(p1nh)) edder_createTAB(derivedpath,ob(p1nh),index,index(obs(b)).t0,'I1H',sweept1); end
if(~isempty(p2nh)) edder_createTAB(derivedpath,ob(p2nh),index,index(obs(b)).t0,'I2H',sweept2); end
if(~isempty(p3nl)) edder_createTAB(derivedpath,ob(p3nl),index,index(obs(b)).t0,'I3L',sweept3); end
if(~isempty(p3nh)) edder_createTAB(derivedpath,ob(p3nh),index,index(obs(b)).t0,'I3H',sweept3); end
fprintf(1,'Macroblock %i out of %i.\n Latest file created from %s\n',b,nob,index(obe(b)).t1str);
end %observation block for loop