-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetData.py
85 lines (64 loc) · 2.23 KB
/
GetData.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
This is a simple script to explore the contents of a file, including metadata and the header format
"""
import numpy as np
from sunpy.net import attrs as a
from sunpy.net import Fido
import sunpy.io
import sunpy.map
#------------------------------------------------------------------------------
# define instrument and time range
dcase = 2
if dcase == 1:
# usually it's not necessary to specify the source.
# An exception is STEREO, where you have to specify the A or B spacecreaft
source = None
instrument = a.Instrument.lasco
detector = a.Detector.c2
timerange = a.Time('2013/05/17 9:00:00', '2013/05/17 11:00:00')
elif dcase == 2:
source = None
instrument = a.Instrument.lasco
detector = a.Detector.c3
timerange = a.Time('2016/07/30 9:30:00', '2016/07/30 11:00:00')
elif dcase == 3:
source = "STEREO_A"
instrument = a.Instrument.secchi
detector = a.Detector.cor1
timerange = a.Time('2013/05/17 9:00:00', '2013/05/17 13:30:00')
elif dcase == 4:
source = "STEREO_B"
instrument = a.Instrument.secchi
detector = a.Detector.cor1
timerange = a.Time('2013/05/17 9:00:00', '2013/05/17 13:30:00')
elif dcase == 5:
source = "STEREO_A"
instrument = a.Instrument.secchi
detector = a.Detector.cor2
timerange = a.Time('2013/05/17 9:00:00', '2013/05/17 13:30:00')
elif dcase == 6:
source = "STEREO_B"
instrument = a.Instrument.secchi
detector = a.Detector.cor2
timerange = a.Time('2013/05/17 9:00:00', '2013/05/17 13:30:00')
else:
print("specify a valid dcase")
exit(1)
#------------------------------------------------------------------------------
basedir = '/home/mark.miesch/sunpy/data/'
dbpath = basedir + instrument.value.lower() + '_' + detector.value.lower() + '/'
if source is None:
qr = Fido.search(timerange, instrument, detector)
else:
qr = Fido.search(timerange, a.Source(source), instrument, detector)
files = Fido.fetch(qr, path = dbpath)
files.sort()
for file in files:
print(file)
file = files[0]
data, header = sunpy.io.fits.read(file)[0]
dmap = sunpy.map.Map(data, header)
if source is None:
print(f"{instrument.value} / {detector.value} : {dmap.date.value}")
else:
print(f"{source} / {instrument.value} / {detector.value} : {dmap.date.value}")