|
1 | 1 | # importing general Python libraries |
2 | | -import pandas as pd |
3 | 2 | import datetime as dt |
4 | 3 | import os |
| 4 | + |
5 | 5 | import matplotlib.pyplot as plt |
6 | | -import pytz |
| 6 | +import pandas as pd |
7 | 7 | import plotly.graph_objects as go |
| 8 | +import pytz |
| 9 | +from orcasound_noise.pipeline.acoustic_util import plot_bb, plot_spec |
8 | 10 |
|
9 | 11 | # importing orcasound_noise libraries |
10 | 12 | from orcasound_noise.pipeline.pipeline import NoiseAnalysisPipeline |
11 | 13 | from orcasound_noise.utils import Hydrophone |
12 | | -from orcasound_noise.pipeline.acoustic_util import plot_spec, plot_bb |
13 | | - |
14 | 14 |
|
15 | 15 | # Set Location and Resolution |
16 | 16 | # Port Townsend, 1 Hz Frequency, 60-second samples |
17 | | -if __name__ == '__main__': |
18 | | - pipeline = NoiseAnalysisPipeline(Hydrophone.BUSH_POINT, |
19 | | - delta_f=10, bands=None, |
20 | | - delta_t=60, mode='safe') |
21 | | - |
22 | | - |
| 17 | +if __name__ == "__main__": |
| 18 | + pipeline = NoiseAnalysisPipeline( |
| 19 | + Hydrophone.BUSH_POINT, delta_f=10, bands=None, delta_t=60, mode="safe" |
| 20 | + ) |
23 | 21 |
|
24 | 22 |
|
25 | 23 | # Generate parquet dataframes with noise levels for a time period |
26 | 24 |
|
27 | | -now = dt.datetime.now(pytz.timezone('US/Pacific')) |
| 25 | +now = dt.datetime.now(pytz.timezone("US/Pacific")) |
28 | 26 | # now = dt.datetime(2024, 11, 20, 10) |
29 | 27 | # now = dt.datetime(2025, 1, 16, 10) |
30 | | -psd_path, broadband_path = pipeline.generate_parquet_file(now - dt.timedelta(hours = 6), |
31 | | - now - dt.timedelta(hours = 1), |
32 | | - upload_to_s3=False) |
| 28 | +psd_path, broadband_path = pipeline.generate_parquet_file( |
| 29 | + now - dt.timedelta(hours=6), now - dt.timedelta(hours=1), upload_to_s3=False |
| 30 | +) |
33 | 31 |
|
34 | 32 | # Read the parquet files |
35 | 33 | psd_df = pd.read_parquet(psd_path) |
36 | 34 | bb_df = pd.read_parquet(broadband_path) |
37 | 35 |
|
38 | 36 | # Create a new directory if it does not exist |
39 | | -if not os.path.exists('img'): |
40 | | - os.makedirs('img') |
| 37 | +if not os.path.exists("img"): |
| 38 | + os.makedirs("img") |
41 | 39 |
|
42 | | -# Create and save psd plot |
| 40 | +# Create and save psd plot |
43 | 41 | fig = plot_spec(psd_df) |
44 | | -fig.write_image('img/psd.png') |
| 42 | +fig.write_image("img/psd.png") |
45 | 43 |
|
46 | 44 | # Create and save bb plot |
47 | 45 | fig = plot_bb(bb_df) |
48 | | -fig.savefig('img/broadband.png') |
| 46 | +fig.savefig("img/broadband.png") |
0 commit comments