Skip to content

Commit

Permalink
Add cell aware getting of gpis in lon lat bbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpaulik authored and Christoph Paulik committed Aug 14, 2017
1 parent 9ddee94 commit c5a36c1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions pygeogrids/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,18 +606,21 @@ def get_bbox_grid_points(self, latmin=-90, latmax=90, lonmin=-180,
longitudes of gpis, if coords=True
"""

index = np.where((self.activearrlat <= latmax) &
(self.activearrlat >= latmin) &
(self.activearrlon <= lonmax) &
(self.activearrlon >= lonmin))

if coords:
return self.activearrlat[index], self.activearrlon[index]
gp_info = np.array(list(self.grid_points()))
gpis = gp_info[:, 0]
lons = gp_info[:, 1]
lats = gp_info[:, 2]
index = np.where((lats <= latmax) &
(lats >= latmin) &
(lons <= lonmax) &
(lons >= lonmin))

if coords is True:
return lats[index], lons[index]
elif both:
return self.activegpis[index], self.activearrlat[index], \
self.activearrlon[index]
return gpis[index], lats[index], lons[index]
else:
return self.activegpis[index]
return gpis[index]

def to_cell_grid(self, cellsize=5.0, cellsize_lat=None, cellsize_lon=None):
"""
Expand Down

0 comments on commit c5a36c1

Please sign in to comment.