pingwyn.bin

pingwyn.bin(obj, bins=1, keep_dims=True, method='mean')

Bin an object by combining datapoints.

Parameters:
  • obj (pingwyn.Curve or pingwyn.Grid or pingwyn.Image or pingwyn.Profile) – The object to bin.

  • bins (int or tuple/list of ints) –

    The number of elements to bin together. If a single integer is provided, the data will be binned based on the object type and a strategy explained below. If bins is an iterable of integers, each integer corresponds to the number of bins to combine per axis. In this case, len(bins) == len(obj.shape) must hold.

    If there are not enough datapoints to bin together (i.e. when obj.shape[i] % bins[i] != 0 for axis i), the remaining unbinnable datapoints are discarded. Note: this will overrule keep_dims=True in a way that the dimensions of the returned object might be close, but not equal, to the dimensions of the input object.

    Binning strategies for single integers: - pingwyn.Curve: the curve datapoints (axis 1) will be binned. - pingwyn.Grid: the datapoints making up the individual curves (axis 2) will be binned. - pingwyn.Image: both axes will be binned equally. - pingwyn.Profile: multiple curves (axis 0) will be binned together.

  • keep_dims (bool, optional) – If set to True, will ensure that the object shape does not change. If false, the no. of bins will determine the new shape of the returned object. Default: True.

  • method (str, optional) – Method of combining the datapoints. Can be “mean” or “median”. Default: “mean”.

Returns:

An object with the same type as obj, with datapoints binned together.

Return type:

pingwyn.Curve or pingwyn.Grid or pingwyn.Image or pingwyn.Profile