Skip to content

Optimize Non-Conservative Zonal Average in zonal.py #1181

Closed

Description

@hongyuchen1030

Proposed new feature or change:

Overview

The goal of this issue is to optimize the non-conservative zonal average routine by:

  • Avoiding redundant recalculations
  • Reusing intermediary computational steps to minimize overhead

Note: The current implementation uses data copying in its general helper function to support broad user scenarios. This behavior will remain for user-facing functions.

Proposed Approach

  • Dedicated Helper Functions:
    Build specialized helper functions tailored for the non-conservative zonal average routine.

  • Specialized Routine for Internal Use:
    Implement an optimized version that avoids unnecessary data copying internally, while preserving the general helper function that uses copies for general user use.

  • Intermediary Step Reuse:
    Identify and reuse common intermediary steps in the computation to avoid redundant calculations.

  • Module Organization:
    Create a separate zonal.py file that bundles all related functions for clarity and maintainability.

Tasks

  • Review the current implementation in zonal.py for inefficiencies.
  • Design and implement specialized helper functions optimized for the zonal average routine.
  • Maintain the current general helper function (with data copies) for users who need its generality.
  • Implement caching or reuse of intermediary steps to reduce recalculation.
  • Test the new implementation to ensure performance improvements and correctness.
  • Update documentation and add unit tests for the new code.

Example Reference

In a similar non-conservative zonal average implementation, dedicated helper functions are built to work specifically for that routine. While general helper functions may use data copying for broad usability, an optimized internal version can focus on performance by reusing intermediary steps and minimizing overhead.

Activity

  1. added
    improvement
    on Mar 12, 2025
  2. moved this from 📚 Backlog to 🏗 In progress in UXarray Developmenton Mar 12, 2025
  3. moved this from 🏗 In progress to 👀 In review in UXarray Developmenton Mar 18, 2025
  4. erogluorhan commented on Jun 14, 2025

    @erogluorhan
    Member

    Confirmed with @hongyuchen1030 that this can be closed.

  5. moved this from 👀 In review to ✅ Done in UXarray Developmenton Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

improvement

Type

Fields

Priority

None yet

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions