Decode the given Dataset or Datastore according to CF conventions into a new Dataset. Parameters ---------- obj : Dataset or DataStore Object to decode. concat_characters : bool, optional Should character arrays be concatenated to strings, for example: ["
(
obj: T_DatasetOrAbstractstore,
concat_characters: bool = True,
mask_and_scale: bool = True,
decode_times: bool | CFDatetimeCoder | Mapping[str, bool | CFDatetimeCoder] = True,
decode_coords: bool | Literal["coordinates", "all"] = True,
drop_variables: T_DropVariables = None,
use_cftime: bool | None = None,
decode_timedelta: bool
| CFTimedeltaCoder
| Mapping[str, bool | CFTimedeltaCoder]
| None = None,
)
| 496 | |
| 497 | |
| 498 | def decode_cf( |
| 499 | obj: T_DatasetOrAbstractstore, |
| 500 | concat_characters: bool = True, |
| 501 | mask_and_scale: bool = True, |
| 502 | decode_times: bool | CFDatetimeCoder | Mapping[str, bool | CFDatetimeCoder] = True, |
| 503 | decode_coords: bool | Literal["coordinates", "all"] = True, |
| 504 | drop_variables: T_DropVariables = None, |
| 505 | use_cftime: bool | None = None, |
| 506 | decode_timedelta: bool |
| 507 | | CFTimedeltaCoder |
| 508 | | Mapping[str, bool | CFTimedeltaCoder] |
| 509 | | None = None, |
| 510 | ) -> Dataset: |
| 511 | """Decode the given Dataset or Datastore according to CF conventions into |
| 512 | a new Dataset. |
| 513 | |
| 514 | Parameters |
| 515 | ---------- |
| 516 | obj : Dataset or DataStore |
| 517 | Object to decode. |
| 518 | concat_characters : bool, optional |
| 519 | Should character arrays be concatenated to strings, for |
| 520 | example: ["h", "e", "l", "l", "o"] -> "hello" |
| 521 | mask_and_scale : bool, optional |
| 522 | Lazily scale (using scale_factor and add_offset) and mask |
| 523 | (using _FillValue). |
| 524 | decode_times : bool | CFDatetimeCoder | Mapping[str, bool | CFDatetimeCoder], optional |
| 525 | Decode cf times (e.g., integers since "hours since 2000-01-01") to |
| 526 | np.datetime64. |
| 527 | decode_coords : bool or {"coordinates", "all"}, optional |
| 528 | Controls which variables are set as coordinate variables: |
| 529 | |
| 530 | - "coordinates" or True: Set variables referred to in the |
| 531 | ``'coordinates'`` attribute of the datasets or individual variables |
| 532 | as coordinate variables. |
| 533 | - "all": Set variables referred to in ``'grid_mapping'``, ``'bounds'`` and |
| 534 | other attributes as coordinate variables. |
| 535 | drop_variables : str or iterable, optional |
| 536 | A variable or list of variables to exclude from being parsed from the |
| 537 | dataset. This may be useful to drop variables with problems or |
| 538 | inconsistent values. |
| 539 | use_cftime : bool, optional |
| 540 | Only relevant if encoded dates come from a standard calendar |
| 541 | (e.g. "gregorian", "proleptic_gregorian", "standard", or not |
| 542 | specified). If None (default), attempt to decode times to |
| 543 | ``np.datetime64[ns]`` objects; if this is not possible, decode times to |
| 544 | ``cftime.datetime`` objects. If True, always decode times to |
| 545 | ``cftime.datetime`` objects, regardless of whether or not they can be |
| 546 | represented using ``np.datetime64[ns]`` objects. If False, always |
| 547 | decode times to ``np.datetime64[ns]`` objects; if this is not possible |
| 548 | raise an error. |
| 549 | |
| 550 | .. deprecated:: 2025.01.1 |
| 551 | Please pass a :py:class:`coders.CFDatetimeCoder` instance initialized with ``use_cftime`` to the ``decode_times`` kwarg instead. |
| 552 | |
| 553 | decode_timedelta : bool | CFTimedeltaCoder | Mapping[str, bool | CFTimedeltaCoder], optional |
| 554 | If True or :py:class:`CFTimedeltaCoder`, decode variables and |
| 555 | coordinates with time units in |
searching dependent graphs…