MedianComputer

class stcal.outlier_detection.median.MedianComputer(full_shape: tuple, in_memory: bool, buffer_size: int | None = None, dtype: str | dtype = 'float32', tempdir: str = '')[source]

Bases: object

Class to efficiently compute a median.

Top-level class to treat median computation uniformly, whether in memory or on disk.

Initialize MedianComputer.

Parameters:
  • full_shape – The shape of the full input dataset.

  • in_memory – Whether to perform the median computation in memory or using temporary files on disk to save memory.

  • buffer_size – The buffer size for the median computation, units of bytes. Has no effect if in_memory is True.

  • dtype – The data type of the input data.

  • tempdir – The parent directory in which to create the temporary directory. Default is the current working directory.

Methods Summary

append(data[, idx])

Append data to the median computer.

evaluate()

Compute the median data from the input data.

Methods Documentation

append(data: ndarray, idx: int | None = None) None[source]

Append data to the median computer.

Parameters:
  • data – The data to append to the median computer. Must have shape full_shape[1:].

  • idx – The index at which to append the data. Must be between 0 and full_shape[0]. Required if using in-memory median computation.

evaluate() ndarray[source]

Compute the median data from the input data.

Returns:

The median data computed from the input data.

Return type:

np.ndarray