Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    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
Esempio n. 4
0
    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
Esempio n. 5
0
 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
Esempio n. 6
0
def tdatetime(s):
    return util.str_to_time(s, format='%Y-%m-%dT%H:%M:%S')
Esempio n. 7
0
def tdate(s):
    return util.str_to_time(s, '%Y-%m-%d')
Esempio n. 8
0
def tdatetime(s):
    return util.str_to_time(s, format='%Y-%m-%dT%H:%M:%S')
Esempio n. 9
0
def tdate(s):
    return util.str_to_time(s, '%Y-%m-%d')
Esempio n. 10
0
 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