Auto-update: Fri Nov 15 12:44:29 PST 2024
This commit is contained in:
parent
c1b13ca724
commit
2d49d296fb
2 changed files with 21 additions and 8 deletions
|
@ -1,8 +1,11 @@
|
||||||
setuptools
|
setuptools
|
||||||
|
adblockparser
|
||||||
aiofiles
|
aiofiles
|
||||||
aiohttp
|
aiohttp
|
||||||
asyncpg
|
asyncpg
|
||||||
|
better_profanity
|
||||||
elevation
|
elevation
|
||||||
|
matplotlib
|
||||||
pydantic
|
pydantic
|
||||||
python-dotenv
|
python-dotenv
|
||||||
pyyaml
|
pyyaml
|
||||||
|
@ -129,5 +132,3 @@ websockets
|
||||||
whisper
|
whisper
|
||||||
whisperplus
|
whisperplus
|
||||||
youtube_dl
|
youtube_dl
|
||||||
better_profanity
|
|
||||||
adblockparser
|
|
||||||
|
|
|
@ -135,7 +135,10 @@ async def generate_and_save_heatmap(
|
||||||
:param output_path: The path to save the PNG file (optional)
|
:param output_path: The path to save the PNG file (optional)
|
||||||
:return: The path where the PNG file was saved
|
:return: The path where the PNG file was saved
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
start_date = await dt(start_date)
|
start_date = await dt(start_date)
|
||||||
if end_date:
|
if end_date:
|
||||||
end_date = await dt(end_date)
|
end_date = await dt(end_date)
|
||||||
|
@ -149,14 +152,24 @@ async def generate_and_save_heatmap(
|
||||||
lats = [loc.latitude for loc in locations]
|
lats = [loc.latitude for loc in locations]
|
||||||
lons = [loc.longitude for loc in locations]
|
lons = [loc.longitude for loc in locations]
|
||||||
|
|
||||||
plt.figure(figsize=(10, 6))
|
plt.style.use('dark_background')
|
||||||
plt.hist2d(lons, lats, bins=50, cmap='hot')
|
fig, ax = plt.subplots(figsize=(10, 6))
|
||||||
plt.colorbar(label='Count')
|
|
||||||
|
# Create heatmap
|
||||||
|
heatmap, xedges, yedges = np.histogram2d(lons, lats, bins=50)
|
||||||
|
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
|
||||||
|
|
||||||
|
# Plot with no axes or labels
|
||||||
|
ax.imshow(heatmap.T, extent=extent, origin='lower', cmap='hot', interpolation='gaussian')
|
||||||
|
ax.axis('off')
|
||||||
|
|
||||||
|
# Remove white border
|
||||||
|
plt.gca().set_position([0, 0, 1, 1])
|
||||||
|
|
||||||
if output_path is None:
|
if output_path is None:
|
||||||
output_path, relative_path = assemble_journal_path(end_date, filename="map", extension=".png", no_timestamp=True)
|
output_path, relative_path = assemble_journal_path(end_date, filename="map", extension=".png", no_timestamp=True)
|
||||||
|
|
||||||
plt.savefig(output_path)
|
plt.savefig(output_path, bbox_inches='tight', pad_inches=0, transparent=True)
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
l.info(f"Heatmap saved as PNG: {output_path}")
|
l.info(f"Heatmap saved as PNG: {output_path}")
|
||||||
|
@ -167,7 +180,6 @@ async def generate_and_save_heatmap(
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def generate_map(start_date: datetime, end_date: datetime, max_points: int):
|
async def generate_map(start_date: datetime, end_date: datetime, max_points: int):
|
||||||
locations = await fetch_locations(start_date, end_date)
|
locations = await fetch_locations(start_date, end_date)
|
||||||
if not locations:
|
if not locations:
|
||||||
|
|
Loading…
Reference in a new issue