Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why differenth length of value arrays? #87

Open
ferrigno opened this issue Feb 17, 2022 · 2 comments
Open

Why differenth length of value arrays? #87

ferrigno opened this issue Feb 17, 2022 · 2 comments

Comments

@ferrigno
Copy link

Hello.
Thanks for this module !

I downloaded an activity done on an home trainer. I notices that the length of array of power values or cadence values or time values is different. Why ? How can I reconcile the arrays ?

Thanks

@vkurup
Copy link
Owner

vkurup commented Feb 20, 2022

Hi, I no longer actively use this, so I'm not certain. Perhaps someone else will be able to provide some guidance. If you can provide an example data file, it might be helpful to them.

@mbartenschlag
Copy link

mbartenschlag commented Aug 9, 2024

I discovered a similar bug this evening when looking at an activity where the band of my Polar OH1+ arm-worn optical heart rate sensor flipped causing the sensor to face outward and not record data for half of the activity. I flipped it back around for the last 10 minutes of the activity.

The parsed TCX file yields len(tcx.time_values()) = 2985 and len(tcx.hr_values()) = 682.

What I ended up doing instead is iterating through the activity's Trackpoint nodes myself to build a dict of timestamp to heart rate values.

def read_file(source_file):
    tcx = TCXParser(source_file)
    print(f"{source_file}: timestamps = {len(tcx.time_values())}, hr_records = {len(tcx.hr_values())}.") # 2985 != 682
    data = [ ]
    namespace = "http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2"
    for node in tcx.root.xpath("//ns:Trackpoint", namespaces={"ns": namespace}):
        timestamp = int(dt.fromisoformat(str(node.Time)).strftime("%s"))
        hr = int(node.HeartRateBpm.Value) if hasattr(node, "HeartRateBpm") else None
        data.append([timestamp, hr])
    return data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants