uxarray icon indicating copy to clipboard operation
uxarray copied to clipboard

Optimize the `get_cartesian_face_edge_nodes` and `get_lonlat_rad_face_edge_nodes`

Open hongyuchen1030 opened this issue 9 months ago • 23 comments

Related to #730 and #785

Overview

  • Optimize the get_cartesian_face_edge_nodes and get_lonlat_rad_face_edge_nodes functions to make them vectorized and improve performance.
  • This function was called in grid_populate_bounds and will be called in zonal_mean().

Expected Usage

import uxarray as ux
import numpy as np

# Define vertices
vertices = [[0.5, 0.5, 0.5], [-0.5, 0.5, 0.5], [-0.5, -0.5, 0.5], [0.5, -0.5, 0.5]]

# Normalize the vertices
vertices = [x / np.linalg.norm(x) for x in vertices]

# Construct the grid from the vertices
grid = ux.Grid.from_face_vertices(vertices, latlon=False)

# Compute Cartesian face edge nodes
face_edges_connectivity_cartesian = _get_cartesian_face_edge_nodes(
    grid.face_node_connectivity.values,
    grid.node_x.values,
    grid.node_y.values, grid.node_z.values
)


PR Checklist

General

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

Testing

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

Documentation

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

hongyuchen1030 avatar May 20 '24 07:05 hongyuchen1030