xopto.mcml.mclayer.layer module¶
- class Layer(d: float, n: float, mua: float, mus: float, pf: xopto.mcbase.mcpf.pfbase.PfBase)[source]¶
Bases:
xopto.mcbase.mcobject.McObject
Class that represents a single sample layer.
Layer object constructor.
- Parameters
d (float) – Layer thickness (m).
n (float) – Index of refraction.
mua (float) – Absorption coefficient (1/m).
mus (float) – Scattering (NOT reduced) coefficient (1/m).
pf (mcpf.PfBase) – Scattering phase function object that is derived from PhBase class.
The physical properties of the layer can be read or changed through member properties:
d: float - Layer thickness (m).
n: float - Index of refraction.
mua: float - Absorption coefficient (1/m).
mus: float - Scattering (NOT reduced) coefficient (1/m).
pf: mcpf.PfBase - Scattering phase function object that is derived from PhBase class.
Note
The layer boundaries in the z direction are increasing in the direction of the layer stack. Z coordinate 0.0 belongs to the top surface of the first sample layer!
- static cl_declaration(mc: xopto.mcbase.mcobject.McObject) → str[source]¶
Structure and related API that defines a layer in the Monte Carlo simulator.
- cl_type(mc: xopto.mcbase.mcobject.McObject) → xopto.cl.cltypes.Structure[source]¶
Returns a structure data type that is used to represent one Layer instance in the OpenCL kernel of the Monte Carlo simulator.
- Parameters
mc (mcobject.McObject) – Monte Carlo simulator instance.
- Returns
opencl_t – OpenCL Structure that represents a layer.
- Return type
ClLayer
- property d: float¶
Layer thickens (m).
- classmethod fromdict(data: dict) → xopto.mcml.mclayer.layer.Layer[source]¶
Create a new object from dict. The dict keys must match the parameter names defined by the constructor.
- property mua: float¶
Absorption coefficient of the layer (1/m).
- property mus: float¶
Scattering coefficient of the layer (1/m).
- property n: float¶
Refractive index of the layer.
- property pf: xopto.mcbase.mcpf.pfbase.PfBase¶
Phase function object.
- class Layers(layers: List[xopto.mcml.mclayer.layer.Layer])[source]¶
Bases:
xopto.mcbase.mcobject.McObject
Class that represents a stack of layers forming the sample.
Note
The topmost and bottommost layers of the stack are used to describe the medium that surrounds the sample top and bottom surfaces, respectively. Therefore, at least three layers must be always specified, namely two layers of the surrounding medium and one sample layer! The thicknesses of the topmost and bottommost layers will be automatically set to infinity regardless of the layer thickness set by the user.
Constructs a managed sample layer stack from a list of sample layers.
Note
The topmost and bottommost layers of the stack are used to describe the medium that surrounds the sample top and bottom surfaces, respectively. Therefore, at least three layers must be always specified, namely two layers of the surrounding medium and one sample layer!
The bottom surface of the topmost layer (the surrounding medium) is located at z=0. The positive direction of the z axis points in the direction of the layer stack.
The thicknesses of the topmost and bottommost layers will be automatically set to infinity when passed to the OpenCL kernel (regardless of the layer thickness set by the user).
Note that all layers must use the same scattering phase function model.
- Parameters
layers (list or Layers) – A list of sample layers. Requires at least 3 items!
- check()[source]¶
Check if the layers are consistent and using a single scattering phase function type. Raises exception on error.
- cl_pack(mc: xopto.mcbase.mcobject.McObject, target: Optional[_ctypes.Array] = None) → _ctypes.Array[source]¶
Pack the layers into an OpenCL data type. The OpenCL data type is returned by the
Layers.cl_type()
method.- Parameters
mc (mcobject.McObject) – Monte Carlo simulator instance.
target (cltypes.Structure*len(self)) – A structure representing an array of Layers.
- 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) → _ctypes.Array[source]¶
Returns an OpenCL array of ClLayer structures that is used to represent one instance of a layer stack.
- Parameters
mc (mcobject.McObject) – Monte Carlo simulator instance.
- Returns
clarray – Array of ClLayers.
- Return type
cltypes.Structure*len(self)
- classmethod fromdict(data: dict) → xopto.mcml.mclayer.layer.Layers[source]¶
Create a new Layers object from a dict. The dict keys must match the parameter names defined by the constructor.
- layer(index: int) → xopto.mcml.mclayer.layer.Layer[source]¶
Returns layer at the specified index. Note that the first layer (index 0) and the last layer (index -1) represent the medium surrounding the top and bottom surfaces of the sample, respectively
- layer_index(z: float) → int[source]¶
Returns the layer index that contains the given z coordinate. Note that the layer includes the top surface boundary but not the bottom surface boundary, i.e. the z extent of the layer is [z_top, z_bottom), where z_bottom > z_top.
- Parameters
z (float) – Z coordinate of a point.
- Returns
layer_index – Index of the layer that contains the give point z.
- Return type
int
- thickness() → float[source]¶
Thickness of the layer stack excluding the topmost and bottommost layers that surround the sample.
- Returns
thickness – The sample thickness excluding the topmost and bottommost layers of the surrounding medium.
- Return type
float
- tolist() → List[xopto.mcml.mclayer.layer.Layer][source]¶
Returns a weak copy of the list of managed layers.
- Returns
layers – List of managed layers
- Return type
List[layers]