Browse Source

Merge branch 'master' of github.com:pyrocko/pyrocko

sparrow-scatterpipe-experiments
miili 4 years ago
parent
commit
024ff16bca
  1. 20
      src/client/fdsn.py
  2. 8
      src/gf/seismosizer.py
  3. 46
      test/test_gf_sources.py

20
src/client/fdsn.py

@ -36,19 +36,19 @@ g_site_abbr = {
'geonet': 'http://service.geonet.org.nz',
'knmi': 'http://rdsa.knmi.nl',
'ncedc': 'http://service.ncedc.org',
'scedc': 'http://scedc.caltech.edu',
'scedc': 'http://service.scedc.caltech.edu',
'usgs': 'http://earthquake.usgs.gov',
'bgr': 'http://eida.bgr.de',
'koeri': 'http://www.koeri.boun.edu.tr/2/tr',
'ethz': 'http://eida.ethz.ch/fdsnws',
'icgc': 'http://www.icgc.cat/en/xarxasismica',
'ipgp': 'http://centrededonnees.ipgp.fr',
'ingv': 'http://webservices.rm.ingv.it',
'koeri': 'http://eida-service.koeri.boun.edu.tr',
'ethz': 'http://eida.ethz.ch',
'icgc': 'http://ws.icgc.cat',
'ipgp': 'http://eida.ipgp.fr',
'ingv': 'http://webservices.ingv.it',
'isc': 'http://www.isc.ac.uk',
'lmu': 'http://erde.geophysik.uni-muenchen.de',
'noa': 'http://bbnet.gein.noa.gr',
'resif': 'http://portal.resif.fr',
'usp': 'http://www.moho.iag.usp.br'
'noa': 'http://eida.gein.noa.gr',
'resif': 'http://ws.resif.fr',
'usp': 'http://seisrequest.iag.usp.br',
'niep': 'http://eida-sc3.infp.ro'
}
g_default_site = 'geofon'

8
src/gf/seismosizer.py

@ -1294,14 +1294,14 @@ class ExplosionSource(SourceWithDerivedMagnitude):
times, amplitudes = self.effective_stf_pre().discretize_t(
store.config.deltat, 0.0)
amplitudes *= self.get_moment(store, target)
amplitudes *= self.get_moment(store, target) * math.sqrt(2. / 3.)
return meta.DiscretizedExplosionSource(
m0s=amplitudes,
**self._dparams_base_repeated(times))
def pyrocko_moment_tensor(self, store=None, target=None):
a = self.get_moment(store, target) * math.sqrt(2./3.)
a = self.get_moment(store, target) * math.sqrt(2. / 3.)
return mt.MomentTensor(m=mt.symmat6(a, a, a, 0., 0., 0.))
@ -1595,8 +1595,8 @@ class MTSource(Source):
def get_magnitude(self, store=None, target=None):
m6 = self.m6
return mt.moment_to_magnitude(
math.sqrt(num.sum(m6[0:3]**2) + 2.0 * num.sum(m6[3:6]**2))
/ math.sqrt(2.))
math.sqrt(num.sum(m6[0:3]**2) + 2.0 * num.sum(m6[3:6]**2)) /
math.sqrt(2.))
def pyrocko_moment_tensor(self, store=None, target=None):
return mt.MomentTensor(m=mt.symmat6(*self.m6_astuple))

46
test/test_gf_sources.py

@ -302,27 +302,30 @@ class GFSourcesTestCase(unittest.TestCase):
# plot_sources(sources)
def test_explosion_source(self):
target = gf.Target(
interpolation='nearest_neighbor')
ex = gf.ExplosionSource(
magnitude=5.,
volume_change=4.,
depth=5*km)
magnitude=5.,
volume_change=4.,
depth=5 * km)
with self.assertRaises(gf.DerivedMagnitudeError):
ex.validate()
ex = gf.ExplosionSource(
depth=5*km)
depth=5 * km)
ex.validate()
self.assertEqual(ex.get_moment(), 1.0)
# magnitude input
magnitude = 3.
ex = gf.ExplosionSource(
magnitude=3.0,
depth=5*km)
magnitude=magnitude,
depth=5 * km)
store = self.dummy_store()
@ -332,20 +335,43 @@ class GFSourcesTestCase(unittest.TestCase):
volume_change = ex.get_volume_change(
store, target)
self.assertAlmostEqual(
ex.get_magnitude(store, target), magnitude)
# validate with MT source
moment = ex.get_moment(store, target) * float(num.sqrt(2. / 3))
mt = gf.MTSource(mnn=moment, mee=moment, mdd=moment)
self.assertAlmostEqual(
ex.get_magnitude(store, target),
mt.get_magnitude(store=store, target=target))
# discretized sources
d_ex = ex.discretize_basesource(store=store, target=target)
d_mt = mt.discretize_basesource(store=store, target=target)
d_ex_m6s = d_ex.get_source_terms('elastic10')
d_mt_m6s = d_mt.get_source_terms('elastic10')
numeq(d_ex_m6s, d_mt_m6s, 1e-20)
# interpolation method
with self.assertRaises(TypeError):
ex.get_volume_change(
store, gf.Target(interpolation='nearest_neighbour'))
# volume change input
ex = gf.ExplosionSource(
volume_change=volume_change,
depth=5*km)
volume_change=volume_change,
depth=5 * km)
self.assertAlmostEqual(
ex.get_magnitude(store, target), 3.0)
ex = gf.ExplosionSource(
magnitude=3.0,
depth=-5.)
magnitude=3.0,
depth=-5.)
with self.assertRaises(gf.DerivedMagnitudeError):
ex.get_volume_change(store, target)

Loading…
Cancel
Save