A python package with a GUI to calculate x-ray spectra generated in tungsten anodes, as well as the bremsstrahlung component in other media.
from xpecgen import xpecgen as xg
s=xg.calculate_spectrum(100, 12, 3, 150)
s.attenuate(0.12, xg.get_mu(13))
s.attenuate(100, xg.get_mu("air"))
s.export_xlsx("spectrum.xlsx")
s.show_plot()
If you have pip you can install xpecgen as a package by running
pip install xpecgen
and then you can launch the GUI by just executing xpecgen
, see the command line interface by executing xpecgencli -h
, or check the demo.py explaining its use as a library,
You will need tk to make use of the GUI. You can check the advanced guide if you need help for this.
If you do not have python installed yet, check the advanced guide.
The updated API documentation is available here.
You can also use the python help system to check it:
from xpecgen import xpecgen as xg
help(xg)
See CONTRIBUTING.md.
To have a general overview of the model see [1]. The bremsstrahlung calculation is done using full interpolations for the electron fluence, so none of the simplifications in section IV.C were used in this implementation. This description of the fluence can be used with others materials, always via the CSDA scaling, if requested. However, note that its accuracy has not been tested. Both characteristic peaks models in section II.D were implemented. The polynomial one is used by default. Half-value layers are calculated using the exponential model of attenuation (aka narrow beam geometry). In the GUI they are calculated in the sense of dose, but the library allows for generalizing this to any desired reponse function.
Despite the GUI and the API allow selecting different target materials, note the model only considered tungsten in detail. When a different material is selected, its bremsstrahlung cross-section and range scaling are used instead. However, differences in the electron fluence in the target might affect the results. In particular, the penetration depth is increased in low Z materials in units of the CSDA range, so the results should be used with caution, specially in that case.
If you use this application to make use of the models in [1], you should cite it. If you also want to acknowledge the implementation itself you can also cite [2].
[1] Hernández, G., Fernández F. 2016. "A model of tungsten x-ray anode spectra." Medical Physics, 43 4655. doi:10.1118/1.4955120.
[2] Hernández, G., Fernández F. 2016. "xpecgen: A program to calculate x-ray spectra generated in tungsten anodes." The Journal of Open Source Software, 00062. doi:10.21105/joss.00062.