Skip to content

Commit

Permalink
fix pylint flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
sliu008 committed Nov 20, 2023
1 parent fcd9898 commit 20751de
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions podaac/subsetter/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import pandas as pd
import xarray as xr
import xarray.coding.times
from shapely.geometry import Point
from shapely.geometry import Point, Polygon, MultiPolygon
from shapely.ops import transform

from podaac.subsetter import gpm_cleanup as gc
Expand Down Expand Up @@ -959,21 +959,18 @@ def subset_with_shapefile(dataset: xr.Dataset,
# assumption that the shapefile is -180,180.
if is_360(dataset[lon_var_name], lon_scale, lon_offset):
# Transform
def convert_180_to_360(lon, lat):
return tuple(map(lambda value: value + 360 if value < 0 else value, lon)), lat

def translate_longitude(geometry):
def translate_point(point):
# Translate the point's x-coordinate (longitude) by adding 360
return Point((point.x + 360) % 360, point.y)

def translate_polygon(polygon):
def translate_coordinates(coords):
first_coord = coords[0]
if len(coords[0]) == 2:
return [((x+360)%360, y) for x,y in coords]
elif len(coords[0]) == 3:
return [((x+360)%360, y, z) for x,y,z in coords]
return [((x + 360) % 360, y) for x, y in coords]
if len(coords[0]) == 3:
return [((x + 360) % 360, y, z) for x, y, z in coords]
return coords

exterior = translate_coordinates(polygon.exterior.coords)

Expand All @@ -984,7 +981,7 @@ def translate_coordinates(coords):

return Polygon(exterior, interiors)

if isinstance(geometry, (Point, Polygon)):
if isinstance(geometry, (Point, Polygon)): # pylint: disable=no-else-return
return translate_point(geometry) if isinstance(geometry, Point) else translate_polygon(geometry)
elif isinstance(geometry, MultiPolygon):
# Translate each polygon in the MultiPolygon
Expand Down

0 comments on commit 20751de

Please sign in to comment.