MCPcopy Create free account
hub / github.com/NCAR/wrf-python / _file_times

Function _file_times

src/wrf/util.py:2337–2367  ·  view source on GitHub ↗

Yield a time object for the times found in a sequence of files. If *do_xtime* to True, a :class:`datetime.datetime` object is yielded. Otherwise, a :obj:`float` object is yielded. Args: wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ iterable): WRF-A

(wrfin, do_xtime)

Source from the content-addressed store, hash-verified

2335
2336
2337def _file_times(wrfin, do_xtime):
2338 """Yield a time object for the times found in a sequence of files.
2339
2340 If *do_xtime* to True, a :class:`datetime.datetime` object is yielded.
2341 Otherwise, a :obj:`float` object is yielded.
2342
2343 Args:
2344
2345 wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \
2346 iterable): WRF-ARW NetCDF
2347 data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile`
2348 or an iterable sequence of the aforementioned types.
2349
2350 do_xtime (:obj:`bool`): Set to True to parse the 'XTIME' variable
2351 instead of the 'Times' variable.
2352
2353 Yields:
2354
2355 :class:`datetime.datetime` or :obj:`float`: A
2356 :class:`datetime.datetime` object if *do_xtime* is False,
2357 otherwise a :obj:`float`.
2358
2359 """
2360 if not do_xtime:
2361 times = wrfin.variables["Times"][:, :]
2362 for i in py3range(times.shape[0]):
2363 yield _make_time(times[i, :])
2364 else:
2365 xtimes = wrfin.variables["XTIME"][:]
2366 for i in py3range(xtimes.shape[0]):
2367 yield xtimes[i]
2368
2369
2370def _extract_time_map(wrfin, timeidx, do_xtime, meta=False):

Callers 1

extract_timesFunction · 0.85

Calls 2

py3rangeFunction · 0.85
_make_timeFunction · 0.85

Tested by

no test coverage detected