Skip to content

Commit 9a52b98

Browse files
fixed missing netCDF4 import; fixed 'cannot pickle' on adjust_3d functions; adjusted filenames in examples and readme;
1 parent a555820 commit 9a52b98

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

README.md

+16-12
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ import xarray as xr
6464
from cmethods.CMethods import CMethods
6565
cm = CMethods()
6666

67-
obsh = xr.open_dataset('input_data/obs.nc')
68-
simh = xr.open_dataset('input_data/contr.nc')
69-
simp = xr.open_dataset('input_data/scen.nc')
67+
obsh = xr.open_dataset('input_data/observations.nc')
68+
simh = xr.open_dataset('input_data/control.nc')
69+
simp = xr.open_dataset('input_data/scenario.nc')
7070

7171
ls_result = cm.linear_scaling(
7272
obs = obsh['tas'][:,0,0],
@@ -102,14 +102,14 @@ Notes:
102102
`/examples/do_bias_correction.py`: Example script for adjusting climate data
103103

104104
```bash
105-
python3 do_bias_correction.py \
106-
--obs input_data/obs.nc \
107-
--contr input_data/contr.nc \
108-
--scen input_data/scen.nc \
109-
--method linear_scaling \
110-
--variable tas \
111-
--unit '°C' \
112-
--group time.month \
105+
python3 do_bias_correction.py \
106+
--obs input_data/observations.nc \
107+
--contr input_data/control.nc \
108+
--scen input_data/scenario.nc \
109+
--method linear_scaling \
110+
--variable tas \
111+
--unit '°C' \
112+
--group time.month \
113113
--kind +
114114
```
115115

@@ -119,11 +119,15 @@ python3 do_bias_correction.py \
119119

120120
---
121121

122-
## Notes:
122+
## Notes
123123

124124
- Computation in Python takes some time, so this is only for demonstration. When adjusting large datasets, its best to the C++ implementation mentioned above.
125125
- Formulas and references can be found in the implementations of the corresponding functions.
126126

127+
## Space for improvements
128+
129+
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 30-day interval, which takes the 30 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).
130+
127131
## References
128132

129133
- 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/)

cmethods/CMethods.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ def adjust_3d(cls,
124124
)
125125
'''
126126

127-
obs = obs.transpose('lat', 'lon', 'time')
128-
simh = simh.transpose('lat', 'lon', 'time')
129-
simp = simp.transpose('lat', 'lon', 'time')
127+
obs = obs.transpose('lat', 'lon', 'time')#.load()
128+
simh = simh.transpose('lat', 'lon', 'time')#.load()
129+
simp = simp.transpose('lat', 'lon', 'time').load()
130130

131131
if group == None and method in cls.SCALING_METHODS: group = 'time.month'
132-
133-
result = simp.copy(deep=True).load()
132+
133+
result = simp.copy(deep=True)
134134
len_lat, len_lon = len(obs.lat), len(obs.lon)
135135

136136
if method in cls.CUSTOM_METHODS:

cmethods/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
VERSION = (0,5,4)
1+
VERSION = (0,5,4,1)
22
__version__ = '.'.join(map(str, VERSION))

cmethods/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
numpy
22
xarray
3-
tqdm
3+
tqdm
4+
netCDF4

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# What packages are required for this module to be executed?
1919
REQUIRED = [
20-
'xarray', 'numpy', 'tqdm' # <- always conflicts on install with tqdm
20+
'xarray', 'numpy', 'tqdm', 'netCDF4' # <- always conflicts on install with tqdm on test.pypi..
2121
]
2222

2323
# What packages are optional?
@@ -118,11 +118,11 @@ def run(self):
118118
install_requires=REQUIRED,
119119
extras_require=EXTRAS,
120120
include_package_data=True,
121-
license='MIT',
121+
license='GPLv3',
122122
classifiers=[
123123
# Trove classifiers
124124
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
125-
'License :: OSI Approved :: MIT License',
125+
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
126126
'Programming Language :: Python',
127127
'Programming Language :: Python :: 3.7',
128128
],

0 commit comments

Comments
 (0)