location.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:eemeter 作者: openeemeter 项目源码 文件源码
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]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号