21
21
from cmethods .scaling import linear_scaling as __linear_scaling
22
22
from cmethods .scaling import variance_scaling as __variance_scaling
23
23
from cmethods .static import SCALING_METHODS
24
- from cmethods .utils import UnknownMethodError , check_xr_types
24
+ from cmethods .utils import UnknownMethodError , ensure_xr_dataarray
25
25
26
26
if TYPE_CHECKING :
27
27
from cmethods .types import XRData
37
37
38
38
def apply_ufunc (
39
39
method : str ,
40
- obs : XRData ,
41
- simh : XRData ,
42
- simp : XRData ,
40
+ obs : xr . xarray . core . dataarray . DataArray ,
41
+ simh : xr . xarray . core . dataarray . DataArray ,
42
+ simp : xr . xarray . core . dataarray . DataArray ,
43
43
** kwargs : dict ,
44
- ) -> XRData :
44
+ ) -> xr . xarray . core . dataarray . DataArray :
45
45
"""
46
46
Internal function used to apply the bias correction technique to the
47
47
passed input data.
48
48
"""
49
- check_xr_types (obs = obs , simh = simh , simp = simp )
49
+ ensure_xr_dataarray (obs = obs , simh = simh , simp = simp )
50
50
if method not in __METHODS_FUNC__ :
51
51
raise UnknownMethodError (method , __METHODS_FUNC__ .keys ())
52
52
@@ -96,11 +96,11 @@ def apply_ufunc(
96
96
97
97
def adjust (
98
98
method : str ,
99
- obs : XRData ,
100
- simh : XRData ,
101
- simp : XRData ,
99
+ obs : xr . xarray . core . dataarray . DataArray ,
100
+ simh : xr . xarray . core . dataarray . DataArray ,
101
+ simp : xr . xarray . core . dataarray . DataArray ,
102
102
** kwargs ,
103
- ) -> XRData :
103
+ ) -> xr . xarray . core . dataarray . DataArray | xr . xarray . core . dataarray . Dataset :
104
104
"""
105
105
Function to apply a bias correction technique on single and multidimensional
106
106
data sets. For more information please refer to the method specific
@@ -119,19 +119,19 @@ def adjust(
119
119
:param method: Technique to apply
120
120
:type method: str
121
121
:param obs: The reference/observational data set
122
- :type obs: XRData
122
+ :type obs: xr.xarray.core.dataarray.DataArray
123
123
:param simh: The modeled data of the control period
124
- :type simh: XRData
124
+ :type simh: xr.xarray.core.dataarray.DataArray
125
125
:param simp: The modeled data of the period to adjust
126
- :type simp: XRData
126
+ :type simp: xr.xarray.core.dataarray.DataArray
127
127
:param kwargs: Any other method-specific parameter (like
128
128
``n_quantiles`` and ``kind``)
129
129
:type kwargs: dict
130
130
:return: The bias corrected/adjusted data set
131
- :rtype: XRData
131
+ :rtype: xr.xarray.core.dataarray.DataArray | xr.xarray.core.dataarray.Dataset
132
132
"""
133
133
kwargs ["adjust_called" ] = True
134
- check_xr_types (obs = obs , simh = simh , simp = simp )
134
+ ensure_xr_dataarray (obs = obs , simh = simh , simp = simp )
135
135
136
136
if method == "detrended_quantile_mapping" : # noqa: PLR2004
137
137
raise ValueError (
@@ -169,6 +169,8 @@ def adjust(
169
169
obs_group = group ["obs" ]
170
170
simh_group = group ["simh" ]
171
171
simp_group = group ["simp" ]
172
+ else :
173
+ raise ValueError ("'group' must be a string or a dict!" )
172
174
173
175
del kwargs ["group" ]
174
176
0 commit comments