In [1]:
from sunpy import lightcurve
from sunpy.time import TimeRange
tr = TimeRange('2011-06-07 06:00', '2011-06-07 08:00')
In [3]:
%matplotlib inline
In [2]:
goes = lightcurve.GOESLightCurve.create(tr)
goes.peek()
In [4]:
from sunpy.net import vso
client=vso.VSOClient()
In [5]:
qr = client.query(vso.attrs.Time(tr.start(), tr.end()), vso.attrs.Instrument('lasco'))
In [6]:
qr.num_records()
Out[6]:
In [7]:
qr.show()
In [9]:
res=client.get(qr)
In [10]:
res
Out[10]:
In [14]:
print(res.progress)
In [13]:
import sunpy
In [25]:
file = '/Users/schriste/Desktop/SunPy_ODDE_Proposal/ISWA_KP.txt'
iswa_kp = read_iswa_data_dat(file)
plt.figure()
iswa_kp.plot()
plt.title('KP (ISWA)')
plt.ylabel('KP Index')
plt.show()
In [30]:
file = '/Users/schriste/Desktop/20120712_193500_ENLIL_time_line.dat.txt'
col_names = ['B_enl','V_enl','n_enl','T_enl']
enlil_data = read_iswa_enlil_dat(file, col_names=col_names)
kp90exp=9.5-np.exp(2.17676-(0.000052001)*((enlil_data.V_enl)**1.3333)*((enlil_data.B_enl)**0.6666)*(np.sin((np.pi/2)/2)**(8/3.)))
kp135exp=9.5-np.exp(2.17676-(0.000052001)*((enlil_data.V_enl)**1.3333)*((enlil_data.B_enl)**0.6666)*(np.sin((3*np.pi/4)/2)**(8/3.)))
kp180exp=9.5-np.exp(2.17676-(0.000052001)*((enlil_data.V_enl)**1.3333)*((enlil_data.B_enl)**0.6666)*(np.sin((np.pi)/2)**(8/3.)))
plt.figure()
kp90exp.plot()
kp135exp.plot()
kp180exp.plot()
plt.title("ENLIL Predicted KP Index")
plt.ylabel("KP")
plt.show()
In [24]:
def read_iswa_data_dat(file):
data = pandas.read_csv(file, delim_whitespace=True)
times_str = [str(t[0]) + ' ' + str(t[1]['Timestamp'])[0:-2] for t in data.iterrows()]
times = [datetime.strptime(str_time, '%Y-%m-%d %H:%M:%S') for str_time in times_str]
data['times'] = times
data = data.set_index('times')
data = data.drop('Timestamp',1)
return data
In [23]:
import pandas
from datetime import datetime
import matplotlib.pyplot as plt
In [28]:
def read_iswa_enlil_dat(file, col_names):
names = ['year', 'month', 'day', 'hour', 'minute'] + col_names
data = pandas.read_csv(file, skiprows=2, names=names, delim_whitespace=True)
times_str = [str(int(t[1]['year'])) + '-' + str(int(t[1]['month'])).zfill(2) + '-' + str(int(t[1]['day'])).zfill(2) + ' ' + str(int(t[1]['hour'])).zfill(2) + ':' + str(int(t[1]['minute'])).zfill(2) for t in data.iterrows()]
times = [datetime.strptime(t, '%Y-%m-%d %H:%M') for t in times_str]
data['times'] = times
data = data.set_index('times')
data = data.drop('year',1)
data = data.drop('month',1)
data = data.drop('day',1)
data = data.drop('hour',1)
data = data.drop('minute',1)
return data
In [ ]: