assert alpha <= 1. window = num.ones(N) n = num.arange(N)
N_f = int((alpha * N)//2) window[:N_f] = .5 * (1. - num.cos((2*num.pi * n[:N_f])/(alpha * N))) window[(N-N_f):] = window[:N_f][::-1] return window
assert epsilon <= 1. window = num.ones(N) n = num.arange(N)
N_f = int((epsilon * N)) window[:N_f] = \ (1. + num.exp((epsilon * N) / n[:N_f] - (epsilon * N) / ((epsilon * N - n[:N_f]))))**-1. window[(N-N_f):] = window[:N_f][::-1] return window
raise NotImplementedError
raise NotImplementedError
AbstractTractionField.T(), default=[], help='Ordered list of tractions')
npatches = nx * ny tractions = num.zeros((npatches, 3))
for comp in self.components: if comp.operation == 'add': tractions += comp.get_tractions(nx, ny, patches) elif comp.operation == 'mult': tractions *= comp.get_tractions(nx, ny, patches) else: raise AttributeError( 'Component %s has an invalid operation %s.' % (comp, comp.operation))
return tractions
logger.debug('adding traction component') self.components.append(field)
default=1., help='Uniform traction in strike, dip and normal direction [Pa]')
npatches = nx * ny return num.full((npatches, 3), self.traction)
default=1., help='Tractions in strike direction [Pa]') default=1., help='Traction in dip direction (up) [Pa]') default=1., help='Traction in normal direction [Pa]')
(self.strike, self.dip, self.normal), npatches) \ .reshape(-1, 3)
default=0., help='rake angle in [deg], ' 'measured counter-clockwise from right-horizontal ' 'in on-plane view. Rake is translated into homogenous tractions ' 'in strike and up-dip direction.') default=1., help='Traction in rake direction [Pa]')
default=.2, help='Width of the taper as a fraction of the plane.') choices=('tukey', ), default='tukey', help='Type of the taper, default "tukey"')
if self.type == 'tukey': x = tukey_window(nx, self.width) y = tukey_window(ny, self.width) return (x[:, num.newaxis] * y).ravel()[:, num.newaxis]
raise AttributeError('unknown type %s' % self.type)
help='Depth where the taper begins [km]')
help='Depth where taper stops, and drops to 0. [km]')
choices=('linear', ), default='linear', help='Type of the taper, default "linear"')
assert self.depth_stop > self.depth_start depths = num.array([p.depth for p in patches])
if self.type == 'linear': slope = self.depth_stop - self.depth_start depths -= self.depth_stop depths /= -slope depths[depths > 1.] = 1. depths[depths < 0.] = 0. return depths[:, num.newaxis]
import matplotlib.pyplot as plt from pyrocko.modelling.okada import OkadaSource
source = OkadaSource( lat=0., lon=0., depth=depth, al1=-20*km, al2=20*km, aw1=-15*km, aw2=15*km,
strike=120., dip=90., rake=90., slip=5.)
patches, _ = source.discretize(nx, ny) tractions = tractions.get_tractions(nx, ny, patches) tractions = tractions[:, 0].reshape(nx, ny)
fig = plt.figure() ax = fig.gca()
ax.imshow(tractions)
plt.show()
if __name__ == '__main__': tractions = TractionComposition( components=[ UniformTractions(traction=45e3), RectangularTaper(), DepthTaper(depth_start=10.*km, depth_stop=30.*km) ])
plot_tractions(tractions) |