themis_stations.py 文件源码

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

项目:pyrsss 作者: butala 项目源码 文件源码
def get_station_info(info_url=INFO_URL, parse_map=PARSE_MAP):
    """
    Parse information for magnetometer sites that report data to the
    THEMIS project. Returns a mapping between station IDs and
    :class:`Info` regarding the site.
    """
    station_info = OrderedDict()
    with closing(urlopen(info_url)) as fid:
        stn_data = {}
        for line in fid:
            if line.startswith('};'):
                key = stn_data.pop('key')
                if 'mlat' not in stn_data:
                    stn_data['mlat'] = float('nan')
                if 'mlon' not in stn_data:
                    stn_data['mlon'] = float('nan')
                station_info[key] = Info(**stn_data)
                stn_data = {}
            line = line.lstrip()
            for search_key, (key, convert) in parse_map.iteritems():
                if line.startswith(search_key):
                    stn_data[key] = convert(line.split('"')[1])
    return station_info
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号