OpticalElement¶
- class marxs.optics.OpticalElement(**kwargs)[source] [edit on github]¶
Bases:
SimulationSequenceElement
Base class for all optical elements in marxs.
This class cannot be used to instanciate an optical element directly, rather it serves as a base class from with other optical elements will be derived.
At the very minumum, any derived class needs to implement
__call__
which typically callsintersect
and eitherprocess_photon
orprocess_photons
. If the interaction with the photons (e.g. scattering of a mirror surface) can be implemented in a vectorized way using numpy array operations, the derived class should overwriteprocess_photons
(process_photon
is not used in this case). If no vectorized implementation is available, it is sufficient to overwriteprocess_photon
. Marxs will callprocess_photons
, which (if not overwritten) contains a simple for-loop to loop over all photons in the array and callprocess_photon
on each of them.Define a new MARXS element.
Attributes Summary
Dictionary for display specifications, e.g. color.
Methods Summary
__call__
(photons)Call self as a function.
process_photon
(dir, pos, energy, polarization)Simulate interaction of optical element with a single photon.
process_photons
(photons, intersect, ...)Simulate interaction of optical element with photons - vectorized.
Attributes Documentation
- display = {}¶
Dictionary for display specifications, e.g. color
- pos4d¶
Methods Documentation
- __call__(photons)[source] [edit on github]¶
Call self as a function.
- process_photon(dir, pos, energy, polarization)[source] [edit on github]¶
Simulate interaction of optical element with a single photon.
This is called from the
process_photons
method in a loop over all photons. That method also collects the output values and inserts them into the photon list.process_photon
can return any number of values in additon to the required dir, pos, etc.. Define a class attributeoutput_columns
as a list of strings to determine how into which column these numbers should be inserted.- Parameters:
- dir
numpy.ndarray
4-d direction vector of ray in homogeneous coordinates
- pos
numpy.ndarray
4-d position of last interaction pf the photons with any optical element in homogeneous coordinates. Together with
dir
this determines the equation of the ray.- energyfloat
Photon energy in keV.
- polarizationfloat
Polarization angle of the photons.
- dir
- Returns:
- dir
numpy.ndarray
4-d direction vector of ray in homogeneous coordinates
- pos
numpy.ndarray
4-d position of last interaction pf the photons with any optical element in homogeneous coordinates. Together with
dir
this determines the equation of the ray.- energyfloat
Photon energy in keV.
- polarizationfloat
Polarization angle of the photons.
- probabilityfloat
Probability that the photon passes this optical element. Set to 0 if the photon is absorbed, to 1 if it passes and to number between 0 and 1 to express a probability that the photons passes.
- otherfloats
One number per entry in
output_columns
.
- dir
- process_photons(photons, intersect, interpos, intercoos)[source] [edit on github]¶
Simulate interaction of optical element with photons - vectorized.
Derived classes should overwrite this function or
process_photon
.- Parameters:
- photons: `astropy.table.Table` or `astropy.table.Row`
Table with photon properties
- intersectarray
Boolean array marking which photons should be processed by this element.
- interpos, intercoosarray (N, 4)
The array
interpos
contains the intersection points in the global coordinate system,intercoos
in a local coordiante system (2d in most cases).
- Returns:
- photons:
astropy.table.Table
orastropy.table.Row
Table with photon properties. If possible, the input table is modified in place, but in some cases this might not be possible and the returned Table may be a copy. Do not rely on either - use
photons.copy()
if you want to ensure you are working with an independent copy.
- photons: