@@ -160,7 +160,7 @@ def average(
160
160
data_var : str ,
161
161
weighted : bool = True ,
162
162
keep_weights : bool = False ,
163
- skipna : Union [ bool , None ] = None ,
163
+ skipna : bool | None = None ,
164
164
):
165
165
"""
166
166
Returns a Dataset with the average of a data variable and the time
@@ -202,7 +202,7 @@ def average(
202
202
keep_weights : bool, optional
203
203
If calculating averages using weights, keep the weights in the
204
204
final dataset output, by default False.
205
- skipna : bool or None, optional
205
+ skipna : bool | None, optional
206
206
If True, skip missing values (as marked by NaN). By default, only
207
207
skips missing values for float dtypes; other dtypes either do not
208
208
have a sentinel missing value (int) or ``skipna=True`` has not been
@@ -257,6 +257,7 @@ def group_average(
257
257
weighted : bool = True ,
258
258
keep_weights : bool = False ,
259
259
season_config : SeasonConfigInput = DEFAULT_SEASON_CONFIG ,
260
+ skipna : bool | None = None ,
260
261
):
261
262
"""Returns a Dataset with average of a data variable by time group.
262
263
@@ -335,6 +336,11 @@ def group_average(
335
336
>>> ["Jul", "Aug", "Sep"], # "JulAugSep"
336
337
>>> ["Oct", "Nov", "Dec"], # "OctNovDec"
337
338
>>> ]
339
+ skipna : bool | None, optional
340
+ If True, skip missing values (as marked by NaN). By default, only
341
+ skips missing values for float dtypes; other dtypes either do not
342
+ have a sentinel missing value (int) or ``skipna=True`` has not been
343
+ implemented (object, datetime64 or timedelta64).
338
344
339
345
Returns
340
346
-------
@@ -413,6 +419,7 @@ def group_average(
413
419
weighted = weighted ,
414
420
keep_weights = keep_weights ,
415
421
season_config = season_config ,
422
+ skipna = skipna ,
416
423
)
417
424
418
425
def climatology (
@@ -423,6 +430,7 @@ def climatology(
423
430
keep_weights : bool = False ,
424
431
reference_period : Optional [Tuple [str , str ]] = None ,
425
432
season_config : SeasonConfigInput = DEFAULT_SEASON_CONFIG ,
433
+ skipna : bool | None = None ,
426
434
):
427
435
"""Returns a Dataset with the climatology of a data variable.
428
436
@@ -510,6 +518,11 @@ def climatology(
510
518
>>> ["Jul", "Aug", "Sep"], # "JulAugSep"
511
519
>>> ["Oct", "Nov", "Dec"], # "OctNovDec"
512
520
>>> ]
521
+ skipna : bool | None, optional
522
+ If True, skip missing values (as marked by NaN). By default, only
523
+ skips missing values for float dtypes; other dtypes either do not
524
+ have a sentinel missing value (int) or ``skipna=True`` has not been
525
+ implemented (object, datetime64 or timedelta64).
513
526
514
527
Returns
515
528
-------
@@ -593,6 +606,7 @@ def climatology(
593
606
keep_weights ,
594
607
reference_period ,
595
608
season_config ,
609
+ skipna ,
596
610
)
597
611
598
612
def departures (
@@ -603,6 +617,7 @@ def departures(
603
617
keep_weights : bool = False ,
604
618
reference_period : Optional [Tuple [str , str ]] = None ,
605
619
season_config : SeasonConfigInput = DEFAULT_SEASON_CONFIG ,
620
+ skipna : bool | None = None ,
606
621
) -> xr .Dataset :
607
622
"""
608
623
Returns a Dataset with the climatological departures (anomalies) for a
@@ -697,6 +712,11 @@ def departures(
697
712
>>> ["Jul", "Aug", "Sep"], # "JulAugSep"
698
713
>>> ["Oct", "Nov", "Dec"], # "OctNovDec"
699
714
>>> ]
715
+ skipna : bool | None, optional
716
+ If True, skip missing values (as marked by NaN). By default, only
717
+ skips missing values for float dtypes; other dtypes either do not
718
+ have a sentinel missing value (int) or ``skipna=True`` has not been
719
+ implemented (object, datetime64 or timedelta64).
700
720
701
721
Returns
702
722
-------
@@ -777,11 +797,7 @@ def departures(
777
797
inferred_freq = _infer_freq (ds [self .dim ])
778
798
if inferred_freq != freq :
779
799
ds_obs = ds_obs .temporal .group_average (
780
- data_var ,
781
- freq ,
782
- weighted ,
783
- keep_weights ,
784
- season_config ,
800
+ data_var , freq , weighted , keep_weights , season_config , skipna
785
801
)
786
802
787
803
# 4. Calculate the climatology of the data variable.
@@ -794,6 +810,7 @@ def departures(
794
810
keep_weights ,
795
811
reference_period ,
796
812
season_config ,
813
+ skipna ,
797
814
)
798
815
799
816
# 5. Calculate the departures for the data variable.
@@ -815,7 +832,7 @@ def _averager(
815
832
keep_weights : bool = False ,
816
833
reference_period : Optional [Tuple [str , str ]] = None ,
817
834
season_config : SeasonConfigInput = DEFAULT_SEASON_CONFIG ,
818
- skipna : Union [ bool , None ] = None ,
835
+ skipna : bool | None = None ,
819
836
) -> xr .Dataset :
820
837
"""Averages a data variable based on the averaging mode and frequency."""
821
838
ds = self ._dataset .copy ()
@@ -1141,7 +1158,7 @@ def _drop_leap_days(self, ds: xr.Dataset):
1141
1158
return ds
1142
1159
1143
1160
def _average (
1144
- self , ds : xr .Dataset , data_var : str , skipna : Union [ bool , None ] = None
1161
+ self , ds : xr .Dataset , data_var : str , skipna : bool | None = None
1145
1162
) -> xr .DataArray :
1146
1163
"""Averages a data variable with the time dimension removed.
1147
1164
@@ -1151,7 +1168,7 @@ def _average(
1151
1168
The dataset.
1152
1169
data_var : str
1153
1170
The key of the data variable.
1154
- skipna : bool or None, optional
1171
+ skipna : bool | None, optional
1155
1172
If True, skip missing values (as marked by NaN). By default, only
1156
1173
skips missing values for float dtypes; other dtypes either do not
1157
1174
have a sentinel missing value (int) or ``skipna=True`` has not been
@@ -1178,7 +1195,7 @@ def _average(
1178
1195
return dv
1179
1196
1180
1197
def _group_average (
1181
- self , ds : xr .Dataset , data_var : str , skipna : Union [ bool , None ] = None
1198
+ self , ds : xr .Dataset , data_var : str , skipna : bool | None = None
1182
1199
) -> xr .DataArray :
1183
1200
"""Averages a data variable by time group.
1184
1201
@@ -1188,7 +1205,7 @@ def _group_average(
1188
1205
The dataset.
1189
1206
data_var : str
1190
1207
The key of the data variable.
1191
- skipna : bool or None, optional
1208
+ skipna : bool | None, optional
1192
1209
If True, skip missing values (as marked by NaN). By default, only
1193
1210
skips missing values for float dtypes; other dtypes either do not
1194
1211
have a sentinel missing value (int) or ``skipna=True`` has not been
0 commit comments