Skip to content

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

@hongyuchen1030

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.

Metadata

Metadata

Labels

improvementImprovements on existing features or infrastructure

Type

Projects

Status

✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions