33
33
_normalize_path ,
34
34
)
35
35
from xarray .backends .locks import _get_scheduler
36
+ from xarray .coders import CFDatetimeCoder
36
37
from xarray .core import indexing
37
38
from xarray .core .combine import (
38
39
_infer_concat_order_from_positions ,
@@ -481,7 +482,10 @@ def open_dataset(
481
482
cache : bool | None = None ,
482
483
decode_cf : bool | None = None ,
483
484
mask_and_scale : bool | Mapping [str , bool ] | None = None ,
484
- decode_times : bool | Mapping [str , bool ] | None = None ,
485
+ decode_times : bool
486
+ | CFDatetimeCoder
487
+ | Mapping [str , bool | CFDatetimeCoder ]
488
+ | None = None ,
485
489
decode_timedelta : bool | Mapping [str , bool ] | None = None ,
486
490
use_cftime : bool | Mapping [str , bool ] | None = None ,
487
491
concat_characters : bool | Mapping [str , bool ] | None = None ,
@@ -543,9 +547,10 @@ def open_dataset(
543
547
be replaced by NA. Pass a mapping, e.g. ``{"my_variable": False}``,
544
548
to toggle this feature per-variable individually.
545
549
This keyword may not be supported by all the backends.
546
- decode_times : bool or dict-like, optional
550
+ decode_times : bool, CFDatetimeCoder or dict-like, optional
547
551
If True, decode times encoded in the standard NetCDF datetime format
548
- into datetime objects. Otherwise, leave them encoded as numbers.
552
+ into datetime objects. Otherwise, use :py:class:`coders.CFDatetimeCoder` or leave them
553
+ encoded as numbers.
549
554
Pass a mapping, e.g. ``{"my_variable": False}``,
550
555
to toggle this feature per-variable individually.
551
556
This keyword may not be supported by all the backends.
@@ -569,6 +574,10 @@ def open_dataset(
569
574
raise an error. Pass a mapping, e.g. ``{"my_variable": False}``,
570
575
to toggle this feature per-variable individually.
571
576
This keyword may not be supported by all the backends.
577
+
578
+ .. deprecated:: 2025.01.1
579
+ Please pass a :py:class:`coders.CFDatetimeCoder` instance initialized with ``use_cftime`` to the ``decode_times`` kwarg instead.
580
+
572
581
concat_characters : bool or dict-like, optional
573
582
If True, concatenate along the last dimension of character arrays to
574
583
form string arrays. Dimensions will only be concatenated over (and
@@ -698,7 +707,10 @@ def open_dataarray(
698
707
cache : bool | None = None ,
699
708
decode_cf : bool | None = None ,
700
709
mask_and_scale : bool | None = None ,
701
- decode_times : bool | None = None ,
710
+ decode_times : bool
711
+ | CFDatetimeCoder
712
+ | Mapping [str , bool | CFDatetimeCoder ]
713
+ | None = None ,
702
714
decode_timedelta : bool | None = None ,
703
715
use_cftime : bool | None = None ,
704
716
concat_characters : bool | None = None ,
@@ -761,9 +773,11 @@ def open_dataarray(
761
773
`missing_value` attribute contains multiple values a warning will be
762
774
issued and all array values matching one of the multiple values will
763
775
be replaced by NA. This keyword may not be supported by all the backends.
764
- decode_times : bool, optional
776
+ decode_times : bool, CFDatetimeCoder or dict-like, optional
765
777
If True, decode times encoded in the standard NetCDF datetime format
766
- into datetime objects. Otherwise, leave them encoded as numbers.
778
+ into datetime objects. Otherwise, use :py:class:`coders.CFDatetimeCoder` or leave them encoded as numbers.
779
+ Pass a mapping, e.g. ``{"my_variable": False}``,
780
+ to toggle this feature per-variable individually.
767
781
This keyword may not be supported by all the backends.
768
782
decode_timedelta : bool, optional
769
783
If True, decode variables and coordinates with time units in
@@ -781,6 +795,10 @@ def open_dataarray(
781
795
represented using ``np.datetime64[ns]`` objects. If False, always
782
796
decode times to ``np.datetime64[ns]`` objects; if this is not possible
783
797
raise an error. This keyword may not be supported by all the backends.
798
+
799
+ .. deprecated:: 2025.01.1
800
+ Please pass a :py:class:`coders.CFDatetimeCoder` instance initialized with ``use_cftime`` to the ``decode_times`` kwarg instead.
801
+
784
802
concat_characters : bool, optional
785
803
If True, concatenate along the last dimension of character arrays to
786
804
form string arrays. Dimensions will only be concatenated over (and
@@ -903,7 +921,10 @@ def open_datatree(
903
921
cache : bool | None = None ,
904
922
decode_cf : bool | None = None ,
905
923
mask_and_scale : bool | Mapping [str , bool ] | None = None ,
906
- decode_times : bool | Mapping [str , bool ] | None = None ,
924
+ decode_times : bool
925
+ | CFDatetimeCoder
926
+ | Mapping [str , bool | CFDatetimeCoder ]
927
+ | None = None ,
907
928
decode_timedelta : bool | Mapping [str , bool ] | None = None ,
908
929
use_cftime : bool | Mapping [str , bool ] | None = None ,
909
930
concat_characters : bool | Mapping [str , bool ] | None = None ,
@@ -961,9 +982,9 @@ def open_datatree(
961
982
be replaced by NA. Pass a mapping, e.g. ``{"my_variable": False}``,
962
983
to toggle this feature per-variable individually.
963
984
This keyword may not be supported by all the backends.
964
- decode_times : bool or dict-like, optional
985
+ decode_times : bool, CFDatetimeCoder or dict-like, optional
965
986
If True, decode times encoded in the standard NetCDF datetime format
966
- into datetime objects. Otherwise, leave them encoded as numbers.
987
+ into datetime objects. Otherwise, use :py:class:`coders.CFDatetimeCoder` or leave them encoded as numbers.
967
988
Pass a mapping, e.g. ``{"my_variable": False}``,
968
989
to toggle this feature per-variable individually.
969
990
This keyword may not be supported by all the backends.
@@ -987,6 +1008,10 @@ def open_datatree(
987
1008
raise an error. Pass a mapping, e.g. ``{"my_variable": False}``,
988
1009
to toggle this feature per-variable individually.
989
1010
This keyword may not be supported by all the backends.
1011
+
1012
+ .. deprecated:: 2025.01.1
1013
+ Please pass a :py:class:`coders.CFDatetimeCoder` instance initialized with ``use_cftime`` to the ``decode_times`` kwarg instead.
1014
+
990
1015
concat_characters : bool or dict-like, optional
991
1016
If True, concatenate along the last dimension of character arrays to
992
1017
form string arrays. Dimensions will only be concatenated over (and
@@ -1118,7 +1143,10 @@ def open_groups(
1118
1143
cache : bool | None = None ,
1119
1144
decode_cf : bool | None = None ,
1120
1145
mask_and_scale : bool | Mapping [str , bool ] | None = None ,
1121
- decode_times : bool | Mapping [str , bool ] | None = None ,
1146
+ decode_times : bool
1147
+ | CFDatetimeCoder
1148
+ | Mapping [str , bool | CFDatetimeCoder ]
1149
+ | None = None ,
1122
1150
decode_timedelta : bool | Mapping [str , bool ] | None = None ,
1123
1151
use_cftime : bool | Mapping [str , bool ] | None = None ,
1124
1152
concat_characters : bool | Mapping [str , bool ] | None = None ,
@@ -1180,9 +1208,9 @@ def open_groups(
1180
1208
be replaced by NA. Pass a mapping, e.g. ``{"my_variable": False}``,
1181
1209
to toggle this feature per-variable individually.
1182
1210
This keyword may not be supported by all the backends.
1183
- decode_times : bool or dict-like, optional
1211
+ decode_times : bool, CFDatetimeCoder or dict-like, optional
1184
1212
If True, decode times encoded in the standard NetCDF datetime format
1185
- into datetime objects. Otherwise, leave them encoded as numbers.
1213
+ into datetime objects. Otherwise, use :py:class:`coders.CFDatetimeCoder` or leave them encoded as numbers.
1186
1214
Pass a mapping, e.g. ``{"my_variable": False}``,
1187
1215
to toggle this feature per-variable individually.
1188
1216
This keyword may not be supported by all the backends.
@@ -1206,6 +1234,10 @@ def open_groups(
1206
1234
raise an error. Pass a mapping, e.g. ``{"my_variable": False}``,
1207
1235
to toggle this feature per-variable individually.
1208
1236
This keyword may not be supported by all the backends.
1237
+
1238
+ .. deprecated:: 2025.01.1
1239
+ Please pass a :py:class:`coders.CFDatetimeCoder` instance initialized with ``use_cftime`` to the ``decode_times`` kwarg instead.
1240
+
1209
1241
concat_characters : bool or dict-like, optional
1210
1242
If True, concatenate along the last dimension of character arrays to
1211
1243
form string arrays. Dimensions will only be concatenated over (and
0 commit comments