Skip to content

Commit 31998f9

Browse files
Merge pull request #13 from btschwertfeger/9-create-a-documentation
Create the documentation
2 parents 41e37c1 + f26157d commit 31998f9

25 files changed

+1148
-1593
lines changed

.github/workflows/_build_doc.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
3+
# Github: https://github.com/btschwertfeger
4+
#
5+
# Template workflow to build documentation.
6+
#
7+
8+
name: Build Doc
9+
10+
on:
11+
workflow_call:
12+
inputs:
13+
os:
14+
type: string
15+
required: true
16+
python-version:
17+
type: string
18+
required: true
19+
20+
jobs:
21+
Build:
22+
runs-on: ${{ inputs.os }}
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v3
26+
27+
- name: Set up Python ${{ inputs.python-version }}
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: ${{ inputs.python-version }}
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install -r docs/requirements.txt
36+
37+
- name: Build the documentation
38+
run: cd docs && make html

.github/workflows/_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
required: true
1919

2020
jobs:
21-
Test-Spot:
21+
Test:
2222
name: Test ${{ inputs.os }} ${{ inputs.python-version }}
2323
runs-on: ${{ inputs.os }}
2424
steps:
@@ -37,5 +37,5 @@ jobs:
3737
- name: Install package
3838
run: python -m pip install ".[dev]"
3939

40-
- name: Testing Spot REST endpoints
40+
- name: Run unit tests
4141
run: pytest tests/

.github/workflows/cicd.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ jobs:
3737
os: ${{ matrix.os }}
3838
python-version: ${{ matrix.python-version }}
3939

40+
## Build the documentation
41+
##
42+
Build-Doc:
43+
needs: [Pre-Commit]
44+
uses: ./.github/workflows/_build_doc.yml
45+
with:
46+
os: "ubuntu-latest"
47+
python-version: "3.11"
48+
4049
## Run the unit tests for Python 3.8 until 3.11
4150
##
4251
Test:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ del*.py
135135
*.csv
136136
*.log
137137
*.zip
138+
.vscode/
138139

139140
*.egg-info/
140141
conda.stuff/

.pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,14 @@ function-naming-style=snake_case
176176

177177
# Good variable names which should always be accepted, separated by a comma.
178178
good-names=i,
179+
x,
179180
j,
180181
k,
181182
ex,
182183
Run,
183184
_,
184185
X,
185186
QDM1,
186-
a,
187187
LS_simh,LS_simp,VS_1_simh,VS_2_simp,VS_1_simp,
188188
CMethods
189189

@@ -335,7 +335,7 @@ indent-string=' '
335335
max-line-length=100
336336

337337
# Maximum number of lines in a module.
338-
max-module-lines=1000
338+
max-module-lines=10000
339339

340340
# Allow the body of a class to be on the same line as the declaration if body
341341
# contains single statement.

.readthedocs.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the version of Python and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.11"
13+
# You can also specify other tool versions:
14+
# nodejs: "19"
15+
# rust: "1.64"
16+
# golang: "1.19"
17+
18+
# Build documentation in the docs/ directory with Sphinx
19+
sphinx:
20+
configuration: docs/conf.py
21+
22+
# If using Sphinx, optionally build your docs in additional formats such as PDF
23+
# formats:
24+
# - pdf
25+
26+
# Optionally declare the Python requirements required to build your docs
27+
python:
28+
install:
29+
- requirements: docs/requirements.txt

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pre-commit:
4646
## Clean the workspace
4747
##
4848
clean:
49-
rm -rf .pytest_cache build/ dist/ python_cmethods.egg-info docs/_build
49+
rm -rf .pytest_cache build/ dist/ python_cmethods.egg-info docs/_build examples/.ipynb_checkpoints
5050
rm -f .coverage cmethods/_version.py
5151

5252
find tests -name "__pycache__" | xargs rm -rf

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
![release](https://shields.io/github/release-date/btschwertfeger/python-cmethods)
1515
![release](https://shields.io/github/v/release/btschwertfeger/python-cmethods?display_name=tag)
1616
[![DOI](https://zenodo.org/badge/496160109.svg)](https://zenodo.org/badge/latestdoi/496160109)
17+
[![Documentation Status](https://readthedocs.org/projects/python-cmethods/badge/?version=stable)](https://python-cmethods.readthedocs.io/en/latest/?badge=stable)
1718

1819
</div>
1920

2021
This Python module contains a collection of different scale- and distribution-based bias adjustment techniques for climatic research (see `/examples/examples.ipynb` for help).
2122

22-
### 📍 For the application of bias corrections on _lage data sets_ it is recomanded to use the C++ tool [BiasAdjustCXX](https://github.com/btschwertfeger/Bias-Adjustment-Cpp) since bias corrections are complex statistical transformation which are very slow in Python compared to the C++ implementation.
23+
The documentation is available at: [https://python-kraken-sdk.readthedocs.io/en/stable/](https://python-kraken-sdk.readthedocs.io/en/stable/)
24+
25+
> ⚠️ For the application of bias corrections on _lage data sets_ it is recomanded to use the command-line tool [BiasAdjustCXX](https://github.com/btschwertfeger/BiasAdjustCXX) since bias corrections are complex statistical transformation which are very slow in Python compared to the C++ implementation.
2326
2427
---
2528

@@ -42,7 +45,7 @@ These programs and data structures are designed to help minimize discrepancies b
4245

4346
<figure>
4447
<img
45-
src="images/biasCdiagram.png?raw=true"
48+
src="docs/images/biasCdiagram.png?raw=true"
4649
alt="Schematic representation of a bias adjustment procedure"
4750
style="background-color: white; border-radius: 7px">
4851
<figcaption>Figure 1: Schematic representation of a bias adjustment procedure</figcaption>
@@ -52,7 +55,7 @@ In this way, for example, modeled data, which on average represent values that a
5255

5356
<figure>
5457
<img
55-
src="images/dm-doy-plot.png?raw=true"
58+
src="docs/images/dm-doy-plot.png?raw=true"
5659
alt="Temperature per day of year in modeled, observed and bias-adjusted climate data"
5760
style="background-color: white; border-radius: 7px">
5861
<figcaption>Figure 2: Temperature per day of year in observed, modeled, and bias-adjusted climate data</figcaption>
@@ -93,8 +96,7 @@ python3 -m pip install python-cmethods
9396

9497
```python
9598
import xarray as xr
96-
from cmethods.CMethods import CMethods
97-
cm = CMethods()
99+
from cmethods.CMethods import CMethods as cm
98100

99101
obsh = xr.open_dataset('input_data/observations.nc')
100102
simh = xr.open_dataset('input_data/control.nc')
@@ -125,7 +127,7 @@ Notes:
125127
- When using the `adjust_3d` method you have to specify the method by name.
126128
- For the multiplicative linear scaling and the delta method as well as the variance scaling method a maximum scaling factor of 10 is defined. This can be changed by the parameter `max_scaling_factor`.
127129

128-
## Examples (see repository on [GitHub](https://github.com/btschwertfeger/Bias-Adjustment-Python))
130+
## Examples (see repository on [GitHub](https://github.com/btschwertfeger/python-cmethods))
129131

130132
Notebook with different methods and plots: `/examples/examples.ipynb`
131133

@@ -153,23 +155,24 @@ python3 do_bias_correction.py \
153155

154156
## 5. Notes
155157

156-
- Computation in Python takes some time, so this is only for demonstration. When adjusting large datasets, its best to use the C++ tool [BiasAdjustCXX](https://github.com/btschwertfeger/Bias-Adjustment-Cpp).
158+
- Computation in Python takes some time, so this is only for demonstration. When adjusting large datasets, its best to use the C++ tool [BiasAdjustCXX](https://github.com/btschwertfeger/BiasAdjustCXX).
157159
- Formulas and references can be found in the implementations of the corresponding functions.
158160

159161
### Space for improvements:
160162

161-
Since the scaling methods implemented so far scale by default over the mean values of the respective months, unrealistic long-term mean values may occur at the month transitions. This can be prevented either by selecting `group='time.dayofyear'`. Alternatively, it is possible not to scale using long-term mean values, but using a 31-day interval, which takes the 31 surrounding values over all years as the basis for calculating the mean values. This is not yet implemented in this module, but is available in the C++ implementation [here](https://github.com/btschwertfeger/Bias-Adjustment-Cpp).
163+
Since the scaling methods implemented so far scale by default over the mean values of the respective months, unrealistic long-term mean values may occur at the month transitions. This can be prevented either by selecting `group='time.dayofyear'`. Alternatively, it is possible not to scale using long-term mean values, but using a 31-day interval, which takes the 31 surrounding values over all years as the basis for calculating the mean values. This is not yet implemented in this module, but is available in the C++ tool [BiasAdjustCXX](https://github.com/btschwertfeger/BiasAdjustCXX).
162164

163165
---
164166

165167
<a name="references"></a>
166168

167169
## 6. References
168170

169-
- Schwertfeger, Benjamin Thomas (2022) The influence of bias corrections on variability, distribution, and correlation of temperatures in comparison to observed and modeled climate data in Europe (https://epic.awi.de/id/eprint/56689/)
170-
- Linear Scaling and Variance Scaling based on: Teutschbein, Claudia and Seibert, Jan (2012) Bias correction of regional climate model simulations for hydrological climate-change impact studies: Review and evaluation of different methods (https://doi.org/10.1016/j.jhydrol.2012.05.052)
171-
- Delta Method based on: Beyer, R. and Krapp, M. and Manica, A.: An empirical evaluation of bias correction methods for palaeoclimate simulations (https://doi.org/10.5194/cp-16-1493-2020)
172-
- Quantile and Detrended Quantile Mapping based on: Alex J. Cannon and Stephen R. Sobie and Trevor Q. Murdock Bias Correction of GCM Precipitation by Quantile Mapping: How Well Do Methods Preserve Changes in Quantiles and Extremes? (https://doi.org/10.1175/JCLI-D-14-00754.1)
173-
- Quantile Delta Mapping based on: Tong, Y., Gao, X., Han, Z. et al. Bias correction of temperature and precipitation over China for RCM simulations using the QM and QDM methods. Clim Dyn 57, 1425–1443 (2021). (https://doi.org/10.1007/s00382-020-05447-4)
171+
- Schwertfeger, Benjamin Thomas and Lohmann, Gerrit and Lipskoch, Henrik (2023) _"Introduction of the BiasAdjustCXX command-line tool for the application of fast and efficient bias corrections in climatic research"_, SoftwareX, Volume 22, 101379, ISSN 2352-7110, (https://doi.org/10.1016/j.softx.2023.101379)
172+
- Schwertfeger, Benjamin Thomas (2022) _"The influence of bias corrections on variability, distribution, and correlation of temperatures in comparison to observed and modeled climate data in Europe"_ (https://epic.awi.de/id/eprint/56689/)
173+
- Linear Scaling and Variance Scaling based on: Teutschbein, Claudia and Seibert, Jan (2012) _"Bias correction of regional climate model simulations for hydrological climate-change impact studies: Review and evaluation of different methods"_ (https://doi.org/10.1016/j.jhydrol.2012.05.052)
174+
- Delta Method based on: Beyer, R. and Krapp, M. and Manica, A.: _"An empirical evaluation of bias correction methods for palaeoclimate simulations"_ (https://doi.org/10.5194/cp-16-1493-2020)
175+
- Quantile and Detrended Quantile Mapping based on: Alex J. Cannon and Stephen R. Sobie and Trevor Q. Murdock _"Bias Correction of GCM Precipitation by Quantile Mapping: How Well Do Methods Preserve Changes in Quantiles and Extremes?"_ (https://doi.org/10.1175/JCLI-D-14-00754.1)
176+
- Quantile Delta Mapping based on: Tong, Y., Gao, X., Han, Z. et al. _"Bias correction of temperature and precipitation over China for RCM simulations using the QM and QDM methods"_. Clim Dyn 57, 1425–1443 (2021). (https://doi.org/10.1007/s00382-020-05447-4)
174177

175178
---

0 commit comments

Comments
 (0)