def _parse_code(self, code): """Parse network code. >>> client._parse_code('0101') ('01', '01', None) >>> client._parse_code('0103A') ('01', '03A', None) >>> client._parse_code('010501') ('01', '05', '010501') """ if code not in NETWORK.keys(): msg = "{}: Incorrect network code.".format(code) raise ValueError(msg) elif code.startswith('0105') or code.startswith('0302'): org, net, volc = code[0:2], code[2:4], code else: org, net, volc = code[0:2], code[2:], None return org, net, volc
def info(self, code=None): """List information of networks. Parameters ---------- code: None or str Network code. Examples -------- >>> client.info() 0101 : NIED Hi-net 0103 : NIED F-net (broadband) 0103A : NIED F-net (strong motion) 010501 : NIED V-net (Tokachidake) ... 0703 : Aomori Prefectural Government 0705 : Shizuoka Prefectural Government 0801 : ADEP >>> client.info('0101') == Information of Network 0101 == Name: NIED Hi-net Starttime: 20040401 No. of channels: 2336 """ if code: net = NETWORK[code] info = "== Information of Network {} ==\n".format(code) info += "Name: {}\n".format(net.name) info += "Homepage: {}\n".format(net.url) info += "Starttime: {}\n".format(net.starttime.strftime("%Y%m%d")) info += "No. of channels: {}".format(net.channels) print(info) else: for code in sorted(NETWORK.keys()): print("{:7s}: {}".format(code, NETWORK[code].name))
#!/usr/bin/env python # -*- coding: utf-8 -*- """Check if a network has more channels""" from datetime import datetime, timedelta from HinetPy import Client from HinetPy.header import NETWORK from HinetPy.win32 import _get_channels username = "******" password = "******" client = Client(username, password) difference = {} # always set one day before today as starttime starttime = datetime.today() - timedelta(days=1) for code in sorted(NETWORK.keys()): win32, chfile = client.get_waveform(code, starttime, 1) count = len(_get_channels(chfile)) if count > NETWORK[code].channels: # more difference[code] = count for code in difference.keys(): print(code, difference[code])
#!/usr/bin/env python # -*- coding: utf-8 -*- """Check if a network has more channels""" from datetime import datetime, timedelta from HinetPy import Client from HinetPy.header import NETWORK from HinetPy.win32 import _get_channels username = "******" password = "******" client = Client(username, password) difference = {} # always set one day before today as starttime starttime = datetime.today() - timedelta(days=1) for code in sorted(NETWORK.keys()): win32, chfile = client.get_continuous_waveform(code, starttime, 1) count = len(_get_channels(chfile)) if count > NETWORK[code].channels: # more difference[code] = count for code in difference.keys(): print(code, difference[code])