In [8]:
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime
import glob
plt.rcParams['figure.figsize'] = (10.0, 8.0)

In [9]:
from heroespy.util import times

In [10]:
%matplotlib inline

In [11]:
pd.set_option("display.max_rows", 15)

In [12]:
files = glob.glob('/Users/schriste/Dropbox/heroes_flares_lc_*.csv')

In [13]:
files


Out[13]:
['/Users/schriste/Dropbox/heroes_flares_lc_20130921_170000.csv',
 '/Users/schriste/Dropbox/heroes_flares_lc_20130921_190000.csv',
 '/Users/schriste/Dropbox/heroes_flares_lc_20130921_201000.csv']

In [14]:
year = 2013
month = 9
day = 21
time_ranges = ((datetime(year,month,day,17,0,0), datetime(year,month,day,18,0,0)),
               (datetime(year,month,day,19,5,0), datetime(year,month,day,19,50,0)),
               (datetime(year,month,day,20,20,0), datetime(year,month,day,21,10,0)))
fit_tranges = ((datetime(year,month,day,17,33,28), datetime(year,month,day,17,39,12)),
               (datetime(year,month,day,19,41,8), datetime(year,month,day,19,43,52)),
               (datetime(year,month,day,20,48,4), datetime(year,month,day,20,53,4)))
bkg_tranges = ((datetime(year,month,day,17,8,48), datetime(year,month,day,17,27,12)),
               (datetime(year,month,day,19,8,16), datetime(year,month,day,19,17,44)),
               (datetime(year,month,day,20,23,12), datetime(year,month,day,20,38,24)))

In [15]:
data = pd.read_csv(files[0], parse_dates=True, header=0, index_col=0)

In [16]:
data = data.truncate(before=time_ranges[0][0], after = time_ranges[0][1])

In [17]:
plt.figure()
data.plot()
plt.title('Original data')
plt.show()


<matplotlib.figure.Figure at 0x10de14c10>

In [18]:
resample_rate = '16S'
for file, time_range, fit_trange, bkg_trange in zip(files, time_ranges, fit_tranges, bkg_tranges):
    data = pd.read_csv(file, parse_dates=True, header=0, index_col=0)
    data = data.truncate(before=time_range[0], after=time_range[1])
    plt.figure()
    max = 0
    for col in data.columns:
        data[col].resample(resample_rate, how='sum').plot()
        if max < data[col].resample(resample_rate, how='sum').max():
            max = data[col].resample(resample_rate, how='sum').max()
    plt.axvspan(fit_trange[0], fit_trange[1], facecolor='gray', alpha=0.2, label='fit')
    plt.axvspan(bkg_trange[0], bkg_trange[1], facecolor='g', alpha=0.5, label='bkg')

    #plt.axvspan(time_range[1], 0, max*1.1, linestyle = 'dashed', label='end')
    #plt.axvspan(fit_trange[0], 0, max*1.1, linestyle = 'dashed', label='start')
    #plt.axvspan(fit_trange[1], 0, max*1.1, linestyle = 'dashed', label='end')
    #plt.axvspan(bkg_trange[0], 0, max*1.1, linestyle = 'dashed', label='start')
    #plt.axvspan(bkg_trange[1], 0, max*1.1, linestyle = 'dashed', label='end')
    plt.title('RHESSI')
    plt.ylim((-100,max*1.1))
    plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
    plt.show()


GOES Lightcurve


In [19]:
from sunpy.lightcurve import GOESLightCurve
from sunpy.time import TimeRange

In [20]:
from heroespy.util import times

In [21]:
times.solarobs_target2
TimeRange(times.solarobs_target2)


Out[21]:
    Start: 2013-09-21 15:35:00
    End:   2013-09-21 22:33:00
    Center:2013-09-21 19:04:00
    Duration:0 days or
           418.0 minutes or
           25080.0 seconds

In [22]:
goes = GOESLightCurve.create(TimeRange(times.solarobs_target2))

In [23]:
plt.figure(1)
plt.subplot(211)
ax = goes.data['xrsb'].plot(color='r')
plt.ylabel(r'1 - 8 $\AA$')
plt.title(goes.meta.get('TELESCOP'))
for time_range in time_ranges:
    plt.axvspan(time_range[0], time_range[1], facecolor='gray', alpha=0.5, label='fit')
ax.set_xticklabels([])
plt.subplot(212)
goes.data['xrsa'].plot()
plt.ylabel(r'0.5 - 4 $\AA$')
plt.xlabel(goes.data.index[0].to_datetime().strftime('%Y-%m-%d %H:%m') + ' [UT]')
plt.show()


Searching for XRT Data


In [24]:
from sunpy.net import vso
client = vso.VSOClient()
from datetime import timedelta

In [25]:
from heroespy.util import times

In [26]:
condition = vso.attrs.Detector('xrt')
qr = client.query(vso.attrs.Time(times.solarobs_target2[0], times.solarobs_target2[0] + timedelta(0,500)), condition)

In [5]:
len(qr)


Out[5]:
16

In [6]:
qr[0]


Out[6]:
(QueryResponseBlock){
   info = None
   source = "Hinode"
   provider = "SAO"
   physobs = "intensity"
   fileid = "http://kurasuta-dev-dmz.cfa.harvard.edu/VSO/DataProvider/SAO/hinode/xrt/level0/2013/09/21/H1500/XRT20130921_154000.7.fits"
   time = 
      (Time){
         end = "20130921154000"
         start = "20130921154000"
      }
   instrument = "XRT"
   size = 146880.0
   extra = 
      (Extra){
         thumbnail = 
            (Thumbnail){
               lowres = "http://kurasuta-dev-dmz.cfa.harvard.edu/VSO/DataProvider/SAO/hinode/xrt/thumbs/2013/09/21/H1500/XRT20130921_154000.7.jpeg"
            }
      }
   wave = 
      (Wave){
         waveunit = "Angstrom"
         wavemin = "8.8"
         wavetype = "Broad"
         wavemax = "335"
      }
   extent = 
      (Extent){
         type = "PARTIAL_SUN"
      }
 }

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

Searching for HEK Events


In [ ]: