Collection of bias adjustment procedures for multidimensional climate data
Project description
Bias-Adjustment-Python
Collection of different scale- and distribution-based bias adjustment techniques for climatic research. (see examples.ipynb
for help)
Bias adjustment procedures in Python are very slow, so they should not be used on large data sets. A C++ implementation that works way faster can be found here: https://github.com/btschwertfeger/Bias-Adjustment-Cpp.
Available methods
- Linear Scaling
- Variance Scaling
- Delta (Change) Method
- Quantile Mapping
- Quantile Delta Mapping
Usage
Installation
python3 -m pip install python-cmethods
Import and application
from cmethods.CMethods import CMethods
cm = CMethods()
obsh = xr.open_dataset('input_data/obs.nc')
simh = xr.open_dataset('input_data/contr.nc')
simp = xr.open_dataset('input_data/scen.nc')
ls_result = cm.linear_scaling(
method = 'quantile_delta_mapping',
obs = obsh['tas'][:,0,0],
simh = simh['tas'][:,0,0],
simp = simp['tas'][:,0,0],
kind = '+' # *
)
qdm_result = cm.adjust_2d(
method = 'quantile_delta_mapping',
obs = obsh['tas'],
simh = simh['tas'],
simp = simp['tas'],
n_quaniles = 1000,
kind = '+' # *
)
# * to calculate the relative rather than the absolute change, '*' can be used instead of '+' (this is prefered when adjusting precipitation)
Examples (see repository on GitHub)
/examples/examples.ipynb
: Notebook containing different methods and plots
/examples/do_bias_correctino.py
: Example script for adjusting climate data
python3 do_bias_correction.py \
--obs input_data/obs.nc \
--contr input_data/contr.nc \
--scen input_data/scen.nc \
--method linear_scaling \
--variable tas \
--unit '°C' \
--group time.month \
--kind +
- Linear and variance, as well as delta change method require
--group time.month
as argument. - Adjustment methods that apply changes in distributional biasses (QM. QDM, DQM; EQM, ...) need the
--nquantiles
argument set to some integer. - Data sets should have the same spatial resolutions.
Notes:
- Computation in Python takes some time, so this is only for demonstration. When adjusting large datasets, its best to the C++ implementation mentioned above.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-cmethods-0.5.1.tar.gz
(11.3 kB
view hashes)
Built Distribution
Close
Hashes for python_cmethods-0.5.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6efc87dcb6fee8375769eced72b2e85b4d6fdd57c8d35765140c0e310a544b8b |
|
MD5 | a2aaa8ecfb8771eef6aede3027789fc1 |
|
BLAKE2b-256 | df3438ff0004d810f94d1e8a9745e546ef54b9ac25c0c0759151274d96973fff |