Return True if the domain is a moving nest. This function is used to test for a moving domain, since the WRF output does not set any flags in the file for this. The test will be performed for all files in any sequences and across all times in each file. This result is cached inter
(wrfin, varname=None, latvar=either("XLAT", "XLAT_M"),
lonvar=either("XLONG", "XLONG_M"), _key=None)
| 688 | |
| 689 | |
| 690 | def is_moving_domain(wrfin, varname=None, latvar=either("XLAT", "XLAT_M"), |
| 691 | lonvar=either("XLONG", "XLONG_M"), _key=None): |
| 692 | |
| 693 | """Return True if the domain is a moving nest. |
| 694 | |
| 695 | This function is used to test for a moving domain, since the WRF output |
| 696 | does not set any flags in the file for this. The test will be performed |
| 697 | for all files in any sequences and across all times in each file. |
| 698 | |
| 699 | This result is cached internally, so this potentially lengthy check is |
| 700 | only done one time for any given *wrfin* parameter. |
| 701 | |
| 702 | Args: |
| 703 | |
| 704 | wrfin (:class:`netCDF4.Dataset`, :class:`Nio.NioFile`, or an \ |
| 705 | iterable): WRF-ARW NetCDF |
| 706 | data as a :class:`netCDF4.Dataset`, :class:`Nio.NioFile` |
| 707 | or an iterable sequence of the aforementioned types. |
| 708 | |
| 709 | varname (:obj:`str`, optional): A specific NetCDF variable to test, |
| 710 | which must contain a 'coordinates' attribute. If unspecified, |
| 711 | The *latvar* and *lonvar* parameters are used. Default is None. |
| 712 | |
| 713 | first_ur_corner (:obj:`tuple`): A (latitude, longitude) pair for the |
| 714 | upper right corner found in the initial file. |
| 715 | |
| 716 | latvar (:obj:`str` or :class:`either`, optional): The latitude variable |
| 717 | name. Default is :class:`either('XLAT', 'XLAT_M')`. |
| 718 | |
| 719 | lonvar (:obj:`str` or :class:`either`, optional): The latitude variable |
| 720 | name. Default is :class:`either('XLAT', 'XLAT_M')`. |
| 721 | |
| 722 | _key (:obj:`int`, optional): A caching key. This is used for internal |
| 723 | purposes only. Default is None. |
| 724 | |
| 725 | Returns: |
| 726 | |
| 727 | :obj:`bool`: True if the domain is a moving nest, False otherwise. |
| 728 | |
| 729 | """ |
| 730 | |
| 731 | if isinstance(latvar, either): |
| 732 | latvar = latvar(wrfin) |
| 733 | |
| 734 | if isinstance(lonvar, either): |
| 735 | lonvar = lonvar(wrfin) |
| 736 | |
| 737 | # In case it's just a single file |
| 738 | if not is_multi_file(wrfin): |
| 739 | wrfin = [wrfin] |
| 740 | |
| 741 | # Slow, but safe. Compare the corner points to the first item and see |
| 742 | # any move. User iterator protocol in case wrfin is not a list/tuple. |
| 743 | if not is_mapping(wrfin): |
| 744 | wrf_iter = iter(wrfin) |
| 745 | first_wrfnc = next(wrf_iter) |
| 746 | else: |
| 747 | # Currently only checking the first dict entry. |
no test coverage detected