def _parse_events_page(self, page): events = [] for line in page.splitlines(): toks = line.strip().split(',') if len(toks) != 9: continue try: int(toks[0]) except: continue t = util.str_to_time(','.join(toks[:4]).strip(), format='%Y,%m,%d,%H%M%S.OPTFRAC') lat = float(toks[4]) lon = float(toks[5]) mag = float(toks[6]) depth = float(toks[7]) catalog = toks[8] name = 'USGS-%s-' % catalog + util.time_to_str( t, format='%Y-%m-%d_%H-%M-%S.3FRAC') ev = model.Event(lat=lat, lon=lon, time=t, name=name, depth=depth * 1000., magnitude=mag, catalog=catalog) events.append(ev) return events
def _parse_events_page(self, page): events = [] for line in page.splitlines(): toks = line.strip().split(',') if len(toks) != 9: continue try: int(toks[0]) except: continue t = util.str_to_time(','.join(toks[:4]).strip(), format='%Y,%m,%d,%H%M%S.OPTFRAC') lat = float(toks[4]) lon = float(toks[5]) mag = float(toks[6]) depth = float(toks[7]) catalog = toks[8] name = 'USGS-%s-' % catalog + util.time_to_str(t, format='%Y-%m-%d_%H-%M-%S.3FRAC') ev = model.Event( lat=lat, lon=lon, time=t, name=name, depth=depth*1000., magnitude=mag, catalog=catalog) events.append( ev ) return events
def _parse_events_page(self, page): import json doc = json.loads(page) events = [] for feat in doc['features']: props = feat['properties'] geo = feat['geometry'] lon, lat, depth = [ float(x) for x in geo['coordinates'] ] t = util.str_to_time('1970-01-01 00:00:00') + props['time'] *0.001 if props['mag'] is not None: mag = float(props['mag']) else: mag = None if props['place'] != None: region = str(props['place']) else: region = None catalog= str(props['net'].upper()) name = 'USGS-%s-' % catalog + util.time_to_str(t, format='%Y-%m-%d_%H-%M-%S.3FRAC') ev = model.Event( lat=lat, lon=lon, time=t, name=name, depth=depth*1000., magnitude=mag, region=region, catalog=catalog) events.append(ev) return events
def _parse_events_page(self, page): import json doc = json.loads(page) events = [] for feat in doc['features']: props = feat['properties'] geo = feat['geometry'] lon, lat, depth = [float(x) for x in geo['coordinates']] t = util.str_to_time('1970-01-01 00:00:00') + props['time'] * 0.001 if props['mag'] is not None: mag = float(props['mag']) else: mag = None if props['place'] != None: region = str(props['place']) else: region = None catalog = str(props['net'].upper()) name = 'USGS-%s-' % catalog + util.time_to_str( t, format='%Y-%m-%d_%H-%M-%S.3FRAC') ev = model.Event(lat=lat, lon=lon, time=t, name=name, depth=depth * 1000., magnitude=mag, region=region, catalog=catalog) events.append(ev) return events
def _name_to_date(self, name): ds = name[-23:] t = util.str_to_time(ds, format='%Y-%m-%d_%H-%M-%S.3FRAC') return t
def tdatetime(s): return util.str_to_time(s, format='%Y-%m-%dT%H:%M:%S')
def tdate(s): return util.str_to_time(s, '%Y-%m-%d')