Ingredient Class
Class to represent an ingredient.
- class ingredient.Ingredient(func, label, error_func=None, error_func_kwargs={'scale': 2}, **kwargs)
Functional representation of data (signal or noise) to be created
- func
Functional representation of data to be created
- Type
function
- label
Name or short description of ingredient
- Type
str
- eval(x, yerr=None, ignore_errors=False)
Evaluate ingredient
Evaluate the ingredient function at specified point(s)
- Parameters
x (
array) – numpy array or list of floats or ints. Grid on which to evaluate the ingredient function.yerr (
array, optional) – numpy array or list of floats or ints, representing the error bar at each point in the x grid. Overrides the err_func. Must have the same dimensions as x.ignore_errors (
bool, optional) – if True, will evaluate without y errors
- Returns
- an array of the y values evaluated from the x grid.
If an error_func or yerr was provided, y will be a unumpy.uarray object, containing information for both the y value and its associated errorbar.
- Return type
y (
arrayoruarray)
- generate_errors(x, error_func)
Generates y errors.
Evaluate the ingredient function at specified point(s)
- Parameters
x (
array) – numpy array or list of floats or ints. Grid on which to evaluate the ingredient function.error_func (
function) – function that generates an array of error values if given an x array
- plot(x, marker='.')
Evaluate and plot ingredient
Evaluate the ingredient function at specified point(s) and plot result of evaluation versus respective point(s)
- Parameters
x (
array) – numpy array or list of floats or ints. Grid on which to evaluate the ingredient function and plot against.