uxarray
uxarray copied to clipboard
Optimize Face Bounds Construction
Proposed new feature or change:
Optimize the performance when constructing Grid.face_bounds
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
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
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
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!
Hey @hongyuchen1030, sure!