From 3c7a283f1dd142b131bb78450c3db6a7d5046ac0 Mon Sep 17 00:00:00 2001 From: Bill Ladwig Date: Fri, 10 Mar 2017 15:39:44 -0700 Subject: [PATCH] Now uses NaT for times that fail parsing (geo_em files). Fixes #8. --- src/wrf/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wrf/util.py b/src/wrf/util.py index 88eb6e3..f7c0549 100644 --- a/src/wrf/util.py +++ b/src/wrf/util.py @@ -2203,8 +2203,11 @@ def _make_time(timearr): :class:`datetime.datetime`: A datetime object. """ - return dt.datetime.strptime("".join(npbytes_to_str(timearr)), + try: + return dt.datetime.strptime("".join(npbytes_to_str(timearr)), "%Y-%m-%d_%H:%M:%S") + except ValueError: + return np.datetime64("NaT") def _file_times(wrfin, do_xtime): @@ -3234,6 +3237,7 @@ def _get_proj_obj(ob_type, var, wrfin, varname, timeidx, method, squeeze, return proj_obj + def latlon_coords(var, as_np=False): """Return the latitude and longitude coordinates from a :class:`xarray.DataArray` object.