Skip to content

Commit adb955d

Browse files
committed
hapiplot() doc references
1 parent 0562e27 commit adb955d

File tree

4 files changed

+58
-36
lines changed

4 files changed

+58
-36
lines changed

README.rst

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ Installation
1313
# or
1414
pip install 'git+https://github.com/hapi-server/client-python' --upgrade
1515
16+
pip install hapiplot --upgrade
17+
# or
18+
pip install 'git+https://github.com/hapi-server/plot-python' --upgrade
19+
1620
See the `Appendix <#Appendix>`__ for a fail-safe installation method.
1721

1822
Basic Example
1923
-------------
2024

2125
.. code:: python
2226
23-
# Get and plot Dst index from CDAWeb HAPI server
27+
# Get Dst index from CDAWeb HAPI server
2428
from hapiclient import hapi
25-
from hapiclient import hapiplot
2629
30+
# See http://hapi-server.org/servers/ for a list of
31+
# other HAPI servers and datasets.
2732
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
2833
dataset = 'OMNI2_H0_MRG1HR'
2934
start = '2003-09-01T00:00:00'
@@ -33,21 +38,43 @@ Basic Example
3338
3439
# Get data
3540
data, meta = hapi(server, dataset, parameters, start, stop, **opts)
36-
# Show documentation
37-
#help(hapi)
41+
print(meta)
42+
print(data)
3843
3944
# Plot all parameters
45+
from hapiplot import hapi
4046
hapiplot(data, meta)
41-
# Show documentation
42-
#help(hapiplot)
47+
4348
4449
Documentation
4550
-------------
4651

4752
Basic usage examples for various HAPI servers are given in `hapi_demo.py <https://github.com/hapi-server/client-python/blob/master/hapi_demo.py>`__
4853

54+
See http://hapi-server.org/servers/ for a list of HAPI servers and datasets.
55+
4956
All of the features are extensively demonstrated in the `hapi_demo.ipynb <https://github.com/hapi-server/client-python-notebooks/blob/master/hapi_demo.ipynb>`__ Jupyter Notebook.
5057

58+
59+
Data Model and Time Format
60+
--------------------------
61+
62+
A request for data of the form
63+
```
64+
data, meta = hapi(server, dataset, parameters, start, stop)
65+
```
66+
67+
returns the [Numpy N-D array](https://docs.scipy.org/doc/numpy-1.15.1/user/quickstart.html) `data` and a Python dictionary `meta` from a HAPI-compliant data server `server`. The structure of `data` and `meta` mirrors the structure of a response from a HAPI server.
68+
69+
The HAPI client data model is intentionally basic. There is an ongoing discussion of a data model for Heliophysics data among the `PyHC community <https://heliopython.org/>`_. When this data model is complete, a function that converts `data` and `meta` to that data model will be included in the `hapiclient` package.
70+
71+
Examples of transforming and manipulating `data` is given in a `Jupyter Notebook <https://colab.research.google.com/drive/11Zy99koiE90JKJ4u_KPTaEBMQFzbfU3P#scrollTo=aI_7DxnZtQZ3>`_. The examples include
72+
73+
# Fast and well-tested conversion from ISO 8601 timestamp strings to Python `datetime` objects
74+
# Putting the content of `data` in a Pandas `DataFrame` object
75+
# Creating an Astropy NDArray
76+
77+
5178
Development
5279
-----------
5380

TODO.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

hapi_demo.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# %matplotlib inline
1010
# to revert.
1111

12-
# For a more extensive demo, see
13-
# https://github.com/hapi-server/client-python-notebooks/blob/master/hapi_demo.ipynb
12+
# For more extensive demos and examples, see
13+
# https://colab.research.google.com/drive/11Zy99koiE90JKJ4u_KPTaEBMQFzbfU3P?usp=sharing
1414

1515
def main():
1616

@@ -23,9 +23,9 @@ def main():
2323
print("\033[0;31mError:\033[0m " + str(e))
2424

2525
def omniweb():
26-
26+
2727
from hapiclient import hapi
28-
from hapiclient import hapiplot
28+
from hapiplot import hapiplot
2929

3030
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
3131
dataset = 'OMNI2_H0_MRG1HR'
@@ -36,14 +36,14 @@ def omniweb():
3636

3737
# Get data
3838
data, meta = hapi(server, dataset, parameters, start, stop, **opts)
39-
39+
4040
# Plot all parameters
4141
hapiplot(data, meta)
4242

4343
def sscweb():
4444

4545
from hapiclient import hapi
46-
from hapiclient import hapiplot
46+
from hapiplot import hapiplot
4747

4848
# SSCWeb data
4949
server = 'http://hapi-server.org/servers/SSCWeb/hapi'
@@ -58,7 +58,7 @@ def sscweb():
5858
def cdaweb():
5959

6060
from hapiclient import hapi
61-
from hapiclient import hapiplot
61+
from hapiplot import hapiplot
6262

6363
# CDAWeb data - Magnitude and BGSEc from dataset AC_H0_MFI
6464
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
@@ -69,7 +69,7 @@ def cdaweb():
6969
opts = {'logging': True, 'usecache': True}
7070
data, meta = hapi(server, dataset, parameters, start, stop, **opts)
7171
hapiplot(data, meta, **opts)
72-
72+
7373
# CDAWeb metadata for AC_H0_MFI
7474
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
7575
dataset = 'AC_H0_MFI'
@@ -78,7 +78,7 @@ def cdaweb():
7878
for i in range(0, len(meta['parameters'])):
7979
print(' %s' % meta['parameters'][i]['name'])
8080
print('')
81-
81+
8282
# CDAWeb metadata for all datasets
8383
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
8484
meta = hapi(server, **opts)
@@ -88,31 +88,32 @@ def cdaweb():
8888
print(' ...')
8989
print(' %d. %s' % (len(meta['catalog']), meta['catalog'][-1]['id']))
9090
print('')
91-
91+
9292
# List all servers
9393
servers = hapi(logging=True) # servers is an array of URLs
9494
print('')
95-
95+
9696
def cassini():
9797

9898
from hapiclient import hapi
99-
from hapiclient import hapiplot
100-
99+
from hapiplot import hapiplot
100+
101101
server = 'http://datashop.elasticbeanstalk.com/hapi';
102102
dataset = 'CHEMS_PHA_BOX_FLUXES_FULL_TIME_RES';
103103
parameters = 'HPlus_BEST_T1';
104104
start = '2004-07-01T04:00:00Z';
105105
stop = '2004-07-01T06:00:00Z';
106106
opts = {'usecache': True, 'logging': True}
107-
107+
108108
data, meta = hapi(server, dataset, parameters, start, stop, **opts)
109109

110110
popts = {'logging': False, 'logy': True, 'logz': True}
111111
hapiplot(data, meta, **popts)
112112

113113
def lisird():
114114

115-
from hapiclient import hapi, hapiplot
115+
from hapiclient import hapi
116+
from hapiplot import hapiplot
116117

117118
server = 'http://lasp.colorado.edu/lisird/hapi';
118119
dataset = 'sme_ssi';
@@ -125,4 +126,8 @@ def lisird():
125126
hapiplot(data, meta)
126127

127128
if __name__ == '__main__':
129+
try:
130+
from hapiplot import hapiplot
131+
except:
132+
print('Package hapiplot is not installed. Will not plot results.')
128133
main()

hapiclient/hapi.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def request2path(*args):
110110

111111

112112
def hapiopts():
113-
"""Return allowed options for hapi().
113+
"""Return dict of default options for hapi()
114114
115115
Used by hapiplot() and hapi().
116116
@@ -144,11 +144,12 @@ def hapiopts():
144144
def hapi(*args, **kwargs):
145145
"""Request data from a HAPI server.
146146
147-
For additional documentation and demonstration, see
148-
https://github.com/hapi-server/client-python-notebooks/blob/master/hapi_demo.ipynb
147+
Version: 0.1.9
149148
150-
Version: 0.1.9b0
151149
150+
Examples
151+
----------
152+
`Jupyter Notebook <https://colab.research.google.com/drive/11Zy99koiE90JKJ4u_KPTaEBMQFzbfU3P?usp=sharing>_`
152153
153154
Parameters
154155
----------
@@ -272,9 +273,6 @@ def hapi(*args, **kwargs):
272273
----------
273274
* `HAPI Server Definition <https://github.com/hapi-server/data-specification>`_
274275
275-
Examples
276-
----------
277-
See https://github.com/hapi-server/client-python-notebooks
278276
"""
279277

280278
nin = len(args)

0 commit comments

Comments
 (0)