xarray_regex.library¶
Functions to retrieve values from filename.
Content
Retrieve date from matched elements. |
|
Find a month number from its name. |
-
xarray_regex.library.
get_date
(matches: List, default_date: Optional[Dict] = None, group: Optional[str] = None) → datetime.datetime¶ Retrieve date from matched elements.
If any element is not found in the filename, it will be replaced by the element in the default date. If no match is found, None is returned.
Supports matches with names from Matcher.NAME_RGX.
- Parameters
matches (list) – Matches from a filename, returned by FileFinder.get_matches
group (str) – If not None, restrict matcher to this group.
default_date (dict, optional) – Default date. Dictionnary with keys: year, month, day, hour, minute, and second. Defaults to 1970-01-01 00:00:00
- Raises
KeyError – If no matchers are found to create a date from.:
-
xarray_regex.library.
_find_month_number
(name: str) → int¶ Find a month number from its name.
Name can be the full name (January) or its three letter abbreviation (jan). The casing does not matter.