shoot.fit.fit_ellipse_from_coords#
- shoot.fit.fit_ellipse_from_coords(lons, lats, get_fit=False)[source]#
Fit ellipse to geographic coordinates
Uses least-squares optimization to fit an ellipse to a set of points given in geographic coordinates.
- Parameters:
lons (array-like) – Longitude coordinates in degrees.
lats (array-like) – Latitude coordinates in degrees.
get_fit (bool, default False) – If True, return fit error along with parameters.
- Returns:
Dictionary with keys: - lon : Center longitude in degrees - lat : Center latitude in degrees - a : Semi-major axis in kilometers - b : Semi-minor axis in kilometers - angle : Orientation angle in degrees
If get_fit=True, returns (dict, error) tuple.
- Return type:
Example
>>> import numpy as np >>> from shoot.fit import fit_ellipse_from_coords >>> theta = np.linspace(0, 2 * np.pi, 50) >>> lons = 5.0 + 0.5 * np.cos(theta) >>> lats = 43.0 + 0.3 * np.sin(theta) >>> params = fit_ellipse_from_coords(lons, lats) >>> print(f"center: ({params['lon']:.1f}, {params['lat']:.1f})")