Overview
I am working on a new cool feature for Bad Science Fiction (BSF). It will take a while, so in the meantime, it’s an excellent opportunity to look into BSF-related topics.
I went for a run the other night, and someone asked how many loops around the middle school I completed. My five-mile run was recorded via GPS, and I had a map of my tracks. However, the resolution on the Strava Android app wasn’t clear enough to determine the exact number of loops.
It was a great chance to try out the GPT-4o Canvas feature, which functions similarly to the Code Interpreter and can process Python code generated by the large language model.
A while back, I spent significant time tricking out ChatGPT-4’s Code Interpreter to process GPS data from my running. The Code Interpreter is a Python sandbox that allows the GPT-4 model to execute the code it generates.
The Code Interpreter is limited to handling smaller coding tasks. Because it also operates within a sandbox environment, its ability to work with external data and modules is restricted.
This time, I asked GPT-4o to process a GPX file of my run. I then asked basic questions about the track, which GPT-4o answered by computing answers on the fly—very helpful.
GPT-4o/Canvas performed very well in this fast scripting/quick-answers-from-code role. However, it misinterpreted a key concept in my prompt and chose the wrong algorithm, so I needed to instruct it on a better choice. Once I did that, it performed impressively.
What is Bad Science Fiction?
BSF, or Bad Science Fiction, describes a collaborative software project on GitHub. As explained in the AI Advances articles, the project is so named because its ostensible goal is to develop a story analysis tool specializing in science fiction—a tool to be developed in collaboration with Generative AI. However, it is as much an experiment on how best to leverage large language models (LLMs) to amplify software.
What’s Going On?
Below is the run that started it—a five-miler that loops around a local middle school. The question was, how many loops did I run? From the Strava app on Android, it wasn't easy to tell from the map graphic — Figure 1.
I turned this visual ambiguity into an opportunity to test whether GPT-4o could compute the answer from GPS data represented as GPX points in a file using its new Canvas feature.
I started by asking it to plot the route directly from the data, and it did well—Figure 2. The little blue arrows in its response are links to the Python source code it used.
The source code used by GPT-4o in Figure 2 is below.
import gpxpy
import gpxpy.gpx
import matplotlib.pyplot as plt
# Load the GPX file
gpx_file_path = "/mnt/data/Afternoon_Run.gpx"
with open(gpx_file_path, "r") as gpx_file:
gpx = gpxpy.parse(gpx_file)
# Extract latitude and longitude points
latitudes = []
longitudes = []
for track in gpx.tracks:
for segment in track.segments:
for point in segment.points:
latitudes.append(point.latitude)
longitudes.append(point.longitude)
# Plot the GPS track
plt.figure(figsize=(10, 6))
plt.plot(longitudes, latitudes, marker='o', linestyle='-', markersize=2, color='blue')
plt.xlabel("Longitude")
plt.ylabel("Latitude")
plt.title("GPS Track from GPX File")
plt.grid(True)
plt.show()
My next set of questions was a mixed bag, however. GPT 4o’s computed answer for elevation change matches Strava’s result, so I take that as a win. The second response — 1,582 laps is very incorrect.

I reviewed the code generated by GPT-4o and asked o1 Mini to verify my findings. It turned out that GPT-4o had used a highly localized "bubble" approach to define a "loop"—counting how many times the track entered and exited these small regions (revisits). This wasn't the definition I had in mind. Figure 4 illustrates the algorithm GPT-4o used.

I needed to clarify what a loop was, and I wanted to do it as an algorithm. How many loops did I run around the middle school?
I started by asking o1 mini the following:
A man runs around a building with his Strava, recording his movement. It collects a track of GPX points. The man runs around the building many times, so his GPX track on Strava consists of many points in one long continuous track that winds around and around the building many times. Propose ideas for an algorithm that can count how many times the man ran around the building using the file of GPX data downloaded from Strava.
We noodled on this a bit. The algorithm we settled upon was o1 Mini’s idea, but I reviewed it and double-checked it. I suggested that it estimate the building center from the data — using the lat/lon means. It's a nice algorithm:
I prompted GPT-4o with the text in Figure 5, and I could almost hear it sigh, “Aha, that is what you mean by a loop.” It returned the answer of 10, which is correct. See Figure 6.

Links:
Some previous examples of using GPT 4 and Code Interpreter to process running data (GPS/GPX):
ChatGPT reveals a Riverlands Endurance Run | by Nate Combs | AI Advances
ChatGPT and the Middlesex Fells Trail Analyzer | by Nate Combs | AI Advances