pacelab 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pacelab/__init__.py +6 -0
- pacelab/cli.py +62 -0
- pacelab/errors.py +2 -0
- pacelab/format.py +26 -0
- pacelab/io/__init__.py +51 -0
- pacelab/io/fit.py +96 -0
- pacelab/io/gpx.py +54 -0
- pacelab/io/tcx.py +39 -0
- pacelab/io/xml.py +54 -0
- pacelab/metrics.py +256 -0
- pacelab/model.py +108 -0
- pacelab/py.typed +0 -0
- pacelab-0.1.0.dist-info/METADATA +48 -0
- pacelab-0.1.0.dist-info/RECORD +17 -0
- pacelab-0.1.0.dist-info/WHEEL +4 -0
- pacelab-0.1.0.dist-info/entry_points.txt +3 -0
- pacelab-0.1.0.dist-info/licenses/LICENSE +202 -0
pacelab/__init__.py
ADDED
pacelab/cli.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Annotated
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
|
|
6
|
+
from pacelab import format
|
|
7
|
+
from pacelab.errors import ActivityFileError
|
|
8
|
+
from pacelab.io import load
|
|
9
|
+
from pacelab.metrics import best_efforts, summarize
|
|
10
|
+
from pacelab.model import Activity
|
|
11
|
+
|
|
12
|
+
app = typer.Typer(no_args_is_help=True, help="Analyse FIT, GPX and TCX activity files.")
|
|
13
|
+
|
|
14
|
+
Files = Annotated[list[Path], typer.Argument(exists=True, dir_okay=False, readable=True)]
|
|
15
|
+
File = Annotated[Path, typer.Argument(exists=True, dir_okay=False, readable=True)]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@app.command(help="Print distance, time, pace, heart rate and climb for each file.")
|
|
19
|
+
def summary(files: Files) -> None:
|
|
20
|
+
failed = False
|
|
21
|
+
for path in files:
|
|
22
|
+
try:
|
|
23
|
+
activity = load(path)
|
|
24
|
+
except ActivityFileError as error:
|
|
25
|
+
typer.echo(f"{path}: {error}", err=True)
|
|
26
|
+
failed = True
|
|
27
|
+
continue
|
|
28
|
+
result = summarize(activity)
|
|
29
|
+
heart_rate = f"{result.avg_heart_rate:.0f} bpm" if result.avg_heart_rate else "-"
|
|
30
|
+
typer.echo(
|
|
31
|
+
f"{path.name} {activity.start_time:%Y-%m-%d %H:%M} {activity.sport.value} "
|
|
32
|
+
f"{format.kilometres(result.distance_m)} {format.duration(result.moving_s)} "
|
|
33
|
+
f"{format.pace(result.pace_s_per_km)} {heart_rate} "
|
|
34
|
+
f"+{result.elevation_gain_m:.0f} m"
|
|
35
|
+
)
|
|
36
|
+
if failed:
|
|
37
|
+
raise typer.Exit(1)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@app.command(help="Print the fastest time over standard distances.")
|
|
41
|
+
def efforts(file: File) -> None:
|
|
42
|
+
for distance, seconds in best_efforts(_load(file)).items():
|
|
43
|
+
typer.echo(f"{format.distance_name(distance):>14} {format.duration(seconds)}")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@app.command(help="Write the normalised record stream to .csv or .parquet.")
|
|
47
|
+
def export(file: File, output: Annotated[Path, typer.Argument(dir_okay=False)]) -> None:
|
|
48
|
+
records = _load(file).records
|
|
49
|
+
if output.suffix == ".parquet":
|
|
50
|
+
records.write_parquet(output)
|
|
51
|
+
elif output.suffix == ".csv":
|
|
52
|
+
records.write_csv(output)
|
|
53
|
+
else:
|
|
54
|
+
raise typer.BadParameter("output must end in .csv or .parquet", param_hint="OUTPUT")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _load(path: Path) -> Activity:
|
|
58
|
+
try:
|
|
59
|
+
return load(path)
|
|
60
|
+
except ActivityFileError as error:
|
|
61
|
+
typer.echo(f"{path}: {error}", err=True)
|
|
62
|
+
raise typer.Exit(1) from error
|
pacelab/errors.py
ADDED
pacelab/format.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
def duration(seconds: float) -> str:
|
|
2
|
+
total = round(seconds)
|
|
3
|
+
hours, rest = divmod(total, 3600)
|
|
4
|
+
minutes, secs = divmod(rest, 60)
|
|
5
|
+
return f"{hours}:{minutes:02d}:{secs:02d}" if hours else f"{minutes}:{secs:02d}"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def pace(seconds_per_km: float | None) -> str:
|
|
9
|
+
if seconds_per_km is None:
|
|
10
|
+
return "-"
|
|
11
|
+
return f"{duration(seconds_per_km)} /km"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def kilometres(meters: float) -> str:
|
|
15
|
+
return f"{meters / 1000:.2f} km"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
NAMED_DISTANCES_M = {1609.344: "1 mile", 21097.5: "Half marathon", 42195.0: "Marathon"}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def distance_name(meters: float) -> str:
|
|
22
|
+
if meters in NAMED_DISTANCES_M:
|
|
23
|
+
return NAMED_DISTANCES_M[meters]
|
|
24
|
+
if meters < 1000:
|
|
25
|
+
return f"{meters:g} m"
|
|
26
|
+
return f"{meters / 1000:g} km"
|
pacelab/io/__init__.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import zlib
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from defusedxml import ElementTree
|
|
6
|
+
from defusedxml.common import DefusedXmlException
|
|
7
|
+
|
|
8
|
+
from pacelab.errors import ActivityFileError
|
|
9
|
+
from pacelab.io.fit import read_fit
|
|
10
|
+
from pacelab.io.gpx import read_gpx
|
|
11
|
+
from pacelab.io.tcx import read_tcx
|
|
12
|
+
from pacelab.model import Activity
|
|
13
|
+
|
|
14
|
+
MAX_DECOMPRESSED_BYTES = 256 * 1024 * 1024
|
|
15
|
+
|
|
16
|
+
__all__ = ["ActivityFileError", "load"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def load(source: str | os.PathLike[str] | bytes) -> Activity:
|
|
20
|
+
data = source if isinstance(source, bytes) else Path(source).read_bytes()
|
|
21
|
+
if data[:2] == b"\x1f\x8b":
|
|
22
|
+
data = _gunzip(data)
|
|
23
|
+
if len(data) >= 12 and data[8:12] == b".FIT":
|
|
24
|
+
return read_fit(data)
|
|
25
|
+
if data.lstrip(b"\xef\xbb\xbf \t\r\n")[:1] == b"<":
|
|
26
|
+
return _read_xml(data)
|
|
27
|
+
raise ActivityFileError("unsupported file: expected FIT, GPX or TCX")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _read_xml(data: bytes) -> Activity:
|
|
31
|
+
try:
|
|
32
|
+
root = ElementTree.fromstring(data)
|
|
33
|
+
except (ElementTree.ParseError, DefusedXmlException) as error:
|
|
34
|
+
raise ActivityFileError(f"unreadable XML: {error}") from error
|
|
35
|
+
name = root.tag.rsplit("}", 1)[-1]
|
|
36
|
+
if name == "gpx":
|
|
37
|
+
return read_gpx(root)
|
|
38
|
+
if name == "TrainingCenterDatabase":
|
|
39
|
+
return read_tcx(root)
|
|
40
|
+
raise ActivityFileError(f"unsupported XML document <{name}>")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _gunzip(data: bytes) -> bytes:
|
|
44
|
+
inflater = zlib.decompressobj(wbits=31)
|
|
45
|
+
try:
|
|
46
|
+
out = inflater.decompress(data, MAX_DECOMPRESSED_BYTES)
|
|
47
|
+
except zlib.error as error:
|
|
48
|
+
raise ActivityFileError(f"corrupt gzip data: {error}") from error
|
|
49
|
+
if inflater.unconsumed_tail:
|
|
50
|
+
raise ActivityFileError("decompressed file is larger than 256 MB")
|
|
51
|
+
return out
|
pacelab/io/fit.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import datetime as dt
|
|
2
|
+
import io
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import fitdecode
|
|
6
|
+
|
|
7
|
+
from pacelab.errors import ActivityFileError
|
|
8
|
+
from pacelab.model import Activity, Sport
|
|
9
|
+
|
|
10
|
+
SEMICIRCLE_TO_DEGREES = 180 / 2**31
|
|
11
|
+
|
|
12
|
+
FIT_SPORTS = {
|
|
13
|
+
"running": Sport.RUNNING,
|
|
14
|
+
"walking": Sport.WALKING,
|
|
15
|
+
"hiking": Sport.HIKING,
|
|
16
|
+
"cycling": Sport.CYCLING,
|
|
17
|
+
"swimming": Sport.SWIMMING,
|
|
18
|
+
}
|
|
19
|
+
FIT_RUNNING_SUB_SPORTS = {"trail": Sport.TRAIL_RUNNING, "treadmill": Sport.TREADMILL_RUNNING}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def read_fit(data: bytes) -> Activity:
|
|
23
|
+
rows: list[dict[str, Any]] = []
|
|
24
|
+
sport = Sport.OTHER
|
|
25
|
+
start_time: dt.datetime | None = None
|
|
26
|
+
device: str | None = None
|
|
27
|
+
session_seen = False
|
|
28
|
+
try:
|
|
29
|
+
with fitdecode.FitReader(io.BytesIO(data), check_crc=fitdecode.CrcCheck.ENABLED) as reader:
|
|
30
|
+
for frame in reader:
|
|
31
|
+
if not isinstance(frame, fitdecode.FitDataMessage):
|
|
32
|
+
continue
|
|
33
|
+
if frame.name == "record":
|
|
34
|
+
rows.append(_record(frame))
|
|
35
|
+
elif frame.name == "session" and not session_seen:
|
|
36
|
+
session_seen = True
|
|
37
|
+
sport = _sport(_value(frame, "sport"), _value(frame, "sub_sport"))
|
|
38
|
+
start_time = _value(frame, "start_time")
|
|
39
|
+
elif frame.name == "file_id" and device is None:
|
|
40
|
+
device = _device(frame)
|
|
41
|
+
except fitdecode.FitError as error:
|
|
42
|
+
raise ActivityFileError(f"unreadable FIT file: {error}") from error
|
|
43
|
+
if sport.is_running:
|
|
44
|
+
for row in rows:
|
|
45
|
+
if row["cadence"] is not None:
|
|
46
|
+
row["cadence"] *= 2
|
|
47
|
+
return Activity.from_rows(
|
|
48
|
+
rows, sport=sport, source_format="fit", device=device, start_time=start_time
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _value(frame: Any, name: str) -> Any:
|
|
53
|
+
return frame.get_value(name, fallback=None)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _record(frame: Any) -> dict[str, Any]:
|
|
57
|
+
lat = _value(frame, "position_lat")
|
|
58
|
+
lon = _value(frame, "position_long")
|
|
59
|
+
cadence = _value(frame, "cadence")
|
|
60
|
+
fractional = _value(frame, "fractional_cadence")
|
|
61
|
+
if cadence is not None and fractional is not None:
|
|
62
|
+
cadence += fractional
|
|
63
|
+
return {
|
|
64
|
+
"timestamp": _value(frame, "timestamp"),
|
|
65
|
+
"latitude": lat * SEMICIRCLE_TO_DEGREES if lat is not None else None,
|
|
66
|
+
"longitude": lon * SEMICIRCLE_TO_DEGREES if lon is not None else None,
|
|
67
|
+
"distance": _value(frame, "distance"),
|
|
68
|
+
"speed": _first(frame, "enhanced_speed", "speed"),
|
|
69
|
+
"altitude": _first(frame, "enhanced_altitude", "altitude"),
|
|
70
|
+
"heart_rate": _value(frame, "heart_rate"),
|
|
71
|
+
"cadence": cadence,
|
|
72
|
+
"power": _value(frame, "power"),
|
|
73
|
+
"temperature": _value(frame, "temperature"),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _first(frame: Any, *names: str) -> Any:
|
|
78
|
+
for name in names:
|
|
79
|
+
value = _value(frame, name)
|
|
80
|
+
if value is not None:
|
|
81
|
+
return value
|
|
82
|
+
return None
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _sport(sport: Any, sub_sport: Any) -> Sport:
|
|
86
|
+
resolved = FIT_SPORTS.get(str(sport), Sport.OTHER)
|
|
87
|
+
if resolved is Sport.RUNNING:
|
|
88
|
+
return FIT_RUNNING_SUB_SPORTS.get(str(sub_sport), Sport.RUNNING)
|
|
89
|
+
return resolved
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _device(frame: Any) -> str | None:
|
|
93
|
+
manufacturer = _value(frame, "manufacturer")
|
|
94
|
+
product = _first(frame, "garmin_product", "product_name", "product")
|
|
95
|
+
parts = [str(part) for part in (manufacturer, product) if part is not None]
|
|
96
|
+
return " ".join(parts) or None
|
pacelab/io/gpx.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from xml.etree.ElementTree import Element
|
|
3
|
+
|
|
4
|
+
from pacelab.io.xml import children, descendants, number, text, timestamp
|
|
5
|
+
from pacelab.model import Activity, Sport
|
|
6
|
+
|
|
7
|
+
GPX_SPORTS = {
|
|
8
|
+
"running": Sport.RUNNING,
|
|
9
|
+
"run": Sport.RUNNING,
|
|
10
|
+
"trail_running": Sport.TRAIL_RUNNING,
|
|
11
|
+
"trail running": Sport.TRAIL_RUNNING,
|
|
12
|
+
"walking": Sport.WALKING,
|
|
13
|
+
"walk": Sport.WALKING,
|
|
14
|
+
"hiking": Sport.HIKING,
|
|
15
|
+
"hike": Sport.HIKING,
|
|
16
|
+
"cycling": Sport.CYCLING,
|
|
17
|
+
"biking": Sport.CYCLING,
|
|
18
|
+
"ride": Sport.CYCLING,
|
|
19
|
+
"swimming": Sport.SWIMMING,
|
|
20
|
+
"swim": Sport.SWIMMING,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def read_gpx(root: Element) -> Activity:
|
|
25
|
+
tracks = list(children(root, "trk"))
|
|
26
|
+
sport_name = (text(tracks[0], "type") or "").lower() if tracks else ""
|
|
27
|
+
sport = GPX_SPORTS.get(sport_name, Sport.OTHER)
|
|
28
|
+
cadence_factor = 2 if sport.is_running else 1
|
|
29
|
+
rows = [
|
|
30
|
+
_point(point, cadence_factor)
|
|
31
|
+
for track in tracks
|
|
32
|
+
for segment in children(track, "trkseg")
|
|
33
|
+
for point in children(segment, "trkpt")
|
|
34
|
+
]
|
|
35
|
+
return Activity.from_rows(rows, sport=sport, source_format="gpx")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _point(point: Element, cadence_factor: int) -> dict[str, Any]:
|
|
39
|
+
cadence = _extension(point, "cad")
|
|
40
|
+
return {
|
|
41
|
+
"timestamp": timestamp(text(point, "time")),
|
|
42
|
+
"latitude": number(point.get("lat")),
|
|
43
|
+
"longitude": number(point.get("lon")),
|
|
44
|
+
"altitude": number(text(point, "ele")),
|
|
45
|
+
"heart_rate": _extension(point, "hr"),
|
|
46
|
+
"cadence": cadence * cadence_factor if cadence is not None else None,
|
|
47
|
+
"power": _extension(point, "power"),
|
|
48
|
+
"temperature": _extension(point, "atemp"),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _extension(point: Element, name: str) -> float | None:
|
|
53
|
+
node = next(descendants(point, name), None)
|
|
54
|
+
return number(node.text.strip()) if node is not None and node.text else None
|
pacelab/io/tcx.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from xml.etree.ElementTree import Element
|
|
3
|
+
|
|
4
|
+
from pacelab.io.xml import children, descendants, find, number, text, timestamp
|
|
5
|
+
from pacelab.model import Activity, Sport
|
|
6
|
+
|
|
7
|
+
TCX_SPORTS = {"running": Sport.RUNNING, "biking": Sport.CYCLING}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def read_tcx(root: Element) -> Activity:
|
|
11
|
+
activity = find(root, "Activities", "Activity")
|
|
12
|
+
sport_name = (activity.get("Sport") or "").lower() if activity is not None else ""
|
|
13
|
+
rows = [_trackpoint(point) for point in descendants(root, "Trackpoint")]
|
|
14
|
+
return Activity.from_rows(
|
|
15
|
+
rows, sport=TCX_SPORTS.get(sport_name, Sport.OTHER), source_format="tcx"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _trackpoint(point: Element) -> dict[str, Any]:
|
|
20
|
+
run_cadence = _extension(point, "RunCadence")
|
|
21
|
+
return {
|
|
22
|
+
"timestamp": timestamp(text(point, "Time")),
|
|
23
|
+
"latitude": number(text(point, "Position", "LatitudeDegrees")),
|
|
24
|
+
"longitude": number(text(point, "Position", "LongitudeDegrees")),
|
|
25
|
+
"altitude": number(text(point, "AltitudeMeters")),
|
|
26
|
+
"distance": number(text(point, "DistanceMeters")),
|
|
27
|
+
"heart_rate": number(text(point, "HeartRateBpm", "Value")),
|
|
28
|
+
"cadence": run_cadence * 2 if run_cadence is not None else number(text(point, "Cadence")),
|
|
29
|
+
"speed": _extension(point, "Speed"),
|
|
30
|
+
"power": _extension(point, "Watts"),
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _extension(point: Element, name: str) -> float | None:
|
|
35
|
+
extensions = next(children(point, "Extensions"), None)
|
|
36
|
+
if extensions is None:
|
|
37
|
+
return None
|
|
38
|
+
node = next(descendants(extensions, name), None)
|
|
39
|
+
return number(node.text.strip()) if node is not None and node.text else None
|
pacelab/io/xml.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import datetime as dt
|
|
2
|
+
from collections.abc import Iterator
|
|
3
|
+
from xml.etree.ElementTree import Element
|
|
4
|
+
|
|
5
|
+
from pacelab.errors import ActivityFileError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def local_name(element: Element) -> str:
|
|
9
|
+
return element.tag.rsplit("}", 1)[-1]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def children(element: Element, name: str) -> Iterator[Element]:
|
|
13
|
+
return (child for child in element if local_name(child) == name)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def descendants(element: Element, name: str) -> Iterator[Element]:
|
|
17
|
+
return (node for node in element.iter() if local_name(node) == name)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def find(element: Element, *path: str) -> Element | None:
|
|
21
|
+
current: Element | None = element
|
|
22
|
+
for name in path:
|
|
23
|
+
if current is None:
|
|
24
|
+
return None
|
|
25
|
+
current = next(children(current, name), None)
|
|
26
|
+
return current
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def text(element: Element, *path: str) -> str | None:
|
|
30
|
+
node = find(element, *path)
|
|
31
|
+
if node is None or node.text is None:
|
|
32
|
+
return None
|
|
33
|
+
return node.text.strip() or None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def number(value: str | None) -> float | None:
|
|
37
|
+
if value is None:
|
|
38
|
+
return None
|
|
39
|
+
try:
|
|
40
|
+
return float(value)
|
|
41
|
+
except ValueError as error:
|
|
42
|
+
raise ActivityFileError(f"expected a number, got {value!r}") from error
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def timestamp(value: str | None) -> dt.datetime | None:
|
|
46
|
+
if value is None:
|
|
47
|
+
return None
|
|
48
|
+
try:
|
|
49
|
+
parsed = dt.datetime.fromisoformat(value)
|
|
50
|
+
except ValueError as error:
|
|
51
|
+
raise ActivityFileError(f"expected an ISO 8601 time, got {value!r}") from error
|
|
52
|
+
if parsed.tzinfo is None:
|
|
53
|
+
return parsed.replace(tzinfo=dt.UTC)
|
|
54
|
+
return parsed.astimezone(dt.UTC)
|
pacelab/metrics.py
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import datetime as dt
|
|
2
|
+
from collections.abc import Mapping, Sequence
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
import polars as pl
|
|
8
|
+
|
|
9
|
+
from pacelab.model import Activity
|
|
10
|
+
|
|
11
|
+
FloatArray = np.ndarray[Any, np.dtype[np.float64]]
|
|
12
|
+
|
|
13
|
+
MAX_GAP_S = 30.0
|
|
14
|
+
MOVING_SPEED_MPS = 0.5
|
|
15
|
+
ELEVATION_THRESHOLD_M = 3.0
|
|
16
|
+
GRADE_WINDOW_M = 60.0
|
|
17
|
+
MAX_RUNNING_GRADE = 0.45
|
|
18
|
+
MINETTI_COST = (155.4, -30.4, -43.3, 46.3, 19.5, 3.6)
|
|
19
|
+
FITNESS_DAYS = 42
|
|
20
|
+
FATIGUE_DAYS = 7
|
|
21
|
+
BANISTER_MALE = (0.64, 1.92)
|
|
22
|
+
BANISTER_FEMALE = (0.86, 1.67)
|
|
23
|
+
DEFAULT_EFFORT_DISTANCES_M = (400.0, 1000.0, 1609.344, 5000.0, 10000.0, 21097.5, 42195.0)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True, slots=True)
|
|
27
|
+
class Summary:
|
|
28
|
+
distance_m: float
|
|
29
|
+
elapsed_s: float
|
|
30
|
+
moving_s: float
|
|
31
|
+
pace_s_per_km: float | None
|
|
32
|
+
grade_adjusted_pace_s_per_km: float | None
|
|
33
|
+
avg_heart_rate: float | None
|
|
34
|
+
max_heart_rate: float | None
|
|
35
|
+
avg_cadence: float | None
|
|
36
|
+
avg_power: float | None
|
|
37
|
+
elevation_gain_m: float
|
|
38
|
+
elevation_loss_m: float
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass(frozen=True, slots=True)
|
|
42
|
+
class _Intervals:
|
|
43
|
+
seconds: FloatArray
|
|
44
|
+
meters: FloatArray
|
|
45
|
+
recording: np.ndarray[Any, np.dtype[np.bool_]]
|
|
46
|
+
moving: np.ndarray[Any, np.dtype[np.bool_]]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _column(activity: Activity, name: str) -> FloatArray:
|
|
50
|
+
values: FloatArray = activity.records[name].cast(pl.Float64).fill_null(np.nan).to_numpy()
|
|
51
|
+
return values
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _elapsed(activity: Activity) -> FloatArray:
|
|
55
|
+
micros: FloatArray = activity.records["timestamp"].dt.epoch("us").to_numpy().astype(np.float64)
|
|
56
|
+
elapsed: FloatArray = (micros - micros[0]) / 1e6
|
|
57
|
+
return elapsed
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _intervals(activity: Activity) -> _Intervals:
|
|
61
|
+
seconds = np.diff(_elapsed(activity))
|
|
62
|
+
meters = np.diff(_column(activity, "distance"))
|
|
63
|
+
recording = seconds <= MAX_GAP_S
|
|
64
|
+
with np.errstate(divide="ignore", invalid="ignore"):
|
|
65
|
+
moving = recording & (meters / seconds >= MOVING_SPEED_MPS)
|
|
66
|
+
return _Intervals(seconds, meters, recording, moving)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _weighted_mean(values: FloatArray, weights: FloatArray) -> float | None:
|
|
70
|
+
mask = ~np.isnan(values) & (weights > 0)
|
|
71
|
+
if not mask.any():
|
|
72
|
+
return None
|
|
73
|
+
return float(np.average(values[mask], weights=weights[mask]))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def summarize(activity: Activity) -> Summary:
|
|
77
|
+
steps = _intervals(activity)
|
|
78
|
+
moving_weights = np.where(steps.moving, steps.seconds, 0.0)
|
|
79
|
+
distance = float(np.nansum(steps.meters))
|
|
80
|
+
moving_s = float(moving_weights.sum())
|
|
81
|
+
heart_rate = _column(activity, "heart_rate")
|
|
82
|
+
altitude = _column(activity, "altitude")
|
|
83
|
+
gain, loss = elevation_change(altitude)
|
|
84
|
+
return Summary(
|
|
85
|
+
distance_m=distance,
|
|
86
|
+
elapsed_s=float(_elapsed(activity)[-1]),
|
|
87
|
+
moving_s=moving_s,
|
|
88
|
+
pace_s_per_km=moving_s / (distance / 1000) if distance > 0 else None,
|
|
89
|
+
grade_adjusted_pace_s_per_km=_grade_adjusted_pace(activity, steps, altitude),
|
|
90
|
+
avg_heart_rate=_weighted_mean(heart_rate[:-1], moving_weights),
|
|
91
|
+
max_heart_rate=float(np.nanmax(heart_rate)) if not np.isnan(heart_rate).all() else None,
|
|
92
|
+
avg_cadence=_weighted_mean(_column(activity, "cadence")[:-1], moving_weights),
|
|
93
|
+
avg_power=_weighted_mean(_column(activity, "power")[:-1], moving_weights),
|
|
94
|
+
elevation_gain_m=gain,
|
|
95
|
+
elevation_loss_m=loss,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def grade_adjusted_pace(activity: Activity) -> float | None:
|
|
100
|
+
return _grade_adjusted_pace(activity, _intervals(activity), _column(activity, "altitude"))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _grade_adjusted_pace(
|
|
104
|
+
activity: Activity, steps: _Intervals, altitude: FloatArray
|
|
105
|
+
) -> float | None:
|
|
106
|
+
if not activity.sport.is_running:
|
|
107
|
+
return None
|
|
108
|
+
moving = np.flatnonzero(steps.moving)
|
|
109
|
+
if moving.size == 0:
|
|
110
|
+
return None
|
|
111
|
+
if not (np.isfinite(altitude[moving]) & np.isfinite(altitude[moving + 1])).all():
|
|
112
|
+
return None
|
|
113
|
+
equivalent_m = 0.0
|
|
114
|
+
for block in np.split(moving, np.flatnonzero(np.diff(moving) > 1) + 1):
|
|
115
|
+
meters = steps.meters[block]
|
|
116
|
+
distance = np.concatenate(([0.0], np.cumsum(meters)))
|
|
117
|
+
heights = altitude[np.append(block, block[-1] + 1)]
|
|
118
|
+
grade = np.clip(_window_grade(distance, heights), -MAX_RUNNING_GRADE, MAX_RUNNING_GRADE)
|
|
119
|
+
cost = np.polyval(MINETTI_COST, grade)
|
|
120
|
+
equivalent_m += float(np.sum(meters * cost)) / MINETTI_COST[-1]
|
|
121
|
+
return float(steps.seconds[moving].sum()) * 1000 / equivalent_m
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _window_grade(distance: FloatArray, heights: FloatArray) -> FloatArray:
|
|
125
|
+
total = distance[-1]
|
|
126
|
+
centres = (distance[:-1] + distance[1:]) / 2
|
|
127
|
+
left = np.clip(centres - GRADE_WINDOW_M / 2, 0.0, max(0.0, total - GRADE_WINDOW_M))
|
|
128
|
+
right = np.minimum(left + GRADE_WINDOW_M, total)
|
|
129
|
+
rise = np.interp(right, distance, heights) - np.interp(left, distance, heights)
|
|
130
|
+
grade: FloatArray = rise / (right - left)
|
|
131
|
+
return grade
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def elevation_change(
|
|
135
|
+
altitudes: Sequence[float] | FloatArray, threshold_m: float = ELEVATION_THRESHOLD_M
|
|
136
|
+
) -> tuple[float, float]:
|
|
137
|
+
values = [float(a) for a in altitudes if not np.isnan(a)]
|
|
138
|
+
if not values:
|
|
139
|
+
return 0.0, 0.0
|
|
140
|
+
gain = loss = 0.0
|
|
141
|
+
pivot = candidate = values[0]
|
|
142
|
+
trend = 0
|
|
143
|
+
for altitude in values[1:]:
|
|
144
|
+
if trend == 0:
|
|
145
|
+
if abs(altitude - pivot) >= threshold_m:
|
|
146
|
+
trend = 1 if altitude > pivot else -1
|
|
147
|
+
candidate = altitude
|
|
148
|
+
elif trend == 1:
|
|
149
|
+
if altitude > candidate:
|
|
150
|
+
candidate = altitude
|
|
151
|
+
elif candidate - altitude >= threshold_m:
|
|
152
|
+
gain += candidate - pivot
|
|
153
|
+
pivot, candidate, trend = candidate, altitude, -1
|
|
154
|
+
elif altitude < candidate:
|
|
155
|
+
candidate = altitude
|
|
156
|
+
elif altitude - candidate >= threshold_m:
|
|
157
|
+
loss += pivot - candidate
|
|
158
|
+
pivot, candidate, trend = candidate, altitude, 1
|
|
159
|
+
if trend == 1:
|
|
160
|
+
gain += candidate - pivot
|
|
161
|
+
elif trend == -1:
|
|
162
|
+
loss += pivot - candidate
|
|
163
|
+
return gain, loss
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def best_efforts(
|
|
167
|
+
activity: Activity, distances_m: Sequence[float] = DEFAULT_EFFORT_DISTANCES_M
|
|
168
|
+
) -> dict[float, float]:
|
|
169
|
+
elapsed = _elapsed(activity)
|
|
170
|
+
distance = _column(activity, "distance")
|
|
171
|
+
efforts: dict[float, float] = {}
|
|
172
|
+
for target in distances_m:
|
|
173
|
+
ends = distance + target
|
|
174
|
+
starts = np.flatnonzero(ends <= distance[-1])
|
|
175
|
+
if starts.size == 0:
|
|
176
|
+
continue
|
|
177
|
+
after = np.searchsorted(distance, ends[starts], side="left")
|
|
178
|
+
before = after - 1
|
|
179
|
+
fraction = (ends[starts] - distance[before]) / (distance[after] - distance[before])
|
|
180
|
+
finish = elapsed[before] + fraction * (elapsed[after] - elapsed[before])
|
|
181
|
+
efforts[target] = float(np.min(finish - elapsed[starts]))
|
|
182
|
+
return efforts
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def time_in_zones(activity: Activity, boundaries_bpm: Sequence[float]) -> list[float]:
|
|
186
|
+
steps = _intervals(activity)
|
|
187
|
+
heart_rate = _column(activity, "heart_rate")[:-1]
|
|
188
|
+
mask = steps.recording & ~np.isnan(heart_rate)
|
|
189
|
+
zones = np.searchsorted(np.asarray(boundaries_bpm, dtype=np.float64), heart_rate[mask], "right")
|
|
190
|
+
totals = np.bincount(zones, weights=steps.seconds[mask], minlength=len(boundaries_bpm) + 1)
|
|
191
|
+
return [float(total) for total in totals]
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def trimp(
|
|
195
|
+
activity: Activity,
|
|
196
|
+
resting_hr: float,
|
|
197
|
+
max_hr: float,
|
|
198
|
+
coefficients: tuple[float, float] = BANISTER_MALE,
|
|
199
|
+
) -> float:
|
|
200
|
+
steps = _intervals(activity)
|
|
201
|
+
heart_rate = _column(activity, "heart_rate")[:-1]
|
|
202
|
+
mask = steps.recording & ~np.isnan(heart_rate)
|
|
203
|
+
reserve = np.clip((heart_rate[mask] - resting_hr) / (max_hr - resting_hr), 0.0, 1.0)
|
|
204
|
+
factor, exponent = coefficients
|
|
205
|
+
minutes = steps.seconds[mask] / 60
|
|
206
|
+
return float(np.sum(minutes * reserve * factor * np.exp(exponent * reserve)))
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def aerobic_decoupling(activity: Activity) -> float | None:
|
|
210
|
+
steps = _intervals(activity)
|
|
211
|
+
heart_rate = _column(activity, "heart_rate")[:-1]
|
|
212
|
+
mask = steps.moving & ~np.isnan(heart_rate)
|
|
213
|
+
if not mask.any():
|
|
214
|
+
return None
|
|
215
|
+
seconds, meters, heart_rate = steps.seconds[mask], steps.meters[mask], heart_rate[mask]
|
|
216
|
+
started = np.cumsum(seconds) - seconds
|
|
217
|
+
first = started < seconds.sum() / 2
|
|
218
|
+
halves = [first, ~first]
|
|
219
|
+
if not all(half.any() for half in halves):
|
|
220
|
+
return None
|
|
221
|
+
efficiency = [
|
|
222
|
+
(meters[half].sum() / seconds[half].sum())
|
|
223
|
+
/ np.average(heart_rate[half], weights=seconds[half])
|
|
224
|
+
for half in halves
|
|
225
|
+
]
|
|
226
|
+
return float((efficiency[0] - efficiency[1]) / efficiency[0] * 100)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def training_load(
|
|
230
|
+
daily_loads: Mapping[dt.date, float],
|
|
231
|
+
start: dt.date | None = None,
|
|
232
|
+
end: dt.date | None = None,
|
|
233
|
+
) -> pl.DataFrame:
|
|
234
|
+
first = start or min(daily_loads)
|
|
235
|
+
last = end or max(daily_loads)
|
|
236
|
+
days = [first + dt.timedelta(days=offset) for offset in range((last - first).days + 1)]
|
|
237
|
+
fitness = fatigue = 0.0
|
|
238
|
+
rows = []
|
|
239
|
+
for day in days:
|
|
240
|
+
load = daily_loads.get(day, 0.0)
|
|
241
|
+
form = fitness - fatigue
|
|
242
|
+
fitness += (load - fitness) / FITNESS_DAYS
|
|
243
|
+
fatigue += (load - fatigue) / FATIGUE_DAYS
|
|
244
|
+
rows.append(
|
|
245
|
+
{"date": day, "load": load, "fitness": fitness, "fatigue": fatigue, "form": form}
|
|
246
|
+
)
|
|
247
|
+
return pl.DataFrame(
|
|
248
|
+
rows,
|
|
249
|
+
schema={
|
|
250
|
+
"date": pl.Date(),
|
|
251
|
+
"load": pl.Float64(),
|
|
252
|
+
"fitness": pl.Float64(),
|
|
253
|
+
"fatigue": pl.Float64(),
|
|
254
|
+
"form": pl.Float64(),
|
|
255
|
+
},
|
|
256
|
+
)
|
pacelab/model.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import datetime as dt
|
|
2
|
+
from collections.abc import Iterable, Mapping
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from enum import StrEnum
|
|
5
|
+
from typing import Any, Literal
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import polars as pl
|
|
9
|
+
|
|
10
|
+
from pacelab.errors import ActivityFileError
|
|
11
|
+
|
|
12
|
+
SourceFormat = Literal["fit", "gpx", "tcx", "rows"]
|
|
13
|
+
|
|
14
|
+
EARTH_RADIUS_M = 6_371_008.8
|
|
15
|
+
|
|
16
|
+
STREAM_SCHEMA: dict[str, pl.DataType] = {
|
|
17
|
+
"timestamp": pl.Datetime("us", "UTC"),
|
|
18
|
+
"latitude": pl.Float64(),
|
|
19
|
+
"longitude": pl.Float64(),
|
|
20
|
+
"distance": pl.Float64(),
|
|
21
|
+
"speed": pl.Float64(),
|
|
22
|
+
"altitude": pl.Float64(),
|
|
23
|
+
"heart_rate": pl.Float64(),
|
|
24
|
+
"cadence": pl.Float64(),
|
|
25
|
+
"power": pl.Float64(),
|
|
26
|
+
"temperature": pl.Float64(),
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Sport(StrEnum):
|
|
31
|
+
RUNNING = "running"
|
|
32
|
+
TRAIL_RUNNING = "trail_running"
|
|
33
|
+
TREADMILL_RUNNING = "treadmill_running"
|
|
34
|
+
WALKING = "walking"
|
|
35
|
+
HIKING = "hiking"
|
|
36
|
+
CYCLING = "cycling"
|
|
37
|
+
SWIMMING = "swimming"
|
|
38
|
+
OTHER = "other"
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def is_running(self) -> bool:
|
|
42
|
+
return self in {Sport.RUNNING, Sport.TRAIL_RUNNING, Sport.TREADMILL_RUNNING}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass(frozen=True, slots=True)
|
|
46
|
+
class Activity:
|
|
47
|
+
sport: Sport
|
|
48
|
+
start_time: dt.datetime
|
|
49
|
+
records: pl.DataFrame
|
|
50
|
+
source_format: SourceFormat = "rows"
|
|
51
|
+
device: str | None = None
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def from_rows(
|
|
55
|
+
cls,
|
|
56
|
+
rows: Iterable[Mapping[str, Any]],
|
|
57
|
+
sport: Sport,
|
|
58
|
+
source_format: SourceFormat = "rows",
|
|
59
|
+
device: str | None = None,
|
|
60
|
+
start_time: dt.datetime | None = None,
|
|
61
|
+
) -> "Activity":
|
|
62
|
+
records = normalize_records(rows)
|
|
63
|
+
first: dt.datetime = records["timestamp"][0]
|
|
64
|
+
return cls(
|
|
65
|
+
sport=sport,
|
|
66
|
+
start_time=start_time or first,
|
|
67
|
+
records=records,
|
|
68
|
+
source_format=source_format,
|
|
69
|
+
device=device,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def normalize_records(rows: Iterable[Mapping[str, Any]]) -> pl.DataFrame:
|
|
74
|
+
frame = pl.from_dicts(list(rows), schema=STREAM_SCHEMA, strict=False)
|
|
75
|
+
frame = (
|
|
76
|
+
frame.filter(pl.col("timestamp").is_not_null())
|
|
77
|
+
.sort("timestamp")
|
|
78
|
+
.unique("timestamp", keep="first", maintain_order=True)
|
|
79
|
+
)
|
|
80
|
+
if frame.is_empty():
|
|
81
|
+
raise ActivityFileError("the file contains no timestamped records")
|
|
82
|
+
if frame["distance"].null_count() == frame.height:
|
|
83
|
+
frame = frame.with_columns(distance=pl.Series(_distance_from_positions(frame)))
|
|
84
|
+
frame = frame.with_columns(pl.col("distance").forward_fill().fill_null(0.0).cum_max())
|
|
85
|
+
if frame["speed"].null_count() == frame.height:
|
|
86
|
+
seconds = pl.col("timestamp").diff().dt.total_microseconds() / 1e6
|
|
87
|
+
frame = frame.with_columns(speed=pl.col("distance").diff() / seconds)
|
|
88
|
+
return frame
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _distance_from_positions(frame: pl.DataFrame) -> np.ndarray[Any, np.dtype[np.float64]]:
|
|
92
|
+
lat = np.radians(frame["latitude"].to_numpy().astype(np.float64))
|
|
93
|
+
lon = np.radians(frame["longitude"].to_numpy().astype(np.float64))
|
|
94
|
+
lat, lon = _forward_fill(lat), _forward_fill(lon)
|
|
95
|
+
dlat = np.diff(lat)
|
|
96
|
+
dlon = np.diff(lon)
|
|
97
|
+
a = np.sin(dlat / 2) ** 2 + np.cos(lat[:-1]) * np.cos(lat[1:]) * np.sin(dlon / 2) ** 2
|
|
98
|
+
steps = 2 * EARTH_RADIUS_M * np.arcsin(np.sqrt(a))
|
|
99
|
+
return np.concatenate([[0.0], np.cumsum(np.nan_to_num(steps))])
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _forward_fill(
|
|
103
|
+
values: np.ndarray[Any, np.dtype[np.float64]],
|
|
104
|
+
) -> np.ndarray[Any, np.dtype[np.float64]]:
|
|
105
|
+
valid = ~np.isnan(values)
|
|
106
|
+
index = np.where(valid, np.arange(values.size), 0)
|
|
107
|
+
np.maximum.accumulate(index, out=index)
|
|
108
|
+
return values[index]
|
pacelab/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pacelab
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Parse sports-watch activity files and compute running metrics.
|
|
5
|
+
Keywords: running,fit,gpx,tcx,garmin,training-load,telemetry
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Dist: defusedxml>=0.7.1
|
|
14
|
+
Requires-Dist: numpy>=2.0
|
|
15
|
+
Requires-Dist: fitdecode>=0.11.0
|
|
16
|
+
Requires-Dist: polars>=2.1
|
|
17
|
+
Requires-Dist: typer>=0.29
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Project-URL: Homepage, https://github.com/tanhtruong/pacelab
|
|
20
|
+
Project-URL: Documentation, https://github.com/tanhtruong/pacelab#readme
|
|
21
|
+
Project-URL: Issues, https://github.com/tanhtruong/pacelab/issues
|
|
22
|
+
Project-URL: Source, https://github.com/tanhtruong/pacelab
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# pacelab
|
|
26
|
+
|
|
27
|
+
Parse sports-watch activity files (FIT, GPX, TCX) into one normalised record stream and compute running metrics.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install pacelab
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from pacelab import load
|
|
35
|
+
from pacelab.metrics import best_efforts, summarize
|
|
36
|
+
|
|
37
|
+
activity = load("morning.fit")
|
|
38
|
+
print(summarize(activity))
|
|
39
|
+
print(best_efforts(activity))
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pacelab summary morning.fit
|
|
44
|
+
pacelab efforts morning.fit
|
|
45
|
+
pacelab export morning.fit records.parquet
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
See the [project README](https://github.com/tanhtruong/pacelab) for the full documentation.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
pacelab/__init__.py,sha256=TC56_w_mKr4AKNhOta4iJtu4wf302bY_TuQYXMb8Sdw,214
|
|
2
|
+
pacelab/cli.py,sha256=u8_A9t38JbBaAPLOOGNKgF9Yzspebc83ulK-0Mo6ez8,2274
|
|
3
|
+
pacelab/errors.py,sha256=kNgdJblFmbDS8hmbSEBC9LPCrEH3t5VGuwjzR01CkWw,46
|
|
4
|
+
pacelab/format.py,sha256=rsCaSqqJ--POLU9tEAc0GeVhbPzoI67nCcL_mnyFwmY,743
|
|
5
|
+
pacelab/io/__init__.py,sha256=oQgnZUaqZY2Qjp-pGWQhb1r5DZ7R_vc92liuFNb6ZEM,1695
|
|
6
|
+
pacelab/io/fit.py,sha256=P-CL2jLZy8EWVI9szJ6dI3aQRpPMa7IFaYAKx3cGJKU,3373
|
|
7
|
+
pacelab/io/gpx.py,sha256=0iet3ashjfcDuFJknHMpNK4Dk49p6cr9nuhyCk9NwHY,1842
|
|
8
|
+
pacelab/io/tcx.py,sha256=ZVOUYl9Syy-GZoI022pEv0rMedRrZI5QcsCe0jcd7cY,1628
|
|
9
|
+
pacelab/io/xml.py,sha256=wCbXMLrQKyBJeUsDgXkBzhhRr8w-lAqAFShRYrKv-90,1572
|
|
10
|
+
pacelab/metrics.py,sha256=KhYRUMfzUcYJMrsuJbz1TudY3OQH2b6j8TB4rh0mhBM,9304
|
|
11
|
+
pacelab/model.py,sha256=8TT6p7OHfqo4QwOKy4ivPgJq9JU4VZ4M4KdCtD4-rNw,3509
|
|
12
|
+
pacelab/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
pacelab-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
14
|
+
pacelab-0.1.0.dist-info/WHEEL,sha256=G_-rrEibZr7OEM7zdH1dSO6s-VdjfnS5PA4CLAdI9Vw,80
|
|
15
|
+
pacelab-0.1.0.dist-info/entry_points.txt,sha256=tpCpihQZqoGqc-Nobmnvee11XmGdMUueYC4IdoU6UHA,45
|
|
16
|
+
pacelab-0.1.0.dist-info/METADATA,sha256=uxV8Y2RRxwPOawbZKVohDD2BpnPzTVCQKm6V1DnGPqk,1486
|
|
17
|
+
pacelab-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|