Skip to content

Determining the distance of near earth asteroid 2023 TL4 with python – Part 1

Introduction

Recently, I was participating in a civilized discussion on the internet regarding the probability of a catastrophic asteroid strike on the Earth. That started me down a rabbit-hole where I found that there was a near-earth asteroid the size of 10 Taco Bells discovered in 2023 (assuming an average Taco Bell is approximately 100ft across), which made me wonder how many potentially hazardous asteroids might still be out there. On that path I learned how to use the NASA APIs with python.

According to this article on NASA’s JPL website, written in 2021, we were seeing three thousand new near-Earth asteroids each year. The vast majority are small (less than 140 meters or 460 ft). It seems like that number has stayed consistent, which tells me we are limited by a bottleneck in our detection techniques, most likely telescope time.

NASA Sentry

The NASA Sentry website showed that the asteroid 2023 TL4, at 320m wide, is expected to make its closest approach a close approach (see correction) on Oct 10 of the year 2119. That gives us a good bit of time-cushion to build a rocket that could nudge the rock off its course.

List of close asteroid approaches to Earth

The following chart was found on Wikipedia’s article List of asteroid close approaches to Earth:

50
100
150
200
  •   Discovered > 1 year in advance
  •   Discovered > 7 weeks in advance
  •   Discovered > 1 week in advance
  •   Discovered up to 1 week in advance
  •   < 24 hours’ warning
  •   No warning

Close approaching asteroids are still being discovered all the time! I’m wondering how far away 2023 TL4 was when it was discovered, to get a sense of how much margin we have in detecting these potentially dangerous asteroids.

NASA APIs

I wasn’t able to find out how far away 2023 TL4 was when it was detected from the Sentry website alone. However, using the plethora of APIs available from NASA, we can throw together a quick python script to query for near-earth object (NEO) data directly. Here we see how to query a NASA API with python:

#!/usr/bin/env python

import json
import requests

def get_asteroid_info(asteroid_id: str, api_key: str):
    url = f"https://api.nasa.gov/neo/rest/v1/neo/{asteroid_id}?api_key={api_key}"
    response = requests.get(url)
    if response.status_code == 200:
        return response.json()
    else:
        return "Error: " + str(response.status_code)

# You can actually use this key for quick testing, otherwise get a key at api.nasa.gov
api_key = 'DEMO_KEY'

# Search for asteroid 2023TL4 SPKID at:
# https://ssd.jpl.nasa.gov/tools/sbdb_lookup.html#/
asteroid_spkid = '54392417'  # "2023 TL4" SPKID

# query the API
asteroid_info = get_asteroid_info(asteroid_spkid, api_key)
print(json.dumps(asteroid_info))

AI Analysis (a.k.a. an excuse to use ChatGPT)

I saved the JSON output to this file: 2023TL4.json. Now we could read that file and mentally parse it (or use jq or python), but we could also upload it to ChatGPT 4 for analysis and see what happens..

https://chat.openai.com/share/64f4243b-847f-4931-afa1-aa7ecd81ed79

That was interesting. A few notes:

  1. It figured out the data was a dict-like object, not a list, and used the semantic meaning of the keys to determine the context of the data. Cool!
  2. It misunderstood a question about asking how far away it was (I meant how far away as of 2023) to mean "What will be the closest approach?"

    Interestingly, ChatGPT then correctly found a different closest approach than was displayed on the NASA Sentry website. I’m not sure why the discrepancy (see correction above):

    • API Data: 2090-10-19 — 0.58 lunar distances – half the distance to the moon.
    • NASA Sentry: 2119-10-10 — 1 in 27,000 odds of impact. No distance data was displayed on the website.
  3. It then correctly identified the close approach data and found the one closest to today’s date, where it determined that 2023 TL4 was about 12 lunar distances away from us when we saw it first on Oct 8, 2023.

Conclusion

It’s mind blowing to think that we are currently discovering potentially hazardous asteroids 12 lunar distances away when we see them for the first time. Such short distances would give us little time to mitigate the effects of a potential impact. But seeing and tracking dark specks of rock millions of miles away is like trying to see bats flying against a dark sky.

Twelve lunar distances sounds close, but feels a bit abstract. It would be amazing to be able to visualize exactly what that close pass looked like. In Determining the distance of near earth asteroid 2023 TL4 – Part 2
, we will do just that…

Published inScience

One Comment

Leave a Reply