Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 23, 2024
1 parent 93b813b commit eef44df
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/noise_processing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:
#schedule:
#- cron: '9 * * * *'

jobs:
process:
runs-on: ubuntu-latest
Expand All @@ -22,12 +22,12 @@ jobs:
run: |
pip install -r requirements_noise.txt
- name: Install ffmpeg
run: |
sudo apt-get update
sudo apt-get install ffmpeg
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: ffmpeg
Expand All @@ -53,6 +53,6 @@ jobs:
# uses: AnimMouse/setup-rclone@v1
# with:
# rclone_config: ${{secrets.RCLONE_CONFIG}}
#
#
# - run: |
# rclone copy ambient_sound_analysis/img/broadband.png mydrive:rclone_uploads/
36 changes: 17 additions & 19 deletions noise_processing.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
# importing general Python libraries
import pandas as pd
import datetime as dt
import os

import matplotlib.pyplot as plt
import pytz
import pandas as pd
import plotly.graph_objects as go
import pytz
from orcasound_noise.pipeline.acoustic_util import plot_bb, plot_spec

# importing orcasound_noise libraries
from orcasound_noise.pipeline.pipeline import NoiseAnalysisPipeline
from orcasound_noise.utils import Hydrophone
from orcasound_noise.pipeline.acoustic_util import plot_spec, plot_bb


# Set Location and Resolution
# Port Townsend, 1 Hz Frequency, 60-second samples
if __name__ == '__main__':
pipeline = NoiseAnalysisPipeline(Hydrophone.BUSH_POINT,
delta_f=10, bands=None,
delta_t=60, mode='safe')


if __name__ == "__main__":
pipeline = NoiseAnalysisPipeline(
Hydrophone.BUSH_POINT, delta_f=10, bands=None, delta_t=60, mode="safe"
)


# Generate parquet dataframes with noise levels for a time period

now = dt.datetime.now(pytz.timezone('US/Pacific'))
now = dt.datetime.now(pytz.timezone("US/Pacific"))
now = dt.datetime(2024, 11, 20, 10)
psd_path, broadband_path = pipeline.generate_parquet_file(now - dt.timedelta(hours = 10),
now - dt.timedelta(hours = 8),
upload_to_s3=False)
psd_path, broadband_path = pipeline.generate_parquet_file(
now - dt.timedelta(hours=10), now - dt.timedelta(hours=8), upload_to_s3=False
)

# Read the parquet files
psd_df = pd.read_parquet(psd_path)
bb_df = pd.read_parquet(broadband_path)

# Create a new directory if it does not exist
if not os.path.exists('img'):
os.makedirs('img')
if not os.path.exists("img"):
os.makedirs("img")

# Create and save psd plot
# Create and save psd plot
fig = plot_spec(psd_df)
fig.write_image('img/psd.png')
fig.write_image("img/psd.png")

# Create and save bb plot
fig = plot_bb(bb_df)
fig.savefig('img/broadband.png')
fig.savefig("img/broadband.png")
6 changes: 3 additions & 3 deletions requirements_noise.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
matplotlib
# scipy
m3u8
matplotlib
# scipy
m3u8
git+https://github.com/kkroening/ffmpeg-python
orcasound_noise@git+https://github.com/orcasound/ambient-sound-analysis@ffmpeg-quiet
kaleido
1 change: 1 addition & 0 deletions tests/test_ooi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for OOI workflow"""

import datetime
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions tests/test_spectrograms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for various util functions relating to spectrogram creation"""

import os.path

import matplotlib.pyplot as plt
Expand Down

0 comments on commit eef44df

Please sign in to comment.