G4-DESCSS/utils/draw.py

29 lines
903 B
Python
Raw Normal View History

2022-05-12 16:57:42 +08:00
import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.basemap import Basemap
with open('assets/orbit.csv', 'r') as f:
data = f.readlines()
row_header = int(data[0].split(',')[1].strip())
row_column = int(data[0].split(',')[6].strip())
var = data[row_header - row_column:row_header]
data = [tuple(s.replace('\n', '').strip() for s in row.split(',')) for row in data[row_header:-1]]
dtype = []
for row in var:
row = row.split(',')
row = [s.replace("'", '').strip() for s in row]
dtype.append((row[0], 'float' if int(row[2]) > 0 else 'string'))
data = np.array(data, dtype=dtype)
alt, lat, lon = data['Altitude'], data['Latitude'], data['Longitude'] - 180
m = Basemap()
m.drawcoastlines()
m.fillcontinents(color='white', lake_color='lightskyblue')
m.drawmapboundary(fill_color='skyblue')
m.scatter(lon, lat, s=1)
plt.savefig('docs/orbit.png', bbox_inches='tight')