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

Function _cleanup_netcdf_time_units

xarray/coding/times.py:946–955  ·  view source on GitHub ↗
(units: str)

Source from the content-addressed store, hash-verified

944
945
946def _cleanup_netcdf_time_units(units: str) -> str:
947 time_units, ref_date = _unpack_netcdf_time_units(units)
948 time_units = time_units.lower()
949 if not time_units.endswith("s"):
950 time_units = f"{time_units}s"
951 # don't worry about reifying the units if they're out of bounds or
952 # formatted badly
953 with contextlib.suppress(OutOfBoundsDatetime, ValueError):
954 units = f"{time_units} since {format_timestamp(ref_date)}"
955 return units
956
957
958def _encode_datetime_with_cftime(dates, units: str, calendar: str) -> np.ndarray:

Callers 1

Calls 4

format_timestampFunction · 0.90
lowerMethod · 0.80
endswithMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…