Skip to content

Latest commit

 

History

History

Kepler

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Kepler’s Analysis of Mars Orbit using Jupyter Notebooks and AI-Assisted Coding

Kepler’s analysis of Mars’ orbit remains a landmark example of how data and mathematics can unveil the workings of the universe. This project revisits his pioneering work with modern data science tools, harnessing the power of Python’s ecosystem with Jupyter notebooks, NumPy, Pandas, SciPy, Matplotlib, and leveraging AI-assisted coding to accelerate development.
Our aim is to demonstrate how these state-of-the-art tools can dramatically enhance productivity and transform complex analyses into an interactive, visually engaging experience accessible to a wide audience.

This repository contains the Jupyter notebooks accompanying the blog post
Kepler’s Mars Orbit Analysis with Python Notebooks & AI-Assisted Coding.

Author and contact: [email protected]
First version: February 2025


Overview

Notebooks

The analysis is organized into a series of Jupyter notebooks that progressively build toward triangulating Mars' orbit and verifying Kepler's laws. The methodology follows these steps:

  1. Generating Mars Ephemeris – Compute Mars' celestial positions using JPL's DE421 data.
  2. Key Insight of Kepler's Analysis – Key insight and proof-of-concept of how to use Earth-based observations to estimate Mars' trajectory.
  3. Computing Mars Orbit – Triangulate Mars' position over multiple observations.
  4. Kepler's Laws – Verify Kepler’s laws of planetary motion with real data.
  5. Estimating Earth's Orbit – Compute Earth's heliocentric orbit from Mars and LOS measurements.

Data Files

The Data directory contains the CSV files generated by this analysis:


Running the Analysis

Run the Python notebooks using Jupyter on a local machine or using (free) cloud resources.

  1. Clone the repository:
    git clone https://github.com/lucacanali/Miscellaneous.git
    cd Miscellaneous/Data_Analyses/Kepler
  2. Install dependencies:
    pip install -r requirements.txt
  3. Start Jupyter Notebook or Jupyter Lab:
    jupyter-notebook

Optionally run on cloud resources such as GitHub Codespaces or Google's Colab. CERN users can use the CERN SWAN service.

Clink on this link to run using GitHub Codespaces:

  • Open in GitHub Codespaces

Analysis and Notebooks Breakdown

The project is organized into a series of Jupyter notebooks that progressively build toward triangulating Mars' orbit and verifying Kepler’s laws. The methodology proceeds as follows:

  1. Generating Mars Ephemeris
    Compute Mars' celestial positions using JPL's DE421 data.

    • Replaces decades of historical Mars observations with a modern ephemeris.
    • Computes daily positions for both Mars and the Sun.
    • Filters out observations when Mars is obscured by the Sun.
    • Exports the resulting ephemeris to a CSV file for subsequent processing.
  2. Key Insight of Kepler's Analysis
    Demonstrate how Earth-based observations can be used to estimate Mars' trajectory.

    • Leverages the fact that Mars returns to the same position every 687 days (one Mars year).
    • Uses line-of-sight (LOS) measurements to triangulate Mars' position from different Earth-based perspectives.
    • Provides visualizations that illustrate the triangulation process.
  3. Computing Mars Orbit
    Triangulate Mars' position using multiple observations.

    • Generalizes the triangulation method to compute a robust estimate of Mars' heliocentric coordinates.
    • Aggregates multiple measurements and saves the computed orbit to a CSV file.
    • Plots the estimated Mars orbit.
  4. Kepler's Laws
    Verify Kepler’s laws of planetary motion with real data.

    • First Law:
      • Fit an elliptical model to Mars’ orbit, confirming that it is an ellipse with the Sun at one focus.
      • Compare the derived orbital parameters (eccentricity, semi-major axis) with accepted values.
    • Second Law:
      • Demonstrate that Mars sweeps out equal areas in equal time intervals.
    • Third Law:
      • Validate the harmonic law by comparing the (T^2/a^3) ratio for Mars and Earth.
    • Provides detailed visualizations of each law in action.
  5. Estimating Earth's Orbit
    Compute Earth's heliocentric orbit using Mars and LOS measurements.

    • Uses Mars ephemeris and LOS data to determine Earth's position by solving for the Earth-Sun distance.
    • Fits the computed Earth positions to an elliptical model (with the Sun at one focus).
    • Compares the derived Earth orbital parameters with accepted values.
    • Visualizes Earth's orbit alongside the positions of Mars and the Sun.