GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Shegzimus/NASA_NearEarthObjects_DataPipeline: Airflow powered ETL pipeline for moving Near-Earth-Object data from NASA to Google Cloud

BranchesTags
Open more actions menu

Latest commit

 

History

191 Commits
191 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
airflow
airflow
 
 
assets
assets
 
 
bash
bash
 
 
terraform
terraform
 
 
viz
viz
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
project_log.md
project_log.md
 
 
pyproject.toml
pyproject.toml
 
 
uv.lock
uv.lock
 
 

Repository files navigation

NASA NeoWs pipeline: asteroids over Earth

An Airflow pipeline that downloads NASA's near-Earth-object close-approach data week by week, models it with dbt, reconstructs each asteroid's flyby trajectory past Earth from its orbit, and renders the result on a 3D globe.

The asteroids orbit the Sun, not Earth: none of them hit us. Each one sweeps past on a nearly straight line and keeps going. The globe draws those paths over the 3 days before and after closest approach, with a dot riding along each one as the time slider plays.

Globe of asteroid flyby paths around Earth

15 April 2026, as (2013 GM3) makes the closest pass in the dataset, 0.68 lunar distances (about 260,000 km): the bright hooked curve just west of Africa. Around it are a month of other flybys. Lines brighten in the direction of travel; squares mark asteroids passing at that moment (red = potentially hazardous); the dashed ring is the Moon's distance. The panel on the left filters by time window, position accuracy, hazard and size.

It runs fully locally (Docker, Postgres, files on disk). Pointing it at Google Cloud (GCS + BigQuery) is a configuration change, see Going to GCP.

flowchart LR
  A[NASA NeoWs /feed<br/>weekly windows] -->|neows_feed| B[(Lake<br/>raw JSON per week)]
  B --> C[(Warehouse raw<br/>neo_observation, close_approach)]
  J[JPL SBDB<br/>orbital elements] -->|neows_orbits| D[(raw.sbdb_orbit)]
  C --> E{{neows_publish}}
  D --> E
  E -->|dbt| F[(marts: dim_asteroid,<br/>fct_close_approach, weekly summary)]
  F -->|orbit maths| G[(fct_approach_geo)]
  G -->|export + flyby paths| H[viz/data/approaches.js]
  H --> I[viz/index.html<br/>3D globe]
Loading

Quickstart

Requires Docker with Compose.

cd airflow
cp .env.example .env     # set NASA_API_KEY (free at https://api.nasa.gov), AIRFLOW_UID=$(id -u), and the secrets
docker compose up -d --build

Open Airflow at http://localhost:8081 (no login in local mode). The DAGs are unpaused, so:

  1. neows_feed backfills every week since 2024-01-01 (one API request per week; two weeks run in parallel). DEMO_KEY allows only 30 requests per hour, so use a real key for the backfill.
  2. neows_orbits pulls the orbital elements of every known NEO in a single request.
  3. When both have run, neows_publish builds the dbt models, computes the overhead points and writes viz/data/approaches.js.

Then open viz/index.html in a browser. A snapshot is committed so the page works before you run anything.

Without Docker, the same steps run from the command line (see .env.example for the variables): python -m neows backfill --start 2024-01-01, orbits, geo, export.

How the flyby paths are computed

NeoWs gives a miss distance and a time, not a position. For each approach:

  1. take the asteroid's orbital elements from JPL SBDB and propagate them with a two-body (Keplerian) solution to every 6 hours from 3 days before to 3 days after closest approach,
  2. subtract Earth's position (astropy's built-in ephemeris) to get where the asteroid is relative to Earth: a direction (right ascension/declination) and a distance,
  3. draw the samples against the stars as they stood at the moment of closest approach. The nearest point then floats directly above the place on Earth the asteroid was overhead at that instant (fct_approach_geo stores that point). An Earth-fixed frame would wind every path into a spiral, because the planet rotates underneath.

Distance is drawn on a log scale so that flybys at 0.7 and at 70 lunar distances both fit, which makes the straight paths look gently curved. A dashed ring marks the Moon's distance for scale.

Planetary perturbations are ignored, so every approach is checked against NASA's own miss distance and labelled good (< 5 % off), rough (< 25 %) or poor. On the 2024-2026 data (5,236 approaches), 95.6 % are good (median error 0.2 %); spot checks against JPL Horizons agree to about 0.1 degrees. The globe lets you filter by this accuracy.

Data model

Layer Object Notes
lake raw/feed/start_date=YYYY-MM-DD/feed.json scrubbed API response (the API key is stripped); rerunning a week overwrites it
raw neo_observation, close_approach, sbdb_orbit loaded by Python, one weekly interval replaced atomically per run
marts dim_asteroid latest attributes + orbital elements, one row per asteroid
marts fct_close_approach one row per (asteroid, approach instant); partitioned/clustered on BigQuery
marts mart_weekly_summary approaches, hazardous count, closest pass, largest object per week
marts fct_approach_geo overhead point at closest approach, computed distance, accuracy label

NeoWs asteroid ids are not JPL SPK-IDs, so orbits are joined on the provisional designation (2015 XB128), which matches about 99 % of asteroids.

Going to GCP

The code path is identical; only configuration changes.

  1. Create a GCP project and a service account with Storage Admin and BigQuery Admin (or narrower). Save its key as airflow/credentials/gcp.json (the folder is gitignored).
  2. Create the bucket and datasets:
    cd terraform
    export GOOGLE_APPLICATION_CREDENTIALS=$PWD/../airflow/credentials/gcp.json
    terraform init && terraform apply -var project=YOUR_PROJECT
    terraform output -raw env_snippet >> ../airflow/.env
  3. docker compose up -d again. The lake is now gs://..., loads go to BigQuery, and dbt runs with --target gcp.

The Postgres container still hosts Airflow's own metadata; only the data moves.

Layout

airflow/
  dags/        neows_feed, neows_orbits, neows_publish
  neows/       the package the DAGs call: client, parse, lake, warehouse, sbdb, geo, pipeline
  dbt/neows/   staging views, marts, tests; targets `local` (Postgres) and `gcp` (BigQuery)
  tests/       pytest (no Docker or network needed)
terraform/     optional GCP infrastructure
viz/           the globe page and its exported data

Development

uv run pytest          # unit tests; DAG parse tests run too if Airflow is installed
uv run ruff check airflow

Security notes

  • Secrets live in airflow/.env and airflow/credentials/, both gitignored. Stored raw responses have the NeoWs links blocks removed, because NASA echoes your API key in them.
  • Local services bind to 127.0.0.1 only. Local mode disables the Airflow login screen; remove SIMPLE_AUTH_MANAGER_ALL_ADMINS from docker-compose.yml before exposing it anywhere.

Data: NASA NeoWs and JPL SBDB.

About

Airflow powered ETL pipeline for moving Near-Earth-Object data from NASA to Google Cloud

Topics

airflow-dagairflow-operatorairflow-providersbigquerycelery-redisdockerdocker-composedocker-containergoogle-cloud-platformgooglecloudstoragenasa-api

Resources

Readme
Apache-2.0 license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.