-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaverage_plot.m
More file actions
181 lines (133 loc) · 5.72 KB
/
average_plot.m
File metadata and controls
181 lines (133 loc) · 5.72 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
function funcOut = average_plot(analyVar, indivDataset, avgDataset)
%%% average_plot.m - Joe Whalen 2017.12.15
%%% Edited on 2025.02.07 by Soumya Kanungo to include the function
%%% 'getxy_filtered' which outputs clean datasets based on predefined
%%% Global filters in AnalysisVariables.
%%% Make a plot of the average of any quantity in indivDataset grouped
%%% by the flags in the master batch file.
indVarField = 'imagevcoAtom'; % The Field of an IndivDataset that is to be plotted on the X axis
%depVarField = 'cldRadX';
depVarField = 'numberAtom';
%depVarField = 'sfiIntegral'; % The field of an indivdataset that is to be plotted on the y axis
%[xdata, ydata] = getxy(indVarField, depVarField, analyVar, indivDataset, avgDataset);
%[xdata_clean, ydata_clean] = getxy_filtered(indVarField, depVarField, analyVar, indivDataset, avgDataset);
[xdata_clean, ydata_clean] = getxy(indVarField, depVarField, analyVar, indivDataset, avgDataset);
scanIDs = analyVar.uniqScanList;
x = cell(length(scanIDs));
y = cell(length(scanIDs));
yerr = cell(length(scanIDs));
% for id = 1:length(scanIDs)
% x{id} = [];
%
% for basename = 1:analyVar.numBasenamesAtom
% if scanIDs(id) == analyVar.meanListVar(basename)
% x{id} = union(x{id},xdata{basename});
% end
% end
%
% y{id} = zeros(size(x{id}));
% yerr{id} = zeros(size(x{id}));
%
% tempy = zeros(size(analyVar.meanListVar));
% for i = 1:length(x{id})
% num=0;
% for basename = 1:analyVar.numBasenamesAtom
% if scanIDs(id) == analyVar.meanListVar(basename)
% for j = 1:indivDataset{basename}.CounterAtom
% if xdata{basename}(j) == x{id}(i)
% num = num + 1;
% tempy(num) = ydata{basename}(j);
% end
% end
% end
% end
% num;
% y{id}(i) = mean(tempy(1:num));
% yerr{id}(i) = std(tempy(1:num))/sqrt(num);
% end
% end
%%
AvgSig = zeros(size(scanIDs));
AvgSig_err = zeros(size(scanIDs));
for id = 1:length(scanIDs)
x{id} = [];
for basename = 1:analyVar.numBasenamesAtom
if scanIDs(id) == analyVar.meanListVar(basename)
x{id} = union(x{id},xdata_clean{basename});
end
end
y{id} = zeros(size(x{id}));
yerr{id} = zeros(size(x{id}));
tempy = zeros(size(analyVar.meanListVar));
for i = 1:length(x{id})
num=0;
for basename = 1:analyVar.numBasenamesAtom
if scanIDs(id) == analyVar.meanListVar(basename)
for j = 1:length(xdata_clean{basename})
if xdata_clean{basename}(j) == x{id}(i)
num = num + 1;
tempy(num) = ydata_clean{basename}(j);
end
end
end
end
num;
y{id}(i) = mean(tempy(1:num));
yerr{id}(i) = std(tempy(1:num))/sqrt(num);
end
AvgSig(id) = mean(y{id}); % use this to average over the independent variable and get a scalar for each scanID
AvgSig_err(id) = std(y{id}); % use this to std over the independent variable and get a scalar for each scanID
end
%avgDataset.(depVarField) = y;
%avgDataset.(strcat(depVarField,'_unc')) = yerr;
%avgDataset.(strcat(depVarField,'_x')) = x;
figure;
hold on;
for id = 1:length(scanIDs)
errorbar(x{id}, y{id}, yerr{id},...
'LineStyle','-',...
'Marker', analyVar.MARKERS2(id),...
'MarkerSize', analyVar.markerSize,...
'MarkerFaceColor', analyVar.COLORS(id,:),...
'MarkerEdgeColor', 'none',...
'Color', analyVar.COLORS(id,:));
end
legend(num2str(scanIDs));
title('3P1 Population for Trim Fiels X: V, Y: V, Z: V');
xlabel('rMOT Final Freq (MHz)');
ylabel('Total Number Avg. Fluo');
hold off
%% PLot
% figure;
% hold on;
% errorbar(scanIDs*80e-3, AvgSig, AvgSig_err,...
% 'LineStyle','none',...
% 'Marker', analyVar.MARKERS2(1),...
% 'MarkerSize', analyVar.markerSize,...
% 'MarkerFaceColor', analyVar.COLORS(1,:),...
% 'MarkerEdgeColor', 'none',...
% 'Color', analyVar.COLORS(1,:));
% title('SFI signal dependence vs time of experiment');
% xlabel('Total time for MCS Data (ms)');
% ylabel('Total MCS Counts');
% hold off
% figure;
% hold on;
% for id = 1:length(scanIDs)
% plot(x{id}, y{id}/trapz(x{id},y{id}),...
% 'LineStyle','-',...
% 'Marker', analyVar.MARKERS2(id),...
% 'MarkerSize', analyVar.markerSize,...
% 'MarkerFaceColor', analyVar.COLORS(id,:),...
% 'MarkerEdgeColor', 'none',...
% 'Color', analyVar.COLORS(id,:));
% end
% legend(num2str(scanIDs))
% title('Trapping- Scanning Mot coil Off time - 60 1D2 Line')
% xlabel('826 nm Synth with doubler ON [MHz]')
% ylabel('Normalized by total signal MCS Counts')
% hold off
funcOut.analyVar = analyVar;
funcOut.indivDataset = indivDataset;
funcOut.avgDataset = avgDataset;
end