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

Function is_moving_domain

src/wrf/util.py:690–827  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

688
689
690def 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.

Callers 10

_get_proj_paramsFunction · 0.85
_set_cross_metaFunction · 0.85
_set_line_metaFunction · 0.85
_combine_dictFunction · 0.85
_cat_filesFunction · 0.85
_join_filesFunction · 0.85
_extract_varFunction · 0.85
geo_boundsFunction · 0.85
vertcrossFunction · 0.85
interplineFunction · 0.85

Calls 7

eitherClass · 0.85
is_multi_fileFunction · 0.85
is_mappingFunction · 0.85
viewkeysFunction · 0.85
get_cached_itemFunction · 0.85
_corners_movedFunction · 0.85
cache_itemFunction · 0.85

Tested by

no test coverage detected