Coverage for pyguymer3/geo/max_distSrc/max_dist_euclidean.py: 82%
11 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-08 18:47 +0000
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-08 18:47 +0000
1#!/usr/bin/env python3
3# Define function ...
4def max_dist_euclidean(
5 lons,
6 lats,
7 midLon,
8 midLat,
9 /,
10):
11 # Import special modules ...
12 try:
13 import numpy
14 except:
15 raise Exception("\"numpy\" is not installed; run \"pip install --user numpy\"") from None
17 # **************************************************************************
19 # Check arguments ...
20 assert isinstance(lons, numpy.ndarray), "\"lons\" is not a NumPy array"
21 assert isinstance(lats, numpy.ndarray), "\"lats\" is not a NumPy array"
23 # **************************************************************************
25 # Find the maximum Euclidean distance from the middle to any location ...
26 maxDist = 0.0 # [°]
27 for iLoc in range(lons.size):
28 maxDist = max(
29 maxDist,
30 numpy.hypot(
31 lons[iLoc] - midLon,
32 lats[iLoc] - midLat,
33 ),
34 ) # [°]
36 # Return answer ...
37 return maxDist