Skip to content

Commit 0b20d2f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9eaa523 commit 0b20d2f

File tree

4 files changed

+41
-39
lines changed

4 files changed

+41
-39
lines changed

.github/workflows/noise_processing.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ on:
55
# workflow_dispatch:
66
schedule:
77
- cron: '9 * * * *'
8-
8+
99
workflow_dispatch:
10-
11-
10+
11+
1212
jobs:
1313
process:
1414
runs-on: ubuntu-latest
@@ -27,7 +27,7 @@ jobs:
2727
python -m pip install orcasound_noise@git+https://github.com/orcasound/ambient-sound-analysis
2828
python -m pip install kaleido
2929
30-
30+
3131
- name: Install ffmpeg
3232
run: |
3333
sudo apt-get update
@@ -48,4 +48,3 @@ jobs:
4848
with:
4949
commit_message: Commit to Github
5050
file_pattern: 'img/*.png'
51-

noise_processing.py

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
1-
import pandas as pd
2-
from orcasound_noise.pipeline.pipeline import NoiseAnalysisPipeline
3-
from orcasound_noise.utils import Hydrophone
41
import datetime as dt
52
import os
63

7-
import pandas as pd
84
import matplotlib.pyplot as plt
9-
import pytz
10-
11-
12-
from orcasound_noise.pipeline.acoustic_util import plot_spec, plot_bb
13-
14-
5+
import pandas as pd
156
import plotly.graph_objects as go
7+
import pytz
8+
from orcasound_noise.pipeline.acoustic_util import plot_bb, plot_spec
9+
from orcasound_noise.pipeline.pipeline import NoiseAnalysisPipeline
10+
from orcasound_noise.utils import Hydrophone
1611

17-
#Example 1: Port Townsend, 1 Hz Frequency, 60-second samples
18-
if __name__ == '__main__':
19-
pipeline = NoiseAnalysisPipeline(Hydrophone.PORT_TOWNSEND,
20-
delta_f=10, bands=None,
21-
delta_t=60, mode='safe')
12+
# Example 1: Port Townsend, 1 Hz Frequency, 60-second samples
13+
if __name__ == "__main__":
14+
pipeline = NoiseAnalysisPipeline(
15+
Hydrophone.PORT_TOWNSEND, delta_f=10, bands=None, delta_t=60, mode="safe"
16+
)
2217

2318

24-
now = dt.datetime.now(pytz.timezone('US/Pacific'))
19+
now = dt.datetime.now(pytz.timezone("US/Pacific"))
2520

26-
psd_path, broadband_path = pipeline.generate_parquet_file(now - dt.timedelta(hours = 6),
27-
now - dt.timedelta(hours = 1),
28-
upload_to_s3=False)
21+
psd_path, broadband_path = pipeline.generate_parquet_file(
22+
now - dt.timedelta(hours=6), now - dt.timedelta(hours=1), upload_to_s3=False
23+
)
2924

3025

3126
psd_df = pd.read_parquet(psd_path)
3227
bb_df = pd.read_parquet(broadband_path)
3328

3429

3530
# Create a new directory because it does not exist
36-
if not os.path.exists('img'):
37-
os.makedirs('img')
31+
if not os.path.exists("img"):
32+
os.makedirs("img")
33+
3834

3935
def plot_spec(psd_df):
4036
"""
@@ -48,17 +44,24 @@ def plot_spec(psd_df):
4844
"""
4945

5046
fig = go.Figure(
51-
data=go.Heatmap(x=psd_df.index, y=psd_df.columns, z=psd_df.values.transpose(), colorscale='Viridis',
52-
colorbar={"title": 'Magnitude'}))
47+
data=go.Heatmap(
48+
x=psd_df.index,
49+
y=psd_df.columns,
50+
z=psd_df.values.transpose(),
51+
colorscale="Viridis",
52+
colorbar={"title": "Magnitude"},
53+
)
54+
)
5355
fig.update_layout(
5456
title="Hydrophone Power Spectral Density",
5557
xaxis_title="Time",
5658
yaxis_title="Frequency (Hz)",
57-
legend_title="Magnitude"
59+
legend_title="Magnitude",
5860
)
5961
fig.update_yaxes(type="log")
6062
fig.show()
61-
return(fig)
63+
return fig
64+
6265

6366
def plot_bb(bb_df):
6467
"""
@@ -71,19 +74,17 @@ def plot_bb(bb_df):
7174
"""
7275
plt.figure()
7376
plt.plot(bb_df)
74-
plt.title('Relative Broadband Levels')
75-
plt.xlabel('Time')
76-
plt.ylabel('Relative Decibels')
77-
plt.xticks(rotation = 45)
77+
plt.title("Relative Broadband Levels")
78+
plt.xlabel("Time")
79+
plt.ylabel("Relative Decibels")
80+
plt.xticks(rotation=45)
7881
# plt.show()
79-
return(plt.gcf())
80-
82+
return plt.gcf()
8183

8284

8385
fig = plot_spec(psd_df)
84-
fig.write_image('img/psd.png')
85-
86+
fig.write_image("img/psd.png")
8687

8788

8889
fig = plot_bb(bb_df)
89-
fig.savefig('img/broadband.png')
90+
fig.savefig("img/broadband.png")

tests/test_ooi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Unit tests for OOI workflow"""
2+
23
import datetime
34
import os
45
import shutil

tests/test_spectrograms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Unit tests for various util functions relating to spectrogram creation"""
2+
23
import os.path
34

45
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)