def testAziBaziArrayPythonC(self): ntest = 10000 lats1, lons1, lats2, lons2 = self.get_critical_random_locations(ntest) azis_c, bazis_c = orthodrome.azibazi_numpy( lats1, lons1, lats2, lons2, implementation='c') azis_py, bazis_py = orthodrome.azibazi_numpy( lats1, lons1, lats2, lons2, implementation='python') for i in range(ntest): azi_py, bazi_py = orthodrome.azibazi( float(lats1[i]), float(lons1[i]), float(lats2[i]), float(lons2[i]), implementation='python') azi_c, bazi_c = orthodrome.azibazi( lats1[i], lons1[i], lats2[i], lons2[i], implementation='c') num.testing.assert_almost_equal(azi_py, azis_py[i]) num.testing.assert_almost_equal(bazi_py, bazis_py[i]) num.testing.assert_almost_equal(azi_c, azis_c[i]) num.testing.assert_almost_equal(bazi_c, bazis_c[i]) num.testing.assert_almost_equal(azis_py, azis_c) num.testing.assert_almost_equal(bazis_py, bazis_c)
def draw_figures(self, problem, dataset, history): event = problem.base_source targets = problem.gnss_targets for target in targets: target.set_dataset(dataset) comp_weights = target.component_weights()[0] ws_n = comp_weights[:, 0::3] / comp_weights.max() ws_e = comp_weights[:, 1::3] / comp_weights.max() ws_u = comp_weights[:, 2::3] / comp_weights.max() ws_e = num.array(ws_e[0]).flatten() ws_n = num.array(ws_n[0]).flatten() ws_u = num.array(ws_u[0]).flatten() if ws_n.size == 0: continue distances = target.distance_to(event) azimuths = od.azibazi_numpy( num.array(event.effective_lat)[num.newaxis], num.array(event.effective_lon)[num.newaxis], target.get_latlon()[:, 0], target.get_latlon()[:, 1])[0] labels = target.station_names item = PlotItem(name='station_distribution-N-%s' % target.path) fig, ax, legend = self.plot_station_distribution( azimuths, distances, ws_n, labels, legend_title='Weight, N components') yield (item, fig) item = PlotItem(name='station_distribution-E-%s' % target.path) fig, ax, legend = self.plot_station_distribution( azimuths, distances, ws_e, labels, legend_title='Weight, E components') yield (item, fig) item = PlotItem(name='station_distribution-U-%s' % target.path) fig, ax, legend = self.plot_station_distribution( azimuths, distances, ws_u, labels, legend_title='Weight, U components') yield (item, fig)
def azibazi_to(self, other): ''' Compute azimuth and backazimuth to and from other location object. ''' if self.same_origin(other): other_north_shift, other_east_shift = get_offset(other) azi = r2d * math.atan2(other_east_shift - self.east_shift, other_north_shift - self.north_shift) bazi = azi + 180. else: slat, slon = self.effective_latlon rlat, rlon = get_effective_latlon(other) azi, bazi = orthodrome.azibazi_numpy(slat, slon, rlat, rlon) return float(azi), float(bazi)
def azibazi_to(self, other): ''' Compute azimuth and backazimuth to and from other location object. ''' if self.same_origin(other): if isinstance(other, Location): azi = r2d * math.atan2(other.east_shift - self.east_shift, other.north_shift - self.north_shift) else: azi = 0.0 bazi = azi + 180. else: slat, slon = self.effective_latlon try: rlat, rlon = other.effective_latlon except AttributeError: rlat, rlon = other.lat, other.lon azi, bazi = orthodrome.azibazi_numpy(slat, slon, rlat, rlon) return float(azi), float(bazi)
def draw_figures(self, problem, dataset, history): event = problem.base_source targets = problem.gnss_targets for target in targets: target.set_dataset(dataset) ws = target.station_weights / target.station_weights.max() distances = target.distance_to(event) azimuths = od.azibazi_numpy( num.array(event.effective_lat)[num.newaxis], num.array(event.effective_lon)[num.newaxis], target.get_latlon()[:, 0], target.get_latlon()[:, 1])[0] labels = target.station_names item = PlotItem(name='station_distribution-%s' % target.path) fig, ax, legend = self.plot_station_distribution( azimuths, distances, ws, labels) legend.set_title('Weight') yield (item, fig)
def testAziBaziArrayC(self): ntest = 10000 locs = self.get_critical_random_locations(ntest) orthodrome.azibazi_numpy(*locs, implementation='c')
def testAziBaziArrayC(self): ntest = 10000 locs = self.get_critical_random_locations(ntest) orthodrome.azibazi_numpy( *locs, implementation='c')
from pyrocko import orthodrome # For a single point orthodrome.azibazi(49.1, 20.5, 45.4, 22.3) # >>> (161.05973376168285, -17.617746351508035) # Azimuth and backazimuth import numpy as num # noqa ncoords = 1000 # First set of coordinates lats_a = num.random.uniform(-180., 180., ncoords) lons_a = num.random.uniform(-90., 90., ncoords) # Second set of coordinates lats_b = num.random.uniform(-180., 180., ncoords) lons_b = num.random.uniform(-90., 90., ncoords) orthodrome.azibazi_numpy(lats_a, lons_a, lats_b, lons_b)