Array Tools

Here we group some array tools that we use in the project.

copyright:by Hyperion Authors, see AUTHORS for more details.
license:BSD, see LICENSE for more details.
hyperion.tools.array_tools.array_from_pint_quantities(start, stop, step=None, num=None)

Generates an array from pint values. Use either step or num to divide the range up in steps. (If both are specified, step is used) Using num works similar to numpy.linspace(start, stop, num). Using step works somewhat similar numpy.arange(start, stop, step). Modifications are that the sign of step will be interpreted automatically. And the issue of a missing endpoint due to tiny floating point errors is mitigated. It returns a numpy array and the pint unit.

Parameters:
  • start (pint.quantity) – The start value of the array
  • stop (pint.quantity) – The end value for determining the array
  • step (pint.quantity) – The stepsize between points
  • num (int) – Number of points generate
Returns:

a, b

Return type:

(numpy.array, pint.unit)

hyperion.tools.array_tools.array_from_settings_dict(sweep_dict)

Wrapper around array_from_string_quantities(). sweep_dict should contain ‘start’ and ‘stop’ key. And either ‘step’ or ‘num’ key. The values may have units (that can be interpreted by pint). See array_from_string_quantities() and array_from_pint_quantities() for further details.

Parameters:sweep_dict – Dictionary containing start, stop and step or num keys
Returns:(numpy.array, pint.unit)
hyperion.tools.array_tools.array_from_string_quantities(start, stop, step=None, num=None)

Wrapper around array_from_pint_quantities() that converts string arguments to pint quantities. Arguments start, stop and step should be strings, num could be integer (or string of integer). See array_from_pint_quantities() for further details.