Commit c4011c92 authored by Sebastian Heimann's avatar Sebastian Heimann
Browse files

synthetic tests: add relative_white_noise_scale option

parent cfc3c486
......@@ -772,6 +772,7 @@ class SyntheticTest(Object):
respect_data_availability = Bool.T(default=False)
real_noise_scale = Float.T(default=0.0)
white_noise_scale = Float.T(default=0.0)
relative_white_noise_scale = Float.T(default=0.0)
random_response_scale = Float.T(default=0.0)
real_noise_toffset = Float.T(default=-3600.)
random_seed = Int.T(optional=True)
......@@ -815,26 +816,33 @@ class SyntheticTest(Object):
for iresult, result in enumerate(results):
tr = result.trace.pyrocko_trace()
tfade = tr.tmax - tr.tmin
tr_orig = tr.copy()
tr.extend(tr.tmin - tfade, tr.tmax + tfade)
rstate = num.random.RandomState(
(self.random_seed or 0) + iresult)
if self.random_response_scale != 0:
tf = RandomResponse(scale=self.random_response_scale)
rstate = num.random.RandomState(
(self.random_seed or 0) + iresult)
tf.set_random_state(rstate)
tr = tr.transfer(
tfade=tfade,
transfer_function=tf)
if self.white_noise_scale != 0.0:
rstate = num.random.RandomState(
(self.random_seed or 0) + iresult)
u = rstate.normal(
scale=self.white_noise_scale,
size=tr.data_len())
tr.ydata += u
if self.relative_white_noise_scale != 0.0:
u = rstate.normal(
scale=self.relative_white_noise_scale * num.std(
tr_orig.ydata),
size=tr.data_len())
tr.ydata += u
synthetics[result.trace.codes] = tr
self._synthetics = synthetics
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment