In [1]:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import datetime as dt
import numpy as np
In [15]:
#Input the file name."JoeDupes3_forearth"
fname = 'hotspot_2015'
data = pd.read_csv(fname+".csv", parse_dates=['datetime'], usecols=['latitude','longitude','datetime', 'power'])
#Skip the 1st header row.
#data.next()
data.head()
Out[15]:
In [3]:
max(data.power)
Out[3]:
In [4]:
binwidth = 5
plt.hist(data.power, bins=np.arange(min(data.power), 300, binwidth))
Out[4]:
In [5]:
binwidth = 5
plt.hist(data.temp_kelvin, bins=np.arange(min(data.temp_kelvin), max(data.temp_kelvin), binwidth))
Out[5]:
In [6]:
data.shape
Out[6]:
In [7]:
f = open(fname + '.kml', 'w')
#Writing the kml file.
f.write("<?xml version='1.0' encoding='UTF-8'?>\n")
f.write("<kml xmlns='http://earth.google.com/kml/2.1'>\n")
f.write("<Document>\n")
f.write(" <name>" + fname + '.kml' +"</name>\n")
for i, fid in enumerate(data.FID[:1000]):
if data.power[i] < 50:
continue
f.write(" <Placemark>\n")
f.write(" <name>" + str(data.temp_kelvin[i] -273.15) + "C</name>\n")
f.write(" <description>" + str(data.datetime[i]) +"</description>\n")
f.write(" <Point>\n")
f.write(" <coordinates>" + str(data.longitude[i]) + "," + str(data.latitude[i]) +"</coordinates>\n")
f.write(" </Point>\n")
f.write(" </Placemark>\n")
f.write("</Document>\n")
f.write("</kml>\n")
f.close()
In [16]:
json = data[df.line_race != 0].to_json(orient="records")
In [19]:
f = open('data.js', 'w')
f.write('var data = ' + json + ";")
f.write('var data2 = ' + json2 + ";")
f.close()