forked from DAS4Whales/DAS4Whales
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Example.py
73 lines (56 loc) · 2.9 KB
/
Example.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Download directly from the OOI DAS experiment - details here:
# https://oceanobservatories.org/pi-instrument/ \
# rapid-a-community-test-of-distributed-acoustic-sensing-on-the-ocean-observatories-initiative-regional-cabled-array/
import wget
import os
import das4whales as dw
import scipy.signal as sp
import numpy as np
filename = 'North-C1-LR-P1kHz-GL50m-Sp2m-FS200Hz_2021-11-04T020002Z.h5'
# Check if the file exists otherwise download it
# Files are ~850 MB so the download can take a while
if os.path.exists(filename):
print(filename, ' already exists in path')
else:
url = 'http://piweb.ooirsn.uw.edu/das/data/Optasense/NorthCable/TransmitFiber/' \
'North-C1-LR-P1kHz-GL50m-Sp2m-FS200Hz_2021-11-03T15_06_51-0700/' \
'North-C1-LR-P1kHz-GL50m-Sp2m-FS200Hz_2021-11-04T020002Z.h5'
das_example_file = wget.download(url)
print(['Downloaded: ', das_example_file])
# Read HDF5 files and accessing metadata
# Get the acquisition parameters for the data folder
fs, dx, nx, ns, gauge_length, scale_factor = dw.data_handle.get_acquisition_parameters(filename)
# Select desired channels
selected_channels_m = [20000, 65000,
10] # [20000, 65000, 10] # list of values in meters corresponding to the starting,
# ending and step wanted channels along the FO Cable
# selected_channels_m = [ChannelStart_m, ChannelStop_m, ChannelStep_m]
# in meters
selected_channels = [int(np.floor(selected_channels_m / dx)) for selected_channels_m in
selected_channels_m] # list of values in channel number (spatial sample) corresponding
# to the starting, ending and step wanted
# channels along the FO Cable
# selected_channels = [ChannelStart, ChannelStop, ChannelStep] in channel
# numbers
# Create conditioning for the signal
# Create high-pass filter
sos_hpfilt = dw.dsp.butterworth_filter([2, 5, 'hp'], fs)
# Create band-pass filter for the TX plots
sos_bpfilt = dw.dsp.butterworth_filter([5, [10, 30], 'bp'], fs)
# Load DAS data
tr, time, dist, fileBeginTimeUTC = dw.data_handle.load_das_data(filename, fs, dx, selected_channels, scale_factor)
# apply the high-pass filter
trf = sp.sosfiltfilt(sos_hpfilt, tr, axis=1)
# FK filter
# Create the f-k filter
fk_filter = dw.dsp.fk_filter_design((trf.shape[0], trf.shape[1]), selected_channels, dx, fs, cs_min=1400, cp_min=1480,
cp_max=3400, cs_max=3500)
# Apply the f-k filter to the data
trf_fk = dw.dsp.fk_filter_filt(trf, fk_filter)
# Spatio-temporal plot high-pass filtered data
dw.plot.plot_tx(trf, time, dist, fileBeginTimeUTC, fig_size=(12, 10), v_min=0, v_max=0.2)
# Spatio-temporal plot high-pass + f-k filtered data
dw.plot.plot_tx(trf_fk, time, dist, fileBeginTimeUTC, fig_size=(12, 10), v_min=0, v_max=0.2)
# Spatio-spectral plot
dw.plot.plot_fx(trf_fk, dist, fs, file_begin_time_utc=fileBeginTimeUTC, win_s=2, nfft=512, f_min=10, f_max=35,
fig_size=(25, 10), v_min=0, v_max=0.08)