Skip to content

Calculus methods shouldn't require 1D #1723

Description

@Sevans711

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingextra dimsHandling of non-grid dimensions, such as time or altitudeimprovementImprovements on existing features or infrastructure

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions