Created
April 24, 2025 21:33
-
-
Save tinwatchman/4e23eab170537ecc9e4a64f8a1807869 to your computer and use it in GitHub Desktop.
Time Travel Positioning Program by ChatGPT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Python script to calculate displacement in space between two points in time, compensating for Earth's movement through the solar system and galaxy | |
| Created by ChatGPT | |
| Use at your own risk! I have absolutely no idea if this works! | |
| Saved just in case time travel becomes a thing somehow | |
| """ | |
| from astroquery.jplhorizons import Horizons | |
| from astropy.time import Time | |
| import numpy as np | |
| import math | |
| # Constants | |
| R_EARTH_KM = 6371.0 | |
| SIDEREAL_DAY_SECONDS = 86164.1 # Earth's sidereal rotation | |
| GALACTIC_VELOCITY_KMPS = 220 # Sun’s galactic orbital speed | |
| def gps_to_eci(lat_deg, lon_deg, time_str, alt_km=0): | |
| """ | |
| Converts GPS coordinates to Earth-Centered Inertial (ECI) position at a given time. | |
| """ | |
| lat = math.radians(lat_deg) | |
| lon = math.radians(lon_deg) | |
| time = Time(time_str, scale='utc') | |
| jd = time.jd | |
| sidereal_angle = ((280.46061837 + 360.98564736629 * (jd - 2451545.0)) % 360) | |
| theta = math.radians((lon + sidereal_angle) % 360) | |
| r = R_EARTH_KM + alt_km | |
| x = r * math.cos(lat) * math.cos(theta) | |
| y = r * math.cos(lat) * math.sin(theta) | |
| z = r * math.sin(lat) | |
| return np.array([x, y, z]) | |
| def get_earth_position(time_str): | |
| """ | |
| Gets Earth's position in space from JPL Horizons (relative to solar system barycenter). | |
| """ | |
| obj = Horizons(id='399', location='500@0', epochs=Time(time_str, format='iso').jd) | |
| vec = obj.vectors()[0] | |
| return np.array([float(vec['x']), float(vec['y']), float(vec['z'])]) | |
| def estimate_solar_displacement(time_now, time_target, velocity_kmps=GALACTIC_VELOCITY_KMPS): | |
| """ | |
| Estimates Sun's linear galactic displacement between two times (in +Y direction). | |
| """ | |
| t1 = Time(time_now, scale='utc') | |
| t2 = Time(time_target, scale='utc') | |
| dt_seconds = (t2 - t1).sec | |
| dy = velocity_kmps * dt_seconds | |
| return np.array([0.0, dy, 0.0]) # +Y galactic direction | |
| def calculate_displacement(lat, lon, alt_km, time_now, time_target): | |
| """ | |
| Calculates full spatial displacement in galactic frame for a GPS point between two times. | |
| """ | |
| # Step 1: Get Earth's barycentric position | |
| earth_now = get_earth_position(time_now) | |
| earth_then = get_earth_position(time_target) | |
| # Step 2: Add surface GPS position (ECI adjusted) | |
| local_now = gps_to_eci(lat, lon, time_now, alt_km) | |
| local_then = gps_to_eci(lat, lon, time_target, alt_km) | |
| abs_now = earth_now + local_now | |
| abs_then = earth_then + local_then | |
| # Step 3: Estimate Sun’s galactic displacement | |
| solar_offset = estimate_solar_displacement(time_now, time_target) | |
| galactic_now = abs_now + estimate_solar_displacement(time_now, time_now) | |
| galactic_then = abs_then + solar_offset | |
| # Step 4: Calculate total galactic displacement | |
| vector = galactic_then - galactic_now | |
| displacement_km = np.linalg.norm(vector) | |
| return { | |
| 'displacement_km': displacement_km, | |
| 'vector_km': vector, | |
| 'from_position_km': galactic_now, | |
| 'to_position_km': galactic_then | |
| } | |
| # Example usage | |
| if __name__ == "__main__": | |
| lat = 37.7749 # San Francisco | |
| lon = -122.4194 | |
| alt = 0 # Sea level | |
| time_now = "2025-04-24 00:00" | |
| time_target = "1925-04-24 00:00" | |
| result = calculate_displacement(lat, lon, alt, time_now, time_target) | |
| print(f"\nTotal galactic displacement over time jump: {result['displacement_km']:.2f} km") | |
| print(f"Displacement vector: {result['vector_km']}") | |
| print(f"Start galactic position (km): {result['from_position_km']}") | |
| print(f"End galactic position (km): {result['to_position_km']}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment