How to use the regionmask.core.utils._wrapAngle function in regionmask

To help you get started, we’ve selected a few regionmask examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mathause / regionmask / regionmask / core / mask.py View on Github external
lat_orig = lat

    lon, lat = _extract_lon_lat(lon_or_obj, lat, lon_name, lat_name)

    lon = np.asarray(lon)
    lat = np.asarray(lat)

    # automatically detect whether wrapping is necessary
    if wrap_lon is None:
        grid_is_180 = _is_180(lon.min(), lon.max())

        wrap_lon = not regions_is_180 == grid_is_180

    lon_orig = lon.copy()
    if wrap_lon:
        lon = _wrapAngle(lon, wrap_lon)

    if method not in (None, "rasterize", "shapely", "legacy"):
        msg = "Method must be None or one of 'rasterize', 'shapely', or 'legacy'."
        raise ValueError(msg)

    if method is None:
        method = _determine_method(lon, lat)
    elif method == "rasterize":
        method = _determine_method(lon, lat)
        if "rasterize" not in method:
            msg = "`lat` and `lon` must be equally spaced to use `method='rasterize'`"
            raise ValueError(msg)
    elif method == "legacy":
        msg = "The method 'legacy' will be removed in a future version."
        warnings.warn(msg, FutureWarning, stacklevel=3)