Exemple #1
0
    def call(self):
        """Main work routine of the snuffling."""

        self.cleanup()

        view = self.get_viewer()
        pile = self.get_pile()

        tmin, tmax = view.get_time_range()
        if self.useevent:
            markers = view.selected_markers()
            if len(markers) != 1:
                self.fail("Exactly one marker must be selected.")
            marker = markers[0]
            if not isinstance(marker, EventMarker):
                self.fail("An event marker must be selected.")

            ev = marker.get_event()

            lat, lon = ev.lat, ev.lon
        else:
            lat, lon = self.lat, self.lon

        data = iris_ws.ws_station(
            lat=lat, lon=lon, minradius=self.minradius, maxradius=self.maxradius, timewindow=(tmin, tmax), level="chan"
        )

        stations = iris_ws.grok_station_xml(data, tmin, tmax)
        networks = set([s.network for s in stations])

        t2s = util.time_to_str
        dir = self.tempdir()
        fns = []
        for net in networks:
            nstations = [s for s in stations if s.network == net]
            selection = sorted(iris_ws.data_selection(nstations, tmin, tmax))
            if selection:
                for x in selection:
                    logger.info("Adding data selection: %s.%s.%s.%s %s - %s" % (tuple(x[:4]) + (t2s(x[4]), t2s(x[5]))))

                try:
                    d = iris_ws.ws_bulkdataselect(selection)
                    fn = pjoin(dir, "data-%s.mseed" % net)
                    f = open(fn, "w")
                    f.write(d)
                    f.close()
                    fns.append(fn)

                except urllib2.HTTPError:
                    pass

        all_traces = []
        for fn in fns:
            try:
                traces = list(io.load(fn))

                all_traces.extend(traces)

            except io.FileLoadError, e:
                logger.warning("File load error, %s" % e)
Exemple #2
0
    def call(self):
        '''Main work routine of the snuffling.'''
        
        self.cleanup()

        view = self.get_viewer()
        pile = self.get_pile()

        tmin, tmax = view.get_time_range()
        if self.useevent:
            markers = view.selected_markers()
            if len(markers) != 1:
                self.fail('Exactly one marker must be selected.')
            marker = markers[0]
            if not isinstance(marker, EventMarker):
                self.fail('An event marker must be selected.')

            ev = marker.get_event()
            
            lat, lon = ev.lat, ev.lon
        else:
            lat, lon = self.lat, self.lon
        
        print lat, lon, self.minradius, self.maxradius, util.time_to_str(tmin), util.time_to_str(tmax)

        data = iris_ws.ws_station(lat=lat, lon=lon, minradius=self.minradius, maxradius=self.maxradius, 
                                                     timewindow=(tmin,tmax), level='chan' )
        stations = iris_ws.grok_station_xml(data, tmin, tmax)
        networks = set( [ s.network for s in stations ] )
        
        dir = self.tempdir()
        fns = []
        for net in networks:
            nstations = [ s for s in stations if s.network == net ]
            selection = sorted(iris_ws.data_selection( nstations, tmin, tmax ))
            if selection:
                for x in selection:
                    print x
                
                try:
                    d = iris_ws.ws_bulkdataselect(selection)
                    fn = pjoin(dir,'data-%s.mseed' % net) 
                    f = open(fn, 'w')
                    f.write(d)
                    f.close()
                    fns.append(fn)
                except urllib2.HTTPError:
                    pass

        newstations = []
        for sta in stations:
            if not view.has_station(sta):
                print sta
                newstations.append(sta)

        view.add_stations(newstations)
        for fn in fns:
            traces = list(io.load(fn))
            self.add_traces(traces)
Exemple #3
0
    def call(self):
        '''Main work routine of the snuffling.'''

        self.cleanup()

        view = self.get_viewer()
        pile = self.get_pile()

        tmin, tmax = view.get_time_range()
        if self.useevent:
            markers = view.selected_markers()
            if len(markers) != 1:
                self.fail('Exactly one marker must be selected.')
            marker = markers[0]
            if not isinstance(marker, EventMarker):
                self.fail('An event marker must be selected.')

            ev = marker.get_event()

            lat, lon = ev.lat, ev.lon
        else:
            lat, lon = self.lat, self.lon

        data = iris_ws.ws_station(lat=lat,
                                  lon=lon,
                                  minradius=self.minradius,
                                  maxradius=self.maxradius,
                                  timewindow=(tmin, tmax),
                                  level='chan')

        stations = iris_ws.grok_station_xml(data, tmin, tmax)
        networks = set([s.network for s in stations])

        t2s = util.time_to_str
        dir = self.tempdir()
        fns = []
        for net in networks:
            nstations = [s for s in stations if s.network == net]
            selection = sorted(iris_ws.data_selection(nstations, tmin, tmax))
            if selection:
                for x in selection:
                    logger.info('Adding data selection: %s.%s.%s.%s %s - %s' %
                                (tuple(x[:4]) + (t2s(x[4]), t2s(x[5]))))

                try:
                    d = iris_ws.ws_bulkdataselect(selection)
                    fn = pjoin(dir, 'data-%s.mseed' % net)
                    f = open(fn, 'w')
                    f.write(d.read())
                    f.close()
                    fns.append(fn)

                except iris_ws.NotFound:
                    pass

        all_traces = []
        for fn in fns:
            try:
                traces = list(io.load(fn))

                all_traces.extend(traces)

            except io.FileLoadError, e:
                logger.warning('File load error, %s' % e)