EUROPEAN ORGANIZATION FOR NUCLEAR RESEARCH

PLOT

Values contained in MAD-X tables can be plotted in the form column versus column, with up to four differently scaled vertical axes and up to 10 different variables in total for all vertical axes.

If the horizontal axis is the position "s" of the elements in a sequence, a symbolic representation of the beamline can also be displayed at the top of the plot.

In certain conditions true interpolation of optical functions and parameters inside the element is available through internal slicing of the element and a call to the Twiss module for each slice.

The basic plot attributes, such as line thickness, annotation size, PostScript format and interpolation, can be set with the setplot command.

Note also that for various reasons a sequence must be defined before the PLOT command can be invoked.

First example for plots of tracking data

The following MAD-X code sample defines the tracking of four particles with the generation of a single file with name basisone holding the tracking data for all four particles.
// track particles
track, file=basis, dump, onetable;
 start, x= 2e-3, px=0, y= 2e-3, py=0;
 start, x= 4e-3, px=0, y= 4e-3, py=0;
 start, x= 6e-3, px=0, y= 6e-3, py=0;
 start, x= 8e-3, px=0, y= 8e-3, py=0;
 run,turns=1024;
endtrack;
The following sample code defines the plotting of the x-px and y-py phase space coordinates for all four particles. It takes into account the fact that all coordinates are in a single file with table=trackone and defines the filename where tracking data is to be found (basisone) with trackfile=basis.
// plot trajectories
setplot, post=1; 
title, "FODO phase-space test";
plot, file=plot, table=trackone, trackfile=basis, noversion, multiple, 
      haxis=x, vaxis=px, particle=1,2,3,4; 
plot, file=plot, table=trackone, trackfile=basis, noversion, multiple, 
      haxis=y, vaxis=py, particle=1,2,3,4;
With each plot command a temporary file gnu_plot.gp containing GNUPLOT instruction is generated. The file generated by the first plot command reads:
set terminal postscript color
set pointsize 0.48
set output 'tmpplot.ps'
set title "FODO phase-space test"
set xlabel 'x'
set ylabel 'px'
plot 'basisone' using 3:($1==1 ? $4 : NaN) title 'particle 1' with points pointtype 1 , \
     'basisone' using 3:($1==2 ? $4 : NaN) title 'particle 2' with points pointtype 2 , \
     'basisone' using 3:($1==3 ? $4 : NaN) title 'particle 3' with points pointtype 3 , \
     'basisone' using 3:($1==4 ? $4 : NaN) title 'particle 4' with points pointtype 4 
MAD-X then calls GNUPLOT as a subprocess to execute this file, which generates the file tmpplot.ps. The file tmpplot.ps is then appended to the file plot.ps determined by the attribute file=plot. The files gnu_plot.gp and tmpplot.ps are then discarded. The same process is repeated for the second plot command, resulting in a growing file plot.ps

Second example for plots of tracking data

The following MAD-X code sample defines the tracking of four particles with the generation of individual files with name basis.obs0001.p000i with i=1..4 holding the tracking data for each of the four particles.
// track particles
track, file=basis, dump;
 start, x= 2e-3, px=0, y= 2e-3, py=0;
 start, x= 4e-3, px=0, y= 4e-3, py=0;
 start, x= 6e-3, px=0, y= 6e-3, py=0;
 start, x= 8e-3, px=0, y= 8e-3, py=0;
 run,turns=1024;
endtrack;
The following sample code defines the plotting of the x-px and y-py phase space coordinates for all four particles with the data of all four particles on a single plot. It takes into account the fact that coordinates for all four particles are in separate files with table=trackfodo and defines the filename where tracking data is to be found (basis.obs0001.p000i) with trackfile=basis.
// plot trajectories
setplot, post=1; 
title, "FODO phase-space test";
plot, file=plot, table=trackfodo, trackfile=basis, noversion, multiple, 
      haxis=x, vaxis=px, particle=1,2,3,4; 
plot, file=plot, table=trackfodo, trackfile=basis, noversion, multiple, 
      haxis=y, vaxis=py, particle=1,2,3,4;
With each plot command a temporary file gnu_plot.gp containing GNUPLOT instructions is generated. The file generated by the first plot command reads:
set terminal postscript color
set pointsize 0.48
set output 'tmpplot.ps'
set title "FODO phase-space test"
set xlabel 'x'
set ylabel 'px'
plot 'basis.obs0001.p0001' using 3:4 title 'particle 1' with points pointtype 1 , \
     'basis.obs0001.p0002' using 3:4 title 'particle 2' with points pointtype 2 , \
     'basis.obs0001.p0003' using 3:4 title 'particle 3' with points pointtype 3 , \
     'basis.obs0001.p0004' using 5:4 title 'particle 4' with points pointtype 4 
MAD-X then calls GNUPLOT as a subprocess to execute this file, which generates the file tmpplot.ps. The file tmpplot.ps is then appended to the file plot.ps determined by the attribute file=plot. The files gnu_plot.gp and tmpplot.ps are then discarded. The same process is repeated for the second plot command, resulting in a growing file plot.ps

hansg, June 17, 2002,

rdemaria, September 2007,

Ghislain Roy, May 2nd, 2014.