linux cmdline calcu...
 

  You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more

[Closed] linux cmdline calculate eddington number from *.gpx

16 Posts
11 Users
0 Reactions
96 Views
Posts: 8771
Full Member
Topic starter
 

So I learnt about the Eddington number today and now have a strong need to calculate it but don't want to pay £9.99 a year for Veloviewer to do it for me.

So far I've spent fruitless hours this evening searching and found javascript code, R code, installed bikeXperience (got 27km or more on 27 rides this year alone), but still not found an easy way to feed the distance of a route/track in a gpx into a script.

I assumed there'd be some commandline tool (ie gpsbabel) to tell me the distance of a track/route within a gpx file. Surely I'm not the only mofo in the world to want such a thing?


 
Posted : 05/11/2015 10:50 pm
Posts: 2880
Full Member
 

Can you download the data to excel and use countif to count all rides greater than Or equal to 10,11,12,13... Etc. That should derive the answer fairly quickly I would have thought.


 
Posted : 05/11/2015 11:51 pm
Posts: 8771
Full Member
Topic starter
 

Excel!?!? Excel!?!? Excel!?!?

The GPX files are on computer already. That's 250 for this year. I've got some older ones somewhere too.

The problem is obtaining the distance of the track in each GPX - tracks are made up of points defined by longtitude & lattitude. I don't know the maths for it, I got a C in maths. I want a tool that takes care of that, preferably with a little smoothing...

The tool will simply dump to stdout a summary of each gpx file, distance, duration, avg speed, elevation etc. There's a python library - python-gpxpy - which comes with a tool - gpxinfo - to do such a thing but it aborts on error with the files I have.


 
Posted : 06/11/2015 12:02 am
Posts: 0
Free Member
 

How much is your time worth? Unless you really enjoy programming then I'd just stump up the tenner....


 
Posted : 06/11/2015 12:09 am
 poly
Posts: 8699
Free Member
 

There's a python library - python-gpxpy - which comes with a tool - gpxinfo - to do such a thing but it aborts on error with the files I have.

Can you post an example file you are having the error with somewhere?
Can you also post the exact error you get?

There seems to be a tool which does what you want, the easiest fix seems to be to get that tool to work!


 
Posted : 06/11/2015 12:17 am
Posts: 43345
Full Member
 

Ooh. Never heard of this before but it appears my Eddington Number is 49.

I got that by using the tool at swinny.net against my Strava uploads


 
Posted : 06/11/2015 12:59 am
Posts: 0
Free Member
 

find . -name "*.gpx" -exec gpsbabel -t -r -i gpx -f {} -o kml -F - \; | grep Distance | perl -n -e '/\s(\d+\.?\d?)\s/ && print $1, "\n"' | sort -rn | nl

This gives you the distances in miles for all gpx files in the current directory in decreasing order. I assume the Eddington number can be easily found after that - you move down until the number of the line is greater than the number of miles. Needs gpsbabel and perl, doesn't work if you have more than one ride in a day :).


 
Posted : 06/11/2015 6:32 am
Posts: 840
Full Member
 

[url= https://swinny.net/Strava/-4691-My-Strava-Eddington-Number ]This site[/url] gives me a depressingly low Eddington number. If all your rides are in Strava, maybe it will suit your needs?


 
Posted : 06/11/2015 7:15 am
 kcal
Posts: 5448
Full Member
 

My Eddington is not as large as scotroutes'. sigh.


 
Posted : 06/11/2015 7:27 am
Posts: 8771
Full Member
Topic starter
 

1) @whatnobear, I used to really enjoy programming as a hobby, but...

2) @poly gpxinfo appears to be designed to work with GPX 1.1 files and all my gpx are 1.0. However I still have the Garmin fit files that they were converted from, so I could perform the conversion using gpsbabel adding the gpxver=1.1 option.

3) @otsdr Thanks, impressive one-liner, but guess what! Most of my commutes are recorded as two rides.

4) I had a look at the calculator at swinny.net but couldn't get it working... But now I've disabled ublock/noscript/selfdestructingcookies and hey ho, it works. Duh.

23.


 
Posted : 06/11/2015 4:19 pm
Posts: 91000
Free Member
 

The GPX files are on computer already. That's 250 for this year.

That is exactly what macros are for 🙂


 
Posted : 06/11/2015 4:30 pm
 poly
Posts: 8699
Free Member
 

2) @poly gpxinfo appears to be designed to work with GPX 1.1 files and all my gpx are 1.0. However I still have the Garmin fit files that they were converted from, so I could perform the conversion using gpsbabel adding the gpxver=1.1 option.

mmm... that sounds like a challenge...

molgrips - That is exactly what macros are for

well - not really - they are a bodge, which requires a knowledge of writing that type of macro, an understanding of gpx file formats, and calculating distance from lat/long and then some effort (albeit it can be automated) to collate the data... you could do it with macros, but its almost certainly not the slickest way.


 
Posted : 06/11/2015 11:14 pm
Posts: 3351
Full Member
 

Matlab, Scilab, Octave could do it and I don't even really know what 'it' is


 
Posted : 06/11/2015 11:21 pm
 poly
Posts: 8699
Free Member
 

A quick look at the spec suggests gpxpy/gpxinfo supports 1.0 and 1.1 formatted files and has for a couple of years at least.


 
Posted : 06/11/2015 11:26 pm
Posts: 8771
Full Member
Topic starter
 

#!/bin/bash
#
# script name: eddington
#
# processes *.gpx files in current working directory
# to find eddington number
#
# The GPX files are converted to the KML format. The conversion
# calculates the distance of the track. The converted files are
# stored in ${HOME}/.eddington-temp. Passing "clean" (w/o quotes)
# as first argument will remove them.

# setup temporary storage
TEMP="${HOME}/.eddington-temp"
if [ ! -d "$TEMP" ]; then
mkdir $TEMP
fi

if [ "'$1'" == "'clean'" ]; then
rm $TEMP/*
fi

# associative array for accumulating mileage per date
unset DISTANCE
declare -A DISTANCE

echo "Processing GPX/KML files..."

for GPX in *.gpx
do
FN=$(basename "$GPX")
KML="$TEMP/${FN%.gpx}.kml"

if [ ! -e "$KML" ]; then
echo -n "Converting $GPX... "
gpsbabel -t -r -i gpx -f "$GPX" -o kml -F "$KML"
if [ $? -eq 0 ]; then
echo "Ok"
else
echo "FAIL"
exit 1
fi
fi;

# obtain DATE from KML file
DATE=$(grep -m1 "Start Time" "$KML" | sed -r 's/.*([1-9][0-9]{3}(-[0-9]{2}){2}).*/\1/')
# only count distance measured in miles and discard any in feet
DIST=$(grep "Distance" "$KML" | perl -n -e '/\s(\d+\.?\d\ mi?)\s/ && print $1, "\n"')

if [[ "$DIST" ]]; then
DIST="${DIST% mi}"
if [[ ${DISTANCE[$DATE]} ]]; then
# add to running total for date
DISTANCE[$DATE]=$(echo "${DISTANCE[$DATE]} + $DIST" | bc -l)
else
DISTANCE[$DATE]=$DIST
fi
fi
done

echo "Sorting data..."
# while simultaneously converting to integer
SORTED=($(printf "%0.f\n" "${DISTANCE[@]}" | sort -rn))

E=0
for D in "${SORTED[@]}"
do
if [ $E -gt $D ]; then
printf "Your Eddington number is: %d\n" $((E - 1))
exit
fi
E=$((E + 1))
done


 
Posted : 07/11/2015 4:33 pm
Posts: 43345
Full Member
 

[quote=kcal ]My Eddington is not as large as scotroutes'. sigh.
I imported some older rides (I got into Strava late) and recalculated. I'm now at 62. I reckon a good target would be staying ahead of my age 😆


 
Posted : 07/11/2015 4:36 pm
Posts: 0
Free Member
 

I calculated mine earlier this year as E=56.

Note that it is a daily mileage [b]not[/b] a ride mileage, i.e. it's the total number of miles on a given day. So a commute of ten miles each way would give a figure of twenty not ten even though your longest ride on the day was ten miles.


 
Posted : 07/11/2015 4:54 pm

6 DAYS LEFT
We are currently at 95% of our target!