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.total1Dis the 1D histogram ofxaxisofplot. Use an appropriate axis, there are three available:xaxis,yaxisandcaxis.plot.xaxis.binCentersandaxis.binEdgesare the edges and centers ofxaxisbinsplot.total2Dis the 2D histogramplot.total4Dis the 4D mutual intensity, see fluxKind for the appropriate optionsplot.dx,plot.dyandplot.dEstore fwhm’s of the three 1D histogramsflux or power are accessed as
plot.fluxandplot.power
If you want to save plot results in a scan, you can do this in a generator, as explained here.
