Return a sequence of time objects. If *do_xtime* is False, the 'XTIME' variable is used and each time object is a :obj:`float`. Otherwise, the 'Times' variable is used, and each time object is a :class:`datetime.datetime` object. Args: wrfin (:class:`netCDF4.Dataset`, :c
(wrfin, timeidx, method="cat", squeeze=True, cache=None,
meta=False, do_xtime=False)
| 2402 | |
| 2403 | |
| 2404 | def extract_times(wrfin, timeidx, method="cat", squeeze=True, cache=None, |
| 2405 | meta=False, do_xtime=False): |
| 2406 | |
| 2407 | """Return a sequence of time objects. |
| 2408 | |
| 2409 | If *do_xtime* is False, the 'XTIME' variable is used and each time object |
| 2410 | is a :obj:`float`. Otherwise, the 'Times' variable is used, and each |
| 2411 | time object is a :class:`datetime.datetime` object. |
| 2412 | |
| 2413 | Args: |
| 2414 | |
| 2415 | wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
| 2416 | iterable): WRF-ARW NetCDF |
| 2417 | data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
| 2418 | or an iterable sequence of the aforementioned types. |
| 2419 | |
| 2420 | timeidx (:obj:`int` or :data:`wrf.ALL_TIMES`): The |
| 2421 | desired time index. This value can be a positive integer, |
| 2422 | negative integer, or |
| 2423 | :data:`wrf.ALL_TIMES` (an alias for None) to return |
| 2424 | all times in the file or sequence. |
| 2425 | |
| 2426 | method (:obj:`str`, optional): The aggregation method to use for |
| 2427 | sequences. Must be either 'cat' or 'join'. |
| 2428 | 'cat' combines the data along the Time dimension. |
| 2429 | 'join' creates a new dimension for the file index. |
| 2430 | The default is 'cat'. |
| 2431 | |
| 2432 | squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
| 2433 | with a size of 1 from being automatically removed from the shape |
| 2434 | of the output. Default is True. |
| 2435 | |
| 2436 | cache (:obj:`dict`, optional): A dictionary of (varname, ndarray) |
| 2437 | that can be used to supply pre-extracted NetCDF variables to the |
| 2438 | computational routines. It is primarily used for internal |
| 2439 | purposes, but can also be used to improve performance by |
| 2440 | eliminating the need to repeatedly extract the same variables |
| 2441 | used in multiple diagnostics calculations, particularly when using |
| 2442 | large sequences of files. |
| 2443 | Default is None. |
| 2444 | |
| 2445 | meta (:obj:`bool`, optional): Set to False to disable metadata. |
| 2446 | |
| 2447 | do_xtime (:obj:`bool`): Set to True to parse the 'XTIME' variable |
| 2448 | instead of the 'Times' variable. Default is False. |
| 2449 | |
| 2450 | Returns: |
| 2451 | |
| 2452 | :class:`xarray.DataArray` or :class:`numpy.ndarray`: A sequence of time |
| 2453 | objects. If *meta* is True, the sequence will be of type |
| 2454 | :class:`xarray.DataArray`, otherwise the sequence is |
| 2455 | :class:`numpy.ndarray`. |
| 2456 | |
| 2457 | """ |
| 2458 | if is_mapping(wrfin): |
| 2459 | return _extract_time_map(wrfin, timeidx, do_xtime) |
| 2460 | |
| 2461 | multitime = is_multi_time_req(timeidx) |
no test coverage detected