Commit 4ea497ab authored by Simone Liuzzo's avatar Simone Liuzzo

iax for sempanel

parent 7e7d1fc2
......@@ -530,6 +530,7 @@ termTS=repmat(S,[1 1 nfq]).*(termS2-termS1+termS3);
% the dipoles term
Amplitude_ik=sqrt(bxb*(bxd))/2/sx;
if nbd>0
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
dipoleterm=[zeros(nb,nfq)];
......
......@@ -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.d9data qemb0.d11lensdata qemb0.id25data];
lindata0=[qemb0.lindata qemb0.id07data qemb0.id25data qemb0.d01data qemb0.d17data qemb0.d27data];
beta0=cat(1,lindata0.beta);
beam66=cat(3,lindata.beam66);
sigma2=[squeeze(beam66(1,1,:)) squeeze(beam66(3,3,:))];
......
......@@ -40,7 +40,7 @@ end
semres=struct();
semres.hlist=qemres.hlist;
semres.vlist=qemres.vlist;
semres.iaxemz=NaN(14,1);
semres.iaxemz=NaN(5,1);
semres.wdisp=0;
semres.bvscale=1;
semres.skewkeep=true(1,288);
......
......@@ -37,7 +37,7 @@ nvst=length(vslist);
disp('ANALYTIC QEMPANEL Response V2')
bndidx=find(atgetcells(mach,'BendingAngle'));
%bndidx=sort(bndidx([1:4:end,4:4:end]));% only long part
bndidx=sort(bndidx([1:4:end,4:4:end]));% only long part
%% get anlytical RM response
[...
......@@ -50,7 +50,7 @@ bndidx=find(atgetcells(mach,'BendingAngle'));
blist',... % bpm
hslist,... % correctors
fitlist,... % quadrupoles
bndidx,... % any index, unused.
bndidx',... % any index, unused.
fitlist);
resp=zeros(nbpm*(nhst+nvst),nq);
......
......@@ -22,15 +22,15 @@ if ~isfield(mode,'nsets'), mode.nsets=4; end
if ~isfield(mode,'neigs'), mode.neigs=100; end
if ~isfield(mode,'dispweight'), mode.dispweight=0; end
if ~isfield(mode,'vnorm')
v=sr.fold(std(dresp(1:orbitrange,:),1,1));
mode.vnorm=sqrt(32./sum(v.*v,2)); % normalize each column of dresp
% mode.vnorm=ones(nq/32,1); % no normalization
mode.vnorm=1./std(dresp(1:orbitrange,:),1,1)';
end
inisel=false(size(resp));
if mode.dispweight>0, inisel(orbitrange+(1:nbpm))=true; end % Keep dispersion
bok=repmat(okbpm,nhst+nvst+1,1) & isfinite(resp);
v=sr.unfold(repmat(mode.vnorm,1,32));
w=[ones(orbitrange,1);mode.dispweight*ones(224,1)];
v=ones(size(mode.vnorm));
w=[ones(orbitrange,1);mode.dispweight*ones(nbpm,1)];
hsets=reshape(1:nhst,mode.nsets,[]);
vsets=reshape(1:nvst,[],mode.nsets)';
% hsets=reshape(1:nhst,[],mode.nsets)';
......
function iaxemz = semloadiax(datadir)
%IAXEMZ=SEMLOADIAX(DATADIR) load IAX values
iaxemz=NaN(14,1);
iaxemz=NaN(5,1);
try
dest=[1:12 14 13]; % destination of the values read from file
dest=[5,1:4]; % destination of the values read from file
iax=load(fullfile(datadir, 'iaxemittance'));
iaxemz(dest(1:size(iax.iax_list,1)))=1.0e-9*iax.iax_values;
iaxemz(dest)=iax.iax_values; % [m]
catch
warning('sem:noiax','Cannot read IAX data from the data directory');
end
......
No preview for this file type
......@@ -87,8 +87,10 @@ global qemb qemres semres
%wrongbpms=sr.bpmindex(6,4); % Eliminate BPM C6-4
semres.iaxemz=semloadiax(qemres.datadir);
handles.semdata=sempanelset(qemres.datadir,handles);
qemb(2).skewcor=load_correction(fullfile(qemres.datadir,'skewcor.dat'),...
qemres.skcode,qemres.opticsdir);
A=textscan(fopen(fullfile(qemres.datadir,'skewcor.dat'),'r'),'%s %f','HeaderLines',7); %read from setting manager saved file
qemb(2).skewcor=A{2};
set(handles.pushbutton3,'Enable','On');
qemb(2)=sempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.edit1,'String',qemres.datadir);
......
......@@ -35,7 +35,7 @@ mess=[mess;...
mess0];
if isfield(handles,'text3') % displays values
set(handles.text3,'String',mess);
set(handles.text3,'String',mess,'FontSize',10);
else
fprintf('%s\n',mess{:});
end
......
......@@ -37,7 +37,7 @@ orbit0=findsyncorbit(qemb.at,qemres.ct,qemres.bpmidx);
resp0=[rh2v0(:);rv2h0(:);frv0];
resp=[rh2v(:);rv2h(:);semres.bvscale*frv];
mode=struct('vnorm',sqrt([0.77;2;0.9;1.15;1.15;0.9;2;1]));
mode=struct();
% newks=qemb.ks+semerrfit(length(semres.hlist),length(semres.vlist),resp-resp0,...
% quadresponse,mode,varargin{:});
newks=qemb.ks+semerrfit(length(semres.hlist),length(semres.vlist),resp-resp0,...
......
......@@ -6,19 +6,27 @@ sbpm=cat(1,qemb.lindata.SPos);
sskew=findspos(qemb.at(:),qemres.skewidx);
figure(fig);
switch plotcode
case 1 % ID25 spot
semplotemit(1.0e12*qemb.id25data.beam66([1 3],[1 3]))
case 1 % D01 spot
semplotemit(1.0e12*qemb.d01data.beam66([1 3],[1 3]))
xlabel('x [\mum]');
ylabel('z [\mum]');
case 2 % ID07 spot
semplotemit(1.0e12*qemb.id07data.beam66([1 3],[1 3]))
xlabel('x [\mum]');
ylabel('z [\mum]');
case 2 % D9 spot
semplotemit(1.0e12*qemb.d9data.beam66([1 3],[1 3]))
case 3 % D17 spot
semplotemit(1.0e12*qemb.d17data.beam66([1 3],[1 3]))
xlabel('x [\mum]');
ylabel('z [\mum]');
case 4 % ID25 spot
semplotemit(1.0e12*qemb.id25data.beam66([1 3],[1 3]))
xlabel('x [\mum]');
ylabel('z [\mum]');
case 3 % D9 spot
semplotemit(1.0e12*qemb.d11lensdata.beam66([1 3],[1 3]))
case 5 % D27 spot
semplotemit(1.0e12*qemb.d27data.beam66([1 3],[1 3]))
xlabel('x [\mum]');
ylabel('z [\mum]');
case 4 % RDT
case 6 % RDT
[f1,f2]=semrdt(qemb0.at,qemres,qemb.ks,qemb.skewcor(:,end));
plot(sbpm,[abs(f1) abs(f2)]);
ax=axis;
......@@ -27,7 +35,7 @@ switch plotcode
xlabel('s [m]');
ylabel('RDT');
grid on
case 5 % Gamma-1
case 7 % Gamma-1
gamma=cat(1,qemb.lindata.gamma);
plot(sbpm,gamma-1);
ax=axis;
......
......@@ -4,12 +4,10 @@ function [k,tilts,stdf,meanf]=sqcheck(ks,kn,diptilt,ax)
%DKK=SQCHECK(KL,KL0)
%
nm=size(ks,2);
nq=size(ks,1)/32;
if nq == 10
labels={'QD1','QF2','QD3','QD4','QF5','QF5','QD4','QD6','QF7','QD8','Dip'};
else
labels={'QF2','QD3','QD4','QF5','QF5','QD4','QD6','QF7','Dip'};
end
nq=size(ks,1);
labels=ebs.qpname(1:length(ks));
labels{nq+1} = 'diptilt';
k=zeros(size(ks));
tilts=zeros(size(ks));
......@@ -18,7 +16,7 @@ stdf=NaN*ones(nq,nm);
meanf=NaN*ones(nq,nm);
for i=1:nm
[k(:,i),tilts(:,i)]=semtilt(kn,ks(:,i));
tiltf=sr.fold(tilts(:,i));
tiltf=tilts(:,i);
stdf(:,i)=std(tiltf,1,2);
meanf(:,i)=mean(tiltf,2);
end
......@@ -35,5 +33,5 @@ if nargin >= 4 % displays quad rotations
title(ax,'Magnet rotation errors');
ylabel(ax,'\Theta');
grid(ax,'on');
set(ax,'Xlim',[0 nq+1],'XTickLabel',labels);
set(ax,'Xlim',[0 nq+1],'XTickLabel',labels,'XTickLabelRotation',30);
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment