7 changed files with 113 additions and 8 deletions
@ -0,0 +1,27 @@
|
||||
import pyrocko |
||||
import numpy as num |
||||
|
||||
from .utils import traces_to_numpy_and_meta |
||||
|
||||
|
||||
def remove_idas_instrument_vibration(traces, copy=True, return_ref=False): |
||||
data, meta = traces_to_numpy_and_meta(traces) |
||||
|
||||
ntraces_ref = int((meta.start_distance * 0.9) / meta.spatial_resolution) |
||||
|
||||
ref = num.mean(data[:ntraces_ref], axis=1) |
||||
|
||||
out_traces = [] |
||||
for tr in traces: |
||||
if copy: |
||||
tr = tr.copy() |
||||
tr.ydata -= ref |
||||
out_traces.append(tr) |
||||
|
||||
if return_ref: |
||||
trace_ref = tr.copy(data=False) |
||||
trace_ref.ydata = ref |
||||
trace_ref.station = "ref" |
||||
out_traces.append(trace_ref) |
||||
|
||||
return out_traces |
@ -0,0 +1,53 @@
|
||||
import numpy as num |
||||
from .utils import traces_to_numpy_and_meta |
||||
|
||||
|
||||
def de_to_e(traces, copy=False): |
||||
out_traces = [] |
||||
for tr in traces: |
||||
if copy: |
||||
tr = tr.copy() |
||||
tr.set_ydata(num.cumsum(tr.ydata) * tr.deltat) |
||||
out_traces.append(tr) |
||||
|
||||
return out_traces |
||||
|
||||
|
||||
def de_to_velocity_static_slowness(traces, slowness, copy=False): |
||||
out_traces = de_to_e(traces, copy) |
||||
for tr in out_traces: |
||||
tr.set_ydata(tr.ydata / slowness) |
||||
|
||||
return out_traces |
||||
|
||||
|
||||
def de_to_acceleration_static_slowness(traces, slowness, copy=False): |
||||
out_traces = [] |
||||
for tr in traces: |
||||
if copy: |
||||
tr = tr.copy() |
||||
tr.set_ydata(tr.ydata / slowness) |
||||
|
||||
return out_traces |
||||
|
||||
|
||||
def de_to_relative_displacement(traces, copy=False): |
||||
traces = de_to_e(traces, copy) |
||||
data, meta = traces_to_numpy_and_meta(traces) |
||||
|
||||
data = num.cumsum(data, axis=0) * meta.spatial_resolution |
||||
for itr, tr in enumerate(traces): |
||||
tr.set_ydata(data[itr]) |
||||
|
||||
return traces |
||||
|
||||
|
||||
def de_to_relative_velocity(traces, copy=False): |
||||
traces = de_to_e(traces, copy) |
||||
data, meta = traces_to_numpy_and_meta(traces) |
||||
|
||||
data = num.diff(data, n=1, axis=0) / meta.spatial_resolution |
||||
for itr, tr in enumerate(traces): |
||||
tr.set_ydata(data[itr]) |
||||
|
||||
return traces |
@ -0,0 +1,22 @@
|
||||
import numpy as num |
||||
|
||||
|
||||
class AttrDict(dict): |
||||
def __init__(self, *args, **kwargs): |
||||
super(AttrDict, self).__init__(*args, **kwargs) |
||||
self.__dict__ = self |
||||
|
||||
|
||||
def traces_to_numpy_and_meta(traces): |
||||
ntraces = len(traces) |
||||
nsamples = set(tr.nsamples for tr in traces) |
||||
|
||||
assert len(nsamples) == 1, "Traces nsamples differ" |
||||
nsamples = nsamples[0] |
||||
|
||||
data = num.zeros(ntraces, nsamples) |
||||
for itr, tr in enumerate(traces): |
||||
data[itr, :] = tr.ydata |
||||
meta = tr.meta |
||||
|
||||
return data, AttrDict(meta) |
Loading…
Reference in new issue