示例#1
0
# Let's first grab GOES XRS data for a particular time of interest

tr = TimeRange(['2011-06-07 04:00', '2011-06-07 12:00'])
results = Fido.search(a.Time(tr), a.Instrument('XRS'))
results

###############################################################################
# Then download the data and load it into a TimeSeries

files = Fido.fetch(results)
goes = TimeSeries(files)

###############################################################################
# Next lets grab the HEK data for this time from the NOAA Space Weather
# Prediction Center (SWPC)

client = hek.HEKClient()
flares_hek = client.search(hek.attrs.Time(tr.start, tr.end),
                           hek.attrs.FL, hek.attrs.FRM.Name == 'SWPC')

###############################################################################
# Finally lets plot everything together

goes.peek()
plt.axvline(parse_time(flares_hek[0].get('event_peaktime')))
plt.axvspan(parse_time(flares_hek[0].get('event_starttime')),
            parse_time(flares_hek[0].get('event_endtime')),
            alpha=0.2, label=flares_hek[0].get('fl_goescls'))
plt.legend(loc=2)
plt.show()
示例#2
0
import matplotlib as mpl
import datetime as datetime
from datetime import datetime, timedelta, date
import time
import matplotlib.pyplot as plt
import matplotlib.dates as dates

mpl.rc('font', size=12)
begin_time = datetime(2017, 9, 2, 15, 00, 14)
fin_time = datetime(2017, 9, 2, 17, 30, 14)
firsts = []
for i in range(begin_time.minute, fin_time.minute):
    firsts.append(datetime(2017, 9, 2, 15, i, 14))
    i + 10

plt.figure(figsize=(12, 9))
tr = TimeRange(['2017-09-02 10:25:00', '2017-09-02 19:05:00'])
results = Fido.search(a.Time(tr), a.Instrument('XRS'))
files = Fido.fetch(results)
goes = TimeSeries(files)
client = hek.HEKClient()
flares_hek = client.search(hek.attrs.Time(tr.start, tr.end), hek.attrs.FL,
                           hek.attrs.FRM.Name == 'SWPC')

goes.peek()
#plt.xticks(firsts)
#plt.gca().xaxis.set_major_locator(dates.HourLocator())
plt.gca().xaxis.set_major_formatter(dates.DateFormatter('%H:%M'))
plt.xlim(begin_time, fin_time)
plt.savefig("goes_02092017.png")
示例#3
0
from sunpy.net import Fido
from sunpy.net import attrs as a
from sunpy.timeseries import TimeSeries

###############################################################################
# `sunpy.net.Fido` is the primary interface to search for and download data and
# will automatically search CDAWeb when the ``cdaweb.Dataset`` attribute is provided to
# the search. To lookup the different dataset IDs available, you can use the
# form at https://cdaweb.gsfc.nasa.gov/index.html/
trange = a.Time('2021/07/01', '2021/07/08')
dataset = a.cdaweb.Dataset('SOLO_L2_MAG-RTN-NORMAL-1-MINUTE')
result = Fido.search(trange, dataset)

###############################################################################
# Let's inspect the results. We can see that there's seven files, one for each
# day within the query.
print(result)

###############################################################################
# Let's download the first two files
downloaded_files = Fido.fetch(result[0, 0:2])
print(downloaded_files)

###############################################################################
# Finally we can load and take a look at the data using
# `~sunpy.timeseries.TimeSeries` This requires an installation of the cdflib
# Python library to read the CDF file.
solo_mag = TimeSeries(downloaded_files, concatenate=True)
print(solo_mag.columns)
solo_mag.peek(['B_RTN_0', 'B_RTN_1', 'B_RTN_2'])