Beispiel #1
0
    def load_comparison(self):
        '''
        For comparison in synthetic tests.
        '''
        fn = self.input_filename(caption='Select an event catalog')
        kind_compare = 4
        compare_events = model.load_events(fn)
        markers = [
            gui_util.EventMarker(event=e, kind=kind_compare)
            for e in compare_events
        ]

        self.markers_compare = markers
        self.add_markers(self.markers_compare)
Beispiel #2
0
    def call(self):
        self.mycleanup()
        self.detections = []
        i_detection = 0
        zpeak = 0.
        lat = 0.
        lon = 0.
        for traces in self.chopper_selected_traces(
                mode='all',
                trace_selector=lambda x: x.station == "SMAX",
                fallback=True):
            tr_smax = [tr for tr in traces if tr.location == '']
            tr_i = [tr for tr in traces if tr.location == 'i']
            if not tr_i:
                tr_i = [None] * len(tr_smax)

            for tr_i, tr_stackmax in zip(tr_i, tr_smax):
                tpeaks, apeaks = tr_stackmax.peaks(self.detector_threshold,
                                                   self.tsearch)
                if self.level_trace:
                    ltrace = tr_stackmax.copy(data=False)
                    ltrace.set_ydata(
                        num.ones(tr_stackmax.data_len()) *
                        self.detector_threshold)
                    self.add_trace(ltrace)
                for t, a in zip(tpeaks, apeaks):
                    if tr_i:
                        lat, lon, xpeak, ypeak, zpeak = \
                            self.grid.index_to_location(tr_i(t)[1])

                        lat, lon = orthodrome.ne_to_latlon(
                            lat, lon, xpeak, ypeak)

                    e = model.Event(time=t,
                                    name="%s-%s" % (i_detection, a),
                                    lat=lat,
                                    lon=lon,
                                    depth=zpeak)
                    self.detections.append(
                        gui_util.EventMarker(event=e,
                                             kind=int(self.marker_kind[0])))
                    i_detection += 1
        self.add_markers(self.detections)

        if self.hold_figure:
            self.show_comparison()
Beispiel #3
0
def detections_to_event_markers(fn_detections):
    markers = []
    if fn_detections:
        with open(fn_detections, 'r') as f:
            for line in f.readlines():
                data = line.split()
                i, t_d, t_t, apeak, latpeak, lonpeak, xpeak, ypeak, zpeak = \
                    data
                lat, lon = orthodrome.ne_to_latlon(float(latpeak),
                                                   float(lonpeak),
                                                   float(xpeak), float(ypeak))
                t = util.str_to_time("%s %s" % (t_d, t_t))
                label = "%s-%s" % (apeak, i)
                e = model.Event(lat=lat,
                                lon=lon,
                                depth=float(zpeak),
                                name=label,
                                time=t)
                m = gui_util.EventMarker(e, kind=int(kind_default[0]))
                markers.append(m)

    return markers
Beispiel #4
0

def __snufflings__():
    return [MapMaker()]


if __name__ == '__main__':
    util.setup_logging('map.py', 'info')
    s = MapMaker()
    options, args, parser = s.setup_cli()
    s.markers = []

    if options.stations_filename:
        stations = model.load_stations(options.stations_filename)
        s.stations = stations
    else:
        s.stations = None

    if options.events_filename:
        events = model.load_events(filename=options.events_filename)
        markers = [gui_util.EventMarker(e) for e in events]
        s.markers.extend(markers)

    if options.markers_filename:
        markers = gui_util.load_markers(options.markers_filename)
        s.markers.extend(markers)
    s.open_external = True
    mapmap = {'google': 'Google Maps', 'osm': 'OpenStreetMap'}
    s.map_kind = mapmap[options.map_provider]
    s.call()