Commit 2451d8d0 authored by Simone Liuzzo's avatar Simone Liuzzo

plots per cell or full (new figure)

parent 2745b91a
No preview for this file type
......@@ -22,7 +22,7 @@ function varargout = sempanel2(varargin)
% Edit the above text to modify the response to help sempanel2
% Last Modified by GUIDE v2.5 31-Jan-2019 07:54:26
% Last Modified by GUIDE v2.5 08-Feb-2019 12:20:55
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
......@@ -268,11 +268,9 @@ function pushbutton13_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
%qemb(2).skewcor(:,2)=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(:,2)=A{2};
qemb(2).skewcor(:,2)=ebs.load_correction(fullfile(qemres.datadir,'skewcor.dat'));
set(handles.semdata.cordef,'Enable','On');
set(hObject,'Enable','Off');
qemb(2)=sempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
......@@ -323,11 +321,9 @@ global qemb qemres semres
corfile=fullfile(qemres.datadir, 'skewcor.dat');
[fname,fpath]=uigetfile('*.dat','Load correction:',corfile);
if ischar(fname)
% qemb(2).skewcor(:,2)=load_correction(fullfile(fpath,fname),...
% 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(:,2)=A{2};
qemb(2).skewcor(:,2)=ebs.load_correction(fullfile(fpath,fname),semres.opticsdir);
set(handles.semdata.cordef,'Enable','On');
qemb(2)=sempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
end
......@@ -630,3 +626,17 @@ function neigDipFit_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in largefigure.
function largefigure_Callback(hObject, eventdata, handles)
% hObject handle to largefigure (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of largefigure
global qemres qemb semres
waitfor(set(handles.statustext,'String','figures are being redrawn'));
sempaneldisp(qemres,semres,qemb(2),qemb(1),handles);
set(handles.statustext,'String','new figures done');
......@@ -7,9 +7,9 @@ qemb=qemoptics(qemres,qemb,qemb0);
sbpm=cat(1,qemb.lindata.SPos);
if isfield(handles,'axes1')
sqcheck(qemb.ks,qemb.kn,qemb.diptilt,handles.axes1);
sqcheck(qemb.ks,qemb.kn,qemb.diptilt,handles.axes1,get(handles.largefigure,'Value'));
else
sqcheck(qemb.ks,qemb.kn,qemb.diptilt);
sqcheck(qemb.ks,qemb.kn,qemb.diptilt,[],get(handles.largefigure,'Value'));
end
mess={};
......@@ -41,10 +41,31 @@ else
end
if isfield(handles,'axes4') % displays corr. strengths
bar(handles.axes4,qemb.skewcor);
set(handles.axes4,'XLim',[0 size(qemb.skewcor,1)+1]);
title(handles.axes4,'Corrector strengths');
grid(handles.axes4,'on');
if get(handles.largefigure,'Value')
figure; extfigax = gca;
bar(extfigax,qemb.skewcor);
legend(extfigax,'initial','corrected');
title(extfigax,'Corrector strengths');
grid(extfigax,'on');
else
% colormp default;
Nc = length(qemb.skewcor);
extracor = mod(Nc,32); % remove extra correctors from injection cells
cor_per_cell_std = squeeze(std(reshape(...
qemb.skewcor((1+extracor/2):(Nc-extracor/2),:),...
32,[],size(qemb.skewcor,2)),1,2));
% cor_per_cell_mean = squeeze(mean(reshape(qemb.cor((1+extracor/2):(Nc-extracor/2),:),32,[],2),2));
bar(handles.axes4,cor_per_cell_std,'EdgeColor','none');
title(handles.axes4,'std Corrector strengths (per cell)');
legend(handles.axes4,'initial','corrected');
grid(handles.axes4,'on');
end
% bar(handles.axes4,qemb.skewcor);
% set(handles.axes4,'XLim',[0 size(qemb.skewcor,1)+1]);
% title(handles.axes4,'Corrector strengths');
% grid(handles.axes4,'on');
end
if isfield(handles,'axes2') % displays vertical dispersion
......
function [k,tilts,stdf,meanf]=sqcheck(ks,kn,diptilt,ax)
function [k,tilts,stdf,meanf]=sqcheck(ks,kn,diptilt,ax,largefig)
%SQCHECK Analyzes quadrupole strength errors
%
%DKK=SQCHECK(KL,KL0)
%
nm=size(ks,2);
nq=size(ks,1);
labels=ebs.qpname(1:length(ks));
labels{nq+1} = 'diptilt';
......@@ -29,11 +29,50 @@ for i=1:nq+1
end
if nargin >= 4 % displays quad rotations
plot(ax,[tilts;diptilt]);
title(ax,['Magnet rotation errors: quad (' num2str(length(tilts)) ...
') ,dip (' num2str(length(diptilt)) ') ']);
ylabel(ax,'\Theta');
ax.XLim=[0 length([tilts;diptilt])];
grid(ax,'on');
% set(ax,'Xlim',[0 nq+1],'XTickLabel',labels,'XTickLabelRotation',30);
if largefig
figure;
subplot(2,1,1); extfigax = gca;
plot(extfigax,tilts);
title(extfigax,['Magnet rotation errors: quad (' num2str(length(tilts)) ...
') ']);
ylabel(extfigax,'\Theta');
extfigax.XLim=[0 length([tilts])];
grid(extfigax,'on');
subplot(2,1,2); extfigax = gca;
plot(extfigax,diptilt);
title(extfigax,['Magnet rotation errors: dip (' num2str(length(diptilt)) ') ']);
ylabel(extfigax,'\Theta');
extfigax.XLim=[0 length([diptilt])];
grid(extfigax,'on');
%% set(ax,'Xlim',[0 nq+1],'XTickLabel',labels,'XTickLabelRotation',30);
else
Nc = length([diptilt]);
extracor = mod(Nc,32);
cor_per_cell_dip = squeeze(std(reshape(diptilt((1+extracor/2):(Nc-extracor/2)),32,[]),1,2));
Nc = length([tilts]);
extracor = mod(Nc,32);
cor_per_cell_quad = squeeze(std(reshape(tilts((1+extracor/2):(Nc-extracor/2)),32,[]),1,2));
% colormap default;
yyaxis(ax,'left');
bar(ax,[cor_per_cell_quad],'EdgeColor','none');
ylabel(ax,'\Theta');
yyaxis(ax,'right');
bar(ax,[cor_per_cell_dip],'EdgeColor','none');
legend(ax,'std quad','std dip');
grid(ax,'on');
set(ax,'Xlim',[0 32+1],'FontSize',6);
end
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