Skip to main content

Find valuable gems 💎 in your tracked sport 🚴 activity!

Project description

sportgems

PyPI Python Build Status

Sportgems finds valuable gems 💎 in your tracked sport 🚴 activity!

What is it?

Sportgems lets you efficiently parse your activity data. It will search and find your sections with either max velocity or max climb (see below). It will determine the start, end and speed of whatever desired sections you are interested in, e.g. 1km, 2km, 10km and others.

Sportgems is used in workoutizer to find your fastest 1km (and other 💎) in all your activities and visualize it. See for example this screenshot of an activity in workoutizer, with the fastest 3km section being highlighted in yellow:

Installation

Sportgems is bundled in a python package using pyo3. Simply install it using pip:

pip install sportgems

The following interfacing functions are available:

function name purpose
find_fastest_section parse your activity data to find the fastest section
find_fastest_section_in_fit parse your activity .fit file to find the fastest section
find_best_climb_section parse your activity data to find the best climb section
find_best_climb_section_in_fit parse your activity .fit file to find the best climb section
parse_fit_data parse your activity .fit file to get e.g. timestamps, coordinates, altitude and calories

Have a look at the docstrings of these functions for more details.

How to use it?

In order to search for gems 💎 in your activity, pass a path and desired distance to e.g. find_fastest_section_in_fit like:

from sportgems import find_fastest_section_in_fit

desired_distance = 1_000  # in meter
path_to_fit_file = "tests/data/2019-09-14-17-22-05.fit"
result = find_fastest_section_in_fit(desired_distance, path_to_fit_file)

The result will be a python object with the following attributes:

print(f'Found fastest section, from {result.start=} to {result.end=} with {result.velocity=} m/s')

which prints:

Found fastest section, from result.start=635 to result.end=725 with result.velocity=2.898669803146783 m/s

How does it work?

The following diagram illustrates how the core algorithm (implemented in gem_finder.cpp) works:

Changelog

See CHANGELOG.md.

Running the tests

In order to run the rust unit tests simply run

cargo test --no-default-features

To run the python tests, you first need to install the requirements

pip install -r requirements.txt

and subsequently run the tests

pytest tests/

Contributing

Contributions are welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

sportgems-0.4.2-cp39-none-win_amd64.whl (160.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

sportgems-0.4.2-cp39-cp39-manylinux2014_x86_64.whl (217.9 kB view hashes)

Uploaded CPython 3.9

sportgems-0.4.2-cp39-cp39-macosx_10_7_x86_64.whl (210.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.7+ x86-64

sportgems-0.4.2-cp38-none-win_amd64.whl (160.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

sportgems-0.4.2-cp38-cp38-manylinux2014_x86_64.whl (217.5 kB view hashes)

Uploaded CPython 3.8

sportgems-0.4.2-cp38-cp38-macosx_10_7_x86_64.whl (209.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.7+ x86-64

sportgems-0.4.2-cp38-cp38-linux_armv7l.whl (210.1 kB view hashes)

Uploaded CPython 3.8

sportgems-0.4.2-cp37-none-win_amd64.whl (160.1 kB view hashes)

Uploaded CPython 3.7 Windows x86-64

sportgems-0.4.2-cp37-cp37m-manylinux2014_x86_64.whl (217.4 kB view hashes)

Uploaded CPython 3.7m

sportgems-0.4.2-cp37-cp37m-macosx_10_7_x86_64.whl (209.5 kB view hashes)

Uploaded CPython 3.7m macOS 10.7+ x86-64

sportgems-0.4.2-cp36-none-win_amd64.whl (160.1 kB view hashes)

Uploaded CPython 3.6 Windows x86-64

sportgems-0.4.2-cp36-cp36m-manylinux2014_x86_64.whl (217.4 kB view hashes)

Uploaded CPython 3.6m

sportgems-0.4.2-cp36-cp36m-macosx_10_7_x86_64.whl (209.6 kB view hashes)

Uploaded CPython 3.6m macOS 10.7+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page