Skip to content

Creates UxDataArray.laplacian() - #1873

Draft
Sevans711 wants to merge 6 commits into
mainfrom
sevans/laplacian
Draft

Sevans711 wants to merge 6 commits into
mainfrom
sevans/laplacian

Conversation

@Sevans711

Copy link
Copy Markdown
Collaborator

Closes #538

Overview

Creates UxDataArray.laplacian(), as requested by #538. Currently only supports Laplacian of a scalar field. The Laplacian is the divergence of the gradient, laplacian(q) == div(grad(q)).

Very intentionally put * before the scale_by_radius kwarg here to ensure nobody starts writing arr.laplacian(True) or arr.laplacian(False); see also #1573. Importantly, this also leaves room for later adding a "Laplacian of a vector field" feature like arr.laplacian(other), without needing any deprecation cycle first.

Draft PR; still need to do the following:

  • More comprehensive tests, including actually testing correctness of numerical results.
  • Update vector_calculus.ipynb notebook to demonstrate this feature.

Small expansion of scope:

  • Vector calculus docs page fix: Laplacian formula in a comment was missing the metric term. That cell was computing the Laplacian from div and grad operators directly, so the numerical values did already include the metric term, only the commented formula was incorrect.

Expected Usage

import uxarray as ux

grid_path = "/path/to/grid.nc"
data_path = "/path/to/data.nc"

uxds = ux.open_dataset(grid_path, data_path)

# result is a UxDataArray telling the Laplacian
result = uxds["var"].laplacian()

PR Checklist

General

  • An issue is created and linked
  • Added appropriate labels (if your uxarray repo permissions allow it)
  • Filled out Overview and Expected Usage (if applicable) sections

Testing & Benchmarking

  • There is adequate test coverage of changes from this PR (add new tests if needed)
  • [N/A] If this PR could affect performance, ran ASV benchmarks and confirmed they show expected behavior (add a new benchmark if necessary)

Documentation and Examples

  • Docstrings updated with any function changes, and included in all new functions
  • User (public) functions added to docs/api.rst; internal (private) function names start with an underscore (_)
  • If touched any notebook files, cleared the output of all cells before committing
  • [N/A] If added new notebook files, put into appropriate directories and referenced in appropriate files

AI Disclosure

AI Usage: GitHub Copilot's inline code suggestions, some Claude

  • I have tested and take responsibility for all AI-generated content in my PR.

@Sevans711 Sevans711 added the new feature New user-facing functionality label Nov 2, 2026
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

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

Labels

new feature New user-facing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Laplacian of a Scalar Field

1 participant