|
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 | | -psd_path, broadband_path = pipeline.generate_parquet_file(now - dt.timedelta(hours = 10), |
30 | | - now - dt.timedelta(hours = 8), |
31 | | - upload_to_s3=False) |
| 27 | +psd_path, broadband_path = pipeline.generate_parquet_file( |
| 28 | + now - dt.timedelta(hours=10), now - dt.timedelta(hours=8), upload_to_s3=False |
| 29 | +) |
32 | 30 |
|
33 | 31 | # Read the parquet files |
34 | 32 | psd_df = pd.read_parquet(psd_path) |
35 | 33 | bb_df = pd.read_parquet(broadband_path) |
36 | 34 |
|
37 | 35 | # Create a new directory if it does not exist |
38 | | -if not os.path.exists('img'): |
39 | | - os.makedirs('img') |
| 36 | +if not os.path.exists("img"): |
| 37 | + os.makedirs("img") |
40 | 38 |
|
41 | | -# Create and save psd plot |
| 39 | +# Create and save psd plot |
42 | 40 | fig = plot_spec(psd_df) |
43 | | -fig.write_image('img/psd.png') |
| 41 | +fig.write_image("img/psd.png") |
44 | 42 |
|
45 | 43 | # Create and save bb plot |
46 | 44 | fig = plot_bb(bb_df) |
47 | | -fig.savefig('img/broadband.png') |
| 45 | +fig.savefig("img/broadband.png") |
0 commit comments