Space Science Blog

Bringing You The Future Of Science and Technology


In this section we will learn the basics of orbital geometry and the classical orbital elements commonly used to launch things into space and how we can use Python to perform these calculations.

Artificial Intelligence | DIY Electronics Projects | Game Design Workshop | Gallery | Random Generators | Planetary Science | Rocket Science


Art and Web Design

Contact me for information about rates and availability.

Latest Articles

International Space Station
(current position)

 How to Calculate Orbital Elements of a Spacecraft Using Python

International Space Station (source - NASA)
In this tutorial, I will introduce you to some basic rocket science equations and then show you how to calculate them using the Python programming language. In this tutorial I will be focusing on the International Space Station for our calculations. The results of our calculations can then be compared to those provided by the European Space Agency, NASA and the Heaven's Above websites.

The International Space Station, or ISS, is the largest orbiting space station ever built by man. It is the result of the combined efforts of several nations, over the course of several years to construct. It was initially launched into orbit on 20 November 1998. It orbits the Earth at an altitude of 370-460 km. It is approximately 109 meters wide, 74 meters long and 45 meters high, with a mass of approximately 925,335 pounds (419,725 kilograms). The ISS has a habitable volume of about 13,696 cubic feet (388 cubic meters), not including visiting vehicles. It has an orbital inclination of 51.6° and an orbital velocity of 7.6-7.7 km/s (around 27 500 km/h).

 Mass, Velocity and Orbital Period of the ISS

As noted above, the total mass of the International Space Station is approximately 419725 kg. With this value we can calculate the gravitational forces acting between the ISS and the Earth below. We can also determine the weight of the ISS at the point where it is farthest away from the Earth, or apogee (460 km) and when it is closest to Earth, or perigee (370 km). With mass (m) and velocity (v), we can calculate the amount of kinetic energy (KE), potential energy (PE) and total energy (E) of the ISS as it travels around the Earth. We could take this a step further and calculate the change in velocity of the ISS as it travels from perigee to apogee and back again.

Let us begin by calculating the gravitational field of Earth, and then we can demonstrate the effects of altitude on gravity by showing the change in weight of the ISS from sea-level (6378 km from Earth's center of mass) to an altitude of 460 km (apogee). Before we can calculate the gravitational effects of Earth, we need to define a few parameters.

We will be using pi, which is a mathematical constant equal to 3.14159265359. Pi is defined as the ratio between a circle's circumference to it's diameter.

We will also use the universal gravitational constant (G), which is an empirical physical constant involved in the calculation of gravitational effects developed by Sir Isaac Newton in his law of universal gravitation and used by Albert Einstein in his general theory of relativity.

pi (π) = 3.14159265359
Universal gravitational constant (G) = 6.67408 * 10-11 m3 kg-1 s-2

>>> pi = 3.14159265359
>>> G = 6.67408 * 10**-11 # Universal gravitational constant

With the universal gravitational constant, we can calculate the gravitational acceleration and gravitational parameters for the Sun and each planet.

Gravitational parameter (μ) = G * M
Gravitational acceleration (ge) = G * (M / R2)

Since we will be focusing on the International Space Station, let us calculate the gavitational parameter (mu) and gravitational acceleration (ge) at Earth's surface. Earth's radius is 6378.8 km and it has a mass of approximately 5.98 * 1024 kg. Don't forget to convert the radius from kilometers to meters before calculating the gravitational acceleration.

>>> Me = 5.98*10**24
>>> Re = 6378.8*1000
>>> mu = G * Me
>>> ge = G * (Me/Re**2)

Now we can calculate the weight of the ISS, if were floating on the ocean for example, by multiplying the mass of the ISS by the gravitational acceleration of the Earth.


>>> Miss = 416725 # Mass of ISS in kilograms
>>> Wiss = Miss * ge # Convert mass to Weight on Earth's surface (lbs)
>>> Wiss

The ISS is located far above the Earth's surface, and so we need to account for the increase in altitude by adding the altitude of the ISS (370-460 km) to the radius of the Earth (6378.8 km). Again, don't forget to convert from kilometers to meters before we calculate weight at an altitude of 460 km. Keep in mind, astronauts aboard the ISS are not experiencing zero-gravity, as they are way too close to Earth to be free of it's gravitational field. Rather, astronauts experience what is called micro-gravity. Therefore, the ISS, as well as all thouse aboard, still have some weight behind them as will be demonstrated below.

>>> Riss = Re + (460*1000)
>>> ge = G * Me/Riss**2
>>> Wiss = Miss * ge # Convert mass to weight at 460 km above Earth's surface (lbs)
>>> Wiss

For fun, you could also calculate your own weight aboard the ISS. First convert your weight to mass by dividing your weight by the Earth's gravitational acceleration at sea-level. Then you can calculate your weight at any altitude, simply by increasing the radius of the orbit. The important thing to remember, your mass never changes - only your weight.

Knowing the mass of the Earth and the height of the ISS above Earth's surface allows us to calculate the satellite's orbital period. A spacecraft's orbital period is the amount of time it takes to make one complete orbit around another object, in this case Earth. For this equation, which is a little more math-intensive, we will need to import the Math module. To calculate the orbital period using pi, we will use the following equation:

T = 2π√R3/G*Me

Before we code this in Python, import the Math module:

>>> import math
>>> T = 2*pi*math.sqrt(Riss**3/(G*Me)) # Orbital period in seconds
>>> T
>>> t = T /60 # converts from seconds to minutes
>>> t
93.7458770383134br />

In the code above, we calculated the orbital period of(T) the ISS as 93.75 minutes, which a quick search on the internet will show this to be pretty close to the actual value of 92.49 minutes. Knowing the spacecraft's orbital period, we can now calculate it's orbital velocity (V) using the following equation:

V = 2πR/T

>>> V = (2*pi*Riss)/T # Velocity measured in meters per second.
>>> V

This speed matches the orbital velocity values provided by the European Space Agency (7.6-7.7 km per second). The ISS does not orbit the Earth in a perfect circle. At it's closest approach, the ISS reaches an altitude of about 370 km (perigee) and at it's farthest point it is about 460 km (apogee). This change in altitude twice per orbit causes an increase and decrease in velocity. This is the result in a change from kinetic energy (KE) to potential energy (PE) and back again. More on that below.

When the ISS approaches apogee (Ra), all of it kinetic energy is lost while potential energy increases (decrease in velocity). Once the spacecraft begins its aproach to perigee (Rp) it will again trade potential energy for kinetic energy (increase in velocity). To do this, let us create four new variables: ha, hp, Ra and Rp.

>>> ha = 460*1000 # height at apogee, converted from km to m
>>> hp = 370*1000 # height at perigee, converted from km to m
>>> Ra = Re + ha # radius of orbit at apogee, from center of Earth
>>> Rp = Re + hp # radius of orbit at perigee, from center of Earth
>>> Va = (2*pi*Ra)/T # in meters per second
>>> Va
>>> Vp = (2*pi*Rp)/T # in meters per second
>>> Vp

 Kinetic Energy Versus Potential Energy

When considering the motion of a spacecraft around it's orbit, it is important to consider the spacecraft's total mechanical energy (E), which is derived from it's position and motion. Total mechanical energy is composed of potential energy (PE), which is due to the spacecraft's position, and it's kinetic energy (KE), which is determined by the spacecraft's motion. To compute a spacecraft's potential energy, we need to know the spacecraft's mass (m), it's position above a reference point (R) and the acceleration due to gravity (μ) at that reference point.

Now that we know the mass of the Earth (Me) and the ISS (Miss), the altitude at which the ISS (Riss) orbits and Earth's gravitational parameter (μ), we can calculate the spacecraft's potential energy using following equation. Potential energy is energy derived from the spacecraft's altitude, with greater heights resulting in greater potential energy.

PE = m*μ/R

We will perform this calculation twice; once for perigee and once for apogee. In Python, this would look like:

>>> PEa = Miss*mu/Ra # Potential Energy at apogee (kg km**2/s**2)
>>> PEa
>>> PEp = Miss*mu/Rp # Potential Energy at perigee (kg km**2/s**2)
>>> PEp

Using the spacecraft's mass and velocity at perigee and apogee, which needs to be converted to meters per second, we can calculate it's kinetic energy (KE) at any point in it's orbit:

>>> KEa = 1/2*Miss*Va**2 # Kinetic Energy at apogee (kg km**2/s**2)
>>> KEa 12159962865005.559 >>> KEp = 1/2*Miss*Vp**2 # Kintetic Energy at perigee (kg km**2/s**2)
>>> KEp 11842013687821.654

Lastly, we can use the spacecraft's potential and kinetic energy to calculate the total energy generated by the ISS as it travels along it's orbit. We will calculate the energy at apogee and perigee to see the difference a slight change in altitude will have on the velocity, and therefore the amount of energy at each of these points in it's orbit.

E = KE + PE

>>> Ea = KEa + PEa
>>> Ea
>>> Ep = KEp + PEp
>>> Ep