cana.util¶
Utility functions.
Functions
curvature(func, x[, ftype, order]) |
Measure the curvature of a function. |
find_nearest(array, value) |
Find nearest value in array. |
get_truncated_normal([mean, sd, low, upp]) |
Return truncaded normal. |
kwargupdate(defaults, options) |
Modify or extend a kwarg dict. |
verboseprint(text[, underline, bold]) |
Adjust the style of the print. |
Classes
Parameter(value, uncertainty) |
Methods |
-
cana.util.curvature(func, x, ftype='polynomial', order=4)[source]¶ Measure the curvature of a function.
Parameters: - func: coefcients, spline or function
The function for deriving the curvature. F(x)
- x:
The x axis for the F(x) function.
- ftype: string
‘polynomial’: func is the polynomial coefcients arrays ‘spline’: func is a scipy.UnivariateSpline object ‘analytical’: a self defined function
- order: int (optional)
The order for fitting the analytical function. Only used if ftype=’analytical’
Returns: - The curvature array
-
cana.util.find_nearest(array, value)[source]¶ Find nearest value in array.
Parameters: - array : 1D float numpy array
Array for the search
- value: float
Value to be searched
Returns: - idx , array[idx]: int, float
Index and value of nearest point