source: MML/trunk/machine/SOLEIL/StorageRing/insertions/IDStarter/premiertests.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 11.3 KB
Line 
1soleilinit
2getx
3plot(getx)
4family2dev('BPMx')
5family2tango('BPMx')
6help getx
7help family2tango
8doc tango
9tango_command_inout('ANS-C08/EI/M-HU80.2_CHAN1', 'State')
10tango_error
11dev = 'ANS-C08/EI/M-HU80.2_CHAN1';
12class(dev)
13a=2
14class(a)
15tango_state(dev)
16tango_status(dev)
17devM='ans-c08/ei/m-hu80.2_motorscontrol'
18tango_command_inout('ANS-C08/EI/M-HU80.2_CHAN1', 'State')
19tango_command_inout(devM, 'State')
20tango_command_inout2(devM, 'State')
21tango_command_inout(devM, 'State4')
22tango_command_inout2(devM, 'State4')
23tango_command_inout2(devM, 'ON')
24tango_command_inout2(devM, 'On')
25tango_command_inout2(devM, 'Status')
26tango_command_inout2(devM, 'State')
27pp = tango_command_inout2(devM, 'State')
28tango_command_inout2(devM, 'State')
29print(ans)
30printf('%s\n', ans)
31fprintf('%s\n', ans)
32ans
33a=2
34ans
352
36ans
37tango_read_attribute2(devM, 'encoder1Position')
38a = tango_read_attribute2(devM, 'encoder1Position')
39a
40a.value
41datestr(a.time)
42readattribute([devM, 'encoder1Position'])
43[devM, 'encoder1Position'])
44[devM, 'encoder1Position']
45[devM, '/encoder1Position']
46readattribute([devM, '/encoder1Position'])
47[a z ] = readattribute([devM, '/encoder1Position'])
48help readattribute
49[a z t] = readattribute([devM, '/encoder1Position'])
50edit readattribute.m
51datestr(t)
52[a z t] = readattribute([devM, '/encoder2Position'])
53[a z t] = readattribute([devM, '/encoder3Position'])
54[a z t] = readattribute([devM, '/encoder4Position'])
55[a z t] = readattribute([devM, '/encoder5Position'])
56[a z t] = readattribute([devM, '/encoder6Position'])
57tango_command_inout2(devM, 'GotoGap', 2400000)
58tango_command_inout2(devM, 'GotoGap', int32(2400000))
59[a z t] = readattribute([devM, '/encoder2Position'])
60tango_command_inout2(devM, 'Init')
61tango_command_inout2(devM, 'State')
62tango_command_inout2(devM, 'On')
63tango_command_inout2(devM, 'ResetError')
64tango_command_inout2(devM, 'Reset')
65tango_command_inout2(devM, 'GotoGap', int32(2100000))
66tango_command_inout2(devM, 'GotoPhase', int32(50000), int32(50000))
67tango_command_inout2(devM, 'GotoPhase', {int32(50000), int32(50000)})
68tango_command_inout2(devM, 'GotoPhase', [int32(50000), int32(50000)])
69tango_command_inout2(devM, 'Init')
70tango_command_inout2(devM, 'GotoPhase', [int32(0), int32(0)])
71tango_command_inout2(devM, 'GotoPhase', [int32(100000), int32(-100000)])
72tango_command_inout2(devM, 'GotoPhase', [int32(0), int32(0)])
73tango_command_inout2(devM, 'GotoGap', int32(2500000))
74
75getx
76getz
77getam('BPMx')
78getam('BPMx',[1 1])
79getam('BPMx',[1 1; 1 2])
80getam('BPMx',[5 1; 5 2])
81family2tangodev('BPMx',[5 1; 5 2])
82family2dev('BPMx')
83family2status('BPMx')
84modelbeta
85solorbit
86getx
87X = getx
88I=getdcct
89
90/home/matlabML/mmlcontrol/Ringspecific/insertions
91
92/home/matlabML/measdata/Ringdata/insertions/HU80_TEMPO/
93
94% H orbit
95EI.X = getx;
96% V orbit
97EI.Z = getz;
98% encoder #2
99EI.encoder2= readattribute([devM, '/encoder2Position']);
100% stored current
101EI.current = getdcct;
102% tunes
103EI.tune = gettune;
104
105% measure dispersion functions
106[dx dz] = measdisp('Physics');
107
108EI.dx = dx;
109EI.dz = dz;
110
111EI.date = datestr(now); % convert date to string
112
113pause(1); % 1 second pause
114
115% measure chromaticities
116EI.ksi = measchro('Physics');
117
118%%%%%%%%%%%%%% ARchiving
119
120% If the filename contains a directory then make sure it exists
121Filename = 'exemple4Oleg';
122
123FileName = appendtimestamp('G20_P0');
124DirectoryName = getfamilydata('Directory','HU80_TEMPO');
125DirStart = pwd;
126[DirectoryName, ErrorFlag] = gotodirectory(DirectoryName);
127save(FileName, 'EI_G20_P0');
128cd(DirStart);
129
130
131edit soleilinit
132Filename = 'exemple4Oleg'
133FileName = appendtimestamp(Filename)
134getfamilydata('Directory','HU80_TEMPO')
135ls
136rm HU80_2006-09-12_17-24-36
137remove HU80_2006-09-12_17-24-36
138delete HU80_2006-09-12_17-24-36.mat
139ls
140dir
141help save
142doc save
143getmcf
144pwd
145save 'toto' EI
146
147%%%%%%%%%%%%%% Calculating theoretical Beta values at the positions of BPMs
148modelbeta('BPMx')
149[bx bz]=modelbeta('BPMx')
150bx
151[phx, phz] = modelphase('BPMx')
152phx
153modeltune
154[nux nuz] = modeltune
155nu = modeltune
156
157%%%%%%%%%%%%%% Measuring COD vs Corrector Currents (to estimate corrector efficiency)
158tableCurInCor = [0 0 0 0; -10 0 0 0; -5 0 0 0; 0 0 0 0; 5 0 0 0; 10 0 0 0; 0 0 0 0; 0 -10 0 0; 0 -5 0 0; 0 0 0 0; 0 5 0 0; 0 10 0 0; 0 0 0 0; 0 0 -10 0; 0 0 -5 0; 0 0 0 0; 0 0 5 0; 0 0 10 0; 0 0 0 0; 0 0 0 -10; 0 0 0 -5; 0 0 0 0; 0 0 0 5; 0 0 0 10]
159[fileNames, res] = idMeasCorEffic('HU80_PLEIADES', tableCurInCor, 0, 'C1G200', 1)
160
161%To measure electron beam and read undulator state, and save the data
162%structure to a file
163stMeas = idMeasElecBeamUnd('U20_PROXIMA1', 0, 'test_for_chams', 1)
164
165%to estimate effective field integrals of U20
166st = idCalcFldIntFromElecBeamMeasForUndSOLEIL_1('U20_PROXIMA1', '/home/matlabML/measdata/Ringdata/insertions/U20_PROXIMA1', 'u20_g5_5_2006-09-29_12-29-58', 'u20_g30_2006-09-29_11-59-57', '', -1)
167
168% Write a table : attributename to be changed
169A=[0 1 2 3;
170      10 0.2 0.4 0.5;
171      20 0.5 0.21 0.45];
172 
173tango_write_attribute2(dev,'correctionCHEParallelMode',A); 
174
175% how to write at the same time all the correctors
176dev= 'ANS-C08/EI/M-HU80.2';
177attr_name_val_list(1).value = 0
178attr_name_val_list(2).value = 0
179attr_name_val_list(3).value = 0
180attr_name_val_list(4).value = 0
181attr_name_val_list(1).name='currentCHE'
182attr_name_val_list(2).name='currentCVE'
183attr_name_val_list(4).name='currentCVS'
184attr_name_val_list(3).name='currentCHS'
185
186tango_write_attributes(dev,attr_name_val_list);
187
188% to calculate correction tables for feed-forward
189%HU80:
190stFileNamesMeasCOD = load('/home/operateur/GrpGMI/HU80_TEMPO/cod_II_filelist_2006-12-10_13-11-12');
191vPhase = [-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40];
192vGap = [15.5, 16, 18, 20, 22.5, 25, 27.5, 30, 35, 40, 50, 60, 70, 80, 90, 100, 110, 130, 150];
193fileNamesMeasBkg = idAuxPrepFileNameListMeasAndBkg(stFileNamesMeasCOD.filelist, length(vGap));
194arBPM2Skip = [58];
195[mCHE, mCVE, mCHS, mCVS] = idCalcFeedForwardCorTables('HU80_TEMPO', {{'phase', vPhase}, {'gap', vGap}}, fileNamesMeasBkg, '', '', arBPM2Skip);
196mCHE_with_Arg = idAuxMergeCorTableWithArg2D(vGap, vPhase, mCHE);
197mCVE_with_Arg = idAuxMergeCorTableWithArg2D(vGap, vPhase, mCVE);
198mCHS_with_Arg = idAuxMergeCorTableWithArg2D(vGap, vPhase, mCHS);
199mCVS_with_Arg = idAuxMergeCorTableWithArg2D(vGap, vPhase, mCVS);
200
201
202
203%U20:
204stFileNamesMeasCOD = load('/home/operateur/GrpGMI/U20_PROXIMA1/test_cod_filelist_2007-01-24_13-17-20.mat');
205vGap = [30, 27];
206fileNamesMeasBkg = idAuxPrepFileNameListMeasAndBkg(stFileNamesMeasCOD.filename, length(vGap))
207[mCHE, mCVE, mCHS, mCVS] = idCalcFeedForwardCorTables('U20_PROXIMA1', {{'gap', vGap}}, fileNamesMeasBkg, '', '', -1)
208
209%%
210dev = 'ANS-C04/EI/M-HU80.1';
211
212tango_write_attribute2(dev,'parallelModeCHE', mCHE_res_with_arg);
213tango_write_attribute2(dev,'parallelModeCVE', mCVE_res_with_arg);
214tango_write_attribute2(dev,'parallelModeCHS', mCHS_res_with_arg);
215tango_write_attribute2(dev,'parallelModeCVS', mCVS_res_with_arg);
216
217%%To measure COD vs Undulator Param(s) automatically:
218[resFileNames, resErrorFlag] = idMeasElecBeamVsUndParam('HU80_TEMPO', {{'phase', [-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40]}, {'gap', [15.5]}}, {}, inclPerturbMeas, fileNameCore, dispData)
219[resFileNames, resErrorFlag] = idMeasElecBeamVsUndParam('HU80_TEMPO', {{'phase', [-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40], 0.01}, {'gap', [15.5], 0.01}}, {{'gap', 250, 0.01}, {'phase', 0, 0.01}}, 2, 0, 'test', 1)
220[resFileNames, resErrorFlag] = idMeasElecBeamVsUndParam('HU80_TEMPO', {{'phase', [-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40], 0.01}, {'gap', [15.5, 16, 18, 20, 22.5, 25, 27.5, 30, 35, 40, 50, 60, 70, 80, 90, 100, 110, 130, 150], 0.01}}, {{'gap', 250, 0.01}, {'phase', 0, 0.01}}, 1, 0, 'cod_X_01_07', 1)
221[resFiles, resErr] = idMeasElecBeamVsUndParam('HU80_PLEIADES', {{'phase', [-40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40], 0.01}, {'gap', [15.5, 16, 18, 20], 0.01}}, {{'gap', 250, 0.01}, {'phase', 0, 0.01}}, 1, 0, 'cod_extra_II', 1)
222[resFiles, resErr] = idMeasElecBeamVsUndParam('HU80_CASSIOPEE', {{'phase', [-40,-37.5, -35,-32.5, -30,-27.5, -25,-22.5, -20,-17.5, -15,-12.5, -10,-7.5, -5,-2.5, 0,2.5, 5,7.5, 10,12.5, 15,17.5, 20,22.5, 25,27.5, 30,32.5, 35, 37.5,40], 0.01}, {'gap', [15.5, 16, 18, 20, 22.5, 25, 27.5, 30, 35, 40, 50, 60, 70, 80, 90, 100, 110, 130, 150, 175, 200, 225, 250], 0.01}}, {{'phase', 0, 0.01}, {'gap', 250, 0.01}}, 1, 0, 'cod_1st_test', 1)
223[resFiles, resErr] = idMeasElecBeamVsUndParam('HU80_CASSIOPEE', {{'phase', [-40,-37.5, -35,-32.5, -30,-27.5, -25,-22.5, -20,-17.5, -15,-12.5, -10,-7.5, -5,-2.5, 0,2.5, 5,7.5, 10,12.5, 15,17.5, 20,22.5, 25,27.5, 30,32.5, 35, 37.5,40], 0.01}, {'gap', [15.5, 16, 18, 20, 22.5, 25, 27.5, 30, 35, 40, 50, 60, 70, 80, 90, 100, 110, 130, 150, 175, 200, 225, 250], 0.01}}, {{'phase', 0, 0.01}, {'gap', 250, 0.01}}, 1, 0, 'cod_gen_X', 1)
224[resFiles, resErr] = idMeasElecBeamVsUndParam('HU80_CASSIOPEE', {{'phase', [40], 0.01}, {'gap', [15.5, 16, 18, 20, 22.5, 25, 27.5, 30, 35, 40, 50, 60, 70, 80, 90, 100, 110, 130, 150], 0.01}}, {{'phase', 0, 0.01}, {'gap', 250, 0.01}}, 1, 0, 'cod_1st_test', 1)
225[resFileNames, resErrorFlag] = idMeasElecBeamVsUndParam('U20_PROXIMA1', {{'gap', [5.5, 6, 10], 0.01}}, {{'gap', 30, 0.01}}, 1, 0, 'test_cod', 1)
226
227%U20 COD meas. and calc. of cor. tables:
228[resFileNames, resErrorFlag] = idMeasElecBeamVsUndParam('U20_PROXIMA1', {{'gap', [5.5, 6, 10], 0.01}}, {{'gap', 30, 0.01}}, 1, 0, 'test_cod', 1)
229%st.filelist = resFileNames; idSaveStruct(st, 'test_cod_filelist', 'U20_PROXIMA1', 0)
230    %do something else...
231%ls /home/operateur/GrpGMI/U20_PROXIMA1
232%stFileNamesMeasCOD = load('/home/operateur/GrpGMI/U20_PROXIMA1/test_cod_filelist_2007-01-24_14-20-54.mat');
233%vGap = [5.5, 6, 10];
234%fileNamesMeasBkg = idAuxPrepFileNameListMeasAndBkg(stFileNamesMeasCOD.filelist, length(vGap));
235%[mCHE, mCVE, mCHS, mCVS] = idCalcFeedForwardCorTables('U20_PROXIMA1', {{'gap', vGap}}, fileNamesMeasBkg, '', '', -1);
236[mCHE, mCVE, mCHS, mCVS] = idCalcFeedForwardCorTables('U20_PROXIMA1', resFileNames.params, resFileNames.filenames_meas_bkg, '', '', -1)
237
238%CHAMS, I've tested the COD meas. using idMeasElecBeamVsUndParam. It seems to work fine now. 03/02/2007 OC
239[resFNames, resErrorFlag] = idMeasElecBeamVsUndParam('U20_PROXIMA1', {{'gap', [29.5, 29.7], 0.01}}, {{'gap', 30, 0.01}}, 1, 0, 'test_cod_to_delete', 1)
240
241
242%Make Bump walking aroung eventual saturation of BPMs:
243idSetOrbitBump('BPMx', [4 1;4 2], [4.5,4.5], 'HCOR', [-4,-3,-2,-1,1,2,3,4]);
244%Measurement of COD vs Horizontal Bump:
245[resBumpMeasPLEIADES, ErrorFlag] = idMeasElecBeamVsUndParamVsBump('HU80_PLEIADES', {{'phase', [-40,-20,0,20,40], 0.01}, {'gap', [15.5], 0.01}}, {{'gap', 250, 0.01}, {'phase', 0, 0.01}}, 2, 0, 'inj_problem', 1, 'H', {[1,1],[-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5]}, [-4,-3,-2,-1,1,2,3,4]);
246%Calculation of Field Integrals and other characteristics vs Horizontal Bump:
247[vI1x, vI2x, vI1z, vI2z, vPosBump, vKickX1, vKickX2, vKickZ1, vKickZ2, dNuX, dNuZ] = idCalcFldIntVsBumpFromElecBeamMeasForUndSOLEIL('HU80_PLEIADES', '/home/operateur/GrpGMI/GrpGMI/HU80_PLEIADES', resBumpMeasPLEIADES, {{'phase', -40}, {'gap', 15.5}}, '', {[3 3],[3 4],[3 5],[3 6],[3 7],[3 8],[4 1],[4 2],[4 3],[4 4],[4 5],[4 6],[4 7],    [5.3]});
248
249 [vI1xP0c, vI2xP0c, vI1zP0c, vI2zP0c, vPosBumpC, vKickX1P0c, vKickX2P0c, vKickZ1P0c, vKickZ2P0c, dNuXP0c, dNuZP0c] = idCalcFldIntVsBumpFromElecBeamMeasForUndSOLEIL('HU80_CASSIOPEE', '/home/operateur/GrpGMI/HU80_CASSIOPEE', stBumpCAS.resBumpMeas, {{'phase', 0}, {'gap', 15.5}}, '', {[8 1],[8 2],[8 3],[8 4],[8 5],[8 6],[8 7],[9 1],[9 2],[9 3],[9 4],[9 5],[9 6],[9 7]})
250
Note: See TracBrowser for help on using the repository browser.