roentgen - read the docs · ii. roentgen, release 1.1.dev6+gcd4d4e1 this is a python package for...
TRANSCRIPT
roentgenRelease 1.1.dev6+gcd4d4e1
Sep 08, 2020
CONTENTS
1 Guide 3
2 Reference 19
3 Examples 27
4 Contributing 35
5 Authors 37
6 License 39
7 Changelog 43
8 Indices and tables 45
Python Module Index 47
Index 49
i
ii
roentgen, Release 1.1.dev6+gcd4d4e1
This is a Python package for the quantitative analysis of the interaction of energetic x-rays with matter. This package isnamed after one of the discoverers of X-rays, Wilhelm Roentgen. He was awarded the very first Nobel Prize in Physics“in recognition of the extraordinary services he has rendered by the discovery of the remarkable rays subsequentlynamed after him”. X-rays were originally referred to as Roentgen rays.
CONTENTS 1
roentgen, Release 1.1.dev6+gcd4d4e1
2 CONTENTS
CHAPTER
ONE
GUIDE
This is a Python package for the quantitative analysis of the interaction of energetic x-rays with matter. This package isnamed after one of the discoverers of X-rays, Wilhelm Roentgen. He was awarded the very first Nobel Prize in Physics“in recognition of the extraordinary services he has rendered by the discovery of the remarkable rays subsequentlynamed after him”. X-rays were originally referred to as Roentgen rays.
The scope of this package is evolving but it currently includes the penetration or absorption of x-rays in materials.These materials may be metals, gases, biological, or detector materials. It also includes the generation of x-rays fromemission lines.
1.1 Theory of Transmission and Absorption
1.1.1 Mass Attenuation Coefficient
If a narrow beam of monoenergetic photons with intensity, 𝐼0, are impinged on a material of thickness 𝑥,the intensityis attenuated exponentially,
𝐼(𝑥) = 𝐼0 exp(−𝜇𝑥)
The parameter 𝜇 is called the linear attenuation coefficient and measures the absorptivity of the material. It hasunits of 𝑐𝑚−1. This value captures the sum of the probabilities of individual processes which might remove anindividual photon from the impinging beam. Those interactions most relevant to the x-ray and gamma-ray range arethe photoelectric interaction and Compton scattering. In a photoelectric interaction, the entire incident energy of theinteracting photon is absorbed by the material while in Compton scattering, only a portion of the incident energy isabsorbed. These interactions are energy dependent which means that the linear attenuation coefficient is also. Anotherway to represent the linear attenuation coefficient is through the mass attenuation coefficient or
𝜇𝑚 =𝜇
𝜌
where 𝜌 is the density of the medium. It has units of 𝑐𝑚2𝑔−1. This is the measure used by this module.
This equation can be re-written in the following form
𝜇
𝜌=
1
𝑥ln
(︂𝐼0𝐼
)︂which suggests a method for measuring the mass attenuation coefficient.
3
roentgen, Release 1.1.dev6+gcd4d4e1
1.1.2 Transmission and Absorption
As described above the probability of transmission through a material is given by
𝐼𝑡𝑟𝑎𝑛𝑠 = 𝐼0 exp
(︂−𝜇
𝜌𝑥
)︂therefore the absorption is given by
𝐼𝑡𝑟𝑎𝑛𝑠 = 𝐼0
(︂1− exp
(︂−𝜇
𝜌𝑥
)︂)︂
1.1.3 Multiple Materials
Since we are dealing with probabilities of interactions if there are multiple materials present the probabilities must bemultiplied. For example, if we are interested in the amount of flux which passes through two materials, a and b, bothwith thickness x, it is given by the following equation
𝐼𝑡𝑟𝑎𝑛𝑠 = 𝐼0 exp
(︂−𝜇𝑎
𝜌𝑎𝑥
)︂exp
(︂−𝜇𝑏
𝜌𝑏𝑥
)︂which can be simplified to
𝐼𝑡𝑟𝑎𝑛𝑠 = 𝐼0 exp
(︂−(︂𝜇𝑎
𝜌𝑎+
𝜇𝑏
𝜌𝑏
)︂𝑥
)︂If we are interested in the amount of flux deposited in a detector of thickness, t made of material b after travelingthrough material a with thickness T
𝐹 = 𝐼0 exp
(︂−𝜇𝑎
𝜌𝑎𝑇
)︂(︂1− exp
(︂−𝜇𝑏
𝜌𝑏𝑡
)︂)︂
1.1.4 Reference
• Mass attenuation coefficient Wikipedia
1.2 Transmission and Absorption of X-rays in matter
The purpose of this guide is to present an overview of the roentgen.absorption module which provides for thecalculation of the transmission and absorption of X-rays through and by various materials.
1.2.1 Mass Attenuation Coefficient
The primary component that mediates the x-ray attenuation through a material is its mass attenuation coefficient.These tabulated values can be inspected using roentgen.absorption.MassAttenuationCoefficient.To create one:
from roentgen.absorption import MassAttenuationCoefficientsi_matten = MassAttenuationCoefficient('Si')
Tabulated values for all elements are provided as well as additional specialized materials. Elements can be specificiedby their symbol name or by their full name (e.g. Si, Silicon). A list of all of the elements is provided by:
4 Chapter 1. Guide
roentgen, Release 1.1.dev6+gcd4d4e1
roentgen.elements
Specialized materials, referred to as compounds, are also available. A complete list is provided by:
roentgen.compounds
Here is the mass attenuation coefficient for Silicon.
import astropy.units as uimport matplotlib.pyplot as pltfrom roentgen.absorption import MassAttenuationCoefficient
si_matten = MassAttenuationCoefficient('Si')plt.plot(si_matten.energy, si_matten.data)plt.yscale('log')plt.xscale('log')plt.xlabel('Energy [' + str(si_matten.energy[0].unit) + ']')plt.ylabel('Mass Attenuation Coefficient [' + str(si_matten.data[0].unit) + ']')plt.title(si_matten.name)
100 101 102 103 104
Energy [keV]
10 1
100
101
102
103
Mas
s Atte
nuat
ion
Coef
ficie
nt [c
m2
/ g]
Silicon
1.2. Transmission and Absorption of X-rays in matter 5
roentgen, Release 1.1.dev6+gcd4d4e1
1.2.2 Material
In order to determine the x-ray attenuation through a material the roentgen.absorption.Material object isprovided. This object can be created by providing the thickness of the material through which the x-rays are interacting.The thickness must be given by a Quantity. For example, a 500 micron thick layer of Aluminum can be createdlike so:
al = Material('Al', 500 * u.micron)
An optional density can also be provided. A default density is assumed if none is provided. Default values can befound in elements.csv for elements or in compounds_mixtures.csv for compounds. To inspect the density:
al.density
Using this object it is possible to get the absorption and transmission as a function of energy:
energy = u.Quantity(np.arange(1,30), 'keV')al.transmission(energy)al.absoprtion(energy)
Here is a plot of the transmission of x-rays through 500 micron of Aluminum, a standard thickness for electronicsboxes. The transmission and absorption is given on a scale from 0 (no absorption or no transmission) to 1 (completeabsorption or complete transmission).
import numpy as npimport matplotlib.pyplot as pltimport astropy.units as u
from roentgen.absorption import Material
al = Material('Al', 500 * u.micron)energy = u.Quantity(np.arange(1, 30, 0.2), 'keV')
plt.plot(energy, al.transmission(energy))plt.ylabel('Transmission')plt.xlabel('Energy [' + str(energy.unit) + ']')plt.title(al.name)
From the above plot, one can see that the this thickness of Aluminum blocks almost all x-rays below about 7 keV.The relationship between transmission and absorption can be seen in the following plot for 500 microns of Silicon, astandard thickness for a soft x-ray detector.
import numpy as npimport matplotlib.pyplot as pltimport astropy.units as u
from roentgen.absorption import Material
si = Material('Si', 500 * u.micron)energy = u.Quantity(np.arange(1, 50), 'keV')
plt.plot(energy, si.absorption(energy), label='Absorption')plt.plot(energy, si.transmission(energy), label='Transmission')plt.xlabel('Energy [' + str(energy.unit) + ']')plt.title(si.name)plt.legend(loc='lower left')
6 Chapter 1. Guide
roentgen, Release 1.1.dev6+gcd4d4e1
0 5 10 15 20 25 30Energy [keV]
0.0
0.2
0.4
0.6
0.8
Tran
smiss
ion
Aluminum
1.2. Transmission and Absorption of X-rays in matter 7
roentgen, Release 1.1.dev6+gcd4d4e1
0 10 20 30 40 50Energy [keV]
0.0
0.2
0.4
0.6
0.8
1.0
Silicon
AbsorptionTransmission
8 Chapter 1. Guide
roentgen, Release 1.1.dev6+gcd4d4e1
Besides elements, a number of compounds and mixtures are also available. As a simple example, here is the transmis-sion of x-rays through 10 meters of air.
import numpy as npimport matplotlib.pyplot as pltimport astropy.units as u
from roentgen.absorption import Material
thickness = 10 * u.mair = Material('air', thickness)energy = u.Quantity(np.arange(1, 30, 0.2), 'keV')
plt.plot(energy, air.transmission(energy))plt.ylabel('Transmission')plt.xlabel('Energy [' + str(energy.unit) + ']')plt.title("{0} {1}".format(str(thickness), air.name))
0 5 10 15 20 25 30Energy [keV]
0.0
0.1
0.2
0.3
0.4
0.5
0.6
Tran
smiss
ion
10.0 m Air (dry)
This plot shows that air, though not a dense material, does block low energy x-rays over long distances. For conve-nience, the function density_ideal_gas is provided which can calculate the density of a gas given a pressureand temperature.
1.2. Transmission and Absorption of X-rays in matter 9
roentgen, Release 1.1.dev6+gcd4d4e1
1.2.3 Compounds
Materials can be added together to form more complex optical paths. If two or more materials are added together theyform a roentgen.absorption.Compound. A simple example is the transmission through air and then througha thermal blanket composed of a thin layer of mylar and Aluminum:
optical_path = Material('air', 2 * u.m) + Material('mylar', 5 * u.micron) + Material(→˓'Al', 5 * u.micron)
This new object also provides transmission and absorption of the combination of these materials. Here is a plot of thattransmission over energy
import numpy as npimport matplotlib.pyplot as pltimport astropy.units as u
from roentgen.absorption import Material
optical_path = Material('air', 2 * u.m) + Material('mylar', 5 * u.micron) + Material(→˓'Al', 5 * u.micron)energy = u.Quantity(np.arange(1, 30, 0.2), 'keV')
plt.plot(energy, optical_path.transmission(energy), label='Transmission')plt.ylabel('Efficiency')plt.xlabel('Energy [' + str(energy.unit) + ']')plt.legend(loc='upper left')
Frequently, it is useful to consider the response function of a particular detector which includes absorption throughmaterials in front of a detector. This can be calculated by multiplying the transmission of the materials before thedetector with the absorption of the detector material.
To simplify this process, the roentgen.absorption.Response class is provided. The following example usesthe same optical path as defined above and assumes a Silicon detector.
import astropy.units as uimport matplotlib.pyplot as pltfrom roentgen.absorption import Material, Responseimport numpy as np
optical_path = [Material('air', 2 * u.m), Material('mylar', 5 * u.micron), Material(→˓'Al', 5 * u.micron)]detector = Material('Si', 500 * u.micron)resp = Response(optical_path=optical_path, detector=detector)energy = u.Quantity(np.arange(1, 30, 0.2), 'keV')
plt.plot(energy, resp.response(energy))plt.xlabel('Energy [' + str(energy.unit) + ']')plt.ylabel('Response')
This plot shows that the peak efficiency for this detector system is less than 50% and lies around 15 keV.
10 Chapter 1. Guide
roentgen, Release 1.1.dev6+gcd4d4e1
0 5 10 15 20 25 30Energy [keV]
0.0
0.2
0.4
0.6
0.8
Effic
ienc
y
Transmission
1.2. Transmission and Absorption of X-rays in matter 11
roentgen, Release 1.1.dev6+gcd4d4e1
0 5 10 15 20 25 30Energy [keV]
0.0
0.1
0.2
0.3
0.4
Resp
onse
12 Chapter 1. Guide
roentgen, Release 1.1.dev6+gcd4d4e1
1.3 Comparison with CXRO
The Center for X-ray Optics (CXRO) at LBL provides an online tool to calculate the X-ray transmission throughmaterials called the X-ray Interactions with Matter. This section compares the results of this package with those ofCXRO. The primary difference between results from this package and those from CXRO are that we make use of theNIST-provided Mass Attenuation coefficients while the CXRO makes use of optical constants from the following
• B.L. Henke, E.M. Gullikson, and J.C. Davis. X-ray interactions: photoabsorption, scattering, transmission, andreflection at E=50-30000 eV, Z=1-92, Atomic Data and Nuclear Data Tables Vol. 54 (no.2), 181-342 (July 1993)
These data only extend up to 30 keV while the NIST-provided data extend to 20 MeV. For more information on datasources see the README in the data directory. The comparison here shows that the results generally agree with eachother.
import osimport matplotlib.pyplot as plt
import numpy as npfrom astropy.io import asciifrom astropy.table import Tableimport astropy.units as ufrom astropy.constants import atm
import roentgenfrom roentgen.absorption import Materialfrom roentgen.util import density_ideal_gas
cxro_filenames = ('be_100micron.dat', 'al_1mm.dat', 'si_500micron.dat','water_1000micron.dat', 'ge_500micron.dat','air_1m_1atm_295kelvin.dat')
cxro_files = [os.path.join(roentgen._data_directory, 'cxro', f) for f incxro_filenames]
material_list = ['Be', 'Al', 'Si', 'water', 'ge', 'air']thick_list = [100 * u.micron, 1 * u.mm, 500 * u.micron, 1000 * u.micron, 500 * u.→˓micron, 1 * u.m]
def trans_plot(ax, x, a, b):ax.plot(x, a, label='cxro', linewidth=5)ax.plot(x, b, label='roentgen')
ax.grid(which='major', alpha=0.7)ax.grid(which='minor', alpha=0.2)ax.set_yscale('log')ax.set_ylim(1e-7, 1)ax.legend()
fig, axis = plt.subplots(len(material_list), figsize=(10, 20))
for ax, this_material, this_thickness, this_file in zip(axis, material_list, thick_→˓list, cxro_files):
cxro_data = Table(ascii.read(this_file, data_start=2, delimiter=' ', names=[→˓'energy', 'transmission']))
if this_material == 'air':density = density_ideal_gas(atm, 295 * u.Kelvin)
(continues on next page)
1.3. Comparison with CXRO 13
roentgen, Release 1.1.dev6+gcd4d4e1
(continued from previous page)
mat = Material(this_material, thickness=this_thickness, density=density)else:
mat = Material(this_material, thickness=this_thickness)transmission = mat.transmission(u.Quantity(cxro_data['energy'], 'eV'))print(f'{this_material} {mat.density}')trans_plot(ax, cxro_data['energy']/1000, cxro_data['transmission'], transmission)ax.set_title(f'{this_material} {this_thickness}')ax.set_ylabel('Transmission')
plt.show()
1.4 Graphical User Interface
This package provides a simple graphical user interface to enable quick calculations of x-ray transmission and absorp-tion through materials. This GUI makes use of bokeh.
To run it locally use the following command:
bokeh serve --show <roengten_directory>/gui
A working version of the GUI can be found installed on heroku at the following url https://roentgen-gui.herokuapp.com/gui.
1.5 Emission Lines
Characteristic radiation come from interactions between a high-energy particle, such as an electron, and an orbitalelectron in an atom. These interactions or collisions can, if the energy of the incoming electron is greater than thebinding energy of the orbital electron, kick out the electron and leave a vacancy. An electron from a high energy levelcan move down to fill the vacancy. In the process, it gives up energy which is emitted in the form of a photon. Forinner orbitals vacancies, these photons are generally in the x-ray regime. This process is schematically shown in thediagram below.
There are two notations used to refer to these transitions. Siegbahn notation has historically been used in the areaof X-ray spectroscopy. Though still widely used, it has been replaced by a newer nomenclature recommended bythe International Union of Pure and Applied Chemistry (IUPAC). It is referred to here as IUPAC notation. Thecorrespondence between these two nomenclatures is shown in the table below.
14 Chapter 1. Guide
roentgen, Release 1.1.dev6+gcd4d4e1
0 5 10 15 20 25 3010 7
10 5
10 3
10 1
Tran
smiss
ion
Be 100.0 microncxroroentgen
0 5 10 15 20 25 3010 7
10 5
10 3
10 1
Tran
smiss
ion
Al 1.0 mmcxroroentgen
0 5 10 15 20 25 3010 7
10 5
10 3
10 1
Tran
smiss
ion
Si 500.0 microncxroroentgen
0 5 10 15 20 25 3010 7
10 5
10 3
10 1
Tran
smiss
ion
water 1000.0 microncxroroentgen
0 5 10 15 20 25 3010 7
10 5
10 3
10 1
Tran
smiss
ion
ge 500.0 microncxroroentgen
0 5 10 15 20 25 3010 7
10 5
10 3
10 1
Tran
smiss
ion
air 1.0 mcxroroentgen
1.5. Emission Lines 15
roentgen, Release 1.1.dev6+gcd4d4e1
Table 1: Emission line translationsiegbahn iupacK1 K-L3K2 K-L2K1 K-M3K3 K-M2L1 L3-M5L2 L3-M4L1 L2-M4L2 L3-N5L3 L1-M3L4 L1-M2L5 L3-O4,5L6 L3-N1L7 L1-O1L9 L1-M5Ll L3-M1M1 M5-N7
For a more full listing see Table VIII.2 in IUPAC Report.
The energies of the x-rays from these transitions are unique to each element and are provided by a number of sources.This package makes use of those provided by the X-ray Data Booklet (October 2009). It provides energies in Table1-3 as well as relative intensities. More precise transition energies can be found at the NIST X-ray transition energiesdatabase.
The full table of energies is provided in:
from roentgen import emission_lines
It is possible to search for all known characteristic lines in an energy range with:
>>> import astropy.units as u>>> from roentgen.lines import get_lines>>> lines = get_lines(5 * u.keV, 5.2 * u.keV)>>> print(lines)energy z transition intensity
eV------ --- ---------- ---------5013.5 59 L2 115033.7 59 L1 1005034.0 54 L1 85042.1 57 L1 605156.5 56 L2,15 205177.2 63 Ll 4
If you are only interested in lines from a particular element, the search can be limited with:
>>> import astropy.units as u>>> from roentgen.lines import get_lines>>> ni_lines = get_lines(5 * u.keV, 10 * u.keV, element='Ni')>>> print(ni_lines)energy z transition intensity
eV------ --- ---------- ---------
(continues on next page)
16 Chapter 1. Guide
roentgen, Release 1.1.dev6+gcd4d4e1
(continued from previous page)
7460.9 28 K2 518264.7 28 K1,3 177478.2 28 K1 100
1.5. Emission Lines 17
roentgen, Release 1.1.dev6+gcd4d4e1
18 Chapter 1. Guide
CHAPTER
TWO
REFERENCE
2.1 Material
2.1.1 roentgen.absorption Package
Classes
Compound(materials) An object which enables the calculation of the x-raytransmission and absorption of a compound material(i.e.
MassAttenuationCoefficient(material) The mass attenuation coefficient.Material(**func_kwargs) An object which enables the calculation of the x-ray
transmission and absorption of a material (e.g.Response(optical_path, detector) An object to handle the response of a detector material
which includes an optical path or filter through whichx-rays must first traverse before reaching the detector.
Compound
class roentgen.absorption.Compound(materials)Bases: object
An object which enables the calculation of the x-ray transmission and absorption of a compound material (i.e.many materials). This object is usually created automatically when Material objects are added together.
Parameters materials (list) – A list of Material objects
Examples
>>> from roentgen.absorption.material import Material, Compound>>> import astropy.units as u>>> detector = Compound([Material('Pt', 5 * u.um), Material('cdte', 500 * u.um)])
19
roentgen, Release 1.1.dev6+gcd4d4e1
Methods Summary
absorption(energy) Provides the absorption fraction (0 to 1).transmission(energy) Provide the transmission fraction (0 to 1).
Methods Documentation
absorption(energy)Provides the absorption fraction (0 to 1).
Parameters energy (astropy.units.Quantity) – An array of energies in keV.
transmission(energy)Provide the transmission fraction (0 to 1).
Parameters energy (astropy.units.Quantity) – An array of energies in keV
MassAttenuationCoefficient
class roentgen.absorption.MassAttenuationCoefficient(material)Bases: object
The mass attenuation coefficient.
Parameters material_str (str) – A string representation of the material which includes anelement symbol (e.g. Si), an element name (e.g. Silicon), or the name of a compound (e.g. cdte,mylar).
dataThe mass attenuation data values.
Type astropy.units.Quantity array
energyThe energy values of the mass attenuation values.
Type astropy.units.Quantity
symbolThe material symbol
Type str
nameThe material name
Type str
funcA function which returns the interpolated mass attenuation value at any given energy. Energies must begiven by an astropy.units.Quantity.
Type lambda func
20 Chapter 2. Reference
roentgen, Release 1.1.dev6+gcd4d4e1
Material
class roentgen.absorption.Material(**func_kwargs)Bases: object
An object which enables the calculation of the x-ray transmission and absorption of a material (e.g. an elementor a compound/mixture).
Parameters
• material_str (str) – A string representation of the material which includes an ele-ment symbol (e.g. Si), an element name (e.g. Silicon), or the name of a compound (e.g.cdte, mylar). For all supported elements see elements.csv and for compounds seecompounds_mixtures.csv.
• thickness (astropy.units.Quantity) – The thickness of the material
• density (astropy.units.Quantity) – The density of the material. If not pro-vided uses default values which can be found in elements.csv for elements or incompounds_mixtures.csv for compounds.
symbolThe material symbol
Type str
nameThe material name
Type str
mass_attenuation_coefficientThe mass attenuation coefficient for the material.
Type MassAttenuationCoefficient
Examples
>>> from roentgen.absorption.material import Material>>> import astropy.units as u>>> detector = Material('cdte', 500 * u.um)>>> thermal_blankets = Material('mylar', 0.5 * u.mm)
Methods Summary
absorption(energy) Provides the absorption fraction (0 to 1).transmission(energy) Provide the transmission fraction (0 to 1).
2.1. Material 21
roentgen, Release 1.1.dev6+gcd4d4e1
Methods Documentation
absorption(energy)Provides the absorption fraction (0 to 1).
Parameters energy (astropy.units.Quantity) – An array of energies in keV.
transmission(energy)Provide the transmission fraction (0 to 1).
Parameters energy (astropy.units.Quantity) – An array of energies in keV
Response
class roentgen.absorption.Response(optical_path, detector)Bases: object
An object to handle the response of a detector material which includes an optical path or filter through whichx-rays must first traverse before reaching the detector.
Parameters
• optical_path (list) – A list of Material objects which make up the optical path.
• detector (Material or None) – A Material which represents the detector materialwhere the x-rays are absorbed. If provided with None, than assume a perfectly absorbingdetector material.
Examples
>>> from roentgen.absorption.material import Material, Response>>> import astropy.units as u>>> optical_path = [Material('air', 1 * u.m), Material('Al', 500 * u.mm)]>>> resp = Response(optical_path, detector=Material('cdte', 500 * u.um))
Methods Summary
response(energy) Returns the response as a function of energy whichcorresponds to the transmission through the opticalpath multiplied by the absorption in the detector.
Methods Documentation
response(energy)Returns the response as a function of energy which corresponds to the transmission through the opticalpath multiplied by the absorption in the detector.
Parameters energy (astropy.units.Quantity) – An array of energies in keV.
22 Chapter 2. Reference
roentgen, Release 1.1.dev6+gcd4d4e1
Class Inheritance Diagram
Compound
MassAttenuationCoefficient
Material
Response
2.2 Emmision Lines
2.2.1 roentgen.lines Package
Functions
get_lines(energy_low, energy_high[, element]) Retrieve all emission lines in an energy range.
get_lines
roentgen.lines.get_lines(energy_low, energy_high, element=None)Retrieve all emission lines in an energy range.
Parameters
• energy_low (astropy.units.Quantity) – The low end of the energy range
• energy_high (astropy.units.Quantity) – The high end of the energy range
• element (str, optional) – Select only lines from a specific element
Returns line_list
Return type astropy.table.QTable
2.2. Emmision Lines 23
roentgen, Release 1.1.dev6+gcd4d4e1
2.3 Utilities
2.3.1 roentgen.util Package
Functions
density_ideal_gas(pressure, temperature) Given pressure and temperature of a dry gas, return thedensity using the ideal gas law
get_atomic_number(element_str) Return the atomic number of the elementget_compound_index(compound_str) Return the index of the compound in the compound ta-
bleget_density(material_str) Given a material name return the default densityget_element_symbol(element_str) Return the element abbreviationis_an_element(element_str) Returns True if the string represents an elementis_in_known_compounds(compound_str) Returns True is the compound is in the list of known
compounds
density_ideal_gas
roentgen.util.density_ideal_gas(pressure, temperature)Given pressure and temperature of a dry gas, return the density using the ideal gas law
get_atomic_number
roentgen.util.get_atomic_number(element_str)Return the atomic number of the element
get_compound_index
roentgen.util.get_compound_index(compound_str)Return the index of the compound in the compound table
get_density
roentgen.util.get_density(material_str)Given a material name return the default density
get_element_symbol
roentgen.util.get_element_symbol(element_str)Return the element abbreviation
24 Chapter 2. Reference
roentgen, Release 1.1.dev6+gcd4d4e1
is_an_element
roentgen.util.is_an_element(element_str)Returns True if the string represents an element
is_in_known_compounds
roentgen.util.is_in_known_compounds(compound_str)Returns True is the compound is in the list of known compounds
2.3. Utilities 25
roentgen, Release 1.1.dev6+gcd4d4e1
26 Chapter 2. Reference
CHAPTER
THREE
EXAMPLES
3.1 Getting and plotting the Mass Attenuation Coefficient
import numpy as npimport matplotlib.pyplot as plt
import astropy.units as ufrom astropy.visualization import quantity_supportquantity_support()from roentgen.absorption import MassAttenuationCoefficient
cdte_atten = MassAttenuationCoefficient('cdte')
energy = u.Quantity(np.arange(1, 1000), 'keV')atten = cdte_atten.func(energy)
plt.plot(energy, atten)plt.plot(cdte_atten.energy, cdte_atten.data, 'o')plt.yscale('log')plt.xscale('log')plt.xlabel('Energy [' + str(energy.unit) + ']')plt.ylabel('Mass attenuation Coefficient [' + str(atten.unit) + ']')plt.title(cdte_atten.name)plt.show()
3.2 Finding the x-ray absorption of different detector materials
import numpy as npimport matplotlib.pyplot as plt
import astropy.units as ufrom astropy.visualization import quantity_supportquantity_support()
from roentgen.absorption import Material
thickness = 500 * u.micron
material_list = ['cdte', 'Si', 'Ge']energy = u.Quantity(np.arange(1, 100, 0.1), 'keV')
(continues on next page)
27
roentgen, Release 1.1.dev6+gcd4d4e1
100 101 102 103 104
Energy [keV]
10 1
100
101
102
103
104
Mas
s atte
nuat
ion
Coef
ficie
nt [c
m2
/ g]
Cadmium Telluride
28 Chapter 3. Examples
roentgen, Release 1.1.dev6+gcd4d4e1
(continued from previous page)
for material in material_list:mat = Material(material, thickness)plt.plot(energy, mat.absorption(energy), label=mat.name)
plt.xlabel('Energy [' + str(energy.unit) + ']')plt.ylabel('Absorption')plt.legend(loc='lower left')plt.show()
0 20 40 60 80 100Energy [keV]
0.0
0.2
0.4
0.6
0.8
1.0
Abso
rptio
n
Cadmium TellurideSiliconGermanium
3.3 Plotting the x-ray spectrum from a particular element
import numpy as npimport matplotlib.pyplot as plt
from astropy.visualization import quantity_supportimport astropy.units as ufrom astropy.modeling.models import Lorentz1Dquantity_support()
from roentgen.lines import get_lines
(continues on next page)
3.3. Plotting the x-ray spectrum from a particular element 29
roentgen, Release 1.1.dev6+gcd4d4e1
(continued from previous page)
element = 'Ni'energy_range = u.Quantity([7000, 9000], 'eV')
lines = get_lines(energy_range[0], energy_range[1], element=element)spectrum = Lorentz1D(0, x_0=0)for row in lines:
spectrum += Lorentz1D(amplitude=row['intensity'], x_0=row['energy'].value,fwhm=100)
plt.title(element)for row in lines:
plt.vlines([row['energy'].value], [0], row['intensity'],label=f'{row["energy"]} eV {row["transition"]}')
energy_axis = np.linspace(energy_range[0].value, energy_range[1].value, 1000)plt.plot(energy_axis, spectrum(energy_axis))
plt.xlim(energy_range[0].value, energy_range[1].value)plt.ylim(0)plt.ylabel('intensity')plt.xlabel('eV')plt.legend(loc='upper right')plt.show()
7000 7250 7500 7750 8000 8250 8500 8750 9000eV
0
20
40
60
80
100
120
140
inte
nsity
Ni8264.7 eV eV K 1,37478.2 eV eV K 17460.9 eV eV K 2
30 Chapter 3. Examples
roentgen, Release 1.1.dev6+gcd4d4e1
3.4 Finding all x-ray lines in an energy range
import matplotlib.pyplot as plt
import astropy.units as ufrom astropy.visualization import quantity_supportquantity_support()
from roentgen.lines import get_lines
energy_range = [4, 4.2] * u.keVlines = get_lines(energy_range[0], energy_range[1])
for row in lines:plt.vlines([row['energy']], [0], row['intensity'], label=f'{row["z"]} {row[
→˓"transition"]}')
plt.ylabel('intensity')plt.legend(loc='upper left')plt.show()
4020 4040 4060 4080 4100 4120
0
20
40
60
80
100
inte
nsity
20 K 1,352 L 121 K 221 K 154 L 251 L 2,1554 L 157 Ll50 L 1
3.4. Finding all x-ray lines in an energy range 31
roentgen, Release 1.1.dev6+gcd4d4e1
3.5 Finding the response of an x-ray detector
import numpy as npimport matplotlib.pyplot as plt
import astropy.units as ufrom astropy.visualization import quantity_supportquantity_support()
from roentgen.absorption import Material, Response
optical_path = [Material('air', 2 * u.m), Material('mylar', 5 * u.micron), Material(→˓'Al', 5 * u.micron)]detector = Material('Si', 500 * u.micron)
resp = Response(optical_path=optical_path, detector=detector)energy = u.Quantity(np.linspace(1, 100, 300), 'keV')
plt.plot(energy, resp.response(energy), label='detector with optical path')plt.plot(energy, detector.absorption(energy), label='detector without optical path')plt.xlabel('Energy [' + str(energy.unit) + ']')plt.ylabel('Response')plt.ylim(0, 1)plt.legend()plt.show()
0 20 40 60 80 100Energy [keV]
0.0
0.2
0.4
0.6
0.8
1.0
Resp
onse
detector with optical pathdetector without optical path
32 Chapter 3. Examples
roentgen, Release 1.1.dev6+gcd4d4e1
3.6 Finding the x-ray transmission through different materials
import numpy as npimport matplotlib.pyplot as plt
import astropy.units as ufrom astropy.visualization import quantity_supportquantity_support()
from roentgen.absorption import Material
thickness = 5 * u.mm
material_list = ['air', 'Al', 'Pb']energy = u.Quantity(np.arange(1, 100, 0.1), 'keV')
for material in material_list:mat = Material(material, thickness)plt.plot(energy, mat.transmission(energy), label=mat.name)
plt.title(f"Thickness = {thickness}")plt.ylabel('Transmission')plt.legend(loc='lower right')plt.show()
0 20 40 60 80 100keV
0.0
0.2
0.4
0.6
0.8
1.0
Tran
smiss
ion
Thickness = 5.0 mm
Air (dry)AluminumLead
3.6. Finding the x-ray transmission through different materials 33
roentgen, Release 1.1.dev6+gcd4d4e1
3.7 Checking on edges in the Mass Attenuation Coefficient
import numpy as npimport matplotlib.pyplot as plt
import astropy.units as ufrom astropy.visualization import quantity_supportquantity_support()from roentgen.absorption import MassAttenuationCoefficient
e = np.linspace(1e-3, 1e-2, 1000)*u.MeVte = MassAttenuationCoefficient('Te')plt.plot(e, te.func(e), 'x', label='Interpolated')plt.plot(te.energy, te.data, color='black', label='Data')plt.loglog()plt.xlim(4e-3, 6e-3)plt.ylim(1e2, 1e3)plt.xlabel('Photon Energy (MeV)')plt.ylabel(r'$\mu / \rho$ (cm$^{2}$ g$^{-1}$)')plt.title('Te')plt.legend()plt.show()
4 × 10 3 5 × 10 3 6 × 10 3
Photon Energy (MeV)
102
103
2 × 102
3 × 102
4 × 102
6 × 102
/ (c
m2 g
1 )
Te
InterpolatedData
34 Chapter 3. Examples
CHAPTER
FOUR
CONTRIBUTING
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.Have a look at the great guide from the sunpy project which provides advice for new contributors.
35
roentgen, Release 1.1.dev6+gcd4d4e1
36 Chapter 4. Contributing
roentgen, Release 1.1.dev6+gcd4d4e1
38 Chapter 5. Authors
CHAPTER
SIX
LICENSE
Copyright 2019, Steven D. Christe
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance withthe License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an“AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See theLicense for the specific language governing permissions and limitations under the License.
—
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
“License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through9 of this document.
“Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
“Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or areunder common control with that entity. For the purposes of this definition, “control” means (i) the power, direct orindirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership offifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
“You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License.
“Source” form shall mean the preferred form for making modifications, including but not limited to software sourcecode, documentation source, and configuration files.
“Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, includingbut not limited to compiled object code, generated documentation, and conversions to other media types.
“Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, asindicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendixbelow).
“Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) theWork and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, anoriginal work of authorship. For the purposes of this License, Derivative Works shall not include works that remainseparable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
“Contribution” shall mean any work of authorship, including the original version of the Work and any modifications oradditions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Workby the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For
39
roentgen, Release 1.1.dev6+gcd4d4e1
the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent tothe Licensor or its representatives, including but not limited to communication on electronic mailing lists, source codecontrol systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of dis-cussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designatedin writing by the copyright owner as “Not a Contribution.”
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has beenreceived by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publiclydisplay, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide,non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made,use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claimslicensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of theirContribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation againstany entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporatedwithin the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You underthis License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or withoutmodifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and Youmust cause any modified files to carry prominent notices stating that You changed the files; and You mustretain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark,and attribution notices from the Source form of the Work, excluding those notices that do not pertain to anypart of the Derivative Works; and If the Work includes a “NOTICE” text file as part of its distribution, thenany Derivative Works that You distribute must include a readable copy of the attribution notices containedwithin such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works,in at least one of the following places: within a NOTICE text file distributed as part of the DerivativeWorks; within the Source form or documentation, if provided along with the Derivative Works; or, withina display generated by the Derivative Works, if and wherever such third-party notices normally appear.The contents of the NOTICE file are for informational purposes only and do not modify the License. Youmay add Your own attribution notices within Derivative Works that You distribute, alongside or as anaddendum to the NOTICE text from the Work, provided that such additional attribution notices cannot beconstrued as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different licenseterms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works asa whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions statedin this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You tothe Licensor shall be under the terms and conditions of this License, without any additional terms or conditions.Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement youmay have executed with Licensor regarding such Contributions.
6. Trademarks.
40 Chapter 6. License
roentgen, Release 1.1.dev6+gcd4d4e1
This License does not grant permission to use the trade names, trademarks, service marks, or product names of theLicensor, except as required for reasonable and customary use in describing the origin of the Work and reproducingthe content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor providesits Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, eitherexpress or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determin-ing the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise ofpermissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required byapplicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable toYou for damages, including any direct, indirect, special, incidental, or consequential damages of any character arisingas a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss ofgoodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), evenif such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptanceof support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, inaccepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of anyother Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liabilityincurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additionalliability.
END OF TERMS AND CONDITIONS
41
roentgen, Release 1.1.dev6+gcd4d4e1
42 Chapter 6. License
CHAPTER
SEVEN
CHANGELOG
7.1 0.1.0 (2017-03-24)
• First release
7.2 1.0.0 (2020-04-23)
• First stable release
• Added gui, deployed to heroku
• added data and support for emission lines
• Added Response class
• Major update to documentation and moved to sunpy doc theme
43
roentgen, Release 1.1.dev6+gcd4d4e1
44 Chapter 7. Changelog
CHAPTER
EIGHT
INDICES AND TABLES
• genindex
• modindex
• search
45
roentgen, Release 1.1.dev6+gcd4d4e1
46 Chapter 8. Indices and tables
PYTHON MODULE INDEX
rroentgen.absorption, 19roentgen.lines, 23roentgen.util, 24
47
roentgen, Release 1.1.dev6+gcd4d4e1
48 Python Module Index
INDEX
Aabsorption() (roentgen.absorption.Compound
method), 20absorption() (roentgen.absorption.Material
method), 22
CCompound (class in roentgen.absorption), 19
Ddata (roentgen.absorption.MassAttenuationCoefficient
attribute), 20density_ideal_gas() (in module roentgen.util), 24
Eenergy (roentgen.absorption.MassAttenuationCoefficient
attribute), 20
Ffunc (roentgen.absorption.MassAttenuationCoefficient
attribute), 20
Gget_atomic_number() (in module roentgen.util), 24get_compound_index() (in module roentgen.util),
24get_density() (in module roentgen.util), 24get_element_symbol() (in module roentgen.util),
24get_lines() (in module roentgen.lines), 23
Iis_an_element() (in module roentgen.util), 25is_in_known_compounds() (in module roent-
gen.util), 25
Mmass_attenuation_coefficient (roent-
gen.absorption.Material attribute), 21MassAttenuationCoefficient (class in roent-
gen.absorption), 20
Material (class in roentgen.absorption), 21module
roentgen.absorption, 19roentgen.lines, 23roentgen.util, 24
Nname (roentgen.absorption.MassAttenuationCoefficient
attribute), 20name (roentgen.absorption.Material attribute), 21
RResponse (class in roentgen.absorption), 22response() (roentgen.absorption.Response method),
22roentgen.absorption
module, 19roentgen.lines
module, 23roentgen.util
module, 24
Ssymbol (roentgen.absorption.MassAttenuationCoefficient
attribute), 20symbol (roentgen.absorption.Material attribute), 21
Ttransmission() (roentgen.absorption.Compound
method), 20transmission() (roentgen.absorption.Material
method), 22
49