MCPcopy
hub / github.com/pydata/xarray / decode

Method decode

xarray/coding/times.py:1407–1428  ·  view source on GitHub ↗
(self, variable: Variable, name: T_Name = None)

Source from the content-addressed store, hash-verified

1405 return variable
1406
1407 def decode(self, variable: Variable, name: T_Name = None) -> Variable:
1408 units = variable.attrs.get("units", None)
1409 if isinstance(units, str) and "since" in units:
1410 dims, data, attrs, encoding = unpack_for_decoding(variable)
1411
1412 units = pop_to(attrs, encoding, "units")
1413 calendar = pop_to(attrs, encoding, "calendar")
1414 dtype = _decode_cf_datetime_dtype(
1415 data, units, calendar, self.use_cftime, self.time_unit
1416 )
1417 transform = partial(
1418 decode_cf_datetime,
1419 units=units,
1420 calendar=calendar,
1421 use_cftime=self.use_cftime,
1422 time_unit=self.time_unit,
1423 )
1424 data = lazy_elemwise_func(data, transform, dtype)
1425
1426 return Variable(dims, data, attrs, encoding, fastpath=True)
1427 else:
1428 return variable
1429
1430
1431def has_timedelta64_encoding_dtype(attrs_or_encoding: dict) -> bool:

Callers 1

decode_cf_variableFunction · 0.95

Calls 6

unpack_for_decodingFunction · 0.90
pop_toFunction · 0.90
lazy_elemwise_funcFunction · 0.90
VariableClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected