Skip to content

Scale gradient and curl by sphere radius#1517

Open
rajeeja wants to merge 2 commits into
mainfrom
rajeeja/scale-gradient-curl-radius
Open

Scale gradient and curl by sphere radius#1517
rajeeja wants to merge 2 commits into
mainfrom
rajeeja/scale-gradient-curl-radius

Conversation

@rajeeja
Copy link
Copy Markdown
Contributor

@rajeeja rajeeja commented May 29, 2026

Summary

  • scale gradient() and curl() by uxgrid.sphere_radius by default
  • add scale_by_radius=False for unit-sphere derivatives

Closes #1516

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

This PR updates UXarray’s vector calculus API so gradient() and curl() return physically-scaled derivatives by default (using uxgrid.sphere_radius), while still allowing unit-sphere derivatives via scale_by_radius=False.

Changes:

  • Add scale_by_radius parameter (default True) to UxDataArray.gradient() and UxDataArray.curl().
  • Apply 1/radius scaling inside the shared _compute_gradient() implementation.
  • Update and add tests to validate both unit-sphere and radius-scaled behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
uxarray/core/gradient.py Adds optional scaling by uxgrid.sphere_radius to gradient computation.
uxarray/core/dataarray.py Exposes scale_by_radius in public gradient()/curl() APIs and forwards it into _compute_gradient().
test/core/test_vector_calculus.py Updates existing gradient tests to use unit-sphere behavior and adds new scaling-by-radius assertions for gradient/curl.

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

Comment thread test/core/test_vector_calculus.py
Comment thread test/core/test_vector_calculus.py
Comment thread test/core/test_vector_calculus.py Outdated
Comment thread uxarray/core/dataarray.py
Comment thread uxarray/core/dataarray.py Outdated
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.

Scale gradient and curl by grid sphere radius

2 participants