xopto.mccyl.mcdetector.base module

class Detector(raw_data: numpy.ndarray, nphotons: int)[source]

Bases: xopto.mccyl.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.

set_raw_data(data: numpy.ndarray, nphotons: int)[source]
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.mccyl.mcdetector.base.DetectorBase

Base class of the detectors at the outer 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 (OUTER or SPECULAR) – Location of the detector.

property location: str

Location of the detector.

class DetectorDefault(*args, **kwargs)[source]

Bases: xopto.mccyl.mcdetector.base.DetectorAny

Default / dummy detector for the outer 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
Returns

target – Filled structure received as an input argument or a new instance if the input argument target is None.

Return type

cltypes.Structure

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

cltypes.Structure

classmethod fromdict(data: dict)xopto.mccyl.mcdetector.base.DetectorDefault[source]

Create an instance of DetectorDefault from a dictionary.

Parameters

data (dict) – Dictionary created by the DetectorDefault.todict() method.

todict()dict[source]

Export object to dict.

class DetectorOuter(*args, **kwargs)[source]

Bases: xopto.mccyl.mcdetector.base.DetectorBase

Base class of detectors at the outer sample surface.

Create a detector at the outer sample surface.

class DetectorSpecular(*args, **kwargs)[source]

Bases: xopto.mccyl.mcdetector.base.DetectorBase

Base class of the detectors for specular reflections.

Create a detector for specular reflections.

class Detectors(outer: Optional[xopto.mccyl.mcdetector.base.Detector] = None, specular: Optional[xopto.mccyl.mcdetector.base.Detector] = None)[source]

Bases: xopto.mcbase.mcobject.McObject

Create an instance of simulator detectors.

Parameters
  • outer (DetectorBase or Detectors) – Detector at the outer sample surface, None, or an existing Detectors instance. If an existing Detectors instance, a new copy will be made.

  • specular (DetectorBase) – Detector of specular reflections or None.

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 detector for the outer sample surface or the detector of specular reflection are specified, this function activates the OpenCL options that enable the corresponding outer surface detector, i.e. MC_USE_OUTER_DETECTOR for the detector at the outer 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
Returns

target – Filled structure received as an input argument or a new instance if the input argument target is None.

Return type

cltypes.Structure

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:

  • outer: cltypes.Structure

    Detector at the outer sample surface.

  • specular: cltypes.Structure

    Detector of specular reflections.

Return type

cltypes.Structure

property outer: xopto.mccyl.mcdetector.base.Detector

Detector at the outer sample surface.

property specular: xopto.mccyl.mcdetector.base.Detector

Detector of specular reflections.

todict()dict[source]

Export object to dict.

types()tuple[source]

Returns a tuple of detector types assigned to this instance.

update_data(mc: xopto.mcbase.mcobject.McObject, detector: xopto.mccyl.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.