source: MML/trunk/applications/orbit/respgui.m

Last change on this file was 4, checked in by zhangj, 11 years ago

Initial import--MML version from SOLEIL@2013

File size: 27.4 KB
Line 
1function respgui(action, varargin)
2% RESPGUI - Part treating of the response matrice and the correction
3%
4% INPUT
5% 1. action among
6%
7% PlotSVD_Init
8% SVDotActive
9% MoveDot
10% DotUp
11% PlotSVD
12% SolveSystem
13% BackSubSystem
14% SVDEdit
15% MoveSVDDot
16% DisplayRFFit
17% DisplayNsvd
18% UpdateFit
19% RFToggle
20% ExternalFitOff
21% FitOff
22% DispersionPanel
23% EtaXFlag
24% EtaZFlag
25%
26
27
28%
29% Written by J. Corbett
30% Adapted by Laurent S. Nadolski
31
32
33% TODO etaflag and rfflag misused
34% rfflag shoudl be for RF correction
35% etaflag should be for Amman factor substraction (to be implemented)
36
37%globals
38global BPM COR RSP SYS
39
40orbfig = findobj(0,'tag','orbfig');
41plane  = SYS.plane;
42
43switch action
44
45    %==========================================================
46    case 'PlotSVD_Init'                  % *** PlotSVD_Init ***
47        %==========================================================
48        %blue, solid dynamic semilog-line for singular value plot.
49        set(SYS.ahsvd,'Color',[1 1 1],'NextPlot','add');
50        %           'ButtonDownFcn','respgui(''SVDotActive'')');
51
52        set(orbfig,'currentaxes',SYS.ahsvd)
53
54        SYS.svdplot = plot(ones(1,RSP(plane).nsvd),'LineStyle','-', ...
55            'Color','b'); %does this tag axes or line?
56        grid on;
57        SYS.lhsvd = SYS.svdplot;
58
59        SYS.lhdot = line('parent',SYS.ahsvd,...
60            'XData',0,'YData',0,...
61            'ButtonDownFcn','respgui(''SVDotActive'');',...
62            'Marker','o','MarkerSize',8,'MarkerFaceColor','r');
63
64
65        %=============================================================
66    case 'SVDotActive'                       % *** SVDotActive ***
67        %=============================================================
68        %used if mouse clicks on SVD plot dot or anywhere in SVD window
69        %activate window-button-motion
70        set(orbfig,'WindowButtonMotionFcn','respgui(''MoveDot'');',...
71            'WindowButtonUpFcn','respgui(''DotUp'')');
72
73        %==========================================================
74    case 'MoveDot'                            % *** MoveDot ***
75        %==========================================================
76        %The callback of the singular value plot dot drag
77        cpa             = get(SYS.ahsvd,'CurrentPoint');
78        RSP(plane).nsvd = round(cpa(1));
79
80        %check for out-of-range drag above
81        if RSP(plane).nsvd > RSP(plane).nsvdmax
82            RSP(plane).nsvd = RSP(plane).nsvdmax;
83        end
84
85        %check for out-of-range drag below
86        if RSP(plane).nsvd <= 0
87            RSP(plane).nsvd = 1;           
88        end
89
90        setappdata(0,'RSP',RSP);
91
92        %re-draw dot
93        % vector of singular values
94        ydat = diag(RSP(plane).S);
95        % index of the dot
96        indx = RSP(plane).nsvd;
97       
98        if indx <= 0, indx = 1; end
99
100        set(SYS.lhdot,'Xdata',RSP(plane).nsvd,'YData',ydat(indx));
101
102        %==========================================================
103    case 'DotUp'                            % *** DotUp ***
104        %==========================================================
105        respgui('MoveDot');
106
107        set(orbfig,'WindowButtonMotionFcn','','WindowButtonUpFcn','');
108        %update edit boxes
109        set(SYS.svdedit,'String',num2str(RSP(plane).nsvd));
110
111        orbgui('RefreshOrbGUI');
112
113        %==========================================================
114    case 'PlotSVD'                             % ***PlotSVD ***
115        %==========================================================
116        %blue, solid dynamic line for singular value plot
117        set(orbfig,'currentaxes',SYS.ahsvd);
118        %...must have fit valid before plotting
119        if RSP(plane).nsvdmax > 1 && RSP(plane).fit == 1
120            k      = RSP(plane).nsvdmax;
121            ydat   = diag(RSP(plane).S);
122            set(SYS.lhsvd,'Xdata',(1:k),'YData',ydat(1:k));
123            % scale y absciss using log scale
124            axis('tight');
125            %red dot
126            indx = RSP(plane).nsvd;
127            if indx <= 0, indx = 1; end
128            set(SYS.lhdot,'Xdata',RSP(plane).nsvd,'YData',ydat(indx));
129        else %fit not valid
130%             set(SYS.lhsvd,'Xdata',0:10,'YData',ones(1,11));
131%             axis('tight');
132            %no red dot
133            set(SYS.lhdot,'Xdata',[],'YData',[]);
134        end
135
136        %==========================================================
137    case 'SolveSystem'                    % *** SolveSystem ***
138        %==========================================================
139        %solve the system with requested technique (SYS.algo)
140        % 1. check that bpms and correctors selected for fitting
141        % 2. build total response matrix (orbit dispersion)
142        % 3. build total constraint vector (orbit, dispersion)
143        % 4. check dimensions of matrix, constraints
144        % 5. perform inversion
145        % 6. backsubstitute
146       
147        %check for no variables or constraints
148        if isempty(BPM(plane).ifit) || isempty(COR(plane).ifit)
149            RSP(plane).fit = 0;
150            BPM(plane).fit = zeros(length(BPM(plane).act),1);
151            COR(plane).fit = COR(plane).act;
152            setappdata(0,'RSP',RSP);
153            setappdata(0,'BPM',BPM);
154            setappdata(0,'COR',COR);
155
156            if ~RSP(plane).rfflag %% RF fit only
157                SYS.drf = 0;
158                setappdata(0,'SYS',SYS);
159                orbgui('LBox','Warning: select BPMs and CORs first');
160                disp('Warning: select beam position monitors and correctors first');
161                return
162            end
163        end
164
165        %check for no singular values requested
166        if RSP(plane).nsvd <= 0 && RSP(plane).svdtol <=0
167            disp('   Warning: no singular values or tolerance requested in svdfit');
168            return
169        end
170
171        %========================
172        switch SYS.algo
173            %========================
174            case 'SVD'   %use singular value technique to solve system
175
176                % Index the response matrix
177                %...corrector set
178                ActuatorDeviceList      = elem2dev(COR(plane).AOFamily,COR(plane).ifit);
179                ActuatorDeviceListTotal = elem2dev(COR(plane).AOFamily);
180                [corlist, iNotFound]    = findrowindex(ActuatorDeviceList, ActuatorDeviceListTotal);
181                if ~isempty(iNotFound)
182                    for i = iNotFound(:)',
183                        fprintf('   %s(%d,%d) not found\n', S.Actuator.FamilyName, ...
184                            ActuatorDeviceList(i,1), ActuatorDeviceList(i,2));
185                    end
186                    error('Actuator not found');
187                end
188%                 corwt   = COR(plane).wt(corlist);
189 
190%                 %remove dispersion component if rfflag true
191%                 if RSP(plane).rfflag == 1                             %...subtract rf component
192%                     [BPM] = etaoff(plane,BPM,RSP);                    %...calc dispersion component
193%                 else
194                    BPM(plane).rffit = zeros(length(BPM(plane).s),1); %...initialize to zero
195%                 end
196                setappdata(0,'BPM',BPM);
197
198                %...electron BPM orbit and matrix (compressed)
199%                 eBPMlist = BPM(plane).ifit;                                   %...electron BPM list
200                MonitorDeviceList      = elem2dev(BPM(plane).AOFamily,BPM(plane).ifit);
201                MonitorDeviceListTotal = elem2dev(BPM(plane).AOFamily);
202                [eBPMlist, iNotFound]  = findrowindex(MonitorDeviceList,  MonitorDeviceListTotal);
203                if ~isempty(iNotFound)
204                    for i = iNotFound(:)'
205                        fprintf('   %s(%d,%d) not found\n', S.Monitor.FamilyName, MonitorDeviceList(i,1), MonitorDeviceList(i,2));
206                    end
207                    error('Monitor not found');
208                end
209
210                eBPMval = BPM(plane).act - BPM(plane).des - BPM(plane).rffit;%...actual minus reference orbit
211                eBPMval = BPM(plane).wt.*eBPMval;                            %...apply weights
212                BPMval  = eBPMval(eBPMlist);                                 %...compress residual orbit vector
213
214                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215                % Build up R-matrix
216                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217               
218                Rmat    = RSP(plane).Data(eBPMlist,corlist);%...use only selected fit indices
219                wt      = diag(BPM(plane).wt(eBPMlist));    %...bpm weights on diagonal
220                Rmat    = wt*Rmat;                          %...weight matrix lines w/ BPM weights before inversion
221
222                %...add dispersion portion of orbit and matrix (compressed)
223                %   NOTE - only electron BPMs selected for orbit fitting used for dispersion fitting
224%                 if RSP(plane).etaflag                                %...check dispersion fitting flag
225%                     etaBPMval = BPM(plane).dsp-BPM(plane).dspref;    %...actual minus reference dispersion
226%                     etaBPMval = diag(BPM(plane).etawt)*etaBPMval(:); %...apply weights
227%                     etaBPMval = etaBPMval(eBPMlist);                 %...compress residual dispersion vector
228%                     BPMval    = [BPMval; etaBPMval];                 %...concatenate electron and dispersion BPM error signals
229%
230%                     ceta = RSP(plane).eta(eBPMlist,corlist);        %...use only selected fit indices
231%                     wt   = diag(BPM(plane).etawt(eBPMlist));         %...bpm weights on diagonal
232%                     ceta = wt*ceta;                                  %...weight matrix before inversion
233%                     Rmat = [Rmat; ceta];                             %...concatenate dispersion response matrix
234%                 end
235
236                if RSP(plane).etaflag && RSP(plane).rfflag          %...check dispersion fitting flag
237                    eta  = RSP(plane).eta(eBPMlist);            %...use only selected fit indices
238                    RFWeight = 10*mean(std(Rmat))/std(eta); %...bpm weights on diagonal
239                    Rmat = [Rmat RFWeight*eta];             %...concatenate dispersion response matrix
240                end
241
242                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243                %...perform SVD decomposition
244                %...A=USV'   A-1=VU'/S
245                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246
247                [RSP(plane).U , RSP(plane).S, RSP(plane).V] = svd(Rmat,0);   
248               
249                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
250                % Determine the singular vector and error check
251                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252                               
253                %... get singular values 
254                S    = diag(RSP(plane).S);
255           
256                %...reject zeros to get nb of nonzero singular values
257                RSP(plane).nsvdmax = length(S(find(S)));     
258               
259                % Check whether singular value number larger than total number
260                if RSP(plane).nsvd > RSP(plane).nsvdmax
261                    RSP(plane).nsvd = RSP(plane).nsvdmax;
262                    fprintf('Warning: %d zero singular value(s) rejected\n', ...
263                        RSP(plane).nsvd - RSP(plane).nsvdmax)
264                end
265               
266                %...use tolerance method if specified
267                if RSP(plane).svdtol == 0  % user given number
268                    Ivect = 1:RSP(plane).nsvd;
269                else % Tolerance
270                    Ivect = find(S > RSP(plane).svdtol*S(1));
271                    if isempty(Ivect)
272                        disp('   Warning: no singular values requested in svdfit');
273                        RSP(plane).fit = 0; % valid fit flag
274                        return
275                    end
276                end
277
278                %...backsubstitute
279                %Computes first Rmat2=U(1,Ivect)*S(Ivect,Ivect) = Rmat*V(1,:Ivect)
280                Rmat2          =  Rmat*RSP(plane).V(:,Ivect);   
281                SUtBPM         = -Rmat2\BPMval;         
282                Delcm =  RSP(plane).V(:,Ivect)*SUtBPM; %compute actuator values
283               
284                %% Fitted values for correctors
285                if RSP(plane).etaflag && RSP(plane).rfflag % if RF correction
286                    COR(plane).fit = Delcm(1:end-1);
287                    SYS.drf        = RFWeight*Delcm(end);
288                    %% update rf value and rf step for correction
289                    set(SYS.hrf,'String', num2str(getrf(SYS.mode), '%10.7f'));
290                    set(SYS.hdrf,'String',num2str(SYS.drf));
291                else
292                    COR(plane).fit = Delcm;
293                end
294
295                %NOTE: fraction scalar only used at time of corrector application
296
297                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
298                %...compute predicted results
299                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%               
300               
301                % Note: use of RSP(plane).Data and not Rmat for orbit
302                % predicted at all BPM required
303                BPM(plane).fit = RSP(plane).Data(eBPMlist,corlist)*COR(plane).fit;
304
305                %% Case of RF correction
306                if RSP(plane).etaflag && RSP(plane).rfflag
307                    BPM(plane).rffit = eta*SYS.drf;
308                end
309
310                RSP(plane).fit = 1; %...set valid fit flag
311
312                setappdata(0,'BPM',BPM);
313                setappdata(0,'COR',COR);
314                setappdata(0,'RSP',RSP);
315
316            otherwise
317                disp(['Warning: no CASE found in SolveSystem: ' SYS.algo]);
318        end  %end SYS.algo switchyard
319
320        %==========================================================
321%     case 'BackSubSystem'                      % ***BackSubSystem ***
322%         %==========================================================
323%         %backsubstitute to find solution
324%         switch SYS.algo
325%
326%             case 'SVD'                                % ***BackSubSystem ***
327%                 %callback of svdedit via SVDEdit
328%                 %etaoff has already been called
329%
330%                 [BPM,BL,COR]      = BackSubSystem(plane,SYS,BPM,BL,COR,RSP);  %also removes eta, bumps
331%                 RSP(plane).nsvdes = RSP(plane).nsvd;
332%                 RSP(plane).nsvd   = SVDMax(SYS,BPM,BL,COR,RSP);
333%                 if RSP(plane).nsvd <= RSP(plane).nsvdes
334%                     [BPM,COR] = BackSubSystem(plane,SYS,BPM,BL,COR,RSP);  %also removes eta, bumps
335%                 end
336%
337%                 setappdata(0,'BPM',BPM);
338%                 setappdata(0,'COR',COR);
339%                 setappdata(0,'RSP',RSP);
340%
341%             otherwise
342%                 disp(['Warning: no CASE found in BackSubSystem: ' algorithm]);
343%         end  %end backsubsystem switchyard
344%
345%         %==========================================================
346    case 'SVDEdit'                            % *** SVDEdit ***
347        %==========================================================
348        %callback of the singular value edit box.
349
350        val = str2double(get(SYS.svdedit,'String'));
351
352        if isnan(val) || ~isnumeric(val) || ~length(val) == 1
353            % flush the bad string out of the edit; replace with current value:
354            set(SYS.svdedit,'String',num2str(RSP(plane).nsvd));
355            orbgui('LBox','Warning: Invalid entry # singular values');
356            disp('Warning: Invalid SVD entry.');
357            return;
358        else
359
360            RSP(plane).nsvd = round(val);
361
362            if RSP(plane).nsvd == 0        %don't allow zero singular values
363                RSP(plane).nsvd = 1;
364                set(SYS.svdedit,'String',num2str(RSP(plane).nsvd));
365            end
366
367            if RSP(plane).nsvd > RSP(plane).nsvdmax
368                orbgui('LBox','Warning: # singular values exceeds maximum');
369                disp(['Warning: number of singular values exceeds maximum: ',num2str(RSP(plane).nsvdmax)])
370                RSP(plane).nsvd=RSP(plane).nsvdmax;
371                set(SYS.svdedit,'String',num2str(RSP(plane).nsvd));
372            end
373
374            setappdata(0,'RSP',RSP);
375
376            respgui('MoveSVDDot');
377            orbgui('RefreshOrbGUI');
378
379        end
380
381%         %============================================================
382%     case 'SVDSlider'                            % *** SVDSlide ***
383%         %============================================================
384%         %The callback of the singular value slider.
385%         %
386%         val = (get(SYS.svdslide,'Value'));
387%
388%         RSP(plane).nsvd = round(val);
389%
390% %         if RSP(plane).nsvd == 0
391% %             RSP(plane).nsvd = 1;
392% %         end
393%
394%         if RSP(plane).nsvd > RSP(plane).nsvdmax
395%             disp(['Warning: number of singular values exceeds maximum: ',num2str(RSP(plane).nsvdmax)])
396%             RSP(plane).nsvd = RSP(plane).nsvdmax;
397%             set(SYS.svdslide,'Value',RSP(plane).nsvd);
398%         end
399%
400%         setappdata(0,'RSP',RSP);
401%
402%         set(SYS.svdedit,'String', num2str(RSP(plane).nsvd));
403%         respgui('MoveSVDDot');
404%         orbgui('RefreshOrbGUI');
405%
406        %==========================================================
407    case 'MoveSVDDot'                       % ***MoveSVDDot ***
408        %==========================================================
409        if isempty(COR(plane).ifit) || RSP(plane).rfflag, return; end
410       
411        % Vector of singular values
412        yd = diag(RSP(plane).S);
413       
414        % default dot is user defined
415        indx = RSP(plane).nsvd;
416
417        if indx <= 0, indx = 1; end
418       
419        % check number of singular values
420        %nb of correctors included RF
421        ncor = length(COR(plane).ifit) + RSP(plane).rfflag;
422        if RSP(plane).nsvd > ncor
423            RSP(plane).nsvd = ncor;
424            indx            = ncor;
425        end
426
427        % check fit
428        if RSP(plane).fit == 1
429            %move the red dot
430            set(SYS.lhdot,'Xdata',RSP(plane).nsvd,'YData',yd(indx));
431        end
432
433        setappdata(0,'RSP',RSP);
434     
435        %==========================================================
436    case 'DisplayRFFit'                         % ***DisplayRFFit ***
437        %==========================================================
438        %update prediction for rf component
439        if RSP(plane).rfflag == 1     %display rf component
440            set(SYS.hdrf,'String', num2str(SYS.drf));
441        end
442
443        %==========================================================
444    case 'DisplayNsvd'                     % ***DisplayNsvd ***
445        %==========================================================
446        %update SVD Slider
447        %                                      'Value',round(RSP(plane).nsvd));
448        %update SVD Edit Field
449        set(SYS.svdedit,'String',num2str(RSP(plane).nsvd));
450
451        %==========================================================
452    case 'UpdateFit'                         % ***UpdateFit ***
453        %==========================================================
454     
455        bpmgui('PlotFit');        %plots orbit fit, updates limits
456        corgui('PlotFit');        %plots corrector fit (don't need to clear), updates ylimits
457        respgui('DisplayRFFit');  %display rf frequency shift
458
459        if strcmp(SYS.algo,'SVD')
460            respgui('PlotSVD');       %...show singular value plot
461            respgui('DisplayNsvd');   %...display number of singular values
462            respgui('MoveSVDDot');    %...move dot to display number of singular values
463            %update eigenvector plot
464            if strcmpi(RSP(plane).eig(1:2), 'of') || RSP(plane).nsvd==0    %Eigenvector display mode
465                set(SYS.lheig,'XData',[],'YData',[]);
466            else
467                bpmgui('PlotEig');                   %plot matrix column vector
468            end
469        end
470
471        %update response matrix plot
472        if strcmpi(RSP(plane).disp(1:2),'of')
473            set(SYS.lhrsp,'XData',[],'YData',[]);
474        else
475            bpmgui('PlotResp');                   %plot matrix column vector
476        end
477
478        %==========================================================
479    case 'RFToggle'                            % ***RFToggle***
480        %==========================================================
481        %callback of the rf component toggle radio button
482        %radio button toggles state and then executes callback
483        %hence, this routine finds the new state
484        h1  = SYS.rftoggle;
485        val = get(h1,'Value');
486        if val == 1                    %state was just toggled 'on'
487            RSP(plane).rfflag = 1;
488            %add RF singular value
489            RSP(plane).nsvdmax = RSP(plane).nsvdmax + 1;
490            RSP(plane).nsvd = RSP(plane).nsvd + 1;
491        else
492            RSP(plane).rfflag = 0;     %state was just toggled 'off'
493            %retrieve RF singular value
494            RSP(plane).nsvdmax = RSP(plane).nsvdmax - 1;
495            RSP(plane).nsvd = RSP(plane).nsvd - 1;
496        end
497
498        setappdata(0,'RSP',RSP);
499
500        respgui('SolveSystem',SYS.algo);
501        respgui('UpdateFit');
502
503        %==========================================================
504    case 'ExternalFitOff'                     %...ExternalFitOff
505        %==========================================================
506        plane = str2double(varargin{1});     %define requested plane
507        RSP(plane).fit = 0;                  %fit not valid
508
509        switch SYS.algo
510            case 'SVD'
511                RSP(plane).nsvd = 0;
512                setappdata(0,'RSP',RSP);
513        end
514
515
516        %==========================================================
517    case 'FitOff'                             %...FitOff
518        %==========================================================
519        %clear graphics because fit invalid
520        plane = str2double(varargin{1});    %define requested plane
521
522        RSP(plane).fit = 0;                 %fit not valid
523        RSP(plane).U   = [];
524        RSP(plane).S   = [];
525        RSP(plane).V   = [];
526        setappdata(0,'RSP',RSP);
527
528        set(SYS.hdrf,'String', '0.0');
529        %zero out fitting variables
530        BPM(plane).fit = zeros(size(BPM(plane).name,1),1);
531        setappdata(0,'BPM',BPM);
532
533        ncor=length(COR(plane).ifit);
534        COR(plane).fit = zeros(ncor,1);   %COR.fit is compressed
535        COR(plane).sav = COR(plane).fit;  %zero out save vector
536        setappdata(0,'COR',COR);
537
538        bpmgui('ClearPlots');          %remove all bpm fitting plots
539        corgui('ClearFit');            %remove all cor fitting plots
540        corgui('ylimits');
541
542        switch SYS.algo
543            case 'SVD'
544                %RSP=getappdata(0,'RSP');
545                RSP(plane).nsvdmax = 1;
546                RSP(plane).nsvd    = 1;      %keep one singular value - all correctors off then one on
547                setappdata(0,'RSP',RSP);
548                set(SYS.svdedit,'String',num2str(1));  %SVD display box
549                respgui('PlotSVD');
550        end
551
552        %==========================================================
553    case 'DispersionPanel'                   %  DispersionPanel
554        %==========================================================
555        %----------------------------------------------------------------
556        %  create figure
557        %----------------------------------------------------------------
558        h = findobj(0,'tag','dispersionpanel');
559       
560        if ~isempty(h)
561            delete(h);
562        end
563
564        [screen_wide, screen_high] = screensizecm;
565        fig_start = [0.4*screen_wide 0.5*screen_high];
566        fig_size  = [0.5*screen_wide 0.25*screen_high];
567        %----------------------------------------------------------------
568        figh = figure('units','centimeters',...  %...Dispersion Control Figure
569            'Position',[fig_start fig_size],...
570            'tag','dispersionpanel',...
571            'NumberTitle','off',...
572            'Doublebuffer','on',...
573            'Visible','On',...
574            'Name','Dispersion Fitting Control Panel',...
575            'PaperPositionMode','Auto');
576        set(figh,'MenuBar','None');
577        %------------------------------------------------------------------
578
579        %Radio Dispersion On/Off
580        uicontrol('Style','radiobutton',...      %Radio Horizontal Dispersion On/Off
581            'units', 'normalize', ...
582            'Position', [.05 .8 .3 .1], ...
583            'String','Fit Eta-X',...
584            'Tag','etaxflag',...
585            'Value',RSP(1).etaflag,...
586            'ToolTipString','Fit Horizontal Dispersion',...
587            'FontSize',8,'FontWeight','demi',...
588            'Callback','respgui(''EtaXFlag'')');
589
590        uicontrol('Style','radiobutton',...      %Radio Vertical Dispersion On/Off
591            'units', 'normalize', ...
592            'Position', [.5 .8 .3 .1], ...
593            'String','Fit Eta-Z',...
594            'Tag','etazflag',...
595            'Value',RSP(2).etaflag,...
596            'ToolTipString','Fit Vertical Dispersion',...
597            'FontSize',8,'FontWeight','demi',...
598            'Callback','respgui(''EtaZFlag'')');
599
600        %Select Horizontal Dispersion Weights
601        cback = 'rload(''GenFig'',BPM(1).name,BPM(1).status,BPM(1).ifit,';
602        cback = [cback 'BPM(1).etawt,''Horizontal BPMs for Eta Fitting'',''etaxwt'');'];
603        %instructions are used during 'load' procedure of rload window
604        instructions = [...
605            '   global BPM;',...
606            '   tlist = get(gcf,''UserData'');',...
607            '   BPM(1).etawt=tlist{4};',...
608            '   setappdata(0,''BPM'',BPM);',...
609            '   orbgui(''RefreshOrbGUI'');'];
610
611        uicontrol('Style','pushbutton',...                             %Select Horizontal Dispersion Weights
612            'units', 'normalize', ...
613            'Position', [.05 .65 .3 .1], ...
614            'String','Select x-BPM Weights',...
615            'tag','etaxwt',...
616            'Callback',cback,...
617            'Userdata',instructions);
618
619        %Select Vertical Dispersion Weights
620        cback='rload(''GenFig'',BPM(2).name,BPM(2).status,BPM(2).ifit,';
621        cback=[cback 'BPM(2).etawt,''Horizontal BPMs for Eta Fitting'',''etaywt'');'];
622        %instructions are used during 'load' procedure of rload window
623        instructions=[...
624            '   global BPM;',...
625            '   tlist = get(gcf,''UserData'');',...
626            '   BPM(2).etawt=tlist{4};',...
627            '   setappdata(0,''BPM'',BPM);',...
628            '   orbgui(''RefreshOrbGUI'');'];
629
630        uicontrol('Style','pushbutton',... %Select Vertical Dispersion Weights
631            'units', 'normalize', ...
632            'Position', [.5 .65 .3 .1], ...
633            'String','Select z-BPM Weights',...
634            'tag','etaywt',...
635            'Callback',cback,...
636            'Userdata',instructions);
637
638        %==========================================================
639    case 'EtaXFlag'                   %  EtaXFlag
640        %==========================================================
641        RSP(1).etaflag = 0;
642        h = findobj(gcf,'tag','etaxflag');
643        val = get(h,'value');
644        if val == 1
645            RSP(1).etaflag = 1;
646            setappdata(0,'RSP',RSP);
647        end
648
649        %% TODO merge ETAXZflag function
650       
651        %==========================================================
652    case 'EtaZFlag'                   %  EtaZFlag
653        %==========================================================
654        RSP(2).etaflag = 0;
655        h = findobj(gcf,'tag','etazflag');
656        val = get(h,'value');
657        if val == 1
658            RSP(2).etaflag=1;
659            setappdata(0,'RSP',RSP);
660        end
661
662
663        %==========================================================
664    otherwise
665        disp(['Warning: no CASE found in respgui: ' action]);
666end  %end switchyard
Note: See TracBrowser for help on using the repository browser.