statistics: Statistics

A module for performing basic statistical analysis (min, max, mean, std) on large data where numpy is not very efficient.

class Statistics(size=None, dtype=None, template=None, ctx=None, devicetype='all', platformid=None, deviceid=None, block_size=None, profile=False)[source]

Bases: silx.opencl.processing.OpenclProcessing

A class for doing statistical analysis using OpenCL

Parameters
  • size (List[int]) – Shape of input data to treat

  • dtype (numpy.dtype) – Input data type

  • template (numpy.ndarray) – Data template to extract size & dtype

  • ctx – Actual working context, left to None for automatic initialization from device type or platformid/deviceid

  • devicetype (str) – Type of device, can be “CPU”, “GPU”, “ACC” or “ALL”

  • platformid (int) – Platform identifier as given by clinfo

  • deviceid (int) – Device identifier as given by clinfo

  • block_size (int) – Preferred workgroup size, may vary depending on the outcome of the compilation

  • profile (bool) – Switch on profiling to be able to profile at the kernel level, store profiling elements (makes code slightly slower)

kernel_files = ['preprocess.cl']
mapping = {<class 'numpy.int8'>: 's8_to_float', <class 'numpy.uint8'>: 'u8_to_float', <class 'numpy.int16'>: 's16_to_float', <class 'numpy.uint16'>: 'u16_to_float', <class 'numpy.uint32'>: 'u32_to_float', <class 'numpy.int32'>: 's32_to_float'}
buffers = [BufferDescription(name='raw', size=1, dtype=<class 'numpy.float32'>, flags=4), BufferDescription(name='converted', size=1, dtype=<class 'numpy.float32'>, flags=1)]
set_kernel_arguments()[source]

Parametrize all kernel arguments

compile_kernels()[source]

Compile the kernel

send_buffer(data, dest)[source]

Send a numpy array to the device, including the cast on the device if possible

Parameters
  • data (numpy.ndarray) – numpy array with data

  • dest – name of the buffer as registered in the class

process(data, comp=True)[source]

Actually calculate the statics on the data

Parameters
  • data (numpy.ndarray) – numpy array with the image

  • comp – use Kahan compensated arithmetics for the calculation

Returns

Statistics named tuple

Return type

StatResults