Skip to content

Add scalar dot gradient#1500

Open
rajeeja wants to merge 7 commits into
mainfrom
rajeeja/scalardotgradient_539
Open

Add scalar dot gradient#1500
rajeeja wants to merge 7 commits into
mainfrom
rajeeja/scalardotgradient_539

Conversation

@rajeeja
Copy link
Copy Markdown
Contributor

@rajeeja rajeeja commented Apr 28, 2026

Adds UxDataArray.scalardotgradient for computing the dot product between a vector field and scalar-field gradient. Closes #539.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new vector-calculus helper on UxDataArray to compute the dot product between a (u, v) vector field and the gradient of a scalar field q, addressing issue #539.

Changes:

  • Implement UxDataArray.scalardotgradient(v, q) to compute u * dq/dx + v * dq/dy for 1D face-centered fields with validation.
  • Add tests that (a) verify the dot product uses the expected gradient components and (b) rejects misaligned face indexes (no silent realignment).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
uxarray/core/dataarray.py Adds the scalardotgradient method with input validation, alignment, and output metadata.
test/core/test_vector_calculus.py Adds MPAS-Ocean-focused tests for scalardotgradient, including a mocked-gradient correctness test and a misalignment error test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uxarray/core/dataarray.py Outdated
Copy link
Copy Markdown
Member

@erogluorhan erogluorhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great; can you add a quick example of it into the Vector Calculus user guide, then we can get it merged. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dot Product between a Vector Field and Scalar Field

3 participants