ATPLOT Plots optical functions ATPLOT Plots THERING in the current axes ATPLOT(RING) Plots the lattice specified by RING ATPLOT(AX,RING) Plots in the axes specified by AX ATPLOT(AX,RING,DPP) Plots at momentum deviation DPP ATPLOT(...,[SMIN SMAX]) Zoom on the specified range ATPLOT(...,'OptionName',OptionValue,...) Available options: 'inputtwiss',structure of optics transferline optics (ex: [optics_struct,~,~]=atlinopt(ring,0,1); atplot(ring,[0 10],@plBeamSize,'inputtwiss',optics_struct);) 'comment',true|false Prints lattice information (default:true) 'synopt',true|false Plots the lattice elements 'labels',REFPTS Display the names of selected element names 'index',REFPTS Display the index of selected element names 'leftargs',{properties} properties set on the left axis 'rightargs',{properties} properties set on the right axis ATPLOT(...,@PLOTFUNCTION,args...) Allows for a user supplied function providing the values to be plotted PLOTFUNCTION must be of form: PLOTDATA=PLOTFUNCTION(LINDATA,RING,DPP,args...) PLOTDATA: structure array, PLOTDATA(1) describes data for the left (main) axis PLOTDATA(1).VALUES: data to be plotted, length(ring)+1 x nbcurve PLOTDATA(1).LABELS: curve labels, cell array, 1 x nbcurve PLOTDATA(1).AXISLABEL: string PLOTDATA(2) optional, describes data for the right (secondary) axis The default function displayed below as an example plots beta functions and dispersion function plotdata=defaultplot(lindata,ring,dpp,varargin) beta=cat(1,lindata.beta); % left axis plotdata(1).values=beta; plotdata(1).labels={'\beta_x','\beta_z'}; plotdata(1).axislabel='\beta [m]'; dispersion=cat(2,lindata.Dispersion)'; % right axis plotdata(2).values=dispersion(:,1); plotdata(2).labels={'\eta_x'}; plotdata(2).axislabel='dispersion [m]'; end CURVE=ATPLOT(...) Returns handles to some objects: CURVE.PERIODICIY ring periodicity CURVE.LENGTH structure length CURVE.DPP deltap/p CURVE.LEFT Handles to the left axis plots CURVE.RIGHT Handles to the right axis plots CURVE.LATTICE Handles to the Element patches: structure with fields Dipole,Quadrupole,Sextupole,Multipole,BPM,Label CURVE.COMMENT Handles to the Comment text ATPLOT calls the more general ATBASEPLOT function, which uses a slightly different syntax. See also: atbaseplot
0001 function curve = atplot(varargin) 0002 %ATPLOT Plots optical functions 0003 % 0004 %ATPLOT Plots THERING in the current axes 0005 % 0006 %ATPLOT(RING) Plots the lattice specified by RING 0007 % 0008 %ATPLOT(AX,RING) Plots in the axes specified by AX 0009 % 0010 %ATPLOT(AX,RING,DPP) Plots at momentum deviation DPP 0011 % 0012 %ATPLOT(...,[SMIN SMAX]) Zoom on the specified range 0013 % 0014 %ATPLOT(...,'OptionName',OptionValue,...) Available options: 0015 % 'inputtwiss',structure of optics transferline optics 0016 % (ex: [optics_struct,~,~]=atlinopt(ring,0,1); 0017 % atplot(ring,[0 10],@plBeamSize,'inputtwiss',optics_struct);) 0018 % 'comment',true|false Prints lattice information (default:true) 0019 % 'synopt',true|false Plots the lattice elements 0020 % 'labels',REFPTS Display the names of selected element names 0021 % 'index',REFPTS Display the index of selected element names 0022 % 'leftargs',{properties} properties set on the left axis 0023 % 'rightargs',{properties} properties set on the right axis 0024 % 0025 %ATPLOT(...,@PLOTFUNCTION,args...) 0026 % Allows for a user supplied function providing the values to be plotted 0027 % PLOTFUNCTION must be of form: 0028 % PLOTDATA=PLOTFUNCTION(LINDATA,RING,DPP,args...) 0029 % 0030 % PLOTDATA: structure array, 0031 % PLOTDATA(1) describes data for the left (main) axis 0032 % PLOTDATA(1).VALUES: data to be plotted, length(ring)+1 x nbcurve 0033 % PLOTDATA(1).LABELS: curve labels, cell array, 1 x nbcurve 0034 % PLOTDATA(1).AXISLABEL: string 0035 % PLOTDATA(2) optional, describes data for the right (secondary) axis 0036 % 0037 % The default function displayed below as an example plots beta functions 0038 % and dispersion 0039 % 0040 % function plotdata=defaultplot(lindata,ring,dpp,varargin) 0041 % beta=cat(1,lindata.beta); % left axis 0042 % plotdata(1).values=beta; 0043 % plotdata(1).labels={'\beta_x','\beta_z'}; 0044 % plotdata(1).axislabel='\beta [m]'; 0045 % dispersion=cat(2,lindata.Dispersion)'; % right axis 0046 % plotdata(2).values=dispersion(:,1); 0047 % plotdata(2).labels={'\eta_x'}; 0048 % plotdata(2).axislabel='dispersion [m]'; 0049 % end 0050 % 0051 %CURVE=ATPLOT(...) Returns handles to some objects: 0052 % CURVE.PERIODICIY ring periodicity 0053 % CURVE.LENGTH structure length 0054 % CURVE.DPP deltap/p 0055 % CURVE.LEFT Handles to the left axis plots 0056 % CURVE.RIGHT Handles to the right axis plots 0057 % CURVE.LATTICE Handles to the Element patches: structure with fields 0058 % Dipole,Quadrupole,Sextupole,Multipole,BPM,Label 0059 % CURVE.COMMENT Handles to the Comment text 0060 % 0061 % 0062 %ATPLOT calls the more general ATBASEPLOT function, which uses a slightly 0063 %different syntax. 0064 % 0065 %See also: atbaseplot 0066 0067 funcarg=find(cellfun(@(arg) isa(arg,'function_handle'),varargin),1); 0068 if isempty(funcarg) 0069 funcarg=nargin+1; 0070 end 0071 resarg=find(cellfun(@(arg) ischar(arg),varargin(1:funcarg-1)),1); 0072 if isempty(resarg) 0073 resarg=funcarg; 0074 end 0075 options=varargin(resarg:funcarg-1); 0076 [comment,options]=getoption(options,'comment',true); 0077 [intwi,options]=getoption(options,'inputtwiss',[]); 0078 %openline=find(strcmp(options(cellfun(@ischar,options)),'inputtwiss')); 0079 0080 lindata=[]; 0081 0082 if isempty(intwi) % closed ring, DEFAULT 0083 curve=atbaseplot(varargin{1:resarg-1},... 0084 @ringplot,varargin(funcarg:end),options{:}); 0085 else % openline plot 0086 curve=atbaseplot(varargin{1:resarg-1},... 0087 @lineplot,[{intwi} varargin(funcarg:end)],options{:}); 0088 end 0089 0090 if (comment) 0091 ax=get(curve.left(1),'Parent'); 0092 set(ax,'Position',[.13 .11 .775 .775]); 0093 tuneper=lindata(end).mu/2/pi; 0094 tunes=curve.periodicity*tuneper; 0095 circumference=curve.periodicity*curve.length; 0096 if curve.periodicity > 1, plural='s'; else plural=''; end 0097 line1=sprintf('\\nu_x=%8.3f \\deltap/p=%.3f%i %s',tunes(1),curve.dpp); 0098 line2=sprintf('\\nu_z=%8.3f %2i %s, C=%10.3f',tunes(2),... 0099 curve.periodicity,['period' plural],circumference); 0100 curve.comment=text(ax,-0.14,1.12,{line1;line2},'Units','normalized',... 0101 'VerticalAlignment','top'); 0102 end 0103 0104 % RING 0105 function [s,plotdata]=ringplot(ring,dpp,plotfun,varargin) 0106 [lindata,tune,chrom]=atlinopt(ring,dpp,1:length(ring)+1); %#ok<ASGLU> 0107 s=cat(1,lindata.SPos); 0108 if nargin < 3 0109 plotdata=defaultplot(lindata,ring,dpp); 0110 else 0111 plotdata=plotfun(lindata,ring,dpp,varargin{:}); 0112 end 0113 end 0114 0115 % OPEN LINE 0116 function [s,plotdata]=lineplot(ring,dpp,inputtwiss,plotfun,varargin) 0117 lindata=twissline(ring,dpp,inputtwiss,1:length(ring)+1,'chrom'); 0118 s=cat(1,lindata.SPos); 0119 if nargin < 4 0120 plotdata=defaultplot(lindata,ring,dpp); 0121 else 0122 plotdata=plotfun(lindata,ring,dpp,varargin{:}); 0123 end 0124 end 0125 0126 0127 end 0128 0129 function plotdata=defaultplot(lindata,ring,dpp,varargin) %#ok<INUSD> 0130 %DEFAULTPLOT Default plotting function for ATPLOT 0131 % 0132 %Plots beta-functions on left axis and dispersion on right axis 0133 0134 beta=cat(1,lindata.beta); 0135 plotdata(1).values=beta; 0136 plotdata(1).labels={'\beta_x','\beta_z'}; 0137 plotdata(1).axislabel='\beta [m]'; 0138 dispersion=cat(2,lindata.Dispersion)'; 0139 plotdata(2).values=dispersion(:,1); 0140 plotdata(2).labels={'\eta_x'}; 0141 plotdata(2).axislabel='dispersion [m]'; 0142 end