Using xrt¶
Scripting in python¶
You need to prepare a script that gives instructions on how to get the wanted ray properties and prepare the graphs. The scripting is different for different backends (backend is a module or an external program that supplies ray distributions). Currently, xrt supports two backends: raycing – an internal backend – and shadow.
Please consider the supplied examples.
Running a python script¶
You can run it from your shell as python your-script.py or from within an IDE, e.g. Spyder.
Interacting with the plots¶
matplotlib
provides an interactive navigation toolbar that allows zoom,
pan and save functions.
Saving the results¶
You can save a plot using its navigation toolbar or by specifying the parameter saveName of the plot in your Python script.
You can also save any of the plot attributes through a script. For this, use
the parameter afterScript
of xrt.runner.run_ray_tracing
to point to a
function that will be executed after all the repeats have been completed. A
typical usage of such a function is to pickle 1D and 2D histograms, fwhm values
etc. For example:
plot.xaxis.total1D
is the 1D histogram ofxaxis
ofplot
. Use an appropriate axis, there are three available:xaxis
,yaxis
andcaxis
.plot.xaxis.binCenters
andaxis.binEdges
are the edges and centers ofxaxis
binsplot.total2D
is the 2D histogramplot.total4D
is the 4D mutual intensity, see fluxKind for the appropriate optionsplot.dx
,plot.dy
andplot.dE
store fwhm’s of the three 1D histogramsflux or power are accessed as
plot.flux
andplot.power