Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized Non-Conservative Zonal Average #1180

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

hongyuchen1030
Copy link
Contributor

@hongyuchen1030 hongyuchen1030 commented Mar 12, 2025

Closes #1181 #880

Overview

  • Introduce specialized helper functions for the optimized non-conservative zonal average routine in zonal.py
  • Implement caching and reuse of intermediary computational steps to reduce redundant recalculations
  • Retain the general-purpose helper functions (which use data copying) for broader usability
  • Improve overall performance of the zonal averaging computation

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)

# this is how you use this function
some_output = uxds.some_function()

# this is another way to use this function
other_output = uxds.some_function(some_param = True)

PR Checklist

General

  • An issue is linked created and linked
  • Add appropriate labels
  • Filled out Overview and Expected Usage (if applicable) sections

Testing

  • Adequate tests are created if there is new functionality
  • Tests cover all possible logical paths in your function
  • Tests are not too basic (such as simply calling a function and nothing else)

Documentation

  • Docstrings have been added to all new functions
  • Docstrings have updated with any function changes
  • Internal functions have a preceding underscore (_) and have been added to docs/internal_api/index.rst
  • User functions have been added to docs/user_api/index.rst

Examples

  • Any new notebook examples added to docs/examples/ folder
  • Clear the output of all cells before committing
  • New notebook files added to docs/examples.rst toctree
  • New notebook files added to new entry in docs/gallery.yml with appropriate thumbnail photo in docs/_static/thumbnails/

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@hongyuchen1030 hongyuchen1030 self-assigned this Mar 12, 2025
@hongyuchen1030 hongyuchen1030 marked this pull request as draft March 12, 2025 02:03
@hongyuchen1030 hongyuchen1030 linked an issue Mar 12, 2025 that may be closed by this pull request
6 tasks
@hongyuchen1030 hongyuchen1030 changed the title initial commit Optimized Non-Conservative Zonal Average Mar 12, 2025
…rties to grid
@hongyuchen1030 hongyuchen1030 marked this pull request as ready for review March 14, 2025 05:10
@@ -1407,25 +1466,14 @@ def _populate_bounds(
"""

# Ensure grid's cartesian coordinates are normalized
# TODO: Is it possible to have a more flexible normalization? (Avoid duplicated normalizations)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ philipc2 Can we avoid duplicate normalization here? For example if the nodes are already normalized, we will not normalize them.

For example, set an attributes in the grid node_x,node_y,node_z to indicate if they're already normalized or not.

@hongyuchen1030 hongyuchen1030 requested a review from philipc2 March 14, 2025 05:14
@hongyuchen1030 hongyuchen1030 added the run-benchmark Run ASV benchmark workflow label Mar 14, 2025
@rajeeja
Copy link
Contributor

rajeeja commented Mar 14, 2025

ASV Benchmark failing?

@rajeeja rajeeja self-requested a review March 14, 2025 14:12
@philipc2 philipc2 removed the run-benchmark Run ASV benchmark workflow label Mar 17, 2025
@philipc2 philipc2 added the run-benchmark Run ASV benchmark workflow label Mar 18, 2025
@philipc2
Copy link
Member

pre-commit.ci autofix

for more information, see https://pre-commit.ci
use utils instead of arcs
use utils instead of arcs
@hongyuchen1030
Copy link
Contributor Author

@philipc2

The benchmark still doesn't work out for this PR, can you take a look? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-benchmark Run ASV benchmark workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize Non-Conservative Zonal Average in zonal.py
3 participants