uxarray icon indicating copy to clipboard operation
uxarray copied to clipboard

Optimize Face Bounds Construction

Open philipc2 opened this issue 11 months ago • 3 comments

Proposed new feature or change:

Optimize the performance when constructing Grid.face_bounds

philipc2 avatar Mar 20 '24 19:03 philipc2

Re @philipc2's benchmarking:

The GeoFlow grid (12s execution time) has 6000 nodes and 3840 faces.

That's extremely slow for such a small grid (though relatable as the algorithm iterates over each face, and each edge of that face). Taking into account bigger grids might be used, the execution times might make the things impractical, and that makes me think that we should consider either to optimize before a release, or provide caution admonitions, if possible, in the documentation to let the user clearly know the extreme performance bottleneck.

Thoughts?

Originally posted by @erogluorhan in https://github.com/UXARRAY/uxarray/pull/692#pullrequestreview-1963724660

erogluorhan avatar Apr 02 '24 20:04 erogluorhan

Some for-loop-based code needs to be replaced with vectorized ones the issue #346. Though, as part of here (if #346 will take too long), should we still find some intermediate (though not ideal) solutions to make our code look better I believe (rather than using a for loop and list appends), e.g. something like the following?:

face_edges_connectivity_cartesian = np.asarray(list(map(node_lonlat_rad_to_xyz, face_edges_connectivity_lonlat)))

Originally posted by @erogluorhan in https://github.com/UXARRAY/uxarray/pull/692#discussion_r1541423946

erogluorhan avatar Apr 03 '24 04:04 erogluorhan

We should also investigate the performance of lower-level helper functions that are called throughout.

  • _pole_point_inside_polygon
  • extreme_gca_latitude
  • _insert_pt_in_latlonbox
  • _get_cartesian_face_edge_nodes
  • _get_lonlat_rad_face_edge_nodes

philipc2 avatar Apr 03 '24 05:04 philipc2

Hi @erogluorhan @philipc2,

Since the zonal_mean feature is ready for review, can we prioritize the optimization for latlon bounds next? This optimization is the building block for our zonal_mean, a fundamental, core feature that many users are eagerly waiting to use.

Thank you!

hongyuchen1030 avatar Jul 25 '24 21:07 hongyuchen1030

Hey @hongyuchen1030, sure!

erogluorhan avatar Jul 30 '24 20:07 erogluorhan