Skip to content

Commit

Permalink
Merge branch 'Nachtzuster:main' into patch-7
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbelgium authored Mar 8, 2025
2 parents 8f1291a + 50eb978 commit a3c3dc1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ I hope that if you find BirdNET-Pi has been worth your time, you will share your
BirdNET-Pi can also be run as a [Homeassistant](https://www.home-assistant.io/) addon through docker.
For more information : https://github.com/alexbelgium/hassio-addons/blob/master/birdnet-pi/README.md

## Docker

BirdNET-Pi can also be run as as a docker container.
For more information : https://github.com/alexbelgium/hassio-addons/blob/master/birdnet-pi/README_standalone.md

## Cool Links

- [Marie Lelouche's <i>Out of Spaces</i>](https://www.lestanneries.fr/exposition/marie-lelouche-out-of-spaces/) using BirdNET-Pi in post-sculpture VR! [Press Kit](https://github.com/mcguirepr89/BirdNET-Pi-assets/blob/main/dp_out_of_spaces_marie_lelouche_digital_05_01_22.pdf)
Expand Down
2 changes: 1 addition & 1 deletion scripts/daily_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def create_plot(df_plt_today, now, is_top=None):
if conf['COLOR_SCHEME'] == "dark":
facecolor = 'darkgrey'
else:
facecolor = 'none'
facecolor = '#77C487'

f, axs = plt.subplots(1, 2, figsize=(10, height), gridspec_kw=dict(width_ratios=[3, 6]), facecolor=facecolor)

Expand Down
34 changes: 18 additions & 16 deletions scripts/plotly_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@

@st.cache_resource()
def get_connection(path: str):
return sqlite3.connect(path, check_same_thread=False)
uri = f"file:{path}?mode=ro"
return sqlite3.connect(uri, uri=True, check_same_thread=False)


def get_data(_conn: Connection):
Expand Down Expand Up @@ -256,24 +257,24 @@ def hms_to_str(t):

# Plot seen species for selected date range and number of species

fig.add_trace(go.Bar(y=top_N_species.index, x=top_N_species, orientation='h', marker_color='seagreen'), row=1, col=1)
fig.add_trace(go.Bar(y=top_N_species.index.tolist(), x=top_N_species.values.tolist(), orientation='h', marker_color='seagreen'), row=1, col=1)

fig.update_layout(
margin=dict(l=0, r=0, t=50, b=0),
yaxis={'categoryorder': 'total ascending'})

# Set 360 degrees, 24 hours for polar plot
theta = np.linspace(0.0, 360, 24, endpoint=False)
theta = np.linspace(0.0, 360, 24, endpoint=False).tolist()

specie_filt = df5 == specie
df3 = df5[specie_filt]

detections2 = pd.crosstab(df3, df3.index.hour)

d = pd.DataFrame(np.zeros((23, 1))).squeeze()
d = pd.DataFrame(np.zeros((24, 1))).squeeze()
detections = hourly.loc[specie]
detections = (d + detections).fillna(0)
fig.add_trace(go.Barpolar(r=detections, theta=theta, marker_color='seagreen'), row=1, col=2)
fig.add_trace(go.Barpolar(r=detections.tolist(), theta=theta, marker_color='seagreen'), row=1, col=2)
fig.update_layout(
autosize=False,
width=1000,
Expand Down Expand Up @@ -301,7 +302,7 @@ def hms_to_str(t):
)

daily = pd.crosstab(df5, df5.index.date, dropna=True, margins=True)
fig.add_trace(go.Bar(x=daily.columns[:-1], y=daily.loc[specie][:-1], marker_color='seagreen'), row=3, col=2)
fig.add_trace(go.Bar(x=daily.columns[:-1].tolist(), y=daily.loc[specie][:-1].tolist(), marker_color='seagreen'), row=3, col=2)
st.plotly_chart(fig, use_container_width=True) # , config=config)

else:
Expand All @@ -312,17 +313,17 @@ def hms_to_str(t):
specs=[[{"type": "polar", "rowspan": 2}], [{"rowspan": 1}], [{"type": "xy", "rowspan": 1}]]
)
# Set 360 degrees, 24 hours for polar plot
theta = np.linspace(0.0, 360, 24, endpoint=False)
theta = np.linspace(0.0, 360, 24, endpoint=False).tolist()

specie_filt = df5 == specie
df3 = df5[specie_filt]

detections2 = pd.crosstab(df3, df3.index.hour)

d = pd.DataFrame(np.zeros((23, 1))).squeeze()
d = pd.DataFrame(np.zeros((24, 1))).squeeze()
detections = hourly.loc[specie]
detections = (d + detections).fillna(0)
fig.add_trace(go.Barpolar(r=detections, theta=theta, marker_color='seagreen'), row=1, col=1)
fig.add_trace(go.Barpolar(r=detections.tolist(), theta=theta, marker_color='seagreen'), row=1, col=1)
fig.update_layout(
autosize=False,
width=1000,
Expand Down Expand Up @@ -350,7 +351,7 @@ def hms_to_str(t):
)

daily = pd.crosstab(df5, df5.index.date, dropna=True, margins=True)
fig.add_trace(go.Bar(x=daily.columns[:-1], y=daily.loc[specie][:-1], marker_color='seagreen'), row=3, col=1)
fig.add_trace(go.Bar(x=daily.columns[:-1].tolist(), y=daily.loc[specie][:-1].tolist(), marker_color='seagreen'), row=3, col=1)
st.plotly_chart(fig, use_container_width=True) # , config=config)
df_counts = int(hourly[hourly.index == specie]['All'].iloc[0])
st.subheader('Total Detect:' + str('{:,}'.format(df_counts))
Expand Down Expand Up @@ -379,8 +380,8 @@ def hms_to_str(t):
species[1:],
index=0)

df_counts = int(hourly[hourly.index == specie]['All'])
fig = st.container()
df_counts = int(hourly.loc[hourly.index == specie, 'All'].iloc[0])

fig = make_subplots(rows=1, cols=1)

df4 = df2['Com_Name'][df2['Com_Name'] == specie].resample('15min').count()
Expand All @@ -392,14 +393,14 @@ def hms_to_str(t):
fig_x = [d.strftime('%d-%m-%Y') for d in day_hour_freq.index.tolist()]
fig_y = [h.strftime('%H:%M') for h in day_hour_freq.columns.tolist()]
day_hour_freq.columns = fig_dec_y
fig_z = day_hour_freq.values.transpose()
fig_z = day_hour_freq.values.transpose().tolist()

color_pals = px.colors.named_colorscales()
selected_pal = st.sidebar.selectbox('Select Color Pallet for Daily Detections', color_pals)

heatmap = go.Heatmap(
x=fig_x,
y=day_hour_freq.columns,
y=day_hour_freq.columns.tolist(),
z=fig_z, # heat.values,
showscale=False,
texttemplate="%{text}", autocolorscale=False, colorscale=selected_pal
Expand Down Expand Up @@ -440,7 +441,7 @@ def hms_to_str(t):

plt_topN_today = (df6['Com_Name'].value_counts()[:readings])
freq_order = pd.value_counts(df6['Com_Name']).iloc[:readings].index
fig.add_trace(go.Bar(y=plt_topN_today.index, x=plt_topN_today, marker_color='seagreen', orientation='h'), row=1,
fig.add_trace(go.Bar(y=plt_topN_today.index.tolist(), x=plt_topN_today.values.tolist(), marker_color='seagreen', orientation='h'), row=1,
col=1)

df6['Hour of Day'] = [r.hour for r in df6.index.time]
Expand All @@ -449,6 +450,7 @@ def hms_to_str(t):
heat.index = pd.CategoricalIndex(heat.index, categories=freq_order)
heat.sort_index(level=0, inplace=True)

heat.index = heat.index.astype(str)
heat_plot_values = ma.log(heat.values).filled(0)

hours_in_day = pd.Series(data=range(0, 24))
Expand All @@ -459,7 +461,7 @@ def hms_to_str(t):

labels = heat.values.astype(int).astype('str')
labels[labels == '0'] = ""
fig.add_trace(go.Heatmap(x=heat.columns, y=heat.index, z=heat_values_normalized, # heat.values,
fig.add_trace(go.Heatmap(x=heat.columns.tolist(), y=heat.index.tolist(), z=heat_values_normalized, # heat.values,
showscale=False,
text=labels, texttemplate="%{text}", colorscale='Blugrn'
), row=1, col=2)
Expand Down

0 comments on commit a3c3dc1

Please sign in to comment.