From 94b2dc48fbd3c5604be4f06a262e2c6653e8f71d Mon Sep 17 00:00:00 2001 From: Geary-Layne <77741618+Geary-Layne@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:08:23 -0600 Subject: [PATCH] Update grid_proj.py --- python/idsse_common/idsse/common/grid_proj.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/python/idsse_common/idsse/common/grid_proj.py b/python/idsse_common/idsse/common/grid_proj.py index c992e510..e5128d72 100644 --- a/python/idsse_common/idsse/common/grid_proj.py +++ b/python/idsse_common/idsse/common/grid_proj.py @@ -31,6 +31,11 @@ class RoundingMethod(Enum): ROUND = 'ROUND' FLOOR = 'FLOOR' +class Flip(Enum): + """Flip axis indicators to be applied flipping pixel orientation""" + BOTH = 'BOTH' + HORIZONTAL = 'HORIZONTAL' + VERTICAL = 'VERTICAL' class GridProj: """ @@ -97,20 +102,20 @@ def shape(self): """Provides access grid space shape: (width, height)""" return self._w, self._h - def flip(self, axis: Optional[int] = None): - """Reverse the order of pixels along the given axis + def flip(self, flip: Flip = Flip.BOTH): + """Reverse the order of pixels for a given orientation Args: - axis (Optional[int]): The default, axis=None, will flip over both axes. + flip (Flip): The default, flip=BOTH, will flip over both axes. """ - if axis is None: + if flip is Flip.BOTH: self._x_offset, self._y_offset = self.map_pixel_to_crs(self.width, self.height) self._dx *= -1 self._dy *= -1 - elif axis == 0: + elif flip is Flip.HORIZONTAL: self._x_offset, _ = self.map_pixel_to_crs(self.width, 0) self._dx *= -1 - elif axis == 1: + elif flip is Flip.VERTICAL: _, self._y_offset = self.map_pixel_to_crs(0, self.height) self._dy *= -1 else: @@ -118,11 +123,11 @@ def flip(self, axis: Optional[int] = None): def fliplr(self): """Reverse the order of the pixels left to right""" - self.flip(0) + self.flip(Flip.HORIZONTAL) def flipud(self): """Reverse the order of the pixels up to down""" - self.flip(1) + self.flip(Flip.VERTICAL) def map_geo_to_pixel( self,