|
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.PORT_TOWNSEND, |
19 | | - delta_f=10, bands=None, |
20 | | - delta_t=60, mode='safe') |
21 | | - |
22 | | - |
| 17 | +if __name__ == "__main__": |
| 18 | + pipeline = NoiseAnalysisPipeline( |
| 19 | + Hydrophone.PORT_TOWNSEND, 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')) |
28 | | -psd_path, broadband_path = pipeline.generate_parquet_file(now - dt.timedelta(hours = 6), |
29 | | - now - dt.timedelta(hours = 1), |
30 | | - upload_to_s3=False) |
| 25 | +now = dt.datetime.now(pytz.timezone("US/Pacific")) |
| 26 | +psd_path, broadband_path = pipeline.generate_parquet_file( |
| 27 | + now - dt.timedelta(hours=6), now - dt.timedelta(hours=1), upload_to_s3=False |
| 28 | +) |
31 | 29 |
|
32 | 30 | # Read the parquet files |
33 | 31 | psd_df = pd.read_parquet(psd_path) |
34 | 32 | bb_df = pd.read_parquet(broadband_path) |
35 | 33 |
|
36 | 34 | # Create a new directory if it does not exist |
37 | | -if not os.path.exists('img'): |
38 | | - os.makedirs('img') |
| 35 | +if not os.path.exists("img"): |
| 36 | + os.makedirs("img") |
39 | 37 |
|
40 | | -# Create and save psd plot |
| 38 | +# Create and save psd plot |
41 | 39 | fig = plot_spec(psd_df) |
42 | | -fig.write_image('img/psd.png') |
| 40 | +fig.write_image("img/psd.png") |
43 | 41 |
|
44 | 42 | # Create and save bb plot |
45 | 43 | fig = plot_bb(bb_df) |
46 | | -fig.savefig('img/broadband.png') |
| 44 | +fig.savefig("img/broadband.png") |
0 commit comments