Created
July 19, 2019 06:44
-
-
Save kickingvegas/1ab1ba17ac6ea73f8270f18ee87db72e to your computer and use it in GitHub Desktop.
Apollo 11 in Real-TIme Mission Milestones in Local Time Python3 Script
This file contains 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
#!/usr/bin/env python3 | |
# Copyright 2019 Charles Choi | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
# Author: Charles Y. Choi <[email protected]> | |
# | |
## | |
# Apollo 11 Real-Time Mission Experience Milestones Companion | |
# | |
# https://apolloinrealtime.org is an amazing effort in re-living the Apollo 11 | |
# mission. The mission milestones on that website are mapped to elapsed time, | |
# making it challenging to figure out when the "Eagle has landed." | |
# | |
# This python3 script tries to make it a bit easier to map some key milestones | |
# around the landing on the moon. | |
# | |
# You'll need to have python3 and pytz installed. | |
# Tested on macOS 10.13.6, python 3.6.9 | |
import os | |
import sys | |
import getopt | |
import subprocess | |
import shutil | |
from datetime import datetime, timedelta | |
import pytz | |
usageString = '%s ...' % os.path.basename(sys.argv[0]) | |
helpString = """ | |
-h, --help help | |
-v, --version version | |
-z<zonestring> timezone string | |
""" | |
class CommandLineParser: | |
def __init__(self): | |
try: | |
optlist, args = getopt.getopt(sys.argv[1:], 'hvz:', | |
('help', | |
'version')) | |
except getopt.error as error: | |
sys.stderr.write(error.msg + '\n') | |
sys.stderr.write(usageString + '\n') | |
sys.exit(1) | |
app = Apollo11Milestones() | |
app.run(optlist, args) | |
class Apollo11Milestones: | |
def __init__(self): | |
self.version = 1.0 | |
self.options = {} | |
def run(self, optlist, args): | |
tzname = 'America/Los_Angeles' | |
# tzname = 'America/New_York' | |
# tzname = 'America/Chicago' | |
# tzname = 'America/Denver' | |
for o, i in optlist: | |
if o in ('-h', '--help'): | |
sys.stderr.write(usageString) | |
sys.stderr.write(helpString) | |
sys.exit(1) | |
elif o in ('-v', '--version'): | |
sys.stdout.write('%s\n' % str(self.version)) | |
sys.exit(0) | |
elif o in ('-z',): | |
tzname = i | |
utc_ref = pytz.utc.localize(datetime(2019, 7, 16, 13, 32, 0, 0)) | |
try: | |
local_ref = utc_ref.astimezone(pytz.timezone(tzname)) | |
except pytz.exceptions.UnknownTimeZoneError as err: | |
sys.stderr.write('Unknown timezone: {0}\n'.format(err)) | |
sys.exit(1) | |
ref = local_ref | |
now = datetime.now().astimezone(pytz.timezone(tzname)) | |
mission_dt = now - local_ref | |
db = [] | |
db.append(('Local Time', now.strftime('%Y-%m-%d %H:%M:%S %Z'))) | |
db.append(('Crew wake-up', local_ref + timedelta(hours=69, minutes=10, seconds=24))) | |
db.append(('Lunar Orbit Insertion (LOI) burn', local_ref + timedelta(hours=75, minutes=49, seconds=44))) | |
db.append(('In Lunar Orbit', local_ref + timedelta(hours=75, minutes=53, seconds=24))) | |
db.append(('Eagle undocks from Columbia', local_ref + timedelta(hours=100, minutes=11, seconds=53))) | |
db.append(('Separation for Landing', local_ref + timedelta(hours=100, minutes=12, seconds=4))) | |
db.append(('Descent Orbit Insertion', local_ref + timedelta(hours=101, minutes=17, seconds=32))) | |
db.append(('Eagle has landed', local_ref + timedelta(hours=102, minutes=46, seconds=2))) | |
tempList = [] | |
buf = '{0:>35}: {1}'.format('Apollo 11 Mission Elapsed Time', mission_dt) | |
tempList.append(buf) | |
buf = '-' * 65 | |
tempList.append(buf) | |
for line in db: | |
buf = '{0:>35}: {1}'.format(line[0], line[1]) | |
tempList.append(buf) | |
buf = '-' * 65 | |
tempList.append(buf) | |
tempList.append(' ' * 37 + 'https://apolloinrealtime.org') | |
result = '\n'.join(tempList) | |
sys.stdout.write(result) | |
sys.stdout.write('\n') | |
if __name__ == '__main__': | |
CommandLineParser() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script output: