xopto.mcbase.mcsv module

class SamplingVolume(xaxis: xopto.mcbase.mcutil.axis.Axis, yaxis: Optional[xopto.mcbase.mcutil.axis.Axis] = None, zaxis: Optional[xopto.mcbase.mcutil.axis.Axis] = None)[source]

Bases: xopto.mcbase.mcobject.McObject

Sampling volume object constructor. Default constructor disables the functionality by creating a zero-size accumulator array.

Parameters
  • xaxis (Axis or SamplingVolume) – Axis that defines accumulators along the x axis. If a SamplingVolume instance, a new copy is created.

  • yaxis (Axis) – Axis that defines accumulators along the y axis.

  • zaxis (Axis) – Axis that defines accumulators along the z axis.

Note

Sampling volume accumulator buffer data type is inherited from the Monte Carlo simulator mc_accu_t type.

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 SamplingVolume.cl_type() for a detailed list of fields.

Parameters
  • mc (mcobject.McObject) – Monte Carlo simulator instance.

  • target (ClSamplingVolume) – Structure that is filled with the source data.

  • buffer (np.ndarray) – Accumulator buffer or None. Should be checked for proper size. Use xopto.mcml.Mc.types.np_accu method to determine the numpy type of the accumulator used in the Monte Carlo simulator.

Returns

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

Return type

ClSamplingVolume

static cl_type(mc: xopto.mcbase.mcobject.McObject)xopto.cl.cltypes.Structure[source]
clear()[source]

Clear the data buffer (fill with 0) if one exists.

property data: numpy.ndarray

Raw sampling volume accumulator data if any.

classmethod fromdict(data)xopto.mcbase.mcsv.SamplingVolume[source]

Create a new instance of SamplingVolume from dict data exported by the todict() method.

Parameters

data (dict) – Instance data exported to a dict.

Returns

sv – A new SamplingVolume instance initialized with the data.

Return type

SamplingVolume

property k: int

Samping volume floating point to accumulator integer conversion coefficient.

plot(scale: str = 'log', axis: str = 'z', autoscale: bool = True, show: bool = True)[source]

Show sampling volume slices or integral projections.

Parameters
  • scale (str) – Data scaling can be “log” for logarithmic or “lin” for linear.

  • axis (str) – The axis of slicing (“x”, “y” or “z”) or a projection along the selected coordinate axis (“xproj”, “yproj”, “zproj”). Alternatively, specify the projection plane as one of (“xy”, “xz”, or “yz”).

  • autoscale (bool) – Scale the color coding of individual slices to the corresponding range of weights. If True, the color coding changes from slice to slice.

  • show (bool) –

property shape: Tuple[int, int, int]

Sampling volume array shape.

todict()dict[source]

Save the sampling volume configuration without the accumulator data to a dictionary.

Returns

data – Sampling volume configuration as a dictionary.

Return type

dict

update_data(mc: xopto.mcbase.mcobject.McObject, accumulators: List[numpy.ndarray], total_weight: int, **kwargs)[source]

Update the sampling volume accumulator data 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).

  • total_weight (int) – Total detected weight of the processed photon packets in integer units.

  • kwargs (dict) – Additional keyword arguments not used by this implementation.

property weight: float

Total weight of the accumulated photon packets.

property x: numpy.ndarray

Accumulator centers along the x axis.

property xaxis: xopto.mcbase.mcutil.axis.Axis

Accumulator axis object along the x axis.

property y: numpy.ndarray

Accumulator centers along the y axis.

property yaxis: xopto.mcbase.mcutil.axis.Axis

Accumulator axis object along the y axis.

property z: numpy.ndarray

Accumulator centers along the z axis.

property zaxis: xopto.mcbase.mcutil.axis.Axis

Accumulator axis object along the z axis.