gradient

PlasmaCalcs.quantities.patterns.vector_derivatives.gradient(array, components=[Component('x', 0), Component('y', 1), Component('z', 2)], *, _post_slices=None)

return gradient of array as a single vector array.

The result will have ‘components’ dimension.
components: iterable of str or Component objects
which components to include in the result.
result[‘component’][i] will be components[i],
and result.isel(component=j) will be the derivative along str(components[j]).
E.g., if components=[Component(‘x’, 0), Component(‘y’, 1)],
then result[‘component’][1] == Component(‘y’, 1),
and result.isel(component=1) = d(array)/dy.
The derivative is taken along the corresponding dimension,
e.g. d(array)/dy is xarray_differentiate(array, dim=’y’).
Note that any components provided here but missing from array will become 0 in result.
e.g., components=[x,y,z] but ‘z’ not in array –>
np.all(result.isel(component=2) == 0).
_post_slices: None or dict of indexers
[EFF] if provided, apply these indexers to results after taking each derivative,
but before merging into the final array.
Equivalently, could just result.isel(**_post_slices).
But, indexing before merging can help avoid ever creating a large array.