In [1]:
from sunpy import lightcurve
from sunpy.time import TimeRange
tr = TimeRange('2011-06-07 06:00', '2011-06-07 08:00')


/Users/schriste/anaconda/lib/python2.7/site-packages/pandas/io/excel.py:626: UserWarning: Installed openpyxl is not supported at this time. Use >=1.6.1 and <2.0.0.
  .format(openpyxl_compat.start_ver, openpyxl_compat.stop_ver))

In [3]:
%matplotlib inline

In [2]:
goes = lightcurve.GOESLightCurve.create(tr)
goes.peek()


/Users/schriste/Dropbox/Developer/python/sunpy/sunpy/lightcurve/lightcurve.py:253: RuntimeWarning: Using existing file rather than downloading, use overwrite=True to override.
  warnings.warn("Using existing file rather than downloading, use overwrite=True to override.", RuntimeWarning)

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]:
16

In [7]:
qr.show()


Start time           End time             Source  Instrument  Type  
----------           --------             ------  ----------  ----  
2011-06-07 06:04:58  2011-06-07 06:05:23  SOHO    LASCO       CORONA
2011-06-07 06:12:45  2011-06-07 06:13:04  SOHO    LASCO       CORONA
2011-06-07 06:19:43  2011-06-07 06:20:08  SOHO    LASCO       CORONA
2011-06-07 06:27:29  2011-06-07 06:27:48  SOHO    LASCO       CORONA
2011-06-07 06:34:29  2011-06-07 06:34:54  SOHO    LASCO       CORONA
2011-06-07 06:42:15  2011-06-07 06:42:34  SOHO    LASCO       CORONA
2011-06-07 06:49:12  2011-06-07 06:49:37  SOHO    LASCO       CORONA
2011-06-07 06:56:59  2011-06-07 06:57:18  SOHO    LASCO       CORONA
2011-06-07 07:03:58  2011-06-07 07:04:23  SOHO    LASCO       CORONA
2011-06-07 07:11:45  2011-06-07 07:12:04  SOHO    LASCO       CORONA
2011-06-07 07:18:46  2011-06-07 07:19:11  SOHO    LASCO       CORONA
2011-06-07 07:26:36  2011-06-07 07:26:55  SOHO    LASCO       CORONA
2011-06-07 07:33:38  2011-06-07 07:34:03  SOHO    LASCO       CORONA
2011-06-07 07:41:31  2011-06-07 07:41:50  SOHO    LASCO       CORONA
2011-06-07 07:48:34  2011-06-07 07:48:59  SOHO    LASCO       CORONA
2011-06-07 07:56:26  2011-06-07 07:56:45  SOHO    LASCO       CORONA

In [9]:
res=client.get(qr)

In [10]:
res


Out[10]:
<sunpy.net.vso.vso.Results at 0x10fa662d0>

In [14]:
print(res.progress)


None

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()


<matplotlib.figure.Figure at 0x10b95b290>

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 [ ]: