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

class cana.util.Parameter(value, uncertainty)[source]

Methods

to_csv  
to_latex  
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

cana.util.get_truncated_normal(mean=0, sd=1, low=0, upp=10)[source]

Return truncaded normal.

cana.util.kwargupdate(defaults, options)[source]

Modify or extend a kwarg dict.

Parameters:
defauts: dict

The dictionary containing the default values

options: dict

The dictionary containing the modified or new values

Returns:
A merged kwarg dictionary
cana.util.verboseprint(text, underline=False, bold=False)[source]

Adjust the style of the print.