Skip to content

Commit 5fc0d9d

Browse files
committed
Update docs.
1 parent 19b8721 commit 5fc0d9d

File tree

7 files changed

+175
-106
lines changed

7 files changed

+175
-106
lines changed

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ viresclient
99
:target: http://viresclient.readthedocs.io/
1010
:alt: Documentation Status
1111

12+
.. image:: https://requires.io/github/ESA-VirES/VirES-Python-Client/requirements.svg?branch=master
13+
:target: https://requires.io/github/ESA-VirES/VirES-Python-Client/requirements/?branch=master
14+
:alt: Requirements Status
15+
1216
.. image:: https://travis-ci.org/ESA-VirES/VirES-Python-Client.svg?branch=master
1317
:target: https://travis-ci.org/ESA-VirES/VirES-Python-Client
1418

docs/api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ ClientConfig
3232
:show-inheritance:
3333
:inherited-members:
3434

35+
set_token
36+
=========
37+
38+
.. autofunction:: viresclient.set_token
3539

3640
DataUpload
3741
==========

docs/available_parameters.rst

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ You can check which parameters are available with:
1212
req.available_models()
1313
req.available_auxiliaries()
1414
15+
The available measurements are segregated according to the "collection" (essentially Swarm products): each ``collection`` has a number of ``measurements`` associated with it, and the appropriate collection must be set in order to access the measurements. ``auxiliaries`` are available together with any set ``collection``. ``models`` provide magnetic model evaluation on demand, at the locations of the time series which is being accessed.
16+
17+
See the `Swarm Data Handbook`_ for details about the products.
18+
19+
.. _`Swarm Data Handbook`: https://earth.esa.int/web/guest/missions/esa-eo-missions/swarm/data-handbook/
20+
1521
----
1622

1723
``collections``
@@ -71,22 +77,41 @@ For IPD::
7177
``models``
7278
----------
7379

74-
Models are evaluated along the satellite track at the positions of the measurements.
80+
Models are evaluated along the satellite track at the positions of the time series that has been requested. These must be used together with one of the MAG collections, and one or both of the "F" and "B_NEC" measurements. This can yield either the model values together with the measurements, or the data-model residuals.
7581

7682
::
7783

78-
IGRF12, SIFM, CHAOS-6-Combined, CHAOS-6-Core, CHAOS-6-Static,
79-
MCO_SHA_2C, MCO_SHA_2D, MCO_SHA_2F, MLI_SHA_2C, MLI_SHA_2D,
80-
MMA_SHA_2C-Primary, MMA_SHA_2C-Secondary,
81-
MMA_SHA_2F-Primary, MMA_SHA_2F-Secondary,
82-
MIO_SHA_2C-Primary, MIO_SHA_2C-Secondary,
84+
IGRF12,
85+
86+
# Comprehensive inversion (CI) models:
87+
MCO_SHA_2C, # Core
88+
MLI_SHA_2C, # Lithosphere
89+
MMA_SHA_2C-Primary, MMA_SHA_2C-Secondary, # Magnetosphere
90+
MIO_SHA_2C-Primary, MIO_SHA_2C-Secondary, # Ionosphere
91+
92+
# Dedicated inversion models:
93+
MCO_SHA_2D,
94+
MLI_SHA_2D,
8395
MIO_SHA_2D-Primary, MIO_SHA_2D-Secondary
8496

85-
(``residuals`` available when combined with MAG ``measurements`` ``F`` and/or ``B_NEC``)
97+
# Fast-track models:
98+
MMA_SHA_2F-Primary, MMA_SHA_2F-Secondary,
99+
100+
# CHAOS models:
101+
CHAOS-6-Core,
102+
CHAOS-6-Static,
103+
CHAOS-6-MMA-Primary, CHAOS-6-MMA-Secondary
104+
105+
# Other lithospheric models:
106+
MF7, LCS-1
86107

87-
Custom models can be provided as a .shc file and become accessible in the same way as pre-defined models, under the name ``"Custom_Model"``.
108+
Custom (user uploaded) models can be provided as a .shc file and become accessible in the same way as pre-defined models, under the name ``"Custom_Model"``.
109+
110+
Flexible evaluation of models and defining new derived models is possible with the "model expressions" functionality whereby models can be defined like:
111+
112+
.. code-block:: python
88113
89-
Flexible evaluation of models and defining new derived models is possible with the "model expressions" functionality whereby models can be defined like ``"Combined_model = 'MMA_SHA_2F-Primary'(min_degree=1,max_degree=1) + 'MMA_SHA_2F-Secondary'(min_degree=1,max_degree=1)"``
114+
"Combined_model = 'MMA_SHA_2F-Primary'(min_degree=1,max_degree=1) + 'MMA_SHA_2F-Secondary'(min_degree=1,max_degree=1)"
90115
91116
----
92117

docs/config_details.rst

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
Configuration Details
2+
=====================
3+
4+
While it is possible to enter the server URL and access credentials each time a new request object is created,
5+
6+
.. code-block:: python
7+
8+
from viresclient import SwarmRequest
9+
10+
# both URL and access token passed as request object's parameters
11+
request = SwarmRequest(
12+
url="https://vires.services/ows",
13+
token="r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-"
14+
)
15+
16+
it is more convenient to omit them from the code and store them in a private configuration file. This configuration can be done using the :meth:`viresclient.set_token` convenience function, the underlying :meth:`viresclient.ClientConfig` module, or the command line interface (CLI) - see below. These will all set the configuration options in a file which is by default located at ``~/.viresclient.ini`` which can be edited directly, containing for example::
17+
18+
[https://vires.services/ows]
19+
token = r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-
20+
21+
[default]
22+
url = https://vires.services/ows
23+
24+
When creating the configuration file manually make sure the file is readable by its owner only::
25+
26+
$ chmod 0600 ~/.viresclient.ini
27+
$ ls -l ~/.viresclient.ini
28+
-rw------- 1 owner owner 361 May 12 09:12 /home/owner/.viresclient.ini
29+
30+
When the configuration file is present, then the url and token options can be omitted from requests:
31+
32+
.. code-block:: python
33+
34+
# access token read from configuration
35+
request = SwarmRequest(url="https://vires.services/ows")
36+
37+
# both default URL and access token read from configuration
38+
request = SwarmRequest()
39+
40+
The following sections describe how to set the configuration.
41+
42+
43+
Configuration via CLI
44+
^^^^^^^^^^^^^^^^^^^^^
45+
46+
The ``viresclient`` shell command can be used to set the server access configuration::
47+
48+
$ viresclient set_token https://vires.services/ows
49+
Enter access token: r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-
50+
51+
$ viresclient set_default_server https://vires.services/ows
52+
53+
See also: :doc:`cli`
54+
55+
Configuration via Python
56+
^^^^^^^^^^^^^^^^^^^^^^^^
57+
58+
Use the following code to store the token in the ``viresclient`` configuration:
59+
60+
.. code-block:: python
61+
62+
from viresclient import ClientConfig
63+
64+
cc = ClientConfig()
65+
cc.set_site_config("https://vires.services/ows", token="r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-")
66+
cc.default_url = "https://vires.services/ows"
67+
cc.save()
68+
69+
Alternatively, use the convenience function:
70+
71+
.. code-block:: python
72+
73+
from viresclient import set_token
74+
set_token("https://vires.services/ows")
75+
# (you will now be prompted to enter the token)
76+
77+
which calls the same code as above, but makes sure the token remains hidden so that it can't accidentally be shared.
78+
79+
80+
For developers & DISC users
81+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
82+
83+
The accounts for the staging server (``staging.vires.services``), and DISC server (``staging.viresdisc.vires.services``) are separate. Tokens can be similarly generated on these and stored in the same configuration file alongside the others::
84+
85+
$ viresclient set_token https://vires.services/ows
86+
Enter access token: r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-
87+
88+
$ viresclient set_token https://staging.viresdisc.vires.services/ows
89+
Enter access token: VymMHhWjZ-9nSVs-FuPC27ca8C6cOyij
90+
91+
$ viresclient set_default_server https://vires.services/ows
92+
93+
Using ``SwarmRequest()`` without the ``url`` parameter will use the default URL set above. To access a non-default server the URL parameter must be used:
94+
95+
.. code-block:: python
96+
97+
from viresclient import SwarmRequest
98+
99+
# request using the default server (https://vires.services/ows)
100+
request = SwarmRequest()
101+
102+
# request to an alternative, non-default server
103+
request = SwarmRequest(url="https://staging.viresdisc.vires.services/ows")
104+
105+
The older HTTP basic access authentication (i.e. username + password) is still available on the staging servers and these credentials can also be configured using :meth:ClientConfig. However, this is not available on the production server and may be removed in the future, so should not be used.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Welcome to VirES-Python-Client's documentation!
77

88
readme
99
installation
10+
config_details
1011
available_parameters
1112
release_notes
1213

docs/installation.rst

Lines changed: 17 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ It can currently be installed with::
1818

1919
Dependencies::
2020

21-
Jinja2 ≥ 2.10.0
22-
tables ≥ 3.4.4
23-
tqdm ≥ 4.23.0
24-
cdflib ≥ 0.3.9
25-
pandas ≥ 0.18.0
26-
xarray ≥ 0.11.0
21+
requests ≥ 2.0.0
22+
Jinja2 ≥ 2.10.0
23+
tables ≥ 3.4.4
24+
tqdm ≥ 4.23.0
25+
cdflib ≥ 0.3.9
26+
pandas ≥ 0.18.0
27+
xarray ≥ 0.11.0
2728

28-
(pip will fetch these automatically - if you are using conda, it may be better to install these first using conda instead::
29+
pip will fetch these automatically - if you are using conda, it may be better to install these first using conda instead::
2930

30-
conda install jinja2 pytables tqdm pandas xarray
31+
conda install requests jinja2 pytables tqdm pandas xarray
3132
pip install viresclient
3233

3334
Recommended setup if starting without Python already
@@ -53,7 +54,7 @@ Recommended setup if starting without Python already
5354

5455
.. note:: For Jupyter notebook users:
5556

56-
The instructions for first time usage are also provided as a Jupyter notebook which you might find easier to use. Download the notebook to your environment and follow the instructions.
57+
The guide for first time usage are also provided as a Jupyter notebook. Download the notebook to your environment and follow the instructions.
5758

5859
https://github.com/smithara/viresclient_examples/blob/master/0_first_usage.ipynb
5960

@@ -63,99 +64,24 @@ Recommended setup if starting without Python already
6364

6465
then launch the notebook, ``viresclient_examples/0_first_usage.ipynb``
6566

66-
Access to the service is through the same user account as on the web interface (https://vires.services/) and is enabled through a token. To get a token, log in to the website and click on your name on the top right to access the settings. From here, click on "Manage access tokens" and follow the instructions to create a new token.
67+
Access to the service is through the same user account as on the web interface (https://vires.services/) and is enabled through an access token (essentially a password). To get a token, log in to the website and click on your name on the top right to access the settings. From here, click on "Manage access tokens" and follow the instructions to create a new token.
6768

68-
While it is possible to enter the server URL and access credentials each time a new request object is created
69+
To set your token in the client, use either the Python interface:
6970

7071
.. code-block:: python
7172
72-
from viresclient import SwarmRequest
73-
74-
# both URL and access token passed as request object's parameters
75-
request = SwarmRequest(
76-
url="https://vires.services/ows",
77-
token="r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-"
78-
)
79-
80-
it is more convenient to omit them from the code and store them in a private configuration file
81-
82-
.. code-block:: python
83-
84-
# access token read from configuration
85-
request = SwarmRequest(url="https://vires.services/ows")
86-
87-
# both default URL and access token read from configuration
88-
request = SwarmRequest()
89-
90-
The server access configuration can be set either by command line interface (CLI), Python code, or editing of the configuration file, as described in the following sections.
73+
from viresclient import set_token
74+
set_token("https://vires.services/ows")
75+
# (you will now be prompted to enter the token)
9176
92-
Configuration via CLI
93-
^^^^^^^^^^^^^^^^^^^^^
94-
95-
The ``viresclient`` shell command can be used to set the server access configuration::
77+
or the command line tool::
9678

9779
$ viresclient set_token https://vires.services/ows
9880
Enter access token: r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-
9981

10082
$ viresclient set_default_server https://vires.services/ows
10183

102-
Configuration via Python
103-
^^^^^^^^^^^^^^^^^^^^^^^^
104-
105-
Use the following code to store the token in the ``viresclient`` configuration
106-
107-
.. code-block:: python
108-
109-
from viresclient import ClientConfig
110-
111-
cc = ClientConfig()
112-
cc.set_site_config("https://vires.services/ows", token="r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-")
113-
cc.default_url = "https://vires.services/ows"
114-
cc.save()
115-
116-
117-
Configuration File
118-
^^^^^^^^^^^^^^^^^^
119-
120-
The client configuration is saved as a text file at ``~/.viresclient.ini``. This configuration file can edited in a text editor::
121-
122-
[https://vires.services/ows]
123-
token = r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-
124-
125-
[default]
126-
url = https://vires.services/ows
127-
128-
When creating the configuration file manually make sure the file is readable by its owner only::
129-
130-
$ chmod 0600 ~/.viresclient.ini
131-
$ ls -l ~/.viresclient.ini
132-
-rw------- 1 owner owner 361 May 12 09:12 /home/owner/.viresclient.ini
133-
134-
135-
.. note:: For DISC users / developers:
136-
137-
The user account for the DISC server is separate. A token can be generated in the same way and stored in the configuration alongside the token for other site::
138-
139-
$ viresclient set_token https://vires.services/ows
140-
Enter access token: r-8-mlkP_RBx4mDv0di5Bzt3UZ52NGg-
141-
142-
$ viresclient set_token https://staging.viresdisc.vires.services/ows
143-
Enter access token: VymMHhWjZ-9nSVs-FuPC27ca8C6cOyij
144-
145-
$ viresclient set_default_server https://vires.services/ows
146-
147-
Using ``SwarmRequest()`` without the URL parameter will use the default URL set above. To access a non-default server the URL parameter must be used:
148-
149-
.. code-block:: python
150-
151-
from viresclient import SwarmRequest
152-
153-
# request using the default server (https://vires.services/ows)
154-
request = SwarmRequest()
155-
156-
# request to an alternative, non-default server
157-
request = SwarmRequest(url="https://staging.viresdisc.vires.services/ows")
158-
84+
See also: see :doc:`config_details`
15985

16086
3. Example use
16187
--------------

docs/release_notes.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
Release notes
22
=============
33

4+
Changes from 0.4.0 to 0.4.1
5+
---------------------------
6+
7+
- Added low level data upload API and CLI
8+
- Added set_token convenience function for quick configuration
9+
- Changed list of accessible models:
10+
11+
- Removed ``MCO_SHA_2F``, ``SIFM``
12+
- Added ``MF7``, ``LCS-1``
13+
414
Changes from 0.3.0 to 0.4.0
515
---------------------------
616

717
- Fixed issues with running on Windows
8-
918
- Enforcing Python v3.5+ for installation
10-
1119
- Allowing higher versions of cdflib, pandas, and xarray
12-
1320
- Added CLI configuration for setting server address and token
14-
1521
- Metadata for source lineage is now easier to access (names of original ESA data files, details of models used, and filters applied). These are set as properties of :meth:`viresclient.ReturnedData` (i.e. ``data``) and as metadata (``.attrs``) in the ``Dataset`` returned from ``.as_xarray()``::
1622

1723
data.sources
@@ -24,9 +30,7 @@ Changes from 0.3.0 to 0.4.0
2430
ds.RangeFilters
2531

2632
- Added access to collections ``SW_OPER_IPDxIRR_2F``
27-
2833
- Added auxiliary data ``F107`` which is the hourly F10.7 value. This is in addition to ``F10_INDEX`` which was already present, which is a daily average.
29-
3034
- Added possibility of accessing multiple collections simultaneously, e.g.::
3135

3236
request.set_collection("SW_OPER_MAGA_LR_1B", "SW_OPER_MAGC_LR_1B")

0 commit comments

Comments
 (0)