OpticalElement¶
- class marxs.optics.OpticalElement(**kwargs)[source]¶
Bases:
SimulationSequenceElementBase class for all optical elements in marxs.
This class cannot be used to instantiate an optical element directly, rather it serves as a base class from with other optical elements will be derived.
At the very minimum, any derived class needs to implement
__call__which typically callsintersectand eitherprocess_photonorprocess_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_photonis 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_photonon 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
- process_photon(dir, pos, energy, polarization)[source]¶
Simulate interaction of optical element with a single photon.
This is called from the
process_photonsmethod in a loop over all photons. That method also collects the output values and inserts them into the photon list.process_photoncan return any number of values in additon to the required dir, pos, etc.. Define a class attributeoutput_columnsas 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
dirthis determines the equation of the ray.- energyfloat
Photon energy in keV.
- polarizationfloat
Polarization angle of the photons.
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
dirthis 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]¶
Simulate interaction of optical element with photons - vectorized.
Derived classes should overwrite this function or
process_photon.Parameters¶
- photons:
astropy.table.Tableorastropy.table.Row Table with photon properties
- intersectarray
Boolean array marking which photons should be processed by this element.
- interpos, intercoosarray (N, 4)
The array
interposcontains the intersection points in the global coordinate system,intercoosin a local coordinate system (2d in most cases).
Returns¶
- photons:
astropy.table.Tableorastropy.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: