X-ray Spectra Modeling
- xrayphysics.xrayPhysics.simulateSpectra(self, kV, takeOffAngle=11.0, Z=74, gammas=None)
x-ray source spectra model
This model is based on the following paper:
Finkelshtein, A. L., and T. O. Pavlova. “Calculation of x-ray tube spectral distributions.” X-Ray Spectrometry: An International Journal 28, no. 1 (1999): 27-32.
The strength of the characteristic lines were determined using empirical methods.
- Parameters:
kV (scalar) – voltage of a bremsstrahlung spectrum
takeOffAngle (scalar or list) – the take-off angle (degrees) of the reflection anode
Z (int) – the atomic number of the anode material, must be 29, 42, 74, or 79 (Cu, Mo, W, Au)
gammas (numpy array) – the energies for which to model the spectra, if unspecified uses default values
- Returns:
x-ray energy samples, x-ray source spectra model (will be 2D if multiple take-off angles are given)
- xrayphysics.xrayPhysics.changeTakeOffAngle(self, kV, takeOffAngle_cur, takeOffAngle_new, Z, gammas, spectrum_cur)
Change the anode take-off angle of a given x-ray source spectra model
This function uses the Philibert absorption correction factor to modify the given spectra for a different take-off angle. See the paper referenced in the simulateSpectra function for a detailed description of this factor.
- Parameters:
kv (scalar) – voltage of a bremsstrahlung spectrum
takeOffAngle_cur (scalar) – the take-off angle (degrees) of the input spectra
takeOffAngle_new (scalar) – the take-off angle (degress) of the output spectra
Z (int) – the atomic number of the anode material, must be 29, 42, 74, or 79 (Cu, Mo, W, Au)
gammas (numpy array) – the energy samples at which the input spectra is defined
spectrum_cur (numpy array) – the current x-ray spectra model (from any source; does not have to be created by this package)
- Returns:
The modified x-ray spectra model
- xrayphysics.xrayPhysics.detectorResponse(self, chemicalFormula, density, thickness, gammas)
Analytic detector response model
The model is given by
\[\begin{eqnarray*} \gamma \left[ 1 - e^{-\mu(\gamma)L}\right] \end{eqnarray*}\]where \(\mu\) is the LAC of the scintillator, \(\gamma\) is the x-ray energy (keV), and \(L\) is the scintillator thickness. This provides a descent approximation of the detector response. A detailed model of the photodiode response of the detector will provide a better estimate.
- Parameters:
chemicalFormula (string) – atomic number, chemical formula, mixture of compounds with mass fractions, or member of the material library
density (scalar) – the mass density (g/cm^3) of the scintillator
thickness (scalar) – the thickness (cm) of the scintillator
gammas (numpy array) – the energy samples (keV) at which to calculate the detector response
- Returns:
A model of the detector response
- xrayphysics.xrayPhysics.filterResponse(self, chemicalFormula, density, thickness, gammas)
X-ray Filter response model
The model is given by
\[\begin{eqnarray*} e^{-\mu(\gamma)L} \end{eqnarray*}\]where \(\mu\) is the LAC of the filter material, \(\gamma\) is the x-ray energy (keV), and \(L\) is the material thickness.
- Parameters:
chemicalFormula (string) – atomic number, chemical formula, mixture of compounds with mass fractions, or member of the material library
density (scalar) – the mass density (g/cm^3) of the filter material
thickness (scalar) – the thickness (cm) of the filter material
gammas (numpy array) – the energy samples (keV) at which to calculate the filter response
- Returns:
A model of the response to the given x-ray filter
- xrayphysics.xrayPhysics.meanEnergy(self, spectralResponse, gammas)
Calculates the mean energy of a given spectra
- Parameters:
spectralResponse (numpy array) – spectra model
gammas (numpy array) – energies at which the spectra model is defined
- Returns:
The mean energy (keV) of the given spectra
- xrayphysics.xrayPhysics.normalizeSpectrum(self, spectralResponse, gammas)
Normalizes the given spectra
- Parameters:
spectralResponse (numpy array) – spectra model
gammas (numpy array) – energies at which the spectra model is defined
- Returns:
The normalized spectra
- xrayphysics.xrayPhysics.load_spectra(self, fileName)
Load spectra from file (txt or npy)
This function loads two columns of data. In the context of this software, the first column are the x-ray energies and the second column is either the spectra, detector response, LAC values, etc. This data can either be (N,2) data stored in an npy file or an acsii file of two columns of numbers which is a common format used to store spectra in a file.
- Parameters:
fileName (str) – name of file where spectra information is stored
- Returns:
x-ray energy samples, x-ray source spectra model
- xrayphysics.xrayPhysics.save_spectra(self, fileName, spectralResponse, gammas)
Save spectra to file (txt or npy)
This function saves two columns of data. In the context of this software, the first column are the x-ray energies and the second column is either the spectra, detector response, LAC values, etc. This data can either be (N,2) data stored in an npy file or an acsii file of two columns of numbers which is a common format used to store spectra in a file.
- Parameters:
fileName (str) – name of file where spectra information is to be saved
spectralResponse (float 32 numpy array) – the x-ray spectra, detector response, LAC values, etc.
gammas (float 32 numpy array) – the x-ray energy samples (keV)