uxarray
uxarray copied to clipboard
Optimize Face Edge Coordinate Construction
Below are timings taken across multiple grid resolutions on a single NCAR Derecho CPU node.
| Resolution | Nodes | Faces | Edges | Grid Load Time (s) | face_edges_xyz (s) |
|---|---|---|---|---|---|
| 30km | 1,310,720 | 655,362 | 1,966,080 | 1.921 | 0.498 |
| 15km | 5,242,880 | 2,621,442 | 7,864,320 | 7.458 | 2.213 |
| 7.5km | 20,971,520 | 10,485,762 | 31,457,280 | 27.46 | 6.764 |
| 3.75km | 83,886,080 | 41,943,042 | 125,829,120 | 113.993 | 28.683 |
While the performance here is not bad, it is noticeably slow for the higher resolutions.
@hongyuchen1030 pointed out that we could consider caching this variable for re-use, especially since multiple calls to zonal average could take advantage of this. There is an informative discussion about this in #1180
The current implementation only relies on the face_node_connectivity and uses it to derive the edge information. If the edge_node_connectivity and face_edge_connectivity are available, it may be more efficient to use these to index our coordinates.
https://github.com/UXARRAY/uxarray/blob/3b7e8c48ab17b7420500c9fe68b8ebca1bac4af5/uxarray/grid/utils.py#L141-L259