You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Collection of different scale- and distribution-based bias adjustment techniques for climatic research. (see `examples.ipynb` for help)
6
8
7
9
Bias adjustment procedures in Python are very slow, so they should not be used on large data sets.
8
-
A C++ Implementation that works way faster can be found here: [https://github.com/btschwertfeger/Bias-Adjustment-Cpp](https://github.com/btschwertfeger/Bias-Adjustment-Cpp).
10
+
A C++ implementation that works way faster can be found here: [https://github.com/btschwertfeger/Bias-Adjustment-Cpp](https://github.com/btschwertfeger/Bias-Adjustment-Cpp).
11
+
12
+
## Available methods
13
+
- Linear Scaling
14
+
- Variance Scaling
15
+
- Delta (Change) Method
16
+
- Quantile Mapping
17
+
- Quantile Delta Mapping
9
18
____
10
-
## Run adjustment:
19
+
## Usage
20
+
21
+
### Installation
22
+
```bash
23
+
python3 -m pip install python-cmethods
24
+
```
25
+
### Import and application
26
+
```python
27
+
from cmethods.CMethods import CMethods
28
+
cm = CMethods()
29
+
30
+
obsh = xr.open_dataset('input_data/obs.nc')
31
+
simh = xr.open_dataset('input_data/contr.nc')
32
+
simp = xr.open_dataset('input_data/scen.nc')
33
+
34
+
ls_result = cm.linear_scaling(
35
+
method='quantile_delta_mapping',
36
+
obs= obsh['tas'][:,0,0],
37
+
simh= simh['tas'][:,0,0],
38
+
simp= simp['tas'][:,0,0],
39
+
kind='+'# *
40
+
)
41
+
42
+
qdm_result = cm.adjust_2d(
43
+
method='quantile_delta_mapping',
44
+
obs= obsh['tas'],
45
+
simh= simh['tas'],
46
+
simp= simp['tas'],
47
+
n_quaniles=1000,
48
+
kind='+'# *
49
+
)
50
+
# * to calculate the relative rather than the absolute change, '*' can be used instead of '+' (this is prefered when adjusting precipitation)
51
+
```
52
+
53
+
____
54
+
## Examples (see repository on [GitHub](https://github.com/btschwertfeger/Bias-Adjustment-Python))
55
+
56
+
`/examples/examples.ipynb`: Notebook containing different methods and plots
57
+
58
+
`/examples/do_bias_correctino.py`: Example script for adjusting climate data
## Methods implemented by Benjamin T. Schwertfeger:
24
-
|Method|`--method` parameter|
25
-
|-----|-----|
26
-
|Linear Scaling| linear_scaling|
27
-
|Variance Scaling|variance_scaling|
28
-
|Delta Method|delta_method|
29
-
|Quantile Mapping|quantile_mapping|
30
-
|Quantile Delta Mapping|quantile_delta_mapping|
31
70
32
-
____
33
-
# Notes:
34
71
- Linear and variance, as well as delta change method require `--group time.month` as argument.
35
72
- Adjustment methods that apply changes in distributional biasses (QM. QDM, DQM; EQM, ...) need the `--nquantiles` argument set to some integer.
36
73
- Data sets should have the same spatial resolutions.
74
+
____
75
+
## Notes:
37
76
- Computation in Python takes some time, so this is only for demonstration. When adjusting large datasets, its best to the C++ implementation mentioned above.
0 commit comments