Skip to content

Commit 3053d7a

Browse files
committed
Adding content to the documentation.
1 parent 079da01 commit 3053d7a

7 files changed

+305
-82
lines changed

README.md

+62-39
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,56 @@
1+
## VirES for Swarm - Magnetic Models, Coordinates and Other Utilities
12

2-
3-
## Magnetic Model
4-
5-
This repository contains various utilities related to Earth magnetic field
6-
modelling and spherical harmonics.
3+
This repository contains various utilities for calculation of Earth magnetic
4+
field models, magnetic coordinates and other auxiliary variables.
75

86
The repository contains following directories:
97

10-
- `eoxmagmod` - Collection models of the Earth magnetic field - python module
8+
- `eoxmagmod` - Python package for calculation of the Earth magnetic field,
9+
magnetic coordinates, time conversions and other auxiliary variables.
1110
- `qdipole` - Quasi-Dipole apex coordinates evaluation - Fortran code compiled
1211
as a shared library (dependency of the `eoxmagmod` package)
1312
- `libcdf` - [CDF library](https://cdf.gsfc.nasa.gov/) source installation
1413
(dependency of the `eoxmagmod` package)
1514

16-
### Installation from Sources
15+
For more details read the [on-line documentation](https://esa-vires.github.io/MagneticModel/)
16+
17+
### Installation
18+
19+
#### Conda Installation
20+
21+
Step in the MagneticModel directory and follow these steps:
22+
23+
1) Build the binary dependencies:
24+
```
25+
conda install conda-build
26+
conda build ./qdipole
27+
conda build ./libcdf
28+
conda build purge
29+
```
30+
Tested on GNU/Linux. Possibly works on other POSIX systems.
31+
32+
2) Create an new Conda environment and install `eoxmagmod` dependencies
33+
34+
```
35+
conda env create -n <environment-name> -f conda_env.yaml
36+
```
37+
38+
3) Install `eoxmagmod` in your new Conda environment:
39+
```
40+
conda activate <environment-name>
41+
pip install ./eoxmagmod
42+
```
43+
44+
#### Installation from Sources
45+
46+
The installation requires:
47+
- GCC C compiler
48+
- GFortran Fortran compiler
49+
- `make`
1750

18-
#### CDF
51+
1) Build and install `cdf` library
52+
53+
The CDF build script download sources and builds the [NASA CDF library](https://cdf.gsfc.nasa.gov/)
1954

2055
```
2156
$ cd libcdf/
@@ -30,7 +65,7 @@ variable:
3065
$ make install INSTALLDIR=<install directory>
3166
```
3267

33-
#### QDIPOLE
68+
2) Build and install `qdipole` library
3469

3570
```
3671
$ cd qdipole/
@@ -39,44 +74,32 @@ $ make build
3974
$ sudo make install
4075
```
4176

42-
#### EOxMagMod
43-
Requires QDIPOLE, CDF libraries + NumPy and SpacePy Python packages
44-
to be installed.
45-
NumPy and SpacePy can be installed using `pip`.
77+
By default the ``qdipole`` library is installed in the ``/usr`` system directory.
78+
To install the library in a custom location use configuration with a custom prefix::
4679

4780
```
48-
$ cd eoxmagmod/
49-
$ python ./setup.py build
50-
$ sudo python ./setup.py install
81+
./configure --prefix=<install prefix>
5182
```
5283

53-
### Conda installation
54-
55-
The package contains the `conda-build` scripts allowing local conda build and
56-
installation following this procedure:
84+
3) Build and install `eoxmagmod` pip dependencies
5785

58-
1) build the binary dependencies:
5986
```
60-
conda install conda-build
61-
conda build ./qdipole
62-
conda build ./libcdf
63-
conda build purge
87+
pip3 install 'numpy<2'
88+
pip3 install scipy
89+
pip3 install 'SpacePy>0.5'
6490
```
65-
Tested on GNU/Linux. Possibly works on other POSIX systems. Does not work on MS
66-
Windows (primarily because of a missing Fortran compiler).
6791

68-
2) install the `eoxmagmod` in your conda environment:
92+
4) Finally, install `eoxmagmod` package
93+
6994
```
70-
conda activate <target-environment>
71-
conda install --use-local qdipole cdf
72-
conda install numpy scipy matplotlib h5py networkx
73-
conda install gcc_linux-64 # spacepy and eoxmagmod require C compiler
74-
conda install gfortran_linux-64 # spacepy requires Fortran compiler
75-
conda deactivate
76-
conda activate <target-environment> # re-activation is required to update the environment variables
77-
pip install spacepy
78-
pip install ./eoxmagmod
95+
pip3 install ./eoxmagmod
7996
```
8097

81-
The `gfortran_linux-64` and`gcc_linux-64` compilers work on a x86_64 GNU/Linux system.
82-
Other platforms might provide different compilers.
98+
### Testing
99+
100+
To test the fresh installation, leave the `MagneticModel` directory and run
101+
the following command:
102+
103+
```
104+
python3 -m unittest discover -p '[a-z]*.py' -v eoxmagmod
105+
```

conda_env.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
dependencies:
2+
- python >=3.11,<3.12
3+
- pip
4+
- numpy <2
5+
- scipy
6+
- matplotlib
7+
- h5py
8+
- conda-forge::c-compiler
9+
- conda-forge::fortran-compiler
10+
- local::qdipole
11+
- local::cdf
12+
- pip:
13+
- SpacePy >0.5

docs/conf.py

+18-26
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
# For the full list of built-in configuration values, see the documentation:
44
# https://www.sphinx-doc.org/en/master/usage/configuration.html
55

6-
# -- Project information -----------------------------------------------------
7-
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8-
96

107
import os
118
import inspect
129
import shutil
10+
#import sphinx
1311

1412
try: # for Sphinx >= 1.7
1513
from sphinx.ext import apidoc
@@ -20,8 +18,6 @@
2018
os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe()))
2119
)
2220

23-
print(__location__)
24-
2521
output_dir = os.path.join(__location__, "api")
2622
module_dir = os.path.join(__location__, "../eoxmagmod/eoxmagmod")
2723

@@ -31,32 +27,28 @@
3127
except FileNotFoundError:
3228
pass
3329

34-
try:
35-
import sphinx
36-
37-
cmd_line_template = (
38-
"sphinx-apidoc --implicit-namespaces -f -o {outputdir} {moduledir}"
39-
)
40-
cmd_line = cmd_line_template.format(outputdir=output_dir, moduledir=module_dir)
41-
42-
args = cmd_line.split(" ")
43-
if tuple(sphinx.__version__.split(".")) >= ("1", "7"):
44-
# This is a rudimentary parse_version to avoid external dependencies
45-
args = args[1:]
46-
47-
apidoc.main(args)
48-
except Exception as e:
49-
print("Running `sphinx-apidoc` failed!\n{}".format(e))
30+
#try:
31+
# args = (
32+
# f"sphinx-apidoc --implicit-namespaces -f -o {output_dir} {module_dir}"
33+
# ).split(" ")
34+
# if tuple(sphinx.__version__.split(".")) >= ("1", "7"):
35+
# # This is a rudimentary parse_version to avoid external dependencies
36+
# args = args[1:]
37+
# apidoc.main(args)
38+
#except Exception as e:
39+
# print("Running `sphinx-apidoc` failed!\n{}".format(e))
5040

5141

5242
def setup(app):
5343
app.add_css_file("css/custom.css")
5444

5545

56-
project = 'MagneticModel'
57-
copyright = '2022, dolezalovat'
58-
author = 'dolezalovat'
46+
# -- Project information -----------------------------------------------------
47+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
5948

49+
project = 'VirES for Swarm - Magnetic Models, Coordinates and Other Utilities'
50+
copyright = '2022-2024, EOX IT Services GmbH'
51+
author = 'Martin Pačes, Týna Doležalova'
6052

6153
# -- General configuration ---------------------------------------------------
6254
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -72,7 +64,7 @@ def setup(app):
7264
"sphinx.ext.ifconfig",
7365
"sphinx.ext.mathjax",
7466
"sphinx.ext.napoleon",
75-
"myst_parser",
67+
#"myst_parser",
7668
"sphinx_rtd_theme",
7769
"sphinx-jsonschema",
7870
"frigate.sphinx.ext",
@@ -85,7 +77,7 @@ def setup(app):
8577
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
8678

8779
html_theme = "sphinx_rtd_theme"
88-
html_static_path = ["static"]
80+
#html_static_path = ["static"]
8981

9082
source_suffix = {
9183
".rst": "restructuredtext",

docs/index.rst

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
.. MagneticModel documentation master file, created by
2-
sphinx-quickstart on Mon Oct 24 10:55:30 2022.
3-
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
51

6-
Welcome to eoxmagmod documentation!
7-
===================================
2+
.. include:: introduction.rst
83

9-
The ``eoxmagmod``_ library collects low-level subroutines employed
10-
by the `VirES for Swarm`_ service to calculate:
11-
12-
- geomagnetic models (Spherical Harmonic expansion)
13-
- magnetic coordinates (quasi-dipole and dipole latitude and longitude, magnetic local time)
14-
- coordinate system conversions (geodetic, geocentric spherical, geocentric Cartesian coordinates)
15-
- time conversions (modified Julian date 2000, decimal year)
16-
- and perform other auxiliary calculations.
4+
.. toctree::
5+
:hidden:
6+
:caption: VirES for Swarm
177

18-
.. _VirES for Swarm: https://vires.service
19-
.. _eoxmagmod: https://vires.service
8+
Git Repository <https://github.com/ESA-VirES/MagneticModel>
9+
VirES for Swarm Service <https://vires.services>
10+
Swarm Virtual Research Environment (JupyterHub) <https://vre.vires.services>
11+
Example Swarm Notebooks <https://notebooks.vires.services>
12+
VirES Python Client Documentaion <https://viresclient.readthedocs.io>
2013

2114
.. toctree::
2215
:maxdepth: 2
16+
.. toctree::
17+
:hidden:
18+
:caption: Package Documentation
19+
20+
Installation <installation>
21+
License <license>
2322

24-
Module Reference <api/modules>
23+
.. Module Reference <api/modules>
2524
2625
2726

0 commit comments

Comments
 (0)