Currently, UxDataArray's gradient(), curl(), and divergence() methods all require the input array to be 1D (along one of the GRID_DIMS, i.e. n_face, n_edge, or n_node). There does not seem to be any compelling reason to keep this restriction. It should be perfectly reasonable to apply calculus operations along grid dimensions while keeping all other dimensions untouched.
Example:
import uxarray as ux
import xarray as xr
arrA = ux.tutorial.open_dataset('outCSne30-vortex')['psi']
resultA = arrA.gradient()
arrB = arrA * xr.DataArray([1,2,3], dims=['extra_dim'])
resultB = arrB.gradient()
# crashes with DimensionError: Gradient currently requires 1D face-centered data....
I would have expected resultB to be a UxDataArray equivalent to stacking the arrays 1 * resultA, 2 * resultA, 3 * resultA along the "extra_dim" dimension, instead of a crash.
For more details/discussion, see #1461 (comment)
Currently, UxDataArray's gradient(), curl(), and divergence() methods all require the input array to be 1D (along one of the GRID_DIMS, i.e. n_face, n_edge, or n_node). There does not seem to be any compelling reason to keep this restriction. It should be perfectly reasonable to apply calculus operations along grid dimensions while keeping all other dimensions untouched.
Example:
I would have expected resultB to be a UxDataArray equivalent to stacking the arrays
1 * resultA,2 * resultA,3 * resultAalong the "extra_dim" dimension, instead of a crash.For more details/discussion, see #1461 (comment)