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.
-
plot, haxis= vname, hmin=real, hmax=real,
vaxis= vname1,vname2,..,vnamen,
vaxis1= vname1,vname2,..,vnamen,
vaxis2= vname1,vname2,..,vnamen,
vaxis3= vname1,vname2,..,vnamen,
vaxis4= vname1,vname2,..,vnamen,
vmin= reals, vmax= reals,
title= string,
bars= integer, style= integer, colour= integer, symbol= integer,
interpolate= logical, zero_suppr= logical,
noversion= logical, noline= logical, notitle= logical,
marker_plot= logical, range_plot= logical, range= range,
table= table_name, particle= particle1,particle2,..,particlen,
multiple= logical, file= file_name_start, trackfile= table_name,
ptc= logical, ptc_table= table_name;
where the parameters have the following meaning:
- haxis: name of the horizontal axis variable
- hmin, hmax: lower and upper edge for horizontal axis. Both values must be provided.
- vaxis: one or several variables from the table to be plotted
against a single vertical axis. If more than 10 variables are specified, the plot is not produced.
- vaxisi: one or several variables from the table to be plotted
against vertical axis number i. There is a maximum of 4 vertical axes.
If the number of variables given for a single vaxisi would push the
total number of variables beyond the maximum of 10, the variables given for
this vaxisi, as well as those for subsequent vaxes, are ignored but the plot
is produced for the variables accumulated so far.
Important: vaxis and vaxis{1..4} are exclusive in
their application! if vaxis is given, vaxis{1..4} will be simply ignored.}
- vmin, vmax: lower and upper edge(s) for vertical axis or axes,
up to four numbers separated by commas.
Note that both vmin and vmax must be given for an axis to be effective.
- title: plot title string; if absent,
the last overall title is used; if no such overall title as well, the
sequence name is used.
- bars: 0 (default) or 1. With bars=1 all data points are connected to
the horizontal axis with vertical bars.
- style: 1 (default), 2, 3, or 4: line style for connecting the
successive data points, respectively solid, dashed, dotted, and dot-dashed;
the special value style=100 uses the four styles in turn for
successive curves in the same plot.
With style=0 successive data points are not connected.
- colour: 1 (default), 2, 3, 4 or 5: colour for the symbols and lines,
respectively black, red, green, blue, and magenta;
The special value colour=100 uses the five colours in turn for successive symbols and lines.
- symbol: 0 (default), 1, 2, 3, 4, or 5: The symbols to be plotted at data points,
respectively none, dot ("."), plus ("+"), star ("*"), circle ("o"), and cross ("x").
The symbol size may have to be adapted through the SETPLOT command (see below).
Note that if symbol and style are both zero at the same time, style is
forced to its default value (style=1).
- interpolate: logical, default=false. The data points are normally connected
by straight lines; if "interpolate" is specified, the following on-momentum
Twiss parameters are interpolated with calls to the Twiss module inside each element:
beta, sqrt(beta), alfa, phase advance, orbit, angle, dispersion and its first derivative,
for both planes. For all other variables, splines are used to smooth the curves.
Note that setting this option is ineffective if the interpolate option of the SETOPT
command has been set to true; in this case all plots will be interpolated.
- zero_suppr: To be documented (default = false)
- noversion: logical, default=false. If noversion=true, the information concerning
the version of MAD-X and the date of the run are suppressed from the title.
This option frees additional space available for the user specified title of the plot.
- noline: logical, default=false. If s is the horizontal variable,
then a symbolic representation of the beamline is plotted above the plot,
except for tables that have been read back into MAD-X.
In case the horizontal scale is too large and the density of beamline elements
is too high, this may result in hardly legible representation and
a thick black block in teh worst case.
The "noline" option suppresses this symbolic representation of the beamline.
- notitle: logical, default=false. If true, suppresses the title
line, including the information on the version and date.
- marker_plot: logical, default=false. If true, plotting is done
also at the location of marker elements. This is only useful for the
plotting of non-continuous functions like the "N1" from the aperture
module. Beware that the PS file might became very large if this flag
is invoked.
- range_plot: logical, default=false. Allows the specification of
a plotting range for the user defined horizontal axis.
- range: horizontal plot range
given by elements.
- table: name of the table from which data is plotted (default: twiss).
If the first part of the name of the table is "track",
the data to be plotted are taken from the tracking file(s) generated
by a previous TRACK command for each requested particle as defined by
the particle attribute. If the required file has not
been generated by a preceding TRACK command, no plot is done for that particle.
The plot is generated through the GNUPLOT program and is available in the
format specified by the SETPLOT command.
The preceding TRACK command should contain the attribute dump
and may contain the attribute onetable.
The tracking plots are appended to the file file_name.ps where
file_name can be specified via the attributefilename=file_name.
Note that the plots are appended to this file and the file is not overwritten.
The PLOT command uses the following tracking output files depending on the name of the table.
With the attribute table=trackone, the data file is assumed to have been generated
with the ONETABLE=true attribute of the TRACK command,
and the file name has the following format: basisone
where the basis for the file name is defined by the attribute trackfile=basis
(default=track).
With the attribute table=trackxxx where xxx is any string other than "one",
the data files are assumed to have been generated with the
ONETABLE=false attribute of the TRACK command,
and the file names have the following format: basis.obs0001.p00i
where the basis for the file name is defined by the attribute
trackfile=basis (default=track), the observation point fixed is to 1
and the particle number i is given by the attribute particle=i.
- particle: one or several numbers associated to the
tracked particles for which the specified plot has to be displayed.
- multiple: logical, default=false. If true all the curves generated
for each tracked particle are put on one plot. Otherwise there will be
one plot for each particle.
- file: basename for the Postscript file(s). Only
the first occurrence of such a name will be used. Default is "madx" or
"madx_track" if the table attribute is track. Depending on the
format (.ps or .eps, see below) the plots will either all be written
into one file file_name.ps, or one per plot into file_name01.eps,
file_name02.eps, etc.
- trackfile: first part of the name of the files containing tracking data for each
particle (default: track)
- ptc: logical, default=false. If set true,
the data to be plotted are taken from the table defined by the
attribute ptc_table which is expected to be generated
previously by the ptc package. The data belong to the column
identified by one of the names set in the definition of the ptc twiss
table. Interpolation is not available and the attribute
interpolate has no effect.
This option is highly recommended when plotting data obtained from
PTC_TWISS since there is no
mechanism for PLOT to physically interpolate the optical
functions beyond using splines with no mechanism for constraints
with derivatives. In most cases the INTERPOLATE option with data
obtained with PTC_TWISS produces unphysical data representation.
- ptc_table: name of the ptc twiss table to be plotted from (default: ptc_twiss)
-
setplot, post= integer, font= integer,
lwidth= real, xsize= real, ysize= real,
ascale= real, lscale= real, sscale= real, rscale= real,
interpolate= logical;
where the parameters have the following meaning:
- post: default = 1.
If =1, makes one PostScript file (.ps) with all plots;
if =2, makes one Encapsulated PostSscript file (.eps) per plot.
- font: there are two defaults:
1 for screen plotting: this uses characters made from polygons;
-1 for PostScript files; this is Times-Italic.
There are various fonts available for positive and negative integers,
best to be tried out, since they will look different on different systems
anyway. GhostView will show strange vertical axis annotations, but the
printed versions are normally OK.
- lwidth: default = 1. Allows the user to set the curve line width.
Depends on the system as well, so to be tried out.
- xsize: bounding box size for PostScript, default=27 cm.
- ysize: bounding box size for PostScript, default=19 cm.
- ascale: annotation character height scale factor, default=1.
- lscale: axis label character height scale factor, default=1.
- sscale: curve symbol (see above) scale factor, default=1.
- rscale: axis text character height scale factor, default=1.
- interpolate: logical, default=false. The data points are normally connected
by straight lines; if "interpolate" is specified, the following on-momentum
Twiss parameters are interpolated with calls to the Twiss module inside each element:
beta, sqrt(beta), alfa, phase advance, orbit, angle, dispersion and its first derivative,
for both planes. For all other variables, splines are used to smooth the curves.
Note that if the interpolate option is set to true by SETOPT, subsequent plots use
interpolation, irrespective of the setting of the option in the PLOT commands.
If the interpolate option is set to false in SETOPT (default), the interpolate
option of subsequent PLOT command is respected.
-
resplot;
resets all defaults for the setplot command.
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.