forked from hapi-server/client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhapi_demo.py
More file actions
107 lines (84 loc) · 3.22 KB
/
hapi_demo.py
File metadata and controls
107 lines (84 loc) · 3.22 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Basic demo of hapiclient. Install package using
# pip install hapiclient --upgrade
# from command line.
# Note:
# In IPython, enter %matplotlib qt on command line to open plots in
# new window. Enter %matplotlib inline to revert.
# For a more extensive demo, see
# https://github.com/hapi-server/client-python-notebooks/blob/master/hapi_demo.ipynb
def main():
omniweb()
sscweb()
cdaweb()
cassini()
def omniweb():
from hapiclient import hapi
from hapiclient import hapiplot
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
dataset = 'OMNI2_H0_MRG1HR'
start = '2003-09-01T00:00:00'
stop = '2003-12-01T00:00:00'
parameters = 'DST1800'
opts = {'logging': True, 'usecache': False}
# Get data
data, meta = hapi(server, dataset, parameters, start, stop, **opts)
# Plot all parameters
hapiplot(data, meta)
def sscweb():
from hapiclient.hapi import hapi
from hapiclient.hapiplot import hapiplot
# SSCWeb data
server = 'http://hapi-server.org/servers/SSCWeb/hapi'
dataset = 'ace'
start = '2001-01-01T05:00:00'
stop = '2001-01-01T10:00:00'
parameters = 'X_GSE,Y_GSE,Z_GSE'
opts = {'logging': True, 'usecache': True}
data, meta = hapi(server, dataset, parameters, start, stop, **opts)
hapiplot(data, meta, **opts)
def cdaweb():
from hapiclient.hapi import hapi
from hapiclient.hapiplot import hapiplot
# CDAWeb data - Magnitude and BGSEc from dataset AC_H0_MFI
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
dataset = 'AC_H0_MFI'
start = '2001-01-01T05:00:00'
stop = '2001-01-01T10:00:00'
parameters = 'Magnitude,BGSEc'
opts = {'logging': True, 'usecache': True}
data, meta = hapi(server, dataset, parameters, start, stop, **opts)
hapiplot(data, meta, **opts)
# CDAWeb metadata for AC_H0_MFI
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
dataset = 'AC_H0_MFI'
meta = hapi(server, dataset, **opts)
print('Parameters in %s' % dataset)
for i in range(0, len(meta['parameters'])):
print(' %s' % meta['parameters'][i]['name'])
print('')
# CDAWeb metadata for all datasets
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
meta = hapi(server, **opts)
print('%d CDAWeb datasets' % len(meta['catalog']))
for i in range(0, 3):
print(' %d. %s' % (i, meta['catalog'][i]['id']))
print(' ...')
print(' %d. %s' % (len(meta['catalog']), meta['catalog'][-1]['id']))
print('')
# List all servers
servers = hapi(logging=True) # servers is an array of URLs
print('')
def cassini():
from hapiclient import hapi
from hapiclient import hapiplot
server = 'http://datashop.elasticbeanstalk.com/hapi';
dataset = 'CHEMS_PHA_BOX_FLUXES_FULL_TIME_RES';
parameters = 'HPlus_BEST_T1';
start = '2004-07-01T04:00:00Z';
stop = '2004-07-01T06:00:00Z';
opts = {'usecache': True}
data, meta = hapi(server, dataset, parameters, start, stop, **opts)
popts = {'logging': False, 'logy': True, 'logz': True}
hapiplot(data, meta, **popts)
if __name__ == '__main__':
main()