def test_equality_methods(): """ Tests the (in)equality methods of source and receiver objects. They both inherit from the same base class thus they are tested here - but it would also be suitable for the receiver tests. """ src1 = Source(latitude=1, longitude=2) src2 = Source(latitude=3, longitude=3) rec1 = Receiver(latitude=1, longitude=2) rec2 = Receiver(latitude=3, longitude=3) assert src1 == src1 assert src2 == src2 assert rec1 == rec1 assert rec2 == rec2 assert src1 != src2 assert src1 != rec1 assert src1 != rec2 assert src2 != src1 assert src2 != rec1 assert src2 != rec2 assert rec1 != rec2 assert rec1 != src1 assert rec1 != src2 assert rec2 != src1 assert rec2 != src1 assert rec2 != src2
def iterate(self): rec = Receiver(latitude=20, longitude=20) lat = random.random() * 0.5 lat += 44 lng = random.random() * 0.5 lng += 44 depth_in_m = random.random() * 50000 src = Source(latitude=lat, longitude=lng, depth_in_m=depth_in_m) self.db.get_seismograms(source=src, receiver=rec)
def test_sliprate_convenience_methods(): """ Tests some convenience methods of sliprates. """ src = Source(latitude=0.0, longitude=90.0) src.set_sliprate_dirac(2.0, 5) np.testing.assert_allclose(np.array([0.5, 0, 0, 0, 0]), src.sliprate) src = Source(latitude=0.0, longitude=90.0) src.set_sliprate_lp(2.0, 5, 0.1) np.testing.assert_allclose(np.array( [0.023291, 0.111382, 0.211022, 0.186723, 0.045481]), src.sliprate, rtol=1E-3) src = Source(latitude=0.0, longitude=90.0) src.sliprate = np.ones(5) src.dt = 0.25 src.normalize_sliprate() np.testing.assert_allclose(np.ones(5), src.sliprate)
def source(self): fm = self.focmec return Source(latitude=float(self.ui.source_latitude.value()), longitude=float(self.ui.source_longitude.value()), depth_in_m=float(self.source_depth) * 1000.0, m_rr=fm[0], m_tt=fm[1], m_pp=fm[2], m_rt=fm[3], m_rp=fm[4], m_tp=fm[5])
def iterate(self): # Random points on a sphere. lat = np.rad2deg(np.arcsin(2 * random.random() - 1)) lng = random.random() * 360.0 - 180.0 rec = Receiver(latitude=lat, longitude=lng) lat = np.rad2deg(np.arcsin(2 * random.random() - 1)) lng = random.random() * 360.0 - 180.0 depth_in_m = random.random() * self.max_depth src = Source(latitude=lat, longitude=lng, depth_in_m=depth_in_m) self.db.get_seismograms(source=src, receiver=rec)
def test_str_method_of_src(): src = Source(latitude=0.0, longitude=90.0) assert str(src) == ("Instaseis Source:\n" "\tOrigin Time : 1970-01-01T00:00:00.000000Z\n" "\tLongitude : 90.0 deg\n" "\tLatitude : 0.0 deg\n" "\tDepth : not set km\n" "\tMoment Magnitude : -inf\n" "\tScalar Moment : 0.00e+00 Nm\n" "\tMrr : 0.00e+00 Nm\n" "\tMtt : 0.00e+00 Nm\n" "\tMpp : 0.00e+00 Nm\n" "\tMrt : 0.00e+00 Nm\n" "\tMrp : 0.00e+00 Nm\n" "\tMtp : 0.00e+00 Nm\n")
def iterate(self): if self.current_depth_counter >= self.depth_count: self.counter += 1 self.current_depth_counter = 0 # Fix latitude. lat = 0.0 # Longitude values increase in 1 km steps. lng = self.counter * 0.01 src = Source(latitude=lat, longitude=lng, depth_in_m=self.depths[self.current_depth_counter]) self.db.get_seismograms(source=src, receiver=self.rec) self.current_depth_counter += 1
def test_radian_calculations(): src = Source(latitude=90.0, longitude=180.0) assert np.isclose(src.latitude, 90.0) assert np.isclose(src.latitude_rad, np.pi / 2.0) assert np.isclose(src.longitude, 180.0) assert np.isclose(src.longitude_rad, np.pi)
def iterate(self): src = Source(latitude=10, longitude=10) rec = Receiver(latitude=20, longitude=20) self.db.get_seismograms(source=src, receiver=rec)
def iterate(self): src = Source(latitude=10, longitude=10) rec = Receiver(latitude=20, longitude=20) self.db.get_seismograms(source=src, receiver=rec, return_obspy_stream=False)