Commit 96230255 authored by Thomas Perron's avatar Thomas Perron
parents 27849c0f d79ebb22
......@@ -162,6 +162,7 @@ end
ind=atgetcells(mach,'Class','Monitor');
mach(ind)=atsetfieldvalues(mach(ind),'Device',ebs.bpmname(1:sum(ind)));
mach(ind)=atsetfieldvalues(mach(ind),'FamName',ebs.bpmname(1:sum(ind),'BPM_C%02i-%02i'));
ind=atgetcells(mach,'FamName','PINHOLE_.*');
mach(ind)=atsetfieldvalues(mach(ind),'Device',ebs.pinholename(1:sum(ind)));
......
......@@ -60,9 +60,21 @@ curdir=pwd;
mkdir(fulfold);
cd(fulfold);
% ensure sufficent maxorder
indm = atgeetcells(r,'MaxOrder');
np = cellfun(@(a)min(length(a.PolynomB),length(a.PolynomA)),r(indm),'un',1);
r = atsetfieldvalues(r,indm,'MaxOrder',np-1);
% AT lattice
betamodel=r;
save('betamodel.mat','betamodel');
errtab_tmp=errtab; % store input tables
cortab_tmp=cortab;
errtab = atcreateerrortable(r);
cortab = atgetcorrectiontable(r,r); % zeros
save('betamodel.mat','betamodel','errtab','cortab'); % errtab and cortab all zeros.
errtab = errtab_tmp; clear errtab_tmp; % restore input tables
cortab = cortab_tmp; clear cortab_tmp;
% AT lattice for simulator with errors and corrections
disp('errors and correction lattice for simulator (provide errtab and cortab or zeros will be set)')
......
......@@ -32,7 +32,7 @@ classdef OrbitCorrection < RingControl
switch obj.machine
case 'ebs-simu'
b = load('/machfs/liuzzo/EBS/Simulator/commissioningtools/@OrbitCorrection/EBSOrbitRM.mat');
b = load('/machfs/liuzzo/EBS/Simulator/BeamDynamics/matlab/@OrbitCorrection/EBSOrbitRM.mat');
obj.ModelRM = b.ModelRM;
case 'esrf-sr'
......
......@@ -465,11 +465,7 @@ while ~stopped
if corropt.meanzero % no dpp mean0
FRV=[RespV;steermeanlist];
elseif ~corropt.meanzero % no dpp no mean0
FRV=RespV;disp('Correction regressing ');
disp(['rms orbit not decreased: ' num2str(nbpmu)]);
disp(['Before Correction: ' num2str(std2(t0is'))]);
disp(['After Correction: ' num2str(std2(t'))]);
FRV=RespV;
end
......
......@@ -63,7 +63,7 @@ classdef movable < handle
% deal with empty moovable
if isempty(obj.attr_name)
warning('empty moovable')
warning('empty movable')
obj.attribute.value = NaN; % always return NaN
obj.attribute.set = NaN; % define a set field, will store the value set, but no effect on .value.
......
This diff is collapsed.
8.5955e-05
\ No newline at end of file
This diff is collapsed.
srmag/m-sd1ae/inj-inner,-0.0493118390,-0.1046729211,
srmag/m-sd1ae/inj-inner,-0.0492869285,-0.1046200443,
srmag/m-sd1ae/inj-outer,-0.0491360486,-0.1042997756,
srmag/m-sd1ae/inj-outer,-0.0491235072,-0.1042731544,
srmag/m-sd1ae/all,-0.0474022241,-0.1006194328,
srmag/m-sd1bd/inj-inner,-0.0469169458,-0.0995893455,
srmag/m-sd1bd/inj-inner,-0.0469018437,-0.0995572887,
srmag/m-sd1bd/inj-outer,-0.0465246722,-0.0987566769,
srmag/m-sd1bd/inj-outer,-0.0464892766,-0.0986815436,
srmag/m-sd1bd/all,-0.0445409748,-0.0945459354,
srmag/m-sf2/all,0.1144291093,0.0373598427,
srmag/m-sf2ae/inj-outer,0.1219552078,0.0398170309,
srmag/m-sf2ae/inj-outer,0.1220091407,0.0398346394,
srmag/m-sf2ae/inj-inner,0.1225609173,0.0400147884,
srmag/m-sf2ae/inj-inner,0.1226137648,0.0400320425,
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/mntdirect/_machfs/liuzzo/EBS/Simulator/BeamDynamics/matlab/optics/ebs/S28F_3PW_SB/kicker_bumps/injbumpmat.cvs
\ No newline at end of file
-0.000000 -0.000000 0.000000 0.000000 -0.000000
-0.001500 0.000639 0.000734 0.000734 0.000639
-0.003000 0.001279 0.001468 0.001468 0.001279
-0.004500 0.001919 0.002203 0.002203 0.001919
-0.006000 0.002558 0.002939 0.002939 0.002558
-0.007500 0.003198 0.003675 0.003675 0.003198
-0.009000 0.003838 0.004412 0.004412 0.003838
-0.010500 0.004479 0.005149 0.005149 0.004479
-0.012000 0.005119 0.005887 0.005887 0.005119
-0.013500 0.005760 0.006626 0.006626 0.005760
-0.013650 0.005824 0.006700 0.006700 0.005824
-0.013800 0.005888 0.006774 0.006774 0.005888
-0.013950 0.005952 0.006848 0.006848 0.005952
-0.014100 0.006016 0.006921 0.006921 0.006016
-0.014250 0.006080 0.006995 0.006995 0.006080
-0.014400 0.006144 0.007069 0.007069 0.006144
-0.014550 0.006208 0.007143 0.007143 0.006208
-0.014700 0.006272 0.007217 0.007217 0.006272
-0.014850 0.006336 0.007291 0.007291 0.006336
-0.015000 0.006400 0.007365 0.007365 0.006400
-0.015150 0.006465 0.007439 0.007439 0.006465
-0.015300 0.006529 0.007513 0.007513 0.006529
-0.015450 0.006593 0.007587 0.007587 0.006593
-0.015600 0.006657 0.007661 0.007661 0.006657
-0.015750 0.006721 0.007735 0.007735 0.006721
-0.015900 0.006785 0.007809 0.007809 0.006785
-0.016050 0.006850 0.007883 0.007883 0.006850
-0.016200 0.006914 0.007957 0.007957 0.006914
-0.016350 0.006978 0.008031 0.008031 0.006978
-0.016500 0.007042 0.008105 0.008105 0.007042
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -529,7 +529,7 @@ termTS=repmat(S,[1 1 nfq]).*(termS2-termS1+termS3);
% the dipoles term
Amplitude_ik=sqrt(bxb*(bxd))/2/sx;
if nbd>0
if nbd>0 & nfq>nbd
warning('CalcRespXXRespMat_thick_V2: problem if more dipoles than quadrupoles!')
dipoleterm=[zeros(nb,nfq-nbd) (ones(nb,1)*h_j).*Amplitude_ik.*((ones(nb,1)*dI_js1).*S_ij1+(ones(nb,1)*dI_jc1).*C_ij1)];
else
......
function [dkk,stdf,meanf]=qcheck(k,k0,ax)
function [dkk,stdf,meanf]=qcheck(k,k0,dang_ang,ax,largefig)
%QCHECK Analyzes quadrupole strength errors
%
%DKK=QCHECK(KL,KL0)
......@@ -6,16 +6,54 @@ function [dkk,stdf,meanf]=qcheck(k,k0,ax)
[nq,nm]=size(k);
nfamq=nq;
nfamd=length(dang_ang);
labels=ebs.qpname(1:17);
k0l=k0(:,ones(1,nm));
dkk=(k-k0l)./k0l;
bar(ax,[dkk]);
%title(ax,'Gradient errors');
if largefig
figure(41);
subplot(2,1,1);
extfigax = gca;
bar(extfigax,[dkk]);
%title(ax,'Gradient errors');
ylabel(extfigax,'\DeltaK/K');
grid(extfigax,'on');
set(extfigax,'Xlim',[0 nfamq+1],'FontSize',12);
subplot(2,1,2);
extfigax = gca;
bar(extfigax,[dang_ang]);
%title(ax,'Gradient errors');
ylabel(extfigax,'\Delta\Theta/\Theta');
grid(extfigax,'on');
set(extfigax,'Xlim',[0 nfamd+1],'FontSize',12);
end
Nc = length(dang_ang);
extracor = mod(Nc,32);
cor_per_cell_dip = squeeze(std(reshape(dang_ang((1+extracor/2):(Nc-extracor/2)),[],32),1,1));
yyaxis(ax,'right');
bar(ax,[cor_per_cell_dip],'EdgeColor','none');
ylabel(ax,'\Delta\Theta/\Theta');
grid(ax,'on');
set(ax,'Xlim',[0 32+1],'FontSize',6);
Nc = length(dkk);
extracor = mod(Nc,32);
cor_per_cell_quad = squeeze(std(reshape(dkk((1+extracor/2):(Nc-extracor/2)),[],32),1,1));
yyaxis(ax,'left');
bar(ax,[cor_per_cell_quad],'EdgeColor','none');
ylabel(ax,'\DeltaK/K');
grid(ax,'on');
set(ax,'Xlim',[0 nfamq+1],'FontSize',6);
set(ax,'Xlim',[0 32+1],'FontSize',6);
ax.XTick=[1:32];
ax.XTickLabel=arrayfun(@(a)num2str(a),[4:32,1:3],'un',0);
ax.XTickLabelRotation=90;
return
......@@ -24,13 +62,13 @@ return
%stdf=NaN*ones(nfamq,nm);
%meanf=NaN*ones(nfamq,nm);
%for i=1:nm
dkkf=ebs.fold(dkk);
nfamq=length(dkkf);
for ii=1:nfamq
dkkf=ebs.fold(dkk);
nfamq=length(dkkf);
for ii=1:nfamq
stdf(ii,1)=std(dkkf{ii});
meanf(ii,1)=mean(dkkf{ii});
end
end
stda=std(dkk,1,1);
fprintf('%s:\t% .3e\n','all',stda(1));
for i=1:nfamq
......@@ -42,5 +80,6 @@ if nargin >= 3 % displays quad. errors
title(ax,'Gradient errors');
ylabel(ax,'\DeltaK/K');
grid(ax,'on');
set(ax,'Xlim',[0 nfamq+1],'XTick',1:length(labels),'XTickLabel',labels,'XTickLabelRotation',45,'FontSize',6);
set(ax,'Xlim',[0 nfamq+1],'XTick',1:length(labels),...
'XTickLabel',labels,'XTickLabelRotation',45,'FontSize',8);
end
......@@ -15,9 +15,9 @@ if coupling
% qemb.dipdelta,qemb.ks,qemb.skewcor(:,end),qemb.diptilt);
[k,tilts]=semtilt(qemb.kn,qemb.ks);
mach=atsetshift(qemres.at(:),qemres.sextidx,qemb.dxs,qemb.dzs);
mach=atsettilt(mach,qemres.dipidx,qemb.diptilt);
mach=atsettilt(mach,qemres.dipidx,qemb.diptilt); % dipole rotations
mach=setcellstruct(mach,'PolynomA',qemres.skewidx,qemb.skewcor(:,end)./qemres.skewl,2);
mach=atsettilt(mach,qemres.qpidx,tilts);
mach=atsettilt(mach,qemres.qpidx,tilts); % quadrupole tilts
bend=getcellstruct(mach,'BendingAngle',qemres.dipidx);
mach=setcellstruct(mach,'BendingAngle',qemres.dipidx,(1+qemb.dipdelta).*bend);
mach=setcellstruct(mach,'PolynomB',qemres.qcoridx,qemb.cor(:,end)./qemres.qcorl,2);
......
function cor=qemcorrdt(qemres,kn,cor0)
function [cor,qemres]=qemcorrdt(qemres,kn,cor0)
%QEMCORRDT computes quad correction (rdt method)
% COR=QEMCORRDT(QEMRES,QERRORS,COR0)
% Q: quadrupole strengths
......@@ -7,26 +7,99 @@ function cor=qemcorrdt(qemres,kn,cor0)
% see also: QEMCOR, QEMCORFIT, QEMCORGRID
mach=qemres.at(:);
alpha_c = mcf(mach);
%RDT
disp('RDT derivative');
[respx,respz]=qemrdtresp(mach,qemres.bpmidx,[qemres.qpidx qemres.qcoridx]);
dkn=kn-atgetfieldvalues(mach(qemres.qpidx),'PolynomB',{2});
strength=[qemres.ql.*dkn;cor0];
fx=respx*strength;
fz=respz*strength;
warning('The quad disp deriv matrix should be copied where posible from the fit one, and recomputed only if cnecessary.')
if isfield(qemres,'quadhdispresponse')
rx=qemres.quadhdispresponse;
else
[rx,~]=qemdispderiv(mach,qemres.ct,@setk,1.e-3,...
[qemres.qcoridx],qemres.bpmidx); % h dispersion derivative resepct to quadrupoles
qemres.quadhdispresponse = rx;
end
rx=rx./qemres.qcorl(:,ones(1,size(rx,1)))'; % as in semskewresp
function elem=setk(elem,dk)
k=elem.PolynomB(2)+dk;
elem.K=k;
elem.PolynomB(2)=k;
end
if isfield(qemres,'quadtuneresponse')
resptune=qemres.quadtuneresponse;
else
disp('computing analytic tune response to quadrupole gradients')
% dnu = - beta/4/pi * dkl
qind = qemres.qcoridx;
[l,~,~]=atlinopt(mach,0,qind);
betas = [arrayfun(@(a)a.beta(1),l,'un',1);arrayfun(@(a)a.beta(2),l,'un',1)];
L = cellfun(@(a)a.Length,mach(qind),'un',1)';
dTunes_dq = betas /4 /pi .*L; % dQhv/dKn
qemres.quadtuneresponse = dTunes_dq;
resptune = dTunes_dq;
% numeric version
% [resptune]=qemtunederiv(mach,qemres.dpp,@setk,1.e-3,...
% [qemres.qcoridx]);
% qemres.quadtuneresponse = resptune;
end
% dispersion
disp('h dispersion derivative');
frh = qemres.frespx;
[frh0,frv0]=qemfresp(mach,qemres.ct,qemres.bpmidx,[],[],[]); %#ok<ASGLU>
dfrh = (qemres.bhscale*frh-frh0); %alpha_c *
[~,Q0,~]=atlinopt(mach,qemres.dpp,1);
dtunes = (qemres.tunes-Q0)';
a1 = qemres.hdispRDTcorWeight;
if a1 > 1 | a1<0
error('hor. dispersion weigth should be between 0 and 1');
end
a2 = qemres.tuneRDTcorWeight;
if a2 > 1-a1 | a2<0
error(['tune weigth ' num2str(a2) ' should be between 0 and ' num2str(1-a1)]);
end
disp('start correction');
if isfield(qemres,'qcorkeep')
qpmask=qemres.qcorkeep;
else
qpmask=true(size(qemres.qcoridx));
end
sk=[false(size(qemres.qpidx)) qpmask];
rsp=[...
real(respx(:,sk));imag(respx(:,sk));...
real(respz(:,sk));imag(respz(:,sk))];
(1-a1-a2)*real(respx(:,sk));imag(respx(:,sk));...
(1-a1-a2)*real(respz(:,sk));imag(respz(:,sk));...
a1*rx(:,qpmask);...dispersion
a2*resptune]; % tune
b=[...
real(fx);imag(fx);...
real(fz);imag(fz)];
(1-a1-a2)*real(fx);imag(fx);...
(1-a1-a2)*real(fz);imag(fz);...
a1*dfrh;... % dispersion
a2*dtunes]; % tune
cor=cor0;
cor(qpmask)=cor(qpmask)-rsp\b;
% cor(qpmask)=cor(qpmask)-rsp\b;
cor(qpmask)=cor(qpmask)-qemsvd(rsp,b,qemres.neigQuadRDTcor);
end
......@@ -18,7 +18,7 @@ function [dresp,drespskew,dDx_db,dDy_ds]=qemderivAnalytic(mach,dpp,elemfunc,dv,v
%RESP0: Response matrix of the unperturbed mchine on 1 column:
% [HRESPONSE(:);VRESPONSE(:);DFFRESPONSE;TUNES]
global NUMDIFPARAMS
global NUMDIFPARAMS qemres
dpsave=isfield(NUMDIFPARAMS,'DPStep');
if dpsave, dpsp=NUMDIFPARAMS.DPStep; end
......@@ -45,42 +45,68 @@ dval(1:nq)=dv;
dresp=zeros((nhst+nvst)*nbpm+nbpm+2,nq);
drespskew=zeros((nhst+nvst)*nbpm+nbpm,nq);
bndidx=find(atgetcells(mach,'BendingAngle'));
bndidx=find(atgetcells(mach,'BendingAngle')); % all dipoles
bndidx(1) =[]; % remove septum with zero angle giving NAN!
bndidx=sort(bndidx([1:4:end,4:4:end]));% only long part
% disp('ANALYTIC QEMPANEL Response')
% % get anlytical RM response
% [...
% dX_dq, dY_dq, ...
% dDx_dq, dDx_db, Dx, ...
% dXY_ds, dYX_ds, ...
% XY, YX, ...
% dDx_ds, dDy_ds...
% ]=CalcRespXXRespMat_thick_mod(...
% mach',dpp,...
% bpmidx',... % bpm
% hsidxlat,... % correctors
% varidx,... % quadrupoles
% bndidx',...
% varidx);
% bndidx = find(atgetcells(mach,'FamName','[JD]L\w*'));
dispfunc(1,3);
disp('ANALYTIC QEMPANEL Response V2')
% get anlytical RM response
disp('ANALYTIC QEMPANEL Response AT2.0/errors_corrections')
[...
dX_dq, dY_dq, ...
dDx_dq, dDx_db, Dx, ...
dDx_dq, ~, ~, ...
dXY_ds, dYX_ds, ...
dDx_ds, dDy_ds...
]=CalcRespXXRespMat_thick_V2(...
~, dDy_ds, ...
~...
]=AnalyticResponseMatrixDerivative(...
mach',dpp,...
bpmidx',... % bpm
hsidxlat,... % correctors
varidx,... % quadrupoles
bndidx',...
bndidx',... % no dipoles, later
varidx);
%f0=992*PhysConstant.speed_of_light_in_vacuum.value/findspos(mach,length(mach)+1);
alpha_c = mcf(mach);
if isfield(qemres,'quadhdispresponse')
% do not recomput if already available
dDx_dq=qemres.quadhdispresponse;
else
disp('FIRST and only h.disp derivative with respect to quadrupoles');
disp('computation starts on lattice without errors/correctors');
[dDx_dq,~]=qemdispderiv(qemres(1).at,qemres.ct,@setk,1.e-3,...
[varidx],qemres.bpmidx,dispfunc); % h dispersion derivative resepct to quadrupoles
%dDx_dq=dDx_dq./qemres.qcorl(:,ones(1,size(dDx_dq,1)))'; % as in semskewresp
qemres.quadhdispresponse = dDx_dq; % dDx/dKn
disp('finished. stored in qemres.quadhdispresponse')
end
function elem=setk(elem,dk)
k=elem.PolynomB(2)+dk;
elem.K=k;
elem.PolynomB(2)=k;
end
qind=find(atgetcells(mach,'Class','Quadrupole'))'; % response matrix computed always at all quadrupoles
% tune derivative analytic
if isfield(qemres,'quadtuneresponse')
dTunes_dq = qemres.quadtuneresponse ;
else
% dnu = - beta/4/pi * dkl
[l,~,~]=atlinopt(mach,0,qind);
betas = [arrayfun(@(a)a.beta(1),l,'un',1);arrayfun(@(a)a.beta(2),l,'un',1)];
L = cellfun(@(a)a.Length,mach(qind),'un',1)';
dTunes_dq = betas /4 /pi .*L; % dQhv/dKn
qemres.quadtuneresponse = dTunes_dq;
disp('finished. stored in qemres.quadtuneresponse')
end
quadforresponse=find(ismember(qind,varidx)); % quadrupoles to use for fit amoung all
dispfunc(2,3);
......@@ -89,11 +115,11 @@ for iq=1:nq
ib = quadforresponse(iq); % use only selected quadrupoles
rha=dX_dq(:,:,ib);
rva=dY_dq(:,:,ib);
dxdqa=[-dDx_dq(:,ib);0;0]/dval(iq);% analytic, no tune dispersion derivative very different from
dxdqa=[dDx_dq(:,ib);dTunes_dq(:,ib)];%/dval(iq) analytic, no tune dispersion derivative very different from
dresp(:,iq)=[rha(:);rva(:);dxdqa];
rhsa=dXY_ds(:,:,ib);
rvsa=dYX_ds(:,:,ib);
dxdqsa=[-dDy_ds(:,ib)]/dval(iq);% analytic, no tune dispersion derivative very different from
dxdqsa=[dDy_ds(:,ib)];%/dval(iq) analytic, no tune dispersion derivative very different from
drespskew(:,iq)=[rhsa(:);rvsa(:);dxdqsa];
......
......@@ -10,35 +10,35 @@ function [rx,rz,N,S,bang,alldip,usedip]=qemdispderivAnalyticDQ(mach,varidx,bpmid
%RX: derivative of the horizontal response to frequency
%RZ: derivative of the vertical response to frequency
disp('Analytic');
disp('Analytic (DQ)');
nb=length(bpmidx);
alldip=find(atgetcells(mach,'BendingAngle'));
Ndip=numel(alldip);
dipsel=sort([1:Ndip]);
bndidx=sort(alldip(dipsel));% only long part
bang=atgetfieldvalues(mach,alldip,'BendingAngle');
alldip=alldip(bang>1e-9);
bang=bang(bang>1e-9);
% make sure order is as in qempanel vector.
[usedip,b]=ismember(varidx,alldip);
[~,b]=ismember(varidx,bndidx);
%% compute analytic response with all dipoles always.
[N,S,~,~]=dDxyDthetaDQ(mach,bpmidx,alldip,'magmodel','thick');
% negative sign, probably due to dipole sign convention
N_sort=-N(:,b);
N_sort=-N(:,dipsel(b));
% qempanel response in [m/Hz] instead of [m/%]
N_sort=N_sort/mcf(mach);
% in qempanel the response is for scaling factors, not deltas
N_sort=N_sort.*repmat(bang(b)',nb,1);
N_sort=N_sort.*repmat(bang(dipsel(b))',nb,1);
S_sort=S(:,b);
S_sort=S(:,dipsel(b));
% qempanel response in [m/Hz] instead of [m/%]
S_sort=S_sort/mcf(mach);
% in qempanel the response is for scaling factors, not deltas
S_sort=S_sort.*repmat(bang(b)',nb,1);
S_sort=S_sort.*repmat(bang(dipsel(b))',nb,1);
rx=N_sort;
......
......@@ -17,7 +17,8 @@ dfrh=qemres.bhscale*frh-frh0;
[dipresponse,~]=qemdispderiv(mach,qemres.ct,@setbendangle,1.e-3,...
qemres.dipidx,qemres.bpmidx);
bok=isfinite(dfrh)&okbpm;
dipdelta=dipresponse(bok,okfit)\dfrh(bok);
dipdelta = qemsvd(dipresponse(bok,okfit),dfrh(bok),qemres.neigDipFit);
function elt=setbendangle(elt,dval)
ba=elt.BendingAngle;
......
......@@ -14,9 +14,12 @@ if isempty(okfit), okfit=true(size(qemres.dipidx)); end
qemres.brot,qemres.bhgain,qemres.bvgain); %#ok<ASGLU>
[frh0,frv0]=qemfresp(mach,qemres.ct,qemres.bpmidx,[],[],[]); %#ok<ASGLU>
dfrh=qemres.bhscale*frh-frh0;
[dipresponse,~]=qemdispderivAnalytic(mach,qemres.dipidx,qemres.bpmidx);
[dipresponse,~]=qemdispderivAnalyticDQ(mach,qemres.dipidx,qemres.bpmidx);
bok=isfinite(dfrh)&okbpm;
dipdelta=dipresponse(bok,okfit)\dfrh(bok);
% [dipresponseN,~]=qemdispderiv(mach,qemres.ct,@setbendangle,1.e-3,...
% qemres.dipidx,qemres.bpmidx);
dipdelta = qemsvd(dipresponse(bok,okfit),dfrh(bok),qemres.neigDipFit);
function elt=setbendangle(elt,dval)
ba=elt.BendingAngle;
......
......@@ -2,7 +2,7 @@ function qemb = qemoptics(qemres,qemb,qemb0)
%QEMOPTICS Compute optical parameters for the fitted machine
nbpm=length(qemres.bpmidx);
[idx,j,kdx]=unique([qemres.bpmidx qemres.id07idx qemres.id25idx qemres.d01idx qemres.d17idx qemres.d27idx]); %#ok<ASGLU>
[idx,j,kdx]=unique([qemres.bpmidx qemres.id07idx qemres.d17idx qemres.id25idx qemres.d27idx qemres.d01idx]); %#ok<ASGLU>
orbit0=findsyncorbit(qemb.at,qemres.ct,qemres.bpmidx);
dpp=orbit0(5,1);
......@@ -12,10 +12,10 @@ lindata=lindata(kdx);
qemb.lindata=lindata(1:nbpm); % BPM results
qemb.id07data=lindata(nbpm+1); % ID07 results
qemb.id25data=lindata(nbpm+2); % ID25 results
qemb.d01data=lindata(nbpm+3); % D01 results
qemb.d17data=lindata(nbpm+4); % D17 results
qemb.d27data=lindata(nbpm+5); % D27 results
qemb.d17data=lindata(nbpm+2); % D17 results
qemb.id25data=lindata(nbpm+3); % ID25 results
qemb.d27data=lindata(nbpm+4); % D27 results
qemb.d01data=lindata(nbpm+5); % D01 results
dispersion=cat(2,qemb.lindata.Dispersion)';
qemb.tunes=qemb.pm.fulltunes;
qemb.beta=cat(1,qemb.lindata.beta);
......@@ -32,7 +32,7 @@ qemb.emittances=[modemit(:,1:2) cat(1,lindata.emit44)];
qemres.brot,qemres.bhgain,qemres.bvgain,orbit0);
if nargin >= 3
lindata0=[qemb0.lindata qemb0.id07data qemb0.id25data qemb0.d01data qemb0.d17data qemb0.d27data];
lindata0=[qemb0.lindata qemb0.id07data qemb0.d17data qemb0.id25data qemb0.d27data qemb0.d01data];
beta0=cat(1,lindata0.beta);
beam66=cat(3,lindata.beam66);
sigma2=[squeeze(beam66(1,1,:)) squeeze(beam66(3,3,:))];
......
No preview for this file type
This diff is collapsed.
......@@ -3,9 +3,9 @@ tic
if nargin < 5, handles=struct(); end
if isfield(handles,'axes1')
qcheck(qemb.kn,qemb0.kn,handles.axes1);
qcheck(qemb.kn,qemb0.kn,qemb.dipdelta,handles.axes1,get(handles.largefigures,'Value'));
else
qcheck(qemb.kn,qemb0.kn);
qcheck(qemb.kn,qemb0.kn,qemb.dipdelta,[],get(handles.largefigures,'Value'));
end
toc;
qemb.at=qemat(qemres,qemb,true); % builds the at structure
......@@ -32,128 +32,47 @@ mess={...
[' 2*NuX = 153 :' num2str(stpb.h153*1e3,'%2.2f')];...
[' 2*NuZ = 55 :' num2str(stpb.v55*1e3,'%2.2f')]};
if all(isfield(handles,{'axes2','axes3'})) % displays beta modulation
sbpm=cat(1,qemb.lindata.SPos);
qemmodulplot(handles.axes2, sbpm, modulh, '');hold on;
qemmodulplot(handles.axes2, sbpm, modulv, '');hold off;
legend('\beta_x','\beta_z')
% qemd(handles.axes2, sbpm, modulv, '\eta_x');
end
% if all(isfield(handles,{'axes2','axes3'})) % displays beta modulation
% sbpm=cat(1,qemb.lindata.SPos);
% qemmodulplot(handles.axes2, sbpm, modulh, '');hold on;
% qemmodulplot(handles.axes2, sbpm, modulv, '');hold off;
% legend('\beta_x','\beta_z')
%
% % qemd(handles.axes2, sbpm, modulv, '\eta_x');
% end
disp('qemstopbands msg');toc;
%%
if isfield(handles,'axes3') % displays horizontal dispersion
if isfield(qemres,'frespx')
plot(handles.axes3,sbpm,-qemb.pm.alpha*[qemb.frespx-qemb0.frespx...
qemres.bhscale*qemres.frespx-qemb0.frespx...
(qemb.frespx-qemb0.frespx)-(qemres.bhscale*qemres.frespx-qemb0.frespx)]);
else
plot(handles.axes3,sbpm,-qemb.pm.alpha*(qemb.frespx-qemb0.frespx));
end
title(handles.axes3,'Horizontal dispersion');
ax=axis(handles.axes3);
ym=max(abs(ax([3 4])));
axis(handles.axes3,[0 844.39 -ym ym]);
ylabel(handles.axes3,'\eta_x [m]');
grid(handles.axes3,'on');
legend(handles.axes3,'measured','fit','difference')
if all(isfield(handles,{'axes2','axes3'})) % displays beta modulation
sbpm=cat(1,qemb.lindata.SPos);
qemmodulplot(handles.axes2, sbpm, modulh, '\beta_x');
qemmodulplot(handles.axes3, sbpm, modulv, '\beta_z');
end
% %% compare to simulator
% a=load('/operation/appdata/EbsSimulator/s28dseed1order12.mat','s28dseed1order12');
% rs=a.s28dseed1order12;
% inds=1:length(rs);
% indbs=find(atgetcells(rs,'Class','Monitor'))';
%
% [ls,ts,cs]=atlinopt(rs,0,inds);
% ss=arrayfun(@(a)a.SPos(1),ls);
% bxs=arrayfun(@(a)a.beta(1),ls);
% bys=arrayfun(@(a)a.beta(2),ls);
% dxs=arrayfun(@(a)a.Dispersion(1),ls);
% dzs=arrayfun(@(a)a.Dispersion(3),ls);
% modulhS=bmodul(bxs(indbs)',qemb0.beta(:,1));
% modulvS=bmodul(bys(indbs)',qemb0.beta(:,2));
%
% %%
% figure;
% subplot(2,2,1)
% qemmodulplot(gca, sbpm, modulh, '');hold on;
% qemmodulplot(gca, ss(indbs),modulhS, '');hold off;
% legend('\beta_x FIT','\beta_x SIMULATOR','Location','NorthWest')
% subplot(2,2,2)
% qemmodulplot(gca, sbpm, modulv, '');hold on;
% qemmodulplot(gca, ss(indbs),modulvS, '');hold off;
% legend('\beta_z FIT','\beta_z SIMULATOR','Location','NorthWest')
%
% subplot(2,2,3)
%
% if isfield(qemres,'frespx')
% plot(gca,sbpm,-qemb.pm.alpha*[qemb.frespx-qemb0.frespx...
% qemres.bhscale*qemres.frespx-qemb0.frespx...
% (qemb.frespx-qemb0.frespx)-(qemres.bhscale*qemres.frespx-qemb0.frespx)]);