Return True if the corner points have moved. 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 time steps in the NetCDF file. Args: wrfnc (:class:`netCDF4.Dataset` or :cl
(wrfnc, first_ll_corner, first_ur_corner, latvar, lonvar)
| 638 | |
| 639 | |
| 640 | def _corners_moved(wrfnc, first_ll_corner, first_ur_corner, latvar, lonvar): |
| 641 | """Return True if the corner points have moved. |
| 642 | |
| 643 | This function is used to test for a moving domain, since the WRF output |
| 644 | does not set any flags in the file for this. The test will be performed |
| 645 | for all time steps in the NetCDF file. |
| 646 | |
| 647 | Args: |
| 648 | |
| 649 | wrfnc (:class:`netCDF4.Dataset` or :class:`Nio.NioFile`): A single |
| 650 | NetCDF file object. |
| 651 | |
| 652 | first_ll_corner (:obj:`tuple`): A (latitude, longitude) pair for the |
| 653 | lower left corner found in the initial file. |
| 654 | |
| 655 | first_ur_corner (:obj:`tuple`): A (latitude, longitude) pair for the |
| 656 | upper right corner found in the initial file. |
| 657 | |
| 658 | latvar (:obj:`str`): The latitude variable name to use. |
| 659 | |
| 660 | lonvar (:obj:`str`: The longitude variable name to use. |
| 661 | |
| 662 | |
| 663 | Returns: |
| 664 | |
| 665 | :obj:`bool`: True if the corner points have moved, False otherwise. |
| 666 | |
| 667 | """ |
| 668 | lats = wrfnc.variables[latvar][:] |
| 669 | lons = wrfnc.variables[lonvar][:] |
| 670 | |
| 671 | # Need to check all times |
| 672 | for i in py3range(lats.shape[-3]): |
| 673 | start_idxs = [0] * len(lats.shape) # PyNIO does not support ndim |
| 674 | start_idxs[-3] = i |
| 675 | start_idxs = tuple(start_idxs) |
| 676 | |
| 677 | end_idxs = [-1] * len(lats.shape) |
| 678 | end_idxs[-3] = i |
| 679 | end_idxs = tuple(end_idxs) |
| 680 | |
| 681 | if (first_ll_corner[0] != lats[start_idxs] |
| 682 | or first_ll_corner[1] != lons[start_idxs] |
| 683 | or first_ur_corner[0] != lats[end_idxs] |
| 684 | or first_ur_corner[1] != lons[end_idxs]): |
| 685 | return True |
| 686 | |
| 687 | return False |
| 688 | |
| 689 | |
| 690 | def is_moving_domain(wrfin, varname=None, latvar=either("XLAT", "XLAT_M"), |
no test coverage detected