uxarray icon indicating copy to clipboard operation
uxarray copied to clipboard

Performance Issue: Unnecessary Re-conversion of Coordinates in `point_within_gca`

Open amberchen122 opened this issue 1 year ago • 0 comments
trafficstars

Proposed new feature or change:

The current implementation of point_within_gca unnecessarily re-converts lat/lon coordinates from Cartesian coordinates, which negatively impacts performance.

The following lines re-compute lat/lon from Cartesian coordinates:

python

GCRv0_lonlat = np.array(
        _xyz_to_lonlat_rad_no_norm(gca_cart[0][0], gca_cart[0][1], gca_cart[0][2])
    )
GCRv1_lonlat = np.array(
    _xyz_to_lonlat_rad_no_norm(gca_cart[1][0], gca_cart[1][1], gca_cart[1][2])
)

However, Uxarray already stores lat/lon coordinates, which can be passed directly to avoid redundant computation. This approach reduces both time and space complexity while aligning better with the overall architecture.

Proposed Solution:

  • Pass the existing lat/lon coordinates directly to eliminate the unnecessary conversion.
  • Update upstream function calls to point_within_gca

amberchen122 avatar Sep 04 '24 19:09 amberchen122