Skip to content

Commit b339aa2

Browse files
committed
Created Taipy Dashboard to display the PSD's based on user input
1 parent ce4e5d4 commit b339aa2

File tree

6 files changed

+521
-2
lines changed

6 files changed

+521
-2
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ __pycache__/
1111
temp.py
1212
.DS_Store
1313
Icon?
14-
Icon[[:cntrl:]]
14+
Icon[[:cntrl:]]
15+
taipy_visualization/__pycache__/
16+
taipy_visualization/.env
17+
M2_Ship_Data/

3.9

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
Channels:
2+
- conda-forge
3+
- defaults
4+
Platform: win-64
5+
Collecting package metadata (repodata.json): ...working... done
6+
Solving environment: ...working... done
7+
8+
## Package Plan ##
9+
10+
environment location: C:\Users\srima\anaconda3\envs\orca_env
11+
12+
added / updated specs:
13+
- ffmpeg
14+
- python
15+
16+
17+
The following packages will be downloaded:
18+
19+
package | build
20+
---------------------------|-----------------
21+
libmpdec-4.0.0 | hfd05255_1 87 KB conda-forge
22+
pip-26.0.1 | pyh145f28c_0 1.1 MB conda-forge
23+
python-3.14.3 |h4b44e0e_101_cp314 17.4 MB conda-forge
24+
python_abi-3.14 | 8_cp314 7 KB conda-forge
25+
------------------------------------------------------------
26+
Total: 18.6 MB
27+
28+
The following NEW packages will be INSTALLED:
29+
30+
aom conda-forge/win-64::aom-3.9.1-he0c23c2_0
31+
bzip2 conda-forge/win-64::bzip2-1.0.8-h0ad9c76_8
32+
ca-certificates conda-forge/noarch::ca-certificates-2026.1.4-h4c7d964_0
33+
cairo conda-forge/win-64::cairo-1.18.4-h477c42c_1
34+
dav1d conda-forge/win-64::dav1d-1.2.1-hcfcfb64_0
35+
ffmpeg conda-forge/win-64::ffmpeg-8.0.1-gpl_h15a8bbd_712
36+
font-ttf-dejavu-s~ conda-forge/noarch::font-ttf-dejavu-sans-mono-2.37-hab24e00_0
37+
font-ttf-inconsol~ conda-forge/noarch::font-ttf-inconsolata-3.000-h77eed37_0
38+
font-ttf-source-c~ conda-forge/noarch::font-ttf-source-code-pro-2.038-h77eed37_0
39+
font-ttf-ubuntu conda-forge/noarch::font-ttf-ubuntu-0.83-h77eed37_3
40+
fontconfig conda-forge/win-64::fontconfig-2.15.0-h765892d_1
41+
fonts-conda-ecosy~ conda-forge/noarch::fonts-conda-ecosystem-1-0
42+
fonts-conda-forge conda-forge/noarch::fonts-conda-forge-1-hc364b38_1
43+
freetype conda-forge/win-64::freetype-2.14.1-h57928b3_0
44+
fribidi conda-forge/win-64::fribidi-1.0.16-hfd05255_0
45+
gdk-pixbuf conda-forge/win-64::gdk-pixbuf-2.44.5-h1f5b9c4_0
46+
glslang conda-forge/win-64::glslang-16.2.0-h294ba9c_1
47+
graphite2 conda-forge/win-64::graphite2-1.3.14-hac47afa_2
48+
harfbuzz conda-forge/win-64::harfbuzz-12.3.2-h5a1b470_0
49+
icu conda-forge/win-64::icu-78.2-h637d24d_0
50+
lame conda-forge/win-64::lame-3.100-hcfcfb64_1003
51+
lerc conda-forge/win-64::lerc-4.0.0-h6470a55_1
52+
libbrotlicommon conda-forge/win-64::libbrotlicommon-1.2.0-hfd05255_1
53+
libbrotlidec conda-forge/win-64::libbrotlidec-1.2.0-hfd05255_1
54+
libbrotlienc conda-forge/win-64::libbrotlienc-1.2.0-hfd05255_1
55+
libdeflate conda-forge/win-64::libdeflate-1.25-h51727cc_0
56+
libexpat conda-forge/win-64::libexpat-2.7.4-hac47afa_0
57+
libffi conda-forge/win-64::libffi-3.5.2-h3d046cb_0
58+
libfreetype conda-forge/win-64::libfreetype-2.14.1-h57928b3_0
59+
libfreetype6 conda-forge/win-64::libfreetype6-2.14.1-hdbac1cb_0
60+
libglib conda-forge/win-64::libglib-2.86.4-h0c9aed9_0
61+
libhwy conda-forge/win-64::libhwy-1.3.0-ha71e874_1
62+
libiconv conda-forge/win-64::libiconv-1.18-hc1393d2_2
63+
libintl conda-forge/win-64::libintl-0.22.5-h5728263_3
64+
libjpeg-turbo conda-forge/win-64::libjpeg-turbo-3.1.2-hfd05255_0
65+
libjxl conda-forge/win-64::libjxl-0.11.2-hf3f85d1_0
66+
liblzma conda-forge/win-64::liblzma-5.8.2-hfd05255_0
67+
libmpdec conda-forge/win-64::libmpdec-4.0.0-hfd05255_1
68+
libogg conda-forge/win-64::libogg-1.3.5-h2466b09_1
69+
libopus conda-forge/win-64::libopus-1.6.1-h6a83c73_0
70+
libpng conda-forge/win-64::libpng-1.6.55-h7351971_0
71+
librsvg conda-forge/win-64::librsvg-2.60.0-hd5e4115_1
72+
libsqlite conda-forge/win-64::libsqlite-3.51.2-hf5d6505_0
73+
libtiff conda-forge/win-64::libtiff-4.7.1-h8f73337_1
74+
libusb conda-forge/win-64::libusb-1.0.29-h1839187_0
75+
libvorbis conda-forge/win-64::libvorbis-1.3.7-h5112557_2
76+
libvulkan-loader conda-forge/win-64::libvulkan-loader-1.4.341.0-h477610d_0
77+
libwebp-base conda-forge/win-64::libwebp-base-1.6.0-h4d5522a_0
78+
libxml2 conda-forge/win-64::libxml2-2.15.1-h779ef1b_1
79+
libxml2-16 conda-forge/win-64::libxml2-16-2.15.1-h3cfd58e_1
80+
libzlib conda-forge/win-64::libzlib-1.3.1-h2466b09_2
81+
openh264 conda-forge/win-64::openh264-2.6.0-hb17fa0b_0
82+
openssl conda-forge/win-64::openssl-3.6.1-hf411b9b_1
83+
pango conda-forge/win-64::pango-1.56.4-h03d888a_0
84+
pcre2 conda-forge/win-64::pcre2-10.47-hd2b5f0e_0
85+
pip conda-forge/noarch::pip-26.0.1-pyh145f28c_0
86+
pixman conda-forge/win-64::pixman-0.46.4-h5112557_1
87+
python conda-forge/win-64::python-3.14.3-h4b44e0e_101_cp314
88+
python_abi conda-forge/noarch::python_abi-3.14-8_cp314
89+
sdl2 conda-forge/win-64::sdl2-2.32.56-h5112557_0
90+
sdl3 conda-forge/win-64::sdl3-3.4.0-h5112557_0
91+
shaderc conda-forge/win-64::shaderc-2025.5-h8fa7867_1
92+
spirv-tools conda-forge/win-64::spirv-tools-2026.1-h49e36cd_0
93+
svt-av1 conda-forge/win-64::svt-av1-4.0.1-hac47afa_0
94+
tk conda-forge/win-64::tk-8.6.13-h6ed50ae_3
95+
tzdata conda-forge/noarch::tzdata-2025c-hc9c84f9_1
96+
ucrt conda-forge/win-64::ucrt-10.0.26100.0-h57928b3_0
97+
vc conda-forge/win-64::vc-14.3-h41ae7f8_34
98+
vc14_runtime conda-forge/win-64::vc14_runtime-14.44.35208-h818238b_34
99+
vcomp14 conda-forge/win-64::vcomp14-14.44.35208-h818238b_34
100+
vs2015_runtime conda-forge/win-64::vs2015_runtime-14.44.35208-h38c0c73_34
101+
x264 conda-forge/win-64::x264-1!164.3095-h8ffe710_2
102+
x265 conda-forge/win-64::x265-3.5-h2d74725_3
103+
zstd conda-forge/win-64::zstd-1.5.7-h534d264_6
104+
105+
106+
107+
Downloading and Extracting Packages: ...working...python-3.14.3 | 17.4 MB | | 0%
108+
pip-26.0.1 | 1.1 MB | | 0% 
109+
110+
libmpdec-4.0.0 | 87 KB | | 0% 
111+
112+
113+
python_abi-3.14 | 7 KB | | 0% 
114+
115+
libmpdec-4.0.0 | 87 KB | #8 | 18% 
116+
117+
118+
python_abi-3.14 | 7 KB | ########## | 100% python-3.14.3 | 17.4 MB | | 0%
119+
120+
121+
python_abi-3.14 | 7 KB | ########## | 100% 
122+
pip-26.0.1 | 1.1 MB | 1 | 1% 
123+
124+
libmpdec-4.0.0 | 87 KB | ########## | 100% 
125+
126+
127+
python_abi-3.14 | 7 KB | ########## | 100% 
128+
129+
libmpdec-4.0.0 | 87 KB | ########## | 100% 
130+
131+
libmpdec-4.0.0 | 87 KB | ########## | 100% python-3.14.3 | 17.4 MB | 1 | 1%
132+
pip-26.0.1 | 1.1 MB | ##3 | 24% python-3.14.3 | 17.4 MB | 4 | 4%
133+
pip-26.0.1 | 1.1 MB | #########4 | 94% 
134+
pip-26.0.1 | 1.1 MB | ########## | 100% python-3.14.3 | 17.4 MB | #8 | 18% python-3.14.3 | 17.4 MB | ###6 | 37% python-3.14.3 | 17.4 MB | #####4 | 55% python-3.14.3 | 17.4 MB | #######3 | 73% python-3.14.3 | 17.4 MB | #########4 | 95% python-3.14.3 | 17.4 MB | ########## | 100%
135+
pip-26.0.1 | 1.1 MB | ########## | 100% python-3.14.3 | 17.4 MB | ########## | 100%
136+

137+
138+

139+
140+
141+
 done
142+
Preparing transaction: - \ | / - done
143+
Verifying transaction: | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ done
144+
Executing transaction: / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \
145+
| / - \ | / - \ | / - \ | / - \
146+
| / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | / - \ | done
147+
#
148+
# To activate this environment, use
149+
#
150+
# $ conda activate orca_env
151+
#
152+
# To deactivate an active environment, use
153+
#
154+
# $ conda deactivate
155+

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ python-dotenv==1.2.1
1515
plotly==6.5.0
1616
altair<5
1717
pytest
18-
pytest-asyncio
18+
pytest-asyncio
19+
taipy
20+
polars
21+
geopandas

taipy_visualization/data_utils.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import pandas as pd
2+
import polars as pl
3+
import datetime as dt
4+
import geopandas as gpd
5+
from datetime import datetime
6+
from dotenv import load_dotenv
7+
8+
load_dotenv()
9+
10+
s3_path = "s3://acoustic-sandbox/ambient-sound-analysis/data_2.0/psd/"
11+
12+
def _day_prefix(hydrophone, year, month, day):
13+
return (
14+
"s3://acoustic-sandbox/ambient-sound-analysis/data_2.0/psd/"
15+
f"hydrophone={hydrophone}/year={year}/month={int(month):02d}/day={int(day):02d}/"
16+
)
17+
18+
19+
def get_available_hours_map(month_str, day_str, hydrophone, year):
20+
21+
month = int(month_str)
22+
day = int(day_str)
23+
year = int(year)
24+
25+
day_prefix = _day_prefix(hydrophone, year, month, day)
26+
27+
try:
28+
29+
lf = pl.scan_parquet(
30+
day_prefix,
31+
hive_partitioning=True,
32+
storage_options={'aws_region': 'us-west-2'}
33+
)
34+
35+
start_time = dt.datetime(year, month, day, 0, 0, 0)
36+
end_time = dt.datetime(year, month, day, 23, 0, 0)
37+
38+
hours = (
39+
lf.select(
40+
pl.col("__index_level_0__").dt.hour().alias("hour")
41+
)
42+
.filter(
43+
pl.col("hour").is_between(start_time.hour, end_time.hour)
44+
)
45+
.unique()
46+
.sort("hour")
47+
.collect()
48+
.get_column("hour")
49+
.to_list()
50+
)
51+
52+
formatted_hours = [f"{h:02d}:00 to {h+1:02d}:00" for h in hours]
53+
54+
return formatted_hours
55+
56+
except Exception as e:
57+
print(f"An error occured\n: {e}")
58+
return []
59+
60+
def load_ship_data(shp_path):
61+
"""
62+
Loads Radar ship tracks, filters by validity, and formats columns
63+
for the Plotly spectrogram overlay.
64+
"""
65+
try:
66+
# Load the shapefile
67+
gdf = gpd.read_file(shp_path)
68+
69+
gdf['entry_time'] = pd.to_datetime(gdf['sdate'] + ' ' + gdf['stime'])
70+
gdf['exit_time'] = pd.to_datetime(gdf['ldate'] + ' ' + gdf['ltime'])
71+
72+
# Filter for valid tracks (Confidence >= 0.5 or has AIS association)
73+
gdf['valid'] = (gdf['confidence'] >= 0.5) | (gdf['assoc_id'].notna())
74+
gdf = gdf[gdf['valid'] & gdf['geometry'].notna()].sort_values('entry_time')
75+
76+
# Rename distance to closest_approach_km
77+
if 'distance' in gdf.columns:
78+
gdf = gdf.rename(columns={'distance': 'closest_approach_km'})
79+
80+
# Convert to standard Pandas DataFrame (drop geometry)
81+
df = pd.DataFrame(gdf.drop(columns=['geometry'], errors='ignore'))
82+
83+
return df
84+
85+
except Exception as e:
86+
print(f"Error loading Shapefile: {e}")
87+
return pd.DataFrame()
88+
89+
def fetch_acoustic_data(date, start_time, end_time, hydrophone="orcasound_lab"):
90+
"""
91+
This function will fetch all the parquet files for a given day within the start and end time range.
92+
These will then be sorted by index, concatenated, and sent as a dictionary
93+
"""
94+
year = date.year
95+
month = date.month
96+
day = date.day
97+
prefix = _day_prefix(hydrophone, year, month, day)
98+
99+
psd_df = pl.scan_parquet(
100+
prefix,
101+
hive_partitioning=True,
102+
storage_options={'aws_region': 'us-west-2'}
103+
)
104+
105+
try:
106+
pq_files = (
107+
psd_df
108+
.filter(
109+
(pl.col("__index_level_0__").is_between(start_time, end_time))
110+
).collect()
111+
)
112+
return pq_files
113+
114+
except Exception:
115+
print("Could not find data in the selected time range")
116+
return pl.DataFrame()
117+
118+
# print(fetch_acoustic_data(datetime(2026, 2, 7), datetime(2026, 2, 7, 0, 0, 0), datetime(2026, 2, 7, 23, 0, 0)))

0 commit comments

Comments
 (0)