xopto.mcml.mcdetector.base module¶
- class Detector(raw_data: numpy.ndarray, nphotons: int)[source]¶
Bases:
xopto.mcml.mcdetector.base.DetectorAny
Detector base class.
- Parameters
raw_data (np.ndarray) – Raw data accumulator.
nphotons (int) – Number of photon packets used in the simulations.
- property nphotons: int¶
The number of photon packets that produced the raw data accumulator content.
- property raw: numpy.ndarray¶
Raw accumulator data array.
- property shape: tuple¶
Shape of the raw data accumulator array.
- property total¶
Total weight of the accumulated photon packets.
- update_data(mc: xopto.mcbase.mcobject.McObject, accumulators: List[numpy.ndarray], nphotons: int, **kwargs)[source]¶
Update the content of raw data accumulators with simulation results.
- Parameters
mc (mcobject.McObject) – Simulator instance that produced the data.
accumulators (List[np.ndarray]) – List of allocated accumulators (this implementation uses only one).
nphotons (int) – The number of photon packets that produced the raw data accumulator content.
kwargs (dict) – Additional keyword arguments not used by this implementation.
- class DetectorAny(*args, **kwargs)[source]¶
Bases:
xopto.mcml.mcdetector.base.DetectorBase
Base class of the detectors at the top or bottom sample surface or for specular reflections.
Create a detector for any location.
- class DetectorBase(location: none)[source]¶
Bases:
xopto.mcbase.mcobject.McObject
Base class of all detectors.
Detector at the sample surface.
- Parameters
location (TOP or BOTTOM or SPECULAR) – Location of the detector.
- property location: str¶
Location of the detector.
- class DetectorBottom(*args, **kwargs)[source]¶
Bases:
xopto.mcml.mcdetector.base.DetectorBase
Base class of the detectors at the bottom sample surface.
Create a detector at the bottom sample surface.
- class DetectorDefault(*args, **kwargs)[source]¶
Bases:
xopto.mcml.mcdetector.base.DetectorAny
Default / dummy detector for the top or bottom sample surface or for specular reflections.
Create a detector for any location.
- cl_declaration(mc: xopto.mcbase.mcobject.McObject) → str[source]¶
Structure that defines the default detector in the Monte Carlo simulator.
- cl_implementation(mc: xopto.mcbase.mcobject.McObject) → str[source]¶
OpenCL implementation of the default detector
- static cl_options(mc: xopto.mcbase.mcobject.McObject) → str[source]¶
- cl_pack(mc: xopto.mcbase.mcobject.McObject, target: Optional[xopto.cl.cltypes.Structure] = None) → xopto.cl.cltypes.Structure[source]¶
Fills the structure (target) with the data required by the Monte Carlo simulator. See the
DetectorDefault.cl_type()
method for a detailed list of fields.- Parameters
mc (mcobject.McObject) – Monte Carlo simulator instance.
target (cltypes.Structure) – Ctypes structure that is filled with the source data.
- Returns
target – Filled structure received as an input argument or a new instance if the input argument target is None.
- Return type
- cl_type(mc: xopto.mcbase.mcobject.McObject) → xopto.cl.cltypes.Structure[source]¶
Structure that is passed to the Monte carlo simulator kernel.
- Parameters
mc (McObject) – A Monte Carlo simulator instance.
- Returns
struct – A structure type that represents the detectors in the Monte Carlo kernel.
The returned structure type implements the following fields:
- dummy: mc_int_t
Dummy field of the dummy detector.
- Return type
- classmethod fromdict(data: dict) → xopto.mcml.mcdetector.base.DetectorDefault[source]¶
Create an instance of
DetectorDefault
from a dictionary.- Parameters
data (dict) – Dictionary created by the
DetectorDefault.todict()
method.
- class DetectorSpecular(*args, **kwargs)[source]¶
Bases:
xopto.mcml.mcdetector.base.DetectorBase
Base class of the detectors for specular reflections.
Create a detector for specular reflections.
- class DetectorTop(*args, **kwargs)[source]¶
Bases:
xopto.mcml.mcdetector.base.DetectorBase
Base class of detectors at the top sample surface.
Create a detector at the top sample surface.
- class Detectors(top: Optional[xopto.mcml.mcdetector.base.Detector] = None, bottom: Optional[xopto.mcml.mcdetector.base.Detector] = None, specular: Optional[xopto.mcml.mcdetector.base.Detector] = None)[source]¶
Bases:
xopto.mcbase.mcobject.McObject
Create an instance of simulator detectors.
- Parameters
top (DetectorBase or Detectors) – Detector at the top sample surface, None, or an existing Detectors instance. If an existing Detectors instance, a new copy will be made.
bottom (DetectorBase) – Detector at the bottom sample surface or None
specular (DetectorBase) – Detector of specular reflections or None.
- property bottom: xopto.mcml.mcdetector.base.Detector¶
Detector at the bottom sample surface.
- cl_declaration(mc: xopto.mcbase.mcobject.McObject) → str[source]¶
Declarations of detectors in OpenCL.
- cl_implementation(mc: xopto.mcbase.mcobject.McObject) → str[source]¶
Implementation of the detectors.
- cl_options(mc: xopto.mcbase.mcobject.McObject) → str[source]¶
Returns the OpenCL options of the detectors.
If the detectors for the top or bottom sample surface or the detector of specular reflection are specified, this function activates the corresponding OpenCL options that enable the corresponding surface detector, i.e. MC_USE_TOP_DETECTOR for the detector at the top sample surface, MC_USE_BOTTOM_DETECTOR for the detector at the bottom sample surface and MC_USE_SPECULAR_DETECTOR for detector of specular reflections.
- cl_pack(mc: xopto.mcbase.mcobject.McObject, target: Optional[xopto.cl.cltypes.Structure] = None) → xopto.cl.cltypes.Structure[source]¶
Fills the structure (target) with the data required by the Monte Carlo simulator. See the
Detectors.cl_type()
method for a detailed list of fields.- Parameters
mc (mcobject.McObject) – Monte Carlo simulator instance.
target (cltypes.Structure) – Ctypes structure that is filled with the source data.
- Returns
target – Filled structure received as an input argument or a new instance if the input argument target is None.
- Return type
- cl_type(mc: xopto.mcbase.mcobject.McObject) → xopto.cl.cltypes.Structure[source]¶
Structure that is passed to the Monte carlo simulator kernel.
- Parameters
mc (McObject) – A Monte Carlo simulator instance.
- Returns
struct – A structure type that represents surface detectors in the Monte Carlo kernel.
The returned structure type implements the following fields:
- top: cltypes.Structure
Detector at the top sample surface.
- bottom: cltypes.Structure
Detector at the top sample surface.
- specular: cltypes.Structure
Detector of specular reflections.
- Return type
- property specular: xopto.mcml.mcdetector.base.Detector¶
Detector of specular reflections.
- property top: xopto.mcml.mcdetector.base.Detector¶
Detector at the top sample surface.
- update_data(mc: xopto.mcbase.mcobject.McObject, detector: xopto.mcml.mcdetector.base.Detector, data: Dict[numpy.dtype, List[numpy.ndarray]], nphotons: int = 0)[source]¶
Update the detector data with simulation results.
- Parameters
mc (mcobject.McObject) – Simulator instance that produced the results.
detector (Detector or str) – Detector or location to update.
data (Dict[np.dtype: List[np.ndarray]]) – A dict of list of numpy data buffers downloaded from the kernel.
nphotons (int) – The number of photon packets that produced the results.