source: MML/trunk/machine/SOLEIL/common/naff/naffutils/tracy_readtwiss.m @ 17

Last change on this file since 17 was 17, checked in by zhangj, 10 years ago

To have a stable version on the server.

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1function [s2 bx2 bz2 etax2 etaz2 ax2 az2] = tracy_readtwiss(file,cell)
2%function tracy_readtwiss(file,cell) - Plot Twiss functions from TRacy output file
3%
4%  OUPUTS
5%  1. s2 - s-position alon the ring
6%  2. bx2 - Horizontal beta function
7%  3. bz2 - Vertical beta function
8%  4. etax2 - Horizontal dispersion
9%  5. etaz2 - Vertical dispersion
10%  6. ax2 - Horizontal alpha function
11%  7. az2 - Vertical alpha function
12%
13% cell = 1 show all the ring
14% cell = 4 show one out of 4 periods
15
16%
17%% Written by Laurent S. Nadolski, 27/09/08, SOLEIL
18
19DisplayFlag = 0;
20
21if nargin == 0
22    file = 'linlat.out';
23end
24
25if (nargin ==2 && ~isempty(cell))
26    cell = 4;
27else
28    cell = 1;
29end
30
31[dummy s ax bx mux etax etaxp az bz muz etaz etazp] = ...
32    textread(file,'%s %f %f %f %f %f %f %f %f %f %f %f','headerlines',4);
33[s2 idx] = unique(s);
34ax2 = ax(idx); az2 = az(idx);
35bx2 = bx(idx); bz2 = bz(idx);
36etax2 = etax(idx); etaz2 = etaz(idx);
37%%
38if DisplayFlag
39    h = figure(21)
40    cla
41    plot(s,bx,'r-',s,bz,'b-');
42    hold on;
43    plot(s,10*etax,'g-',s,10*etaz,'k--')
44    drawlattice(0,2,gca)
45    %plotlattice(0,2)
46    legend('\beta_x','\beta_z','10\eta_x','10\eta_z')
47    xaxis([0 s(end)/cell])
48    title('Optical functions')
49    xlabel('s (m)')
50    datalabel on
51    %%
52    %% interpolation
53    si    = (s2(1):0.2:s2(end))';
54    bxi   = interp1(s2,bx2,si,'pchip');
55    bzi   = interp1(s2,bz2,si,'pchip');
56    etaxi = interp1(s2,etax2,si,'pchip');
57    etazi = interp1(s2,etaz2,si,'pchip');
58
59    figure(22)
60    cla
61    hold on;
62    plot(si,bxi,'r-',si,bzi,'b-');
63    plot(si,10*etaxi,'g-',si,10*etazi,'k--')
64    drawlattice(0,2,gca)
65    legend('\beta_x','\beta_z','10\eta_x','10\eta_z')
66    xaxis([0 s(end)/cell])
67    title('Optical functions')
68    xlabel('s (m)')
69end
Note: See TracBrowser for help on using the repository browser.