Given the following script to read in latitude, longitude, and magnitude data:
#!/usr/bin/env python
# Read in latitudes and longitudes
eq_data = open('lat_long')
lats, lons = [], []
for index, line in enumerate(eq_data.readlines()):
if index > 0:
lats.append(float(line.split(',')[0]))
lons.append(float(line.split(',')[1]))
#Build the basemap
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
antmap = Basemap(projection='spstere', boundinglat=-20, lon_0=-60, resolution='f')
antmap.drawcoastlines(color='0.50', linewidth=0.25)
antmap.fillcontinents(color='0.95')
x,y = antmap(lons, lats)
antmap.plot(x,y, 'r^', markersize=4)
plt.show()
I receive the following error when attempting to read in the latitudes, longitudes, and magnitudes:
Traceback (most recent call last):
File "./basic_eqplot.py", line 10, in <module>
lats.append(float(line.split(',')[0]))
ValueError: invalid literal for float(): -18.381 -172.320 5.9
The input file looks something like:
-14.990,167.460,5.6
-18.381,-172.320,5.9
-33.939,-71.868,5.9
-22.742,-63.571,5.9
-2.952,129.219,5.7
Any ideas for why this would cause a hiccup?