Updated the HR-Zone Map Plot + App live view Screenshots

This commit is contained in:
2026-05-20 12:41:52 +02:00
parent 8867314622
commit 93a5eeb2c3
3 changed files with 36 additions and 20 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

@@ -466,10 +466,10 @@ _HR_REST = 64.5 # Ruhepuls in bpm kalibriert gegen Strava 550 kcal
HR_MAX_BPM = 220 - _AGE_YEARS # z.B. 185 bei Alter 35
HR_ZONES = [
{"name": "Zone 1", "lower": 0, "upper": 124, "color": "#7FB3FF", "label": "Recovery"},
{"name": "Zone 2", "lower": 124, "upper": 154, "color": "#9DE79A", "label": "Ausdauer"},
{"name": "Zone 3", "lower": 154, "upper": 169, "color": "#FFF29A", "label": "Aerob"},
{"name": "Zone 4", "lower": 169, "upper": 184, "color": "#FFBE7A", "label": "Schwelle"},
{"name": "Zone 5", "lower": 184, "upper": 999, "color": "#FF9AA2", "label": "Neuromuск."},
{"name": "Zone 2", "lower": 124, "upper": 154, "color": "#9DE79A", "label": "Endurance"},
{"name": "Zone 3", "lower": 154, "upper": 169, "color": "#FFF29A", "label": "Aerob/Tempo"},
{"name": "Zone 4", "lower": 169, "upper": 184, "color": "#FFBE7A", "label": "Anaerob/Threshold"},
{"name": "Zone 5", "lower": 184, "upper": 999, "color": "#FF9AA2", "label": "Max. Effort"},
]
def get_zone_for_bpm(bpm):
@@ -1204,7 +1204,7 @@ def create_pixel_heatmap(dataframes,
# -----------------------------------------------------------------------------
# PIXEL-PLOT 2: ELEVATION-MAP Farbe zeigt Steigung/Gefälle je Segment
# Map-PLOT 2: ELEVATION-MAP Farbe zeigt Steigung/Gefälle je Segment
# -----------------------------------------------------------------------------
def create_route_elevation_map(df, height=500):
"""
@@ -1349,7 +1349,7 @@ def create_route_elevation_map(df, height=500):
# -----------------------------------------------------------------------------
# PIXEL-PLOT 3: PACE-MAP Farbe zeigt Tempo je Segment (schnell = blau, langsam = rot)
# Map-PLOT 3: PACE-MAP Farbe zeigt Tempo je Segment (schnell = blau, langsam = rot)
# -----------------------------------------------------------------------------
def create_route_pace_map(df, height=500):
"""
@@ -1400,6 +1400,13 @@ def create_route_pace_map(df, height=500):
[0.75, '#00cc88'],
[1.00, '#0033cc'],
]
#colorscale = [
# [0.00, '#e88080'], # pastell-rot (langsam)
# [0.25, '#f0a875'], # pastell-orange
# [0.50, '#f5e090'], # pastell-gelb (mittel)
# [0.75, '#80d4a8'], # pastell-grün
# [1.00, '#7aaee8'], # pastell-blau (schnell)
#]
def fmt_pace(p):
if np.isnan(p): return ''
@@ -1501,7 +1508,7 @@ def create_route_pace_map(df, height=500):
# -----------------------------------------------------------------------------
# PIXEL-PLOT 4: HEART-RATE-MAP
# Map-PLOT 4: HEART-RATE-MAP
# -----------------------------------------------------------------------------
def create_route_hr_map(df, mode='bpm', height=500):
"""
@@ -1660,12 +1667,17 @@ def create_route_hr_map(df, mode='bpm', height=500):
paper_bgcolor='#0d0d0d',
plot_bgcolor='#0d0d0d',
font=dict(color='white'),
margin=dict(l=0, r=0 if mode == 'bpm' else 130, t=40, b=70),
#margin=dict(l=0, r=0 if mode == 'bpm' else 130, t=40, b=70),
margin=dict(l=0, r=0, t=40, b=70),
height=height,
legend=dict(
x=1.01, y=0.5, xanchor='left',
font=dict(color='white', size=9),
bgcolor='rgba(0,0,0,0.4)',
orientation='h',
x=0.5, xanchor='center',
y=-0.08, yanchor='top',
font=dict(color='white', size=11),
bgcolor='rgba(0,0,0,0)',
entrywidth=0,
tracegroupgap=0,
) if mode == 'zone' else dict(visible=False),
uirevision='hr_map',
dragmode='zoom',
@@ -2480,7 +2492,7 @@ app.layout = html.Div([
# Toggle: Einzellauf ↔ Region
html.Div([
html.Span("Einzellauf", style={
html.Span("Courses", style={
'color': '#aaa', 'fontSize': '12px',
'marginRight': '8px', 'verticalAlign': 'middle'
}),
@@ -2536,8 +2548,9 @@ app.layout = html.Div([
}),
dcc.Checklist(
id='hr-map-mode-toggle',
options=[{'label': ' HR-Zonen', 'value': 'zone'}],
value=[],
#options=[{'label': ' HR-Zonen', 'value': 'zone'}], # Uncomment if you perfere the untoggled Version!
options=[{'label': ' BPM-intensity', 'value': 'bpm'}],
value=[], # Zone as Standard - If you like to load the intensity map add: 'bpm'
inputStyle={
'cursor': 'pointer', 'width': '36px', 'height': '18px',
'accentColor': '#fc4e00', 'verticalAlign': 'middle',
@@ -2656,7 +2669,8 @@ def update_hr_route_map(json_data, toggle_value):
return empty
df = pd.read_json(io.StringIO(json_data), orient='split')
mode = 'zone' if toggle_value and 'zone' in toggle_value else 'bpm'
#mode = 'zone' if toggle_value and 'zone' in toggle_value else 'bpm' # Uncomment if you prefere untoggled!
mode = 'bpm' if toggle_value and 'bpm' in toggle_value else 'zone'
return create_route_hr_map(df, mode=mode, height=500)
@@ -2740,7 +2754,7 @@ def update_pixel_heatmap(selected_file, toggle_value):
n_city_runs=len(city_dfs),
img_width=800, img_height=500,
)
city_info_text = f'Region {city_code} · Einzellauf · Count aus {len(city_dfs)} Läufen'
city_info_text = f'Region {city_code} · single run · Count of {len(city_dfs)} runs'
else:
# --- Region-Modus: alle Läufe der Stadt anzeigen ---
@@ -2751,7 +2765,7 @@ def update_pixel_heatmap(selected_file, toggle_value):
n_city_runs=len(city_dfs),
img_width=800, img_height=500,
)
city_info_text = f'Region {city_code} · {len(city_dfs)} Läufe geladen'
city_info_text = f'Region {city_code} · {len(city_dfs)} runs loaded'
return fig, city_info_text
@@ -2823,6 +2837,8 @@ def export_summary_image(n_clicks, json_data, selected_file):
# === Run Server ===
if __name__ == '__main__':
app.run(debug=True,
#debug=False, # ← 'False' for Netzwerk-use/test http://192.168.2.162:8051 at mobilephone browser
#host='0.0.0.0', # ← For Netzwerk-use/test
port=8051,
threaded=True,
processes=1
@@ -2830,7 +2846,7 @@ if __name__ == '__main__':
# NOTE:
# Zusammenhang zwischen Pace und Geschwindigkeit
# - Pace = Minuten pro Kilometer (z.B. 5:40/km)
# - Geschwindigkeit = Kilometer pro Stunde (z.B. 10.71 km/h)
# Relation between Pace and Speed
# - Pace = Minutes per Kilometer (e.g. 5:40/km)
# - Speed = Kilometer per hour (z.B. 10.71 km/h)
#