Skip to content

Instantly share code, notes, and snippets.

@gmariette
Last active April 14, 2020 11:51
Show Gist options
  • Select an option

  • Save gmariette/5f8dcc3403cb5c51155e3d7b26ea81a3 to your computer and use it in GitHub Desktop.

Select an option

Save gmariette/5f8dcc3403cb5c51155e3d7b26ea81a3 to your computer and use it in GitHub Desktop.
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import random
# Import our csv into a panda dataframe
df = pd.read_csv('iss.csv')
# Convert timestamp column to a datetime format
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='s')
colors = ['green', 'darkblue', 'yellow', 'red', 'blue', 'orange']
for i in range (0,450,90):
try:
start_filter = df['timestamp'][:1] + pd.DateOffset(minutes=i)
end_filter = df['timestamp'][:1] + pd.DateOffset(minutes=i+90)
except:
break
mask = (df['timestamp'].values >= start_filter.values) & (df['timestamp'].values < end_filter.values)
tmpdf = df.loc[mask]
try:
str(tmpdf['timestamp'].head(1).values[0])
except:
break
lat_y = tmpdf['latitude'].tolist()
lon_x = tmpdf['longitude'].tolist()
fig = plt.figure(figsize=(12,9))
m = Basemap(projection='mill',
llcrnrlat = -90,
urcrnrlat = 90,
llcrnrlon = -180,
urcrnrlon = 180,
resolution = 'c')
m.drawcoastlines()
m.drawmapboundary(fill_color='aqua')
#Fill the continents with the land color
m.fillcontinents(color='coral',lake_color='aqua')
m.drawparallels(np.arange(-90,90,10),labels=[True,False,False,False])
m.drawmeridians(np.arange(-180,180,30),labels=[0,0,0,1])
plt.title('ISS traceroute from ' + str(tmpdf['timestamp'].head(1).values[0]), fontsize=20)
m.scatter(lon_x,lat_y, latlon=True, c=random.choice(colors), marker='o', alpha=1, linewidth=1, zorder=3)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment