Skip to content

Commit

Permalink
Update grid_proj.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Geary-Layne authored Oct 13, 2023
1 parent e25815a commit 94b2dc4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions python/idsse_common/idsse/common/grid_proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -97,32 +102,32 @@ 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:
raise ValueError(f'Axis must be 0 or 1, but {axis} was given')

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,
Expand Down

0 comments on commit 94b2dc4

Please sign in to comment.