def split_region(region): west, east, south, north = topo.positive_region(region) if east > 180: return [(west, 180., south, north), (-180., east-360., south, north)] else: return [region]
def extent(lon, lat, w, h, n): x = num.linspace(-0.5*w, 0.5*w, n) y = num.linspace(-0.5*h, 0.5*h, n) slats, slons = od.ne_to_latlon(lat, lon, y[0], x) nlats, nlons = od.ne_to_latlon(lat, lon, y[-1], x) south = slats.min() north = nlats.max() wlats, wlons = od.ne_to_latlon(lat, lon, y, x[0]) elats, elons = od.ne_to_latlon(lat, lon, y, x[-1]) elons = num.where(elons < wlons, elons + 360., elons) if elons.max() - elons.min() > 180 or wlons.max() - wlons.min() > 180.: west = -180. east = 180. else: west = wlons.min() east = elons.max() return topo.positive_region((west, east, south, north))