DAS routines and modelling.
das
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
3.9 KiB

import pytest
1 year ago
import os.path as op
import numpy as num
1 year ago
from copy import deepcopy
from lightguide import gf
1 year ago
from pyrocko.model import Location
from pyrocko import trace
km = 1e3
def test_fiber():
fiber = gf.Fiber(
lat=0.5,
lon=0.5,
1 year ago
store_id="test",
coordinates=((0, 0), (100, 0)),
channel_spacing=1.0,
1 year ago
)
assert fiber.distances.size == 2
1 year ago
assert fiber.distances[0] == 0.0
assert fiber.distances[1] == 100.0
1 year ago
1 year ago
assert fiber.length == 100.0
1 year ago
assert fiber.nchannels == 100
1 year ago
northings, eastings, elevations, azis, dips, channels = fiber.interpolate_channels()
assert channels.size == 100.0
1 year ago
1 year ago
num.testing.assert_equal(azis, 0.0)
num.testing.assert_equal(dips, 0.0)
1 year ago
targets = fiber.get_targets()
assert len(targets) == 100
assert len(targets) == fiber.nchannels
fiber = gf.Fiber(
1 year ago
lat=0.0,
lon=0.0,
store_id="test",
1 year ago
coordinates=(
1 year ago
(0, 0, 0.0),
(-20, 0, 20.0),
(-40, 0, 40.0),
1 year ago
),
1 year ago
channel_spacing=1.0,
interpolation="multilinear",
1 year ago
)
1 year ago
northings, eastings, elevations, azis, dips, channels = fiber.interpolate_channels()
num.testing.assert_equal(azis, 180.0)
num.testing.assert_equal(dips, -45.0)
1 year ago
fiber = gf.Fiber(
1 year ago
lat=0.0,
lon=0.0,
store_id="test",
1 year ago
coordinates=(
1 year ago
Location(north_shift=0.0, east_shift=0, elevation=0),
Location(north_shift=-100.0, east_shift=0, elevation=100),
1 year ago
),
1 year ago
channel_spacing=1.0,
interpolation="multilinear",
1 year ago
)
1 year ago
northings, eastings, elevations, azis, dips, channels = fiber.interpolate_channels()
num.testing.assert_equal(azis, 180.0)
num.testing.assert_equal(dips, -45.0)
1 year ago
def test_process_fiber():
import pyrocko.gf as pgf
fiber = gf.Fiber(
lat=0.0,
lon=0.0,
1 year ago
quantity="strain_rate",
store_id="das_test",
coordinates=((1100, 0), (2000, 1000), (2000, 3000)),
channel_spacing=4.0,
smoothing_sigma=30.0,
1 year ago
)
engine = gf.LocalEngine(use_config=True)
1 year ago
source = pgf.DCSource(lat=0.0, lon=0.0, depth=2 * km, strike=45.0, dip=30.0)
1 year ago
traces = engine.process_fiber(source, fiber)
trace.snuffle(traces)
1 year ago
def test_process_fiber_fft():
import pyrocko.gf as pgf
engine = gf.LocalEngine(use_config=True)
fiber = gf.Fiber(
lat=0.0,
lon=0.0,
quantity="strain",
store_id="das_test",
coordinates=((1100, 0), (2000, 1000), (2000, 3000)),
channel_spacing=4.0,
smoothing_sigma=30.0,
spectral_differences=True,
)
source = pgf.DCSource(lat=0.0, lon=0.0, depth=2 * km, strike=45.0, dip=30.0)
traces_fft = engine.process_fiber(source, fiber)
for tr in traces_fft:
tr.set_location("SSP")
fiber.spectral_differences = False
traces_grad = engine.process_fiber(source, fiber)
for tr in traces_grad:
tr.set_location("SGR")
fiber.quantity = "displacement"
traces_u = engine.process_fiber(source, fiber)
for tr in traces_u:
tr.set_location("U")
tr_u = traces_u[0].copy()
tr_u.set_ydata((traces_u[1].ydata - traces_u[0].ydata) / fiber.channel_spacing)
tr_u.set_location("U2")
trace.snuffle(traces_grad + traces_fft + traces_u + [tr_u])
@pytest.mark.skipif(
not op.exists("das-iceland-locations-stations.txt"),
reason="could not find station file",
)
def test_process_fiber_from_stations():
from pyrocko import trace, model
import pyrocko.gf as pgf
1 year ago
stations = model.load_stations("das-iceland-locations-stations.txt")
fiber = gf.Fiber.from_stations(stations, channel_spacing=10.0, store_id="das_test")
src = pgf.DCSource(
lat=63.82725,
lon=-22.67712,
1 year ago
north_shift=0.0 * km,
east_shift=0.0 * km,
depth=3 * km,
)
engine = gf.LocalEngine(use_config=True)
traces = engine.process_fiber(src, fiber)
trace.snuffle(traces)