Skip to content

Commit

Permalink
Deprecate boundary() for geographic_boundary()
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Nov 24, 2023
1 parent c6a9378 commit 6323814
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/source/howtos/spherical_geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ satellite passes. See trollschedule_ how to generate a list of satellite overpas

>>> from pyresample.spherical_utils import GetNonOverlapUnions

>>> area_boundary = area_def.boundary(vertices_per_side=100) # doctest: +SKIP
>>> area_boundary = area_def.geographic_boundary(vertices_per_side=100) # doctest: +SKIP
>>> area_boundary = area_boundary.contour_poly # doctest: +SKIP

>>> list_of_polygons = []
Expand Down
2 changes: 1 addition & 1 deletion pyresample/future/geometry/_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _get_area_boundary(area_to_cover: AreaDefinition) -> GeographicBoundary:
vertices_per_side = None
else:
vertices_per_side = max(max(*area_to_cover.shape) // 100 + 1, 3)
return area_to_cover.boundary(vertices_per_side=vertices_per_side, force_clockwise=True)
return area_to_cover.geographic_boundary(vertices_per_side=vertices_per_side, order="clockwise")
except ValueError as err:
raise NotImplementedError("Can't determine boundary of area to cover") from err

Expand Down
13 changes: 7 additions & 6 deletions pyresample/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ def is_geostationary(self):
"""Whether this geometry is in a geostationary satellite projection or not."""
return False

Check warning on line 293 in pyresample/geometry.py

View check run for this annotation

Codecov / codecov/patch

pyresample/geometry.py#L293

Added line #L293 was not covered by tests

def get_bbox_lonlats(self, vertices_per_side: Optional[int] = None, force_clockwise: bool = True,
def get_bbox_lonlats(self, vertices_per_side: Optional[int] = None,
force_clockwise: bool = True,
frequency: Optional[int] = None) -> tuple:
"""Return the bounding box lons and lats sides.
Expand Down Expand Up @@ -335,7 +336,7 @@ def get_bbox_lonlats(self, vertices_per_side: Optional[int] = None, force_clockw
vertices_per_side = vertices_per_side or frequency
sides_lons, sides_lats = self._get_boundary_sides(coordinates="geographic",
vertices_per_side=vertices_per_side)
warnings.warn("`get_bbox_lonlats` is pending deprecation. Use `area.boundary().sides` instead",
warnings.warn("`get_bbox_lonlats` is pending deprecation. Use `area.geographic_boundary().sides` instead",
PendingDeprecationWarning, stacklevel=2)
if force_clockwise and not self._corner_is_clockwise(
sides_lons[0][-2], sides_lats[0][-2],
Expand Down Expand Up @@ -518,10 +519,10 @@ def get_edge_lonlats(self, vertices_per_side=None, frequency=None):
warnings.warn("The `frequency` argument is pending deprecation, use `vertices_per_side` instead.",

Check warning on line 519 in pyresample/geometry.py

View check run for this annotation

Codecov / codecov/patch

pyresample/geometry.py#L519

Added line #L519 was not covered by tests
PendingDeprecationWarning, stacklevel=2)
msg = "`get_edge_lonlats` is pending deprecation"
msg += "Use `area.boundary(vertices_per_side=vertices_per_side).contour()` instead."
msg += "Use `area.geographic_boundary(vertices_per_side=vertices_per_side).contour()` instead."
warnings.warn(msg, PendingDeprecationWarning, stacklevel=2)
vertices_per_side = vertices_per_side or frequency
lons, lats = self.boundary(vertices_per_side=vertices_per_side).contour()
lons, lats = self.geographic_boundary(vertices_per_side=vertices_per_side).contour()
return lons, lats

def boundary(self, *, vertices_per_side=None, force_clockwise=False, frequency=None):
Expand Down Expand Up @@ -1121,7 +1122,7 @@ def compute_optimal_bb_area(self, proj_dict=None, resolution=None):
proj_dict = self.compute_bb_proj_params(proj_dict)

area = DynamicAreaDefinition(area_id, description, proj_dict)
lons, lats = self.boundary(vertices_per_side=None).contour()
lons, lats = self.geographic_boundary(vertices_per_side=None).contour()
return area.freeze((lons, lats), shape=(height, width))


Expand Down Expand Up @@ -2910,7 +2911,7 @@ def get_geostationary_bounding_box(geos_area, nb_points=50):
"""
warnings.warn("'get_geostationary_bounding_box' is deprecated. Please call "

Check warning on line 2913 in pyresample/geometry.py

View check run for this annotation

Codecov / codecov/patch

pyresample/geometry.py#L2913

Added line #L2913 was not covered by tests
"'area.boundary().contour()' instead.",
"'area.geographic_boundary().contour()' instead.",
DeprecationWarning, stacklevel=2)
return _get_geostationary_bounding_box_in_lonlats(geos_area, nb_points)

Check warning on line 2916 in pyresample/geometry.py

View check run for this annotation

Codecov / codecov/patch

pyresample/geometry.py#L2916

Added line #L2916 was not covered by tests

Expand Down
2 changes: 1 addition & 1 deletion pyresample/gradient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def _get_border_lonlats(geo_def: AreaDefinition, vertices_per_side=None):
"""Get the border x- and y-coordinates."""
if geo_def.is_geostationary:
vertices_per_side = 3600
lon_b, lat_b = geo_def.boundary(vertices_per_side=vertices_per_side).contour(closed=True)
lon_b, lat_b = geo_def.geographic_boundary(vertices_per_side=vertices_per_side).contour(closed=True)
return lon_b, lat_b


Expand Down
2 changes: 1 addition & 1 deletion pyresample/slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _get_chunk_polygons_for_swath_to_crop(swath_to_crop):
line_slice = expand_slice(line_slice)
col_slice = expand_slice(col_slice)
smaller_swath = swath_to_crop[line_slice, col_slice]
smaller_poly = smaller_swath.boundary(vertices_per_side=10).polygon(shapely=True)
smaller_poly = smaller_swath.geographic_boundary(vertices_per_side=10).polygon(shapely=True)
res.append((smaller_poly, (line_slice, col_slice)))
return res

Expand Down
18 changes: 9 additions & 9 deletions pyresample/test/test_geometry/test_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,7 @@ def test_get_boundary_sides_call_geostationary_utility(self, request, area_def_n
def test_polar_south_pole_projection(self, south_pole_area):
"""Test boundary for polar projection around the South Pole."""
areadef = south_pole_area
boundary = areadef.boundary(force_clockwise=False)
boundary = areadef.geographic_boundary(order=None)

# Check boundary shape
height, width = areadef.shape
Expand All @@ -2131,7 +2131,7 @@ def test_north_pole_projection(self, north_pole_area):
"""Test boundary for polar projection around the North Pole."""
areadef = north_pole_area

boundary = areadef.boundary(force_clockwise=False)
boundary = areadef.geographic_boundary(order=None)

# Check boundary shape
height, width = areadef.shape
Expand All @@ -2151,24 +2151,24 @@ def test_full_disc_geostationary_projection(self, geos_fd_area):

# Check default boundary shape
default_n_vertices = 50
boundary = areadef.boundary(vertices_per_side=None)
boundary = areadef.geographic_boundary(vertices_per_side=None, order=None)
assert boundary.vertices.shape == (default_n_vertices, 2)

# Check minimum boundary vertices
n_vertices = 3
minimum_n_vertices = 4
boundary = areadef.boundary(vertices_per_side=n_vertices)
boundary = areadef.geographic_boundary(vertices_per_side=n_vertices, order=None)
assert boundary.vertices.shape == (minimum_n_vertices, 2)

# Check odd number of vertices per side
# - Rounded to the sequent even number (to construct the sides)
n_odd_vertices = 5
boundary = areadef.boundary(vertices_per_side=n_odd_vertices)
boundary = areadef.geographic_boundary(vertices_per_side=n_odd_vertices)
assert boundary.vertices.shape == (n_odd_vertices + 1, 2)

# Check boundary vertices
n_vertices = 10
boundary = areadef.boundary(vertices_per_side=n_vertices, force_clockwise=False)
boundary = areadef.geographic_boundary(vertices_per_side=n_vertices, order=None)

# Check boundary vertices is in correct order
expected_vertices = np.array([[-7.54251621e+01, 3.53432890e+01],
Expand All @@ -2186,7 +2186,7 @@ def test_full_disc_geostationary_projection(self, geos_fd_area):
def test_global_platee_caree_projection(self, global_platee_caree_area):
"""Test boundary for global platee caree projection."""
areadef = global_platee_caree_area
boundary = areadef.boundary(force_clockwise=False)
boundary = areadef.geographic_boundary(order=None)

# Check boundary shape
height, width = areadef.shape
Expand All @@ -2211,7 +2211,7 @@ def test_global_platee_caree_projection(self, global_platee_caree_area):
def test_minimal_global_platee_caree_projection(self, global_platee_caree_minimum_area):
"""Test boundary for global platee caree projection."""
areadef = global_platee_caree_minimum_area
boundary = areadef.boundary(force_clockwise=False)
boundary = areadef.geographic_boundary(order=None)

# Check boundary shape
height, width = areadef.shape
Expand All @@ -2228,7 +2228,7 @@ def test_minimal_global_platee_caree_projection(self, global_platee_caree_minimu
def test_local_area_projection(self, local_meter_area):
"""Test local area projection in meter."""
areadef = local_meter_area
boundary = areadef.boundary(force_clockwise=False)
boundary = areadef.geographic_boundary(order=None)

# Check boundary shape
height, width = areadef.shape
Expand Down
2 changes: 1 addition & 1 deletion pyresample/test/test_geometry/test_swath.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def test_swath_definition(self, create_test_swath):

# Define SwathDefinition and retrieve GeographicBoundary
swath_def = create_test_swath(lons, lats)
boundary = swath_def.boundary(force_clockwise=False)
boundary = swath_def.geographic_boundary(order=None)

# Check boundary shape
height, width = swath_def.shape
Expand Down

0 comments on commit 6323814

Please sign in to comment.