Coding nerds unite

Not sure how much traction this will gain, but here goes! So I’ve been messing around with Python this year just for fun and to learn something new (the last time I coded was in a Java semester course back in 1999 lol).

For a noob, I’m doing ok with some basic tasks, basically extracting data from my strava (primarily using stravalib) and being able to load fit files for analysis (using fitparse) and then using a visualization tool like bokeh or dash to graph it out (I even have the foundations of a DC Rainmaker style analysis tool with overlaid power files).

I’ve also been messing around with Django as a way to make all of this more web-based. Basically, I’m reinventing the wheel here since there are so many options to upload and analyze ride data out there! But it’s a learning exercise and maybe by doing this then maybe I can get into doing some more advanced things with data.

Anyhow, I know there are some other coders around here, and was curious if any would be interested in participating in sharing code snippets and solve stuff in relation to using bike data.

Here a couple of resources I’ve used to get myself going, my challenge now making the transition of these concepts into Django:

http://johannesjacob.com/analyze-your-cycling-data-python/

http://johannesjacob.com/2019/03/20/build-your-own-performance-management-chart-python/

https://pythonhosted.org/stravalib/

16 Likes

Usually this is followed by a link to your project on GitHub. :slight_smile:

7 Likes

Dear coding nerds,

Please create an app for the following:

Thanks!

3 Likes

I’m pretty new to github, is there a way to make a public github where people can just freely add stuff?

mainly asking to do something as a central repository for folks rather than people going here and there for this sort of thing

when you create a repo it’ll allow you to set it as a public repo.

1 Like

Cool, here we go, feel free to add

5 Likes

bumping my own thread to get some more nerds in.

As for my own tinkering, I’ve managed to connect some dots with Django and loading Fit files for analysis and saving TSS, IF, and NP to a database to potentially use to build a PMC. What I need to do next is to mess with my user profile to indicate different FTPs that are associated with ride dates, right now I’m just using my current value as static.

I’ll try and clean up some code and put it up for anyone else interested in trying this stuff out.

Not quite to Python yet myself. While I have no illusions that a job at TrainerRoad is in the future for me, it was the idea of working on a project like this that made me begin the journey to change professions. My pops has been coding since the 70’s, and was ecstatic when I told him - as he badly wanted me to follow in his footsteps but never pushed me into it.

1 Like

I am interested! I am proficient in Python (I teach bio-informatics), but I need to develop my skills in integrating data analysis with (preferably) interactive web pages. So for example developing an interactive PMC in Django could be nice!

@hubcyclist I will contact you on GitHub so we can share ideas.

Hi all

I started as an assembly level games programmer in the 80’s

I’ve used most programming languages.

But currently focusing on Native to create a running app for Android / iPhobe

nice! My current bang my head against the wall task is getting data from a fit file into the model database, which I knew in advance would be a challenge for me because of how many rows of data are involved. So the info from the fit file makes its way into a dataframe, at the moment I’m passing watts, heartrate, timestamp, cadence, and time (in seconds) and then trying to get that into the model, but I’m clearly doing something wrong with the model to create a mismatch. I’ve tried to do ArrayField and JSONField (using postgresql) but keep hitting this wall when uploading the fit file. It’s stuff like this that makes me remember why I chose not to keep going with computer science as an undergrad lol

(psycopg2.errors.DatatypeMismatch) column "watts" is of 
type integer[] but expression is of type integer
LINE 1: ...tts, heartrate, timestamp, cadence, time) VALUES 
(176, 59, '...
                                                         ^
HINT:  You will need to rewrite or cast the expression.

[SQL: INSERT INTO "PMC_ride" (watts, heartrate, timestamp, 
cadence, time) VALUES (%(watts)s, %(heartrate)s, % 
(timestamp)s, %(cadence)s, %(time)s)]
[parameters: ({'watts': 176, 'heartrate': 59, 'timestamp': 
datetime.datetime(2020, 2, 26, 16, 19, 25), 'cadence': 80, 
'time': 0.0}, {'watts': 176, 'heartrate': 59, 'timestamp': 
datetime.datetime(2020, 2, 26, 16, 19, 26), 'cadence': 80, 
'time': 1.0}

similar background, except it was real-time programming for modems and other communications gear. And using Unix (“Linux”) since mid 80s. But I just casually hack on stuff these days, like taking the Garmin ANT+ FIT SDK and hacking the example code to extract battery levels from the FIT file.

Pretty busy with work, training, and housework, but I might try and help.

you can try using the cast function in postgres

https://www.postgresqltutorial.com/postgresql-cast/

It looks like for whatever reason it’s importing watts as a list or object rather than an integer.

Just to be sure: your intention is to

  • create a SQL table with attributes watts, heartrate, timestamp, cadence and time.
  • each row in the table will contain a single measurement of all these attributes (e.g. row1 will represent second1 in an activity, and row2 will represent second2 in that activity)

How are you going to store different activities in this table?

By the way: for pandas dataframes, the method .to_sql is available. This is super convenient! See https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_sql.html

I’m using df.to_sql method, and have used it with simpler items, it’s just the multi-row nature of fit files is throwing me for a loop.

alright, so I borked my database and started over because clearly I had done something crazy lol The good thing with being small is I can just toss everything in the trash and start over

So I was able to successfully upload a fitfile from a ride, the thing now is that each line is its own object in the model lol. Really I’d like the ride to be the object with a bunch of datapoints in it.

C#/SQL guy here. Would love to help if I had more time, but am just popping in to offer some encouragement. It looks like you are making good progress – keep chipping away and you’ll get there. Cheers!

1 Like

I forked the repo and created a zone for myself to play in, which includes a pretty basic web app setup to take a .fit file and graph out the power / hr / cadence over time. Figure that might be nice for anybody who like me doesn’t do python / django stuff, and wants an easy space to mess around!

Got a couple ideas from stuff on here to mess around with including taking a stab at calculating optimal cadence, and what’s your optimal time of day to workout.

Saw that, thanks for jumping in!

I’ve been wasting a lot of time on this whole handling of Fit files. So the thing with Django which is neat is that there are ListViews and DetailViews, where the listview gives you (obviously lol) a listing of objects and when you click you can get into a detailview where I’m hoping to have the graphs and whatnot. I was hoping to put a lot of the fitparse coding into the detailview to just do that stuff dynamically based on the selected record.

Anyhow I’m continuing to look into what I had been above as far as getting fit files into the model database, but I’m also seeing if there’s a way the detailview class can just access the fit file url of an uploaded fit file. Not sure if this makes any sense! lol I put up some topics on stackoverflow, let’s just say I’m not confident about getting any responses!

Frontend dev here. Mostly react and JavaScript these days. I work for on an infrastructure team, so it’s a lot of moving stuff around to better fit our scaling organization. Happy to look over UI pieces of anyone has questions