gpxplotter.common

This module defines common methods for gpxplotter.

gpxplotter.common.cluster_velocities(velocities, n_clusters=5)[source]

Group the velocities into a predefined set of clusters.

This is used to label velocities as faster, slower, etc.

Parameters:
  • velocities (array_like) – The velocities to cluster.

  • n_clusters (int, optional) – The number of clusters to look for.

Returns:

levels (array_like) – The velocity level (cluster) each velocity is assigned to.

gpxplotter.common.find_regions(yval)[source]

Find borders for regions with equal values.

Parameters:

yval (array_like) – The values we are to locate regions for.

Returns:

new_regions (list of lists of numbers) – The regions where yval is constant. These are on the form [start_index, end_index, constant_y] with the interpretation that yval=constant-y for the index range [start_index, end_index]

gpxplotter.common.format_time_delta(time_delta)[source]

Format time deltas as strings on the form hh:mm:ss.

Parameters:

time_delta (array_like) – A time in seconds.

Returns:

timel (list of strings) – The time_delta formatted as hh:mm:ss

gpxplotter.common.get_limits_txt(limits)[source]

Return heart rate limits as text.

Parameters:

limits (list of list of numbers)

Returns:

txt (dict) – Text representing the heart rate zones.

gpxplotter.common.heart_rate_zone_limits(max_heart_rate=187, limits=None)[source]

Return the limits for the heart rate zones.

Parameters:
  • max_heart_rate (int (or float)) – The maximum heart rate

  • limits (list) – A list of heart rate zone limits as fractions of the maximum heart rate. This list is on the form [[min_zone_1, max_zone_1],]. The default zones are: [(0.5, 0.6), (0.6, 0.7), (0.7, 0.8), (0.8, 0.9), (0.9, 1.0)]

Returns:

out (list of list of numbers) – The heart rates defining the different zones.

gpxplotter.common.update_hr_zones(segment, max_heart_rate=187)[source]

Find and update heart rate zones for a segment.

Parameters:
  • segment (dict) – The segment to add zones for.

  • max_heart_rate (int (or float)) – The maximum heart rate, used for the calculation of zones.