Model Utils API¶
-
pymoc.utils.
check_numpy_version
()¶ Check whether your system is using a numpy version of at least 1.13, required for some modules for gradient calculations.
- Returns
is_sufficient – True if numpy version >= 1.13, False otherwise.
- Return type
logical
-
pymoc.utils.
gridit
(x1, x2, f)¶ Generate a gridded dataset, based on a function in x1 and x2.
- Parameters
x1 (ndarray) – Grid points in the first dimension along which values are to be calculated.
x2 (ndarray) – Grid points in the second dimension along which values are to be calculated.
f (function) – A function in dimensions x1 and x2, that returns a single value for each pair of coordinate values.
- Returns
gridded – A 2D array of shape
(len(x1), len(x2))()
, where each pointgridded[i, j] = f(x1[i], x2[j])()
.- Return type
ndarray
-
pymoc.utils.
make_array
(myst, axis, name)¶ Make an argument of unknown type into an array if needed, along the specified array.
- Parameters
myst (float, function, or ndarray) – The argument to be transformed. Either a single numerical value, a function in a single dimension, or an array.
axis (ndarray) – Grid points in the direction along which the array is to be created.
name (string) – Name of the variable being transformed into an array.
- Returns
made_array – An array representing the data in myst, along axis:
If myst is an ndarray, simply returns myst.
If myst is a float, returns an array of length
len(axis)()
where each row contains the value of myst.If myst is a function, returns an array of length
len(axis)()
where each row contains the valuemade_array[i]=myst(axis[i])()
.
- Return type
ndarray
-
pymoc.utils.
make_func
(myst, axis, name)¶ Make an argument of unknown type into a function if needed, in the dimension of the specified array.
- Parameters
myst (float, function, or ndarray) – The argument to be transformed. Either a single numerical value, a function in a single dimension, or an array.
axis (ndarray) – Grid points in the direction along which the function is to operate. If myst is an array, axis should be of the same length.
name (string) – Name of the variable being transformed into a function.
- Returns
made_func – An function representing the data in myst, along axis:
If myst is a funcion, simply returns myst.
If myst is a float, returns a function that returns the value of myst.
If myst is an array, returns an function that operates along the same dimension as axis, which returns the value
made_func(axis[i])=myst[i]()
, and interpolates values between points in axis.
- Return type
ndarray