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]:
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()
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()
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]:
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()
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]:
In [6]:
qr[0]
Out[6]:
In [7]:
res=client.get(qr)
In [ ]: