📜 ⬆️ ⬇️

Chasing yourself, or a great way to start your day.


Translation of the post Mariusz Jankowski " A Rat Race, or a Great Way to Start the Day ".
The code given in the article can be downloaded here .
Many thanks to Kirill Guzenko KirillGuzenko for help with the translation.
Not so long ago, when winter was raging, clearing the access to the house from snow debris, I decided to recall the good weather, having considered my bicycle route to work using Wolfram Language .

Last year, I decided to engage in such a very common activity as recording my activity data. I noted that over the past few years my trips have become faster and easier for me as the season draws to a close, so it was interesting for me to make sure that there are similar improvements in my fitness. Using only a smartphone and the corresponding application, I recorded 27 trips between home and work, and then used the Wolfram Language to read, analyze and visualize the results.

Here is an image from Google Earth showing my morning bike route, which is a little less than 18 km from east to west.
')


To transfer data from a smartphone, I used GPX (GPS Exchange Format) , a file format supported by major manufacturers of GPS devices and available in most applications. A regular GPX file includes location and elevation data with time stamps, and Wolfram Language returns this data as a list of rules with talking names Geometry , PointElevation, and PointTimestamp .

Here is a fragment of one of the GPX files:



Using the new features in the field of working with geodata in the Wolfram Language and the available time and position data, I was able to quickly and easily create a day trip animation (more details are available in the Initialization section of the attached CDF).




A little more effort, and here's something interesting: I combined all the morning trips for the season in one animated race - these were the rat races to work! The leader of the season is shown in yellow, of course!




Here are the results of this "race":



Consider now travel in chronological order. It turns out that my assumption about the improvement of travel time towards the end of the season and with the increase in mileage turned out to be true.



And let the previous calculations and visualizations are good enough, but we can do something more. GPX files contain elevation data with a time reference, however, not only will this easily visualize the overall profile of the road, but also something else: the detection of the ascent and descent sections by means of a new functionality from the signal processing area — peak detection.

Let's start with the standard road profile:



To determine the ups and downs, I smoothed the data on the rises to record only the largest local maxima and minima in the signal. To do this, I first constructed a linear interpolation of the entire function to get rid of too unstable intervals in the recorded data, and then smoothed it with a GaussianFilter .



The smoothing operation removes the “parasitic” peaks and declines in the height data. I identified the remaining large peaks with FindPeaks and divided the route into ascending and descending sections.



Visualize the sections of the ascent and descent of the morning trip on the elevation chart:



And here are some more useful visualizations - sections of the ascents and descents of the route on the map:




The approximate distances of the sections of ascent and descent are available from the lists of ascents and descents calculated earlier. The following result confirms the simple truth that it is always harder to go to work (i.e. uphill), and therefore less pleasant than to return from it.



I am already looking forward to the next season and all sorts of interesting facts in the analysis of my data using the Wolfram Language.

Source: https://habr.com/ru/post/263537/


All Articles