Commit a4c0e493 authored by Simone Liuzzo's avatar Simone Liuzzo

updated qempanel

parent eda89981
......@@ -68,6 +68,10 @@ disp('ANALYTIC QEMPANEL Response AT2.0/errors_corrections')
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;
......@@ -78,7 +82,6 @@ else
[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;
disp('finished. stored in qemres.quadhdispresponse')
end
......@@ -88,6 +91,8 @@ function elem=setk(elem,dk)
elem.PolynomB(2)=k;
end
dDx_dq=dDx_dq.*alpha_c/2;
qind=find(atgetcells(mach,'Class','Quadrupole'))'; % response matrix computed always at all quadrupoles
quadforresponse=find(ismember(qind,varidx)); % quadrupoles to use for fit amoung all
......
......@@ -210,6 +210,9 @@ function pushbutton7_Callback(hObject, eventdata, handles)
% handles structure with handles and user data (see GUIDATA)
global qemb qemres semres MACHFS
tnow=now();
msgbox('Please correct orbit and tunes NOW. AUTOCOR must be OFF.');
measpath=fullfile(MACHFS,'MDT',datestr(tnow,'yyyy'),datestr(tnow,'yyyy_mm_dd'));
list=dir(fullfile(measpath,'resp*'));
namelist={list.name};
......@@ -328,6 +331,7 @@ function pushbutton9_Callback(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global qemb qemres semres
set(handles.statustext,'String','setting intial errors');
try
[kn,qemb(2).dipdelta,qemb(2).dxs]=qemerrload(qemres,...
fullfile(qemres.opticsdir,'quadinierrors.mat'));
......@@ -338,12 +342,14 @@ catch %#ok<CTCH>
qemb(2).dipdelta=qemb(1).dipdelta;
qemb(2).dxs=qemb(1).dxs;
end
mach=atfittune(qemat(qemres,qemb(2),true),qemres.tunes,'QD6','QF7'); % retune the model
mach = qemat(qemres,qemb(2),true);
% mach=atfittune(qemat(qemres,qemb(2),true),qemres.tunes,'QD6','QF7'); % retune the model
qemb(2).kn=getcellstruct(mach,'PolynomB',qemres.qpidx,2);
qemres.bhscale=1;
set(handles.qemdata.errdef,'Enable','On');
set(hObject,'Enable','Off');
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String',' intial errors are set (DONE) ');
% --- Executes on button press in pushbutton10 : zero errors
function pushbutton10_Callback(hObject, eventdata, handles)
......@@ -351,15 +357,17 @@ function pushbutton10_Callback(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global qemb qemres semres
set(handles.statustext,'String','setting fitted errors to zero');
qemb(2).kn=qemb(1).kn;
qemb(2).dipdelta=qemb(1).dipdelta;
qemb(2).dxs=qemb(1).dxs;
% mach=atfittune(qemat(qemres,qemb(2),true),qemres.tunes,'QD2\w*','QF1\w*'); % retune the model
mach = qemres(1).at;
mach = qemat(qemres,qemb(2),true);
qemb(2).kn=getcellstruct(mach,'PolynomB',qemres.qpidx,{1,2});
set(handles.qemdata.errdef,'Enable','On');
set(hObject,'Enable','Off');
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','zero fitted errors (DONE)');
% --- Executes on button press in pushbutton11: save errors
function pushbutton11_Callback(hObject, eventdata, handles)
......@@ -433,6 +441,7 @@ qemb(2).cor(:,2)=load_correction(fullfile(qemres.datadir,'magcor.dat'),...
set(handles.qemdata.cordef,'Enable','On');
set(hObject,'Enable','Off');
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','correction set to initial');
% --- Executes on button press in pushbutton14: Corrections Zero
......@@ -445,6 +454,7 @@ qemb(2).cor(:,2)=qemb(1).cor;
set(handles.qemdata.cordef,'Enable','On');
set(hObject,'Enable','Off');
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','correction set to zero');
% --- Executes on button press in pushbutton15: Correction Save
......
......@@ -64,7 +64,7 @@ if ~isfield(mode,'vnorm')
% vv=sr.unfold(repmat(vv,1,32));
% mode.vnorm=vv(okfit)';
end
mode.neigs=qemres.negiQuadFit;
mode.neigs=qemres.neigQuadFit;
newkn=qemb.kn;
newkn(okfit)=qemb.kn(okfit)+qemerrfit(nhst,nvst,resp-resp0,dresp,mode,okbpm);
......
......@@ -54,6 +54,7 @@ dpp=o0(5);
[~,fractunes]=atlinopt(qemb.at,dpp,[],o0);
%dresp=qemderivAnalyticDebuggingVersion(qemb.at,dpp,@setk,0.0001,qemres.qpidx(okfit),qemres.bpmidx,shidx,svidx,disparg{:});
dresp=qemderivAnalytic(qemb.at,dpp,@setk,0.0001,qemres.qpidx(okfit),qemres.bpmidx,shidx,svidx,disparg{:});
%drespN=qemderiv(qemb.at,dpp,@setk,0.0001,qemres.qpidx(okfit),qemres.bpmidx,shidx,svidx,disparg{:});
% % % lines for tests
......
......@@ -203,9 +203,10 @@ if nargout >= 3
qemb(2).dxs=qemb(1).dxs;
end
A=textscan(fopen(fullfile(qemres.datadir,'quadcor.dat'),'r'),'%s %f','HeaderLines',7);
qemb(2).cor=A{2};
qemb(2).skewcor=zeros(length(qemres.skewidx),1);
Nq=textscan(fopen(fullfile(qemres.datadir,'quadcor.dat'),'r'),'%s %f','HeaderLines',7);
qemb(2).cor=Nq{2};
Sq=textscan(fopen(fullfile(qemres.datadir,'skewcor.dat'),'r'),'%s %f','HeaderLines',7);
qemb(2).skewcor=Sq{2};%zeros(length(qemres.skewidx),1);
qemb(2).dzs=zeros(length(qemres.sextidx),1);
qemb(2).diptilt=zeros(length(qemres.dipidx),1);
qemb(2).ks=zeros(length(qemres.qpidx),1);
......
......@@ -16,7 +16,13 @@ for iq=1:nq
idq=sidx(iq);
esave=mach{idq};
mach{idq}=elemfunc(esave,iq,kick(iq));
orbit=(findsyncorbit(mach,dct,bidx)-orbit0)/kick(iq);
orbitp=findsyncorbit(mach,dct,bidx);
%orbitp=findorbit6Err(mach,bidx);
%mach{idq}=elemfunc(esave,iq,-kick(iq)); %double sided computation
%orbitm=findsyncorbit(mach,dct,bidx);
%orbitm=findorbit6Err(mach,bidx);
%orbit=(orbitp-orbitm)/kick(iq)/2;
orbit=(orbitp-orbit0)/kick(iq);
mach{idq}=esave;
rh(:,iq)=orbit(1,:)';
rv(:,iq)=orbit(3,:)';
......
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