Commit 9405ecc9 authored by Simone Liuzzo's avatar Simone Liuzzo

tune button, store model moved

parent fb552639
No preview for this file type
......@@ -22,7 +22,7 @@ function varargout = qempanel2(varargin)
% Edit the above text to modify the response to help qempanel2
% Last Modified by GUIDE v2.5 30-Apr-2019 16:33:02
% Last Modified by GUIDE v2.5 22-May-2019 10:02:24
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
......@@ -153,7 +153,7 @@ global qemb qemres semres
qemplotresp(3,qemres.resph,qemres.respv,'response');
set(handles.pushbutton3,'Enable','On');
set(handles.pushbutton19,'Enable','On'); % dipole fit on
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
[qemb(2),qemres]=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
if get(handles.ACRMcheckbox,'Value')
set(handles.statustext,'String','Loaded AC response data');
......@@ -190,7 +190,7 @@ else
end
set([handles.qemdata.errdef handles.pushbutton19],'Enable','On');
delete(hw);
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
[qemb(2),qemres]=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','finished quadrupoles fit');
% --- Executes on button press in pushbutton19: Fit Dips
......@@ -212,7 +212,7 @@ end
qemb(2).dipdelta=qemb(2).dipdelta+dipdelta-mean(dipdelta);
qemb(2).at=qemat(qemres,qemb(2),true); % update at model
qemres.bhscale=qembhscale(qemres,qemb(2).at);
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
[qemb(2),qemres]=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','finished dipoles fit');
% --- Executes on button press in pushbutton7: create new directory
......@@ -223,7 +223,7 @@ function pushbutton7_Callback(hObject, eventdata, handles)
global qemb qemres semres MACHFS
tnow=now();
waitfor(msgbox('Please correct orbit and tunes NOW. AUTOCOR must be OFF.'));
waitfor(msgbox('Please correct orbit and tunes NOW (or set tunes to present). AUTOCOR must be OFF.'));
measpath=fullfile(MACHFS,'MDT',datestr(tnow,'yyyy'),datestr(tnow,'yyyy_mm_dd'));
list=dir(fullfile(measpath,'resp*'));
......@@ -265,7 +265,7 @@ function pushbutton8_Callback(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%set(hObject,'Enable','Off');
global qemres
global qemres semres
status =0; % initialize to good status (0 = no error)
if get(handles.DCRMcheckbox,'Value') % DC/AC DC measurement
if get(handles.PartialRMcheckbox,'Value') % FULL/PARTIAL
......@@ -283,7 +283,12 @@ if get(handles.DCRMcheckbox,'Value') % DC/AC DC measurement
steerlist=allsteer(qemres.hlist);
curdir = pwd;
cd(qemres.datadir);
rc.MeasureOrbitResponseMatrix('Hsteerer',steerlist,'Vsteerer',qemres.vlist); % if full measurement RM CSV files will be stored.
if get(handles.FullRMcheckbox,'Value')
% if full measurement RM CSV files will be stored. also disabled magnets are in the list, an empty response is stored.
rc.MeasureOrbitResponseMatrix('full',true);
else
rc.MeasureOrbitResponseMatrix('Hsteerer',steerlist,'Vsteerer',qemres.vlist);
end
% store measured RM in theory folder.
if get(handles.FullRMcheckbox,'Value')
......@@ -294,6 +299,31 @@ if get(handles.DCRMcheckbox,'Value') % DC/AC DC measurement
copyfile('v_resp_measured.csv',meas_full_rm_path)
end
% update list of steerers removing those who diot give any signal.
rh = ebs.load_resp('.','h',qemres.hlist);
rv = ebs.load_resp('.','v',qemres.vlist);
rh_col_zero = find(all(rh==0));
rv_col_zero = find(all(rv==0));
if ~isempty(rh_col_zero)
disp('the response to steerers: ')
ebs.hsteername(qemres.hlist(rh_col_zero))'
disp('was ZERO');
disp('removing them from steerers list');
qemres.hlist(rh_col_zero)=[];
semres.hlist(rh_col_zero)=[];
end
if ~isempty(rv_col_zero)
disp('the response to steerers: ')
ebs.vsteername(qemres.vlist(rv_col_zero))'
disp('was ZERO');
disp('removing them from steerers list');
qemres.vlist(rv_col_zero)=[];
semres.vlist(rv_col_zero)=[];
end
cd(curdir);
else % AC rm measurement
......@@ -370,7 +400,7 @@ 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);
[qemb(2),qemres]=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
......@@ -388,7 +418,8 @@ mach=atfittune(qemat(qemres,qemb(2),true),qemres.tunes,'QD2\w*','QF1\w*'); % ret
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);
qemres.fithist=[]; % empty error fit residuals history
[qemb(2),qemres]=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','zero fitted errors (DONE)');
% --- Executes on button press in pushbutton11: save errors
......@@ -432,7 +463,7 @@ if ischar(fname)
set(handles.qemdata.errdef,'Enable','On');
qemb(2).at=qemat(qemres,qemb(2),true); % update at model
qemres.bhscale=qembhscale(qemres,qemb(2).at);
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
[qemb(2),qemres]=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
end
......@@ -449,7 +480,7 @@ if ~isempty(fitmethod)
[qemb(2).cor(:,2),qemres]=fitmethod(qemres,qemb(2).kn,qemb(2).cor(:,end));
set(handles.qemdata.cordef,'Enable','On');
end
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
[qemb(2),qemres]=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','correction computed');
......@@ -464,7 +495,7 @@ qemb(2).cor(:,2)=load_correction(fullfile(qemres.datadir,'quadcor.dat'),...
qemres.qpcode,qemres.opticsdir);
set(handles.qemdata.cordef,'Enable','On');
%set(hObject,'Enable','Off');
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
[qemb(2),qemres]=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','correction set to initial');
......@@ -477,7 +508,7 @@ global qemb qemres semres
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);
[qemb(2),qemres]=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','correction set to zero');
......@@ -517,7 +548,7 @@ if ischar(fname)
% qemb(2).cor(:,2)=-qemreadcor(fullfile(fpath,fname));
qemb(2).cor(:,2)=ebs.load_correction(fullfile(fpath,fname),qemres.opticsdir);
set(handles.qemdata.cordef,'Enable','On');
qemb(2)=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
[qemb(2),qemres]=qempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
end
......@@ -1022,3 +1053,26 @@ try
catch
set(handles.statustext,'String','Fitted model NOT saved. Either fit not performed or no permission to write in theory folder');
end
% --- Executes on button press in GetTunesFromTango.
function GetTunesFromTango_Callback(hObject, eventdata, handles)
% hObject handle to GetTunesFromTango (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
disp('try to get tunes from tango');
try
tdev = tango.Device('srdiag/beam-tune/adjust');
set(handles.edit4,'String',num2str(tdev.Qh.read));
set(handles.edit3,'String',num2str(tdev.Qv.read));
disp('tunes updated using tango values');
catch
disp('tunes initialization not possible, tango not available. change by hand');
disp(get(handles.edit4,'String'));
disp(get(handles.edit3,'String'));
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