(units: str)
| 203 | |
| 204 | |
| 205 | def _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 | |
| 220 | def named(name: str, pattern: str) -> str: |
no test coverage detected
searching dependent graphs…