-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_data_to_txt_ver4.m
127 lines (111 loc) · 5.14 KB
/
save_data_to_txt_ver4.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
118
119
120
121
122
123
124
125
126
127
function [files] = save_data_to_txt_ver4(analyVar, indivDataset, avgDataset)
% 2019/02/07 - work-in-progress towards a more versatile function for
% writing output data.
% Subdirectory to write to
output_dir = './out/';
% Options
use_dac = 1;
use_labview = 1;
use_images = analyVar.UseImages;
use_mcs = analyVar.UseMCS;
indVarField = {'imagevcoAtom'};
depVarField = {'sfiIntegral', 'wavemeterAtom', 'wavemeterBack'};
%depVarField = {'wavemeterAtom', 'wavemeterBack'};
%{
indivBatch_header = {
'fileAtom',... % 01 name of the image file
'imagevcoAtom',... % 02 corresponding value of the independent parameter
'principleQuantumAtom',... % 03 principle quantum number n
'angularQuantumAtom',... % 04 principle quantum number \el
'ODTHold',... % 05 odt hold time
'RampDelay',... % 06 rydberg hold time for lifetime measurements
'VCA_1_Voltage',... % 07 3 beam ODT vca 1 static voltage; control relatice power between 3 beams
'VCA_2_Voltage',... % 08 3 beam ODT VCA 2 static voltage; control absolute power of all 3 beams
'initialTrapDepthAtom',... % 09 initial trap depth in volts before evaporation
'TrapPower',... % 10 final trap depth in volts after evaporation
'synthFreq',... % 11 synth frequency driving 640nm cat's eye aom
'numberAtom',... % 12 number of atoms measured by labview
'tempXAtom',... % 13 TOF x temperature measured by labview
'tempYAtom',... % 14 TOF y temperature measured by labview
'fugacityguessAtom',... % 15 left constant
'sigParamAtom',... % 16 left constant
'sigBECParamAtom',... % 17 left constant
'WeightedBECPeakAtom',... % 18 left constant
'BECamplitudeParameterAtom',... % 19 left constant
'wavemeterAtom',... % 20 wavemeter reading
'timestampAtom',... % 21 timestamp of image (YYYY.MM.DD - HH:MM:SS)
};
%}
dac_header = {
'Timestamp',...
'GHz_Synth',...
'UV_Power',...
'Spec_Power',...
'DigiLock_PID1_locked',...
'AI3',...
'AI4',...
'AI5',...
'AI6',...
'AI7'
};
labview_header = {
'numberAtom',...
'tempXAtom',...
'tempYAtom'
};
image_header = {
'winTotNum',...
'atomTempX',...
'atomTempY'
};
% Loop over individual scans
for scan_idx = 1:analyVar.numBasenamesAtom
% Grab independent variable
out = table(indivDataset{scan_idx}.(indVarField{1}), 'VariableNames', indVarField);
% Loop through output from indivDataset
for j = 1:length(depVarField)
out = [out, table(indivDataset{scan_idx}.(depVarField{j}), 'VariableNames', depVarField(j))];
%out = [out, table(indivDataset{scan_idx}.(depVarField{j}))];
end
if use_dac
% Get dac_voltages
for j = 1:length(dac_header)
out = [out, table(indivDataset{scan_idx}.daq_voltages{j}, 'VariableNames', dac_header(j))];
end
end
if use_labview
for j = 1:length(labview_header)
out = [out, table(indivDataset{scan_idx}.(labview_header{j}), 'VariableNames', labview_header(j))];
end
end
if use_images
for j = 1:length(image_header)
out = [out, table(transpose(indivDataset{scan_idx}.(image_header{j})), 'VariableNames', image_header(j))];
end
end
% Output file diretory
output_file_name = strcat(analyVar.basenamevectorAtom{scan_idx},'_out.csv');
writetable(out, strcat(output_dir,output_file_name));
end
outputdir = './out/';
%%%%%%%%%%%% adding code for generating the mcsfiles in folders in the
%%%%%%%%%%%% out folder of Analysis dir.
if use_mcs
for i = 1:analyVar.numBasenamesAtom %% Loop over the batch files.
for j=1:indivDataset{i}.CounterMCS
bin_num = indivDataset{i}.mcsSpectra{j}(:,1);
MCScount = indivDataset{i}.mcsSpectra{j}(:,2);
T = table(bin_num,MCScount);
outputfoldername = strcat(analyVar.basenamevectorAtom{i},'_mcs_files/');
if ~exist(strcat(outputdir,outputfoldername), 'dir')
mkdir(outputdir,outputfoldername)
end
%mkdir(outputdir,outputfoldername)
outputfilename = strcat(analyVar.basenamevectorAtom{i},'_',num2str(j),'_.csv');
outputdestination = strcat(outputdir,outputfoldername,outputfilename);
disp(outputdestination);
writetable(T,outputdestination);
end
end
end
end