Curve¶
The Curve class definition.
-
class
Curve
(x, y, check_fxn=None)¶ Bases:
object
Base class for handling sets of x, y coordinates.
Variables: - _x (ndarray) – 1D array of x coordinates defining the curve. These should, in general, not be accessed directly.
- _y (ndarray) – Same as _x but for the y coordinates of the curve.
-
__init__
(x, y, check_fxn=None)¶ Initialize a curve object from x, y coordinates.
Parameters: x, y (iterable) – Iterables of the same size defining the curve’s x and y coordinates.
check_fxn (function, optional) – Function that takes an x, y pair, and checks if they are valid.
If they are valid the function returns None otherwise raises a ValueError, default is None meaning no function is used to check the x and y values.
Returns: Curve – Instantiated Curve object.
Raises: IndexError
– If x and y do not have the same length.ValueError
– If check_fxn is defined and any x, y pair fails to meet the defined criteria.
-
classmethod
check_input
(x, y, check_fxn=None)¶ Check inputs comply with the required formatting.
-
static
check_types
(x, y)¶ Check type of x and y
- Specifically:
- Cast x and y to ndarray of type double.
- Check x and y have the same length.
-
static
check_values
(x, y, check_fxn)¶ Apply custom checking function on the values of x and y.
Parameters: - x, y (iterable) – x and y value of curve respectively.
- check_fxn (function) – Function that takes an x, y pair, checks if they are valid. If they are valid the function returns None otherwise raises a ValueError.
Returns: None – If x and y pass
Raises: ValueError
– If x and y fail.
-
resample
(xx, inplace=False, interp1d_kwargs=None, res_fxn=None)¶ Resample Curve at select x values.
Parameters: - xx (ndarray) – 1D array containing the locations in terms of x, of the desired interpolated y values.
- inplace (bool, optional) – Indicates whether resampling should be done in-place. If inplace the, attributes _x and _y are overwritten. Otherwise the new values are returned, default is False resampling is not done inplace.
- interp1d_settings (dict, optional) – Settings for use with the interp1d function from scipy. See documentation here for details.
- res_fxn (function, optional) – Define a custom resampling function. It should accept an ndarray of resampling x-coordinates and return the interpolated y-coordinates as an ndarray.
Returns: None or (xx, yy) – None, if inplace=True; _x and _y will be updated. (xx, yy) if inplace=False.
-
classmethod
resample_function
(x, y, **kwargs)¶ Wrapper for interp1d from scipy.