# Simple time elapse mass object orbit algorythm Written By Mark A Hopper - Helicopter Pilot.
# -*- coding: utf-8 -*-
# coding = utf-8 
# Powershell.exe -executionpolicy remotesigned -File  "input_box1.ps1"
# This Python file uses the following encoding: utf-8

import os, sys
import math   

import random
import string
import numpy as np

print(" ")

print ("Let's calculate the period of a single orbital revolution(amount of time in s)") 
print ("for a satellite based on Earth's constant velocity at meters/second.")
print ("This calculation well be based on a single input, the 'radius of a circular orbit' outside of the Earth's surface.")
print ("These man-made objects circle Earth in orbits that range from as near as 240km to 36,200km or 36200000 meters away.")
print ("Most satellites are placed into orbit between 500km or 500000m to 1500km or 1500000m")
# Radius of Earth = 6,371.14 km / or 6,371,000 m     diameter - earth 12,742 km  or 12,742,000 meters
# lowest earth orbit - 167km or 167000 meters        
# GM or g represents the proportional constant between the gravity and the mass of the celestial body(Earth).

# g = 3.986005*(10 ** 14)  at m cubed divided by s squared or m3/s2	
print ("   ")
print ("Please note that the radius of the Earth itself is 6371000m.")
print ("Simply add the satellite's height above MSL[mean sea-level] to Earth's radius and input that sum.")
print ("   ")

print ("Enter a number[integers only-no commas] between 6611000m/42570000m representing the radius of the")
num = int(input("orbiting satellite in meters around the Earth: "))

if num > 42570000 :
   print("Your input is too large,  go back and try again!")
   exit()
if num < 6611000 :
   print("Your input is too small,  go back and try again!")
   exit()
else:
   print("Great Choice!")
   
# equation for problem 4.2 at www.braeunig.us/space/index.htm
# user's input will be the radius of satellite orbit
# Given: Earth's Radius   r = 6,578,140 m   or  6578140

#    P squared equals 4 × pi squared * r cubed divided by GM or g
#    P = sqrt[ 4 × 3.14 squared × r cubed / GM ]

print(type(num))

P = math.sqrt(((4 * (math.pi ** 2)) * (num ** 3) / (3.986005 * (10 ** 14))))
print(type(P))

z1 = 100
int(z1)
test = math.sqrt(z1)
int(test)
# print(test)
O = int(P) 

#P = 5,310 s
print("   ")
print(("The amount of time based on your input is {}" .format(O)) + (" seconds per orbit."))
print("   ")

M = O / 3600
N = round(M, 2)
D = N / 24 
print(("Now calculated to hours it is {}" .format(N)) + (" hours per orbit."))
print("   ")

E = round(D, 3)
print(("Now calculated to Days it is {}" .format(E)) + (" Days per orbit."))
print("   ")
exit()