Skip to content

Commit

Permalink
Merge pull request #222 from mraspaud/fix-unitform-shape
Browse files Browse the repository at this point in the history
Make the uniform shape computation more effective for dask arrays
  • Loading branch information
mraspaud committed Oct 15, 2019
2 parents 995a8be + 254300e commit 9a6fc62
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions pyresample/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,26 @@ def notnull(arr):
return arr.where(arr.notnull(), drop=True)
except AttributeError:
return arr[np.isfinite(arr)]

leftlons = notnull(self.lons[:, 0])
rightlons = notnull(self.lons[:, -1])
middlelons = notnull(self.lons[:, int(self.lons.shape[1] / 2)])
leftlats = notnull(self.lats[:, 0])
rightlats = notnull(self.lats[:, -1])
middlelats = notnull(self.lats[:, int(self.lats.shape[1] / 2)])
leftlons = self.lons[:, 0]
rightlons = self.lons[:, -1]
middlelons = self.lons[:, int(self.lons.shape[1] / 2)]
leftlats = self.lats[:, 0]
rightlats = self.lats[:, -1]
middlelats = self.lats[:, int(self.lats.shape[1] / 2)]
try:
import dask.array as da
except ImportError:
pass
else:
leftlons, rightlons, middlelons, leftlats, rightlats, middlelats = da.compute(leftlons, rightlons,
middlelons, leftlats,
rightlats, middlelats)
leftlons = notnull(leftlons)
rightlons = notnull(rightlons)
middlelons = notnull(middlelons)
leftlats = notnull(leftlats)
rightlats = notnull(rightlats)
middlelats = notnull(middlelats)

az1, az2, width1 = g.inv(leftlons[0], leftlats[0], rightlons[0], rightlats[0])
az1, az2, width2 = g.inv(leftlons[-1], leftlats[-1], rightlons[-1], rightlats[-1])
Expand Down

0 comments on commit 9a6fc62

Please sign in to comment.