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

Function _unpack_netcdf_time_units

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

Source from the content-addressed store, hash-verified

203
204
205def _unpack_netcdf_time_units(units: str) -> tuple[str, str]:
206 # CF datetime units follow the format: "UNIT since DATE"
207 # this parses out the unit and date allowing for extraneous
208 # whitespace. It also ensures that the year is padded with zeros
209 # so it will be correctly understood by pandas (via dateutil).
210 matches = re.match(r"(.+) since (.+)", units)
211 if not matches:
212 raise ValueError(f"invalid time units: {units}")
213
214 delta_units, ref_date = (s.strip() for s in matches.groups())
215 ref_date = _ensure_padded_year(ref_date)
216
217 return delta_units, ref_date
218
219
220def named(name: str, pattern: str) -> str:

Callers 4

_is_time_likeFunction · 0.90

Calls 4

_ensure_padded_yearFunction · 0.85
stripMethod · 0.80
matchMethod · 0.45
groupsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…