Skip to content

Commit f1ae182

Browse files
added the documentation using sphinx
1 parent 41e37c1 commit f1ae182

File tree

13 files changed

+371
-0
lines changed

13 files changed

+371
-0
lines changed

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# -*- coding: utf-8 -*-
2+
# Configuration file for the Sphinx documentation builder.
3+
#
4+
# For the full list of built-in configuration values, see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Project information -----------------------------------------------------
8+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
9+
10+
"""This module is the configuration for the Sphinx documentation building process"""
11+
# pylint: disable=invalid-name
12+
13+
import os
14+
import sys
15+
16+
project = "python-cmethods"
17+
copyright = "2023, Benjamin Thomas Schwertfeger" # pylint: disable=redefined-builtin
18+
author = "Benjamin Thomas Schwertfeger"
19+
20+
21+
# to import the package
22+
sys.path.insert(0, os.path.abspath(".."))
23+
24+
# import links
25+
rst_epilog = ""
26+
# Read link all targets from file
27+
with open("links.rst", encoding="utf-8") as f:
28+
rst_epilog += f.read()
29+
30+
# -- General configuration ---------------------------------------------------
31+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
32+
33+
extensions = [
34+
"sphinx.ext.autodoc",
35+
"sphinx.ext.doctest",
36+
"sphinx.ext.intersphinx",
37+
"sphinx.ext.coverage",
38+
"sphinx.ext.napoleon",
39+
"sphinx.ext.autosectionlabel",
40+
"sphinx.ext.mathjax",
41+
]
42+
43+
templates_path = ["_templates"]
44+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "links.rst"]
45+
46+
47+
# -- Options for HTML output -------------------------------------------------
48+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
49+
html_theme = "sphinx_rtd_theme"
50+
html_static_path = ["_static"]
51+
html_context = {
52+
"display_github": True,
53+
"github_user": "btschwertfeger",
54+
"github_repo": "python-cmethods",
55+
"github_version": "master/docs/",
56+
}
57+
# html_theme_options = {

docs/images/biasCdiagram.png

56.4 KB
Loading

docs/images/dm-doy-plot.png

309 KB
Loading

docs/index.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. python-cmethods documentation master file, created by
2+
sphinx-quickstart on Mon Apr 10 10:04:20 2023.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root ``toctree`` directive.
5+
6+
Welcome to python-cmethods's documentation!
7+
===========================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
src/introduction.rst
14+
src/getting_started.rst
15+
src/cmethods.rst
16+
src/issues.rst
17+
src/license.rst
18+
19+
20+
Indices and tables
21+
==================
22+
23+
* :ref:`genindex`

docs/links.rst

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
.. LINKS
2+
3+
.. _python-cmethods: https://github.com/btschwertfeger/python-cmethods
4+
5+
.. _python-cmethods/issues: https://github.com/btschwertfeger/python-cmethods/issues
6+
7+
.. _python-cmethods/discussions: https://github.com/btschwertfeger/python-cmethods/discussions
8+
9+
.. _BiasAdjustCXX: https://github.com/btschwertfeger/BiasAdjustCXX
10+
11+
.. _tool comparison: https://github.com/btschwertfeger/BiasAdjustCXX-Performance-Test
12+
13+
.. _xclim: https://zenodo.org/record/7535677
14+
15+
16+
.. BADGES
17+
18+
.. |GitHub badge| image:: https://badgen.net/badge/icon/github?icon=github&label
19+
:target: https://github.com/btschwertfeger/python-cmethods
20+
21+
.. |License badge| image:: https://img.shields.io/badge/License-GPLv3-orange.svg
22+
:target: https://www.gnu.org/licenses/gpl-3.0
23+
24+
.. |PyVersions badge| image:: https://img.shields.io/badge/python-3.8_|_3.9_|_3.10_|_3.11-blue.svg
25+
:target: https://github.com/btschwertfeger/python-cmethods
26+
27+
.. |Downloads badge| image:: https://static.pepy.tech/personalized-badge/python-cmethods?period=total&units=abbreviation&left_color=grey&right_color=orange&left_text=downloads
28+
:target: https://pepy.tech/project/python-cmethods
29+
30+
.. |CodeQL badge| image:: https://github.com/btschwertfeger/python-cmethods/actions/workflows/codeql.yml/badge.svg?branch=master
31+
:target: https://github.com/btschwertfeger/python-cmethods/actions/workflows/codeql.yml
32+
33+
.. |CI/CD badge| image:: https://github.com/btschwertfeger/python-cmethods/actions/workflows/cicd.yml/badge.svg?branch=master
34+
:target: https://github.com/btschwertfeger/python-cmethods/actions/workflows/cicd.yml
35+
36+
.. |codecov badge| image:: https://codecov.io/gh/btschwertfeger/python-cmethods/branch/master/badge.svg
37+
:target: https://app.codecov.io/gh/btschwertfeger/python-cmethods
38+
39+
.. |Release date badge| image:: https://shields.io/github/release-date/btschwertfeger/python-cmethods
40+
:target: https://github.com/btschwertfeger/python-cmethods
41+
42+
.. |Release version badge| image:: https://shields.io/github/v/release/btschwertfeger/python-cmethods?display_name=tag
43+
:target: https://github.com/btschwertfeger/python-cmethods
44+
45+
.. |DOI badge| image:: https://zenodo.org/badge/496160109.svg
46+
:target: https://zenodo.org/badge/latestdoi/496160109
47+
48+
.. |Docs latest| image:: https://readthedocs.org/projects/python-cmethods/badge/?version=latest
49+
:target: https://python-cmethods.readthedocs.io/en/latest
50+
:alt: Documentation Status latest
51+
52+
.. |Docs stable| image:: https://readthedocs.org/projects/python-cmethods/badge/?version=stable
53+
:target: https://python-cmethods.readthedocs.io/en/stable
54+
:alt: Documentation Status stable

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
netCDF4>=1.6.1
2+
numpy
3+
setuptools_scm
4+
sphinx
5+
sphinx-rtd-theme
6+
tqdm
7+
xarray>=2022.11.0

docs/src/cmethods.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
Classes and Functions
3+
=====================
4+
5+
.. currentmodule:: cmethods.CMethods
6+
7+
.. autoclass:: CMethods
8+
:members: linear_scaling, variance_scaling, delta_method, quantile_mapping, quantile_delta_mapping, adjust_3d
9+
10+
11+
Some helpful additional methods
12+
-------------------------------
13+
14+
.. automethod:: CMethods.get_pdf
15+
.. automethod:: CMethods.get_cdf
16+
.. automethod:: CMethods.get_inverse_of_cdf
17+
.. automethod:: CMethods.get_adjusted_scaling_factor
18+
.. automethod:: CMethods.get_available_methods

docs/src/getting_started.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Getting Started
2+
===============
3+
4+
Installation
5+
------------
6+
7+
The `python-cmethods`_ module can be installed using the package manager pip:
8+
9+
.. code-block:: bash
10+
11+
python3 -m pip install python-cmethods
12+
13+
14+
Usage and Examples
15+
------------------
16+
17+
The `python-cmethods`_ module can be imported and applied as showing in the following examples.
18+
For more detailed description of the methods, please have a look at the
19+
method specific documentation.
20+
21+
.. code-block:: python
22+
:linenos:
23+
:caption: Apply the Linear Scaling bias correction technique on 1-dimensional data
24+
25+
import xarray as xr
26+
from cmethods.CMethods import CMethods
27+
cm = CMethods()
28+
29+
obsh = xr.open_dataset('input_data/observations.nc')
30+
simh = xr.open_dataset('input_data/control.nc')
31+
simp = xr.open_dataset('input_data/scenario.nc')
32+
33+
ls_result = cm.linear_scaling(
34+
obs = obsh['tas'][:,0,0],
35+
simh = simh['tas'][:,0,0],
36+
simp = simp['tas'][:,0,0],
37+
kind = '+'
38+
)
39+
40+
.. code-block:: python
41+
:linenos:
42+
:caption: Apply the Quantile Delta Mapping bias correction technique on 1-dimensional data
43+
44+
import xarray as xr
45+
from cmethods.CMethods import CMethods
46+
cm = CMethods()
47+
48+
obsh = xr.open_dataset('input_data/observations.nc')
49+
simh = xr.open_dataset('input_data/control.nc')
50+
simp = xr.open_dataset('input_data/scenario.nc')
51+
52+
qdm_result = cm.adjust_3d( # 3d = 2 spatial and 1 time dimension
53+
method = 'quantile_delta_mapping',
54+
obs = obsh['tas'],
55+
simh = simh['tas'],
56+
simp = simp['tas'],
57+
n_quaniles = 1000,
58+
kind = '+'
59+
)
60+
61+
```

0 commit comments

Comments
 (0)