-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcombisource.py
More file actions
executable file
·40 lines (29 loc) · 1.3 KB
/
combisource.py
File metadata and controls
executable file
·40 lines (29 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from pyrocko import gf
from pyrocko.guts import List
import numpy as num
class CombiSource(gf.Source):
discretized_source_class = gf.DiscretizedMTSource
subsources = List.T(gf.Source.T())
def __init__(self, subsources=[], **kwargs):
if subsources:
lats = num.array([subsource.lat for subsource in subsources], dtype=num.float)
lons = num.array([subsource.lon for subsource in subsources], dtype=num.float)
if num.all(lats == lats[0]) and num.all(lons == lons[0]):
lat, lon = lats[0], lons[0]
else:
lat, lon = center_latlon(subsources)
depth = float(num.mean([p.depth for p in subsources]))
t = float(num.mean([p.time for p in subsources]))
kwargs.update(time=t, lat=float(lat), lon=float(lon), depth=depth)
gf.Source.__init__(self, subsources=subsources, **kwargs)
def get_factor(self):
return 1.0
def discretize_basesource(self, store, target=None):
dsources = []
t0 = self.subsources[0].time
for sf in self.subsources:
assert t0 == sf.time
ds = sf.discretize_basesource(store, target)
ds.m6s *= sf.get_factor()
dsources.append(ds)
return gf.DiscretizedMTSource.combine(dsources)