rescaledata#

torchspin.rescaledata(y, yref=None, mode='maxabs', region=None)[source]#

Rescale a data vector.

Parameters:
  • y (array_like) – 1-D data to rescale.

  • yref (array_like, optional) – Reference vector. Required for mode='lsq'. If length differs from y, it is resampled via linear interpolation.

  • mode (str, optional) –

    Scaling mode:

    • 'maxabs' — scale so that max(abs(y)) = 1 (or max(abs(yref)) if given)

    • 'lsq' — least-squares scale: a·y ≈ yref; requires yref

    • 'int' — normalize sum to 1

    • 'dint' — normalize double integral (cumsum sum) to 1

    • 'none' — no scaling (returns copy)

    Default 'maxabs'.

  • region (array_like of bool, optional) – Mask selecting points to include in the scale computation.

Returns:

  • yscaled (ndarray) – Rescaled data.

  • scale (float) – Scaling factor applied (yscaled = y * scale).