-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathactivity_summary_pdf.py
41 lines (34 loc) · 1021 Bytes
/
activity_summary_pdf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
'''
Create a multi-page PDF report of a Garmin activity.
'''
import sys
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import datetime
from matplotlib.backends.backend_pdf import PdfPages
import minimalreport
import activitymap
import parse_tcx
def main(filename):
#Set A4 figure size
plt.rc('figure', figsize=(11.69, 8.27), dpi=100)
basename = filename[:-4]
df = parse_tcx.get_activity_data(filename)
with PdfPages(basename + '-ActivitySummary.pdf') as pdf:
print('Maps')
mapfig = activitymap.activity_map_figure(df)
plt.tight_layout()
pdf.savefig(mapfig)
plt.close(mapfig)
print('Minimal report')
mr_fig = minimalreport.minimal_report_figure(df)
plt.tight_layout()
pdf.savefig(mr_fig)
plt.close(mr_fig)
info = pdf.infodict()
info['CreationDate'] = datetime.datetime.today()
if __name__ == '__main__':
filename = sys.argv[1]
main(filename)