Skip to content

Commit

Permalink
fix problems introduced to resample by a2253b1
Browse files Browse the repository at this point in the history
  • Loading branch information
njwilson23 committed Mar 26, 2017
1 parent a2253b1 commit 634041a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# The short X.Y version.
version = '0.8'
# The full version, including alpha/beta/rc tags.
release = '0.8.2'
release = '0.8.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions karta/raster/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,8 @@ def resample(self, dx, dy, method='nearest'):
"(got {0}, {1})".format(dx, dy))

xmin, xmax, ymin, ymax = self.get_extent()
ny = int((ymax - ymin) // (dy / self.resolution[1])) + 1
nx = int((xmax - xmin) // (dx / self.resolution[0])) + 1
ny = int((ymax - ymin) // dy) + 1
nx = int((xmax - xmin) // dx) + 1

t = self._transform
tnew = (xmin-0.5*dx-0.5*t[4], ymin-0.5*dy-0.5*t[5], dx, dy, t[4], t[5])
Expand Down
2 changes: 1 addition & 1 deletion karta/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.2"
__version__ = "0.8.3"
12 changes: 6 additions & 6 deletions tests/grid_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ def makegrid(start, finish, n, res):
return RegularGrid((0.0, 0.0, res, res, 0.0, 0.0), values=zz)

# node numbers from a line with extreme edges at [0, 1]
g = makegrid(0.0, 1.0-2.0/300, 150, 1.0)
sol = makegrid(0.0, 1.0-6.0/300, 50, 3.0)
gnew = g.resample(3.0, 3.0, method='nearest')
g = makegrid(0.0, 1.0-2.0/300, 150, 2.0)
sol = makegrid(0.0, 1.0-6.0/300, 50, 6.0)
gnew = g.resample(6.0, 6.0, method='nearest')
residue = gnew[:,:] - sol[:,:]
self.assertTrue(np.max(np.abs(residue)) < 1e-12)
return
Expand All @@ -164,9 +164,9 @@ def makegrid(start, finish, n, res):
return RegularGrid((0.0, 0.0, res, res, 0.0, 0.0), values=zz)

# node numbers from a line with extreme edges at [0, 1]
g = makegrid(0.0, 1.0-2.0/300, 150, 1.0)
sol = makegrid(0.0, 1.0-6.0/300, 50, 3.0)
gnew = g.resample(3.0, 3.0, method='linear')
g = makegrid(0.0, 1.0-2.0/300, 150, 2.0)
sol = makegrid(0.0, 1.0-6.0/300, 50, 6.0)
gnew = g.resample(6.0, 6.0, method='linear')
residue = gnew[:,:] - sol[:,:]
self.assertTrue(np.max(np.abs(residue)) < 1e-12)
return
Expand Down

0 comments on commit 634041a

Please sign in to comment.