Commit eab7ca1b authored by Maximilian Schanner's avatar Maximilian Schanner
Browse files

Some PEP 8 and documentation changes.

parent 53d0e749
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
......@@ -35,7 +35,6 @@
# -- Project information -----------------------------------------------------
from pymagglobal import __version__ as release
from pymagglobal.core import __all__ as core_members
copyright = f'2020 Helmholtz Centre Potsdam GFZ, ' \
+ f'German Research Centre for Geosciences, Potsdam, Germany'
......@@ -81,4 +80,4 @@ html_theme = 'classic'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
# html_static_path = ['_static']
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
......
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
......@@ -62,6 +62,7 @@ _models = built_in_models()
listing names and paths to the included models.
'''
class ListModelsAction(argparse.Action):
'''The action class that will produce a list of available models.
'''
......
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
......@@ -22,7 +22,7 @@
import numpy as np
from cartopy import crs as ccrs
from matplotlib import pyplot as plt, colors, cm
from matplotlib import pyplot as plt
from pymagglobal import core
from pymagglobal import utils
......
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
......@@ -49,7 +49,7 @@ def built_in_models() -> dict:
models = {}
for it in os.listdir(datdir):
if os.path.isfile(os.path.join(datdir, it)) and 'license' not in it \
and 'README' not in it:
and 'README' not in it:
models[it] = os.path.join(datdir, it)
return models
......
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
......@@ -100,17 +100,28 @@ def _intcheck(x):
def lm2i(ell, m):
'''Returns the "standard order" index corresponding to a Gauss coefficient
of degree l and order m. The "standard order" is as follows
i l m
-------
1 1 0
2 1 1
3 1 -1
4 2 0
5 2 1
6 2 -1
7 2 2
8 2 -2
...
+-----+-----+-----+
| i | l | m |
+=====+=====+=====+
| 0 | 1 | 0 |
+-----+-----+-----+
| 1 | 1 | 1 |
+-----+-----+-----+
| 2 | 1 | -1 |
+-----+-----+-----+
| 3 | 2 | 0 |
+-----+-----+-----+
| 4 | 2 | 1 |
+-----+-----+-----+
| 5 | 2 | -1 |
+-----+-----+-----+
| 6 | 2 | 2 |
+-----+-----+-----+
| 7 | 2 | -2 |
+-----+-----+-----+
| ... |
+-----+-----+-----+
Parameters
----------
......@@ -144,17 +155,28 @@ def lm2i(ell, m):
def i2lm_l(i):
'''Returns the degree l of a Gauss coefficient at index i, in the "standard
order". The "standard order" is as follows
i l m
-------
1 1 0
2 1 1
3 1 -1
4 2 0
5 2 1
6 2 -1
7 2 2
8 2 -2
...
+-----+-----+-----+
| i | l | m |
+=====+=====+=====+
| 0 | 1 | 0 |
+-----+-----+-----+
| 1 | 1 | 1 |
+-----+-----+-----+
| 2 | 1 | -1 |
+-----+-----+-----+
| 3 | 2 | 0 |
+-----+-----+-----+
| 4 | 2 | 1 |
+-----+-----+-----+
| 5 | 2 | -1 |
+-----+-----+-----+
| 6 | 2 | 2 |
+-----+-----+-----+
| 7 | 2 | -2 |
+-----+-----+-----+
| ... |
+-----+-----+-----+
Parameters
----------
......@@ -182,17 +204,28 @@ def i2lm_l(i):
def i2lm_m(i):
'''Returns the order m of a Gauss coefficient at index i, in the "standard
order". The "standard order" is as follows
i l m
-------
1 1 0
2 1 1
3 1 -1
4 2 0
5 2 1
6 2 -1
7 2 2
8 2 -2
...
+-----+-----+-----+
| i | l | m |
+=====+=====+=====+
| 0 | 1 | 0 |
+-----+-----+-----+
| 1 | 1 | 1 |
+-----+-----+-----+
| 2 | 1 | -1 |
+-----+-----+-----+
| 3 | 2 | 0 |
+-----+-----+-----+
| 4 | 2 | 1 |
+-----+-----+-----+
| 5 | 2 | -1 |
+-----+-----+-----+
| 6 | 2 | 2 |
+-----+-----+-----+
| 7 | 2 | -2 |
+-----+-----+-----+
| ... |
+-----+-----+-----+
Parameters
----------
......@@ -283,7 +316,8 @@ def dsh_basis(lmax, z, out, R=REARTH):
frame.", Geosci. Model Dev., vol. 8, pages 1979-1990, 2014.
.. [FieldTools] H. Matuschek and S. Mauerberger, "FieldTools - A toolbox
for manipulating vector fields on the sphere", GFZ Data Services, 2019.
DOI: `10.5880/fidgeo.2019.033 <http://doi.org/10.5880/fidgeo.2019.033>`_
DOI: `10.5880/fidgeo.2019.033
<http://doi.org/10.5880/fidgeo.2019.033>`_
'''
_intcheck(lmax)
# check input consitency
......
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
......@@ -37,6 +37,7 @@ def get_version(rel_path):
else:
raise RuntimeError("Unable to find version string.")
with open("README.md", "r") as fh:
long_description = fh.read()
......
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import sys
from pathlib import PurePath
......@@ -25,11 +24,12 @@ import unittest
import doctest
import matplotlib
matplotlib.use('Agg') # Select a headless backend
from pymagglobal import utils
from pymagglobal import _commands
matplotlib.use('Agg') # Select a headless backend
# Fetch relative path
tests_path = PurePath(__file__).parent
# By convention the TestLoader discovers TestCases in test_*.py
......
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import unittest
import io
import sys
......
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import unittest
from pathlib import Path
import pymagglobal
# Implicitly check the package index __all__
# Not a test-case since `import *` is only allowed at module level
from pymagglobal import *
try:
from packaging.version import Version
class ParserTestPackage(unittest.TestCase):
'''Unit-tests for the package i.e. __init__.py'''
def test_version(self):
'''Check if pymagglobal.__version__ conforms PEP 440'''
version = Version(pymagglobal.__version__)
Version(pymagglobal.__version__)
except (ImportError, ModuleNotFoundError):
print("Skipped version test, as the packaging package is not available.")
# This file is part of pymagglobal
#
#
# Copyright (C) 2020 Helmholtz Centre Potsdam
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# GFZ German Research Centre for Geosciences, Potsdam, Germany
# (https://www.gfz-potsdam.de)
#
#
# pymagglobal is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# pymagglobal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import unittest
import numpy as np
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment