From 34e1d53398cea933e260a0f08bad5e9b417892f6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:24:40 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pycqa/isort: 5.10.1 → 6.0.0](https://github.com/pycqa/isort/compare/5.10.1...6.0.0) - [github.com/psf/black: 22.1.0 → 25.1.0](https://github.com/psf/black/compare/22.1.0...25.1.0) - [github.com/asottile/pyupgrade: v2.31.0 → v3.19.1](https://github.com/asottile/pyupgrade/compare/v2.31.0...v3.19.1) - [github.com/pycqa/flake8: 4.0.1 → 7.1.1](https://github.com/pycqa/flake8/compare/4.0.1...7.1.1) - [github.com/pre-commit/pre-commit-hooks: v4.1.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.1.0...v5.0.0) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2216565c..feaf7ff6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,29 +1,29 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 6.0.0 hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/psf/black - rev: 22.1.0 + rev: 25.1.0 hooks: - id: black - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 + rev: v3.19.1 hooks: - id: pyupgrade args: ["--py39-plus"] - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 7.1.1 hooks: - id: flake8 additional_dependencies: [pep8-naming] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer From bb58672a059a44333d03b293ad389f3a4f1869e0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:25:19 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/noise_processing.yml | 8 +++--- noise_processing.py | 36 ++++++++++++-------------- requirements_noise.txt | 6 ++--- tests/test_ooi.py | 1 + tests/test_spectrograms.py | 1 + 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/noise_processing.yml b/.github/workflows/noise_processing.yml index bffe2270..a20cd072 100644 --- a/.github/workflows/noise_processing.yml +++ b/.github/workflows/noise_processing.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: schedule: - cron: '2 * * * *' - + jobs: process: runs-on: ubuntu-latest @@ -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 @@ -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/ diff --git a/noise_processing.py b/noise_processing.py index 0d9675a8..2ade3e75 100644 --- a/noise_processing.py +++ b/noise_processing.py @@ -1,48 +1,46 @@ # 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) # now = dt.datetime(2025, 1, 16, 10) -psd_path, broadband_path = pipeline.generate_parquet_file(now - dt.timedelta(hours = 6), - now - dt.timedelta(hours = 1), - upload_to_s3=False) +psd_path, broadband_path = pipeline.generate_parquet_file( + now - dt.timedelta(hours=6), now - dt.timedelta(hours=1), 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") diff --git a/requirements_noise.txt b/requirements_noise.txt index 2d09f7fe..fd4f72a3 100644 --- a/requirements_noise.txt +++ b/requirements_noise.txt @@ -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 kaleido diff --git a/tests/test_ooi.py b/tests/test_ooi.py index 941e2773..ee9dda6f 100644 --- a/tests/test_ooi.py +++ b/tests/test_ooi.py @@ -1,4 +1,5 @@ """Unit tests for OOI workflow""" + import datetime import os import shutil diff --git a/tests/test_spectrograms.py b/tests/test_spectrograms.py index f33787aa..75a319c8 100644 --- a/tests/test_spectrograms.py +++ b/tests/test_spectrograms.py @@ -1,4 +1,5 @@ """Unit tests for various util functions relating to spectrogram creation""" + import os.path import matplotlib.pyplot as plt