This notebook provides a demo for the basic functionality of the hydrophone_request module
First, let's import some dependencies:
import os
import sys
import datetime
import numpy as np
from obspy import read,Stream, Trace
from obspy.core import UTCDateTime
cwd = os.getcwd()
ooipy_dir = os.path.dirname(os.path.dirname(cwd))
sys.path.append(ooipy_dir)
from ooipy.request import hydrophone_request
# Some magic so that the notebook will reload external python modules;
# see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython
%load_ext autoreload
%autoreload 2
Now let's request some broadband hydrophone data from OOI
start_time = datetime.datetime(2017,3,10,0,0,0)
end_time = datetime.datetime(2017,3,10,0,5,0)
node = 'PC01A'
print('Getting Hydrophone Data from OOI: \n')
hydrophone_data = hydrophone_request.get_acoustic_data(start_time, end_time, node, verbose=True)
hydrophone_data is a HydrophoneData object. This object is an exanded version of the Obspy data trace. More information about Obspy Traces can be found at https://docs.obspy.org/packages/autogen/obspy.core.trace.Trace.html
print(f'Returned Data Type: {type(hydrophone_data)}')
print('Hydrophone Data:\n\n')
print(hydrophone_data.data)
print('Hydrophone Data Stats:\n\n')
print(hydrophone_data.stats)
hydrophone_data.compute_spectrogram(avg_time=1)
hydrophone_data.compute_psd_welch()
hydrophone_data.spectrogram.spectrogram
hydrophone_data.spectrogram.visualize(res_reduction_time=1, fmax=32000)
hydrophone_data.psd.visualize(fmax=32000)
hydrophone_data.compute_spectrogram_mp(n_process=3, avg_time=1.0)
hydrophone_data.compute_psd_welch_mp(split=150, n_process=3)
hydrophone_data.spectrogram.visualize(fmax=32000)
for psd in hydrophone_data.psd_list:
psd.visualize(fmax=32000)
p1 = hydrophone_data.plot()
starttime = datetime.datetime(2017,3,10,0,0,5)
endtime = datetime.datetime(2017,3,10,0,0,15)
location = 'Eastern_Caldera'
fmin = 0.1
fmax = 1
# Returns ooipy.ooipy.hydrophone.base.HydrophoneData Object
data_trace = hydrophone_request.get_acoustic_data_LF(starttime, endtime, location, fmin, fmax, zero_mean=True)
data_trace.plot()
device1 = 'broadband_hydrophone'
device2 = 'low_frequency_hydrophone'
location1 = 'PC01A'
location2 = 'Eastern_Caldera'
starttime = datetime.datetime(2017,3,10,0,0,5)
endtime = datetime.datetime(2017,3,10,0,0,6)
fmin = 20
fmax = 40
verbose = True
data_gap_mode = 0
print('Broad Band Hydrophone:')
hydrophone_data_broadband = hydrophone_request.ooipy_read(device1, location1, starttime, endtime, fmin, fmax, verbose, data_gap_mode)
print('\n')
print('Low Frequency Hydrophone:')
hydrophone_data_lf = hydrophone_request.ooipy_read(device2, location2, starttime, endtime, fmin, fmax, verbose, data_gap_mode)
print(hydrophone_data_broadband.stats)
hydrophone_data_broadband.plot()
print(hydrophone_data_lf.stats)
hydrophone_data_lf.plot()