def on_release(event): lon_release, lat_release = m(event.xdata, event.ydata, 'inverse') dist_km = gps2DistAzimuth(lat_press, lon_press, lat_release, lon_release)[0] / 1000. dist_degree = gps2DistDegree(lat_press, lon_press, lat_release, lon_release) if dist_km > 0.1: print 'position release lat: %.2f lon: %.2f' % (lat_release, lon_release) print 'Distance between points: %.2f degree or %.2f km' % (dist_degree, dist_km)
def dist(self, st1, st2, indeg=False): dist_deg = gps2DistDegree(self[st1].latitude, self[st1].longitude, self[st2].latitude, self[st2].longitude) dist_km = gps2DistAzimuth(self[st1].latitude, self[st1].longitude, self[st2].latitude, self[st2].longitude)[0] / 1.e3 if indeg is True: return dist_deg elif indeg is False: return dist_km else: return dist_km, dist_deg
def on_release(event): lon_release, lat_release = m(event.xdata, event.ydata, 'inverse') dist_km = gps2DistAzimuth(lat_press, lon_press, lat_release, lon_release)[0] / 1000. dist_degree = gps2DistDegree(lat_press, lon_press, lat_release, lon_release) if dist_km > 0.1: print 'position release lat: %.2f lon: %.2f' % (lat_release, lon_release) print 'Distance between points: %.2f degree or %.2f km' % ( dist_degree, dist_km)
def pick(self, latitude=None, longitude=None, minval=0, maxval=180, indegree=True, after='1900-01-01', before='3000-01-01', bigger=0., smaller=10., replace=True): """ Pick events fullfilling the given conditions. :param latitude, longitude: coordinates for distance condition :param minval, maxval: distance of event has to be between this values :param indegree: True if minval and maxval in deg, False if in km :param after, before: UTCDateTime objects or strings with time range :param bigger, smaller: magnitude range :param replace: if True the data in the event list is overwritten :return: picked Events instance """ if indegree: degorkm = 'deg' else: degorkm = 'km' newdata = [] dist = 50 for event in self[::-1]: if latitude != None and longitude != None: if not indegree: dist = gps2DistAzimuth(event.latitude, event.longitude, latitude, longitude)[0] / 1000. else: dist = gps2DistDegree(event.latitude, event.longitude, latitude, longitude) if bigger <= event.magnitude and smaller >= event.magnitude and \ dist >= minval and dist <= maxval and \ UTC(after) <= event.datetime and UTC(before) >= event.datetime: newdata.append(event) elif replace: self.remove(event) if latitude == None: latitude = 0 if longitude == None: longitude = 0 log.info( 'Pick %d events with distance between %d%s and %d%s from coordinates lat:%5.2f lon:%5.2f; between the dates %s and %s and between the magnitudes %3.1f and %3.1f' % (len(newdata), minval, degorkm, maxval, degorkm, latitude, longitude, after, before, bigger, smaller)) return self.__class__(newdata[::-1])
def pick(self, latitude=None, longitude=None, minval=0, maxval=180, indegree=True, after='1900-01-01', before='3000-01-01', bigger=0., smaller=10., replace=True): """ Pick events fullfilling the given conditions. :param latitude, longitude: coordinates for distance condition :param minval, maxval: distance of event has to be between this values :param indegree: True if minval and maxval in deg, False if in km :param after, before: UTCDateTime objects or strings with time range :param bigger, smaller: magnitude range :param replace: if True the data in the event list is overwritten :return: picked Events instance """ if indegree: degorkm = 'deg' else: degorkm = 'km' newdata = [] dist = 50 for event in self[::-1]: if latitude != None and longitude != None: if not indegree: dist = gps2DistAzimuth(event.latitude, event.longitude, latitude, longitude)[0] / 1000. else: dist = gps2DistDegree(event.latitude, event.longitude, latitude, longitude) if bigger <= event.magnitude and smaller >= event.magnitude and \ dist >= minval and dist <= maxval and \ UTC(after) <= event.datetime and UTC(before) >= event.datetime: newdata.append(event) elif replace: self.remove(event) if latitude == None: latitude = 0 if longitude == None: longitude = 0 log.info('Pick %d events with distance between %d%s and %d%s from coordinates lat:%5.2f lon:%5.2f; between the dates %s and %s and between the magnitudes %3.1f and %3.1f' % (len(newdata), minval, degorkm, maxval, degorkm, latitude, longitude, after, before, bigger, smaller)) return self.__class__(newdata[::-1])