def lat_lng_to_tmy3_station(lat, lng):
"""Return the closest TMY3 station ID using latitude and
longitude coordinates.
Parameters
----------
lat : float
Latitude coordinate.
lng : float
Longitude coordinate.
Returns
-------
station : str, None
String representing a TMY3 weather station ID or None, if none was
found.
"""
if lat is None or lng is None:
return None
tmy3_station_to_lat_lng_index = _load_tmy3_station_to_lat_lng_index()
index_list = list(tmy3_station_to_lat_lng_index.items())
dists = [haversine(lat, lng, stat_lat, stat_lng)
for _, (stat_lat, stat_lng) in index_list]
return index_list[np.argmin(dists)][0]
评论列表
文章目录