Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Made arrays from GDAL automatically convert to double precision. A fe…
…w characterisation tests had to change slightly as a consequence. This closes issue #75
  • Loading branch information
uniomni committed Feb 14, 2012
1 parent bab4e00 commit 197503a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions engine/test_engine.py
Expand Up @@ -237,7 +237,7 @@ def test_jakarta_flood_study(self):

# Expected values from HKV
expected_values = [2485442, 1537920]
expected_strings = ['<b>2479</b>', '<b>1533</b>']
expected_strings = ['<b>2480</b>', '<b>1533</b>']

i = 0
for filename in ['Flood_Current_Depth_Jakarta_geographic.asc',
Expand Down Expand Up @@ -1021,7 +1021,7 @@ def test_interpolation_tsunami_maumere(self):
assert interpolated_depth > 2.675

# This is a characterisation test for bilinear interpolation
assert numpy.allclose(interpolated_depth, 3.62477215491,
assert numpy.allclose(interpolated_depth, 3.62477204455,
rtol=1.0e-12, atol=1.0e-12)

# Check that interpolated points are within range
Expand Down
12 changes: 6 additions & 6 deletions gui/test_riabdock.py
Expand Up @@ -340,8 +340,8 @@ def test_runEarthquakeFatalityFunction_small(self):

myMessage = ('Unexpected result returned for Earthquake Fatality '
'Function Expected: total population count of '
'847528 , received: \n %s' % myResult)
assert '847528' in myResult, myMessage
'847529 , received: \n %s' % myResult)
assert '847529' in myResult, myMessage

def test_runEarthquakeFatalityFunction_Padang_full(self):
"""Padang 2009 fatalities estimated correctly"""
Expand Down Expand Up @@ -380,8 +380,8 @@ def test_runEarthquakeFatalityFunction_Padang_full(self):

myMessage = ('Unexpected result returned for Earthquake Fatality '
'Function Expected: total population count of '
'31374072 , received: \n %s' % myResult)
assert '31374072' in myResult, myMessage
'31372262 , received: \n %s' % myResult)
assert '31372262' in myResult, myMessage

def test_runTsunamiBuildingImpactFunction(self):
"""Tsunami function runs in GUI with Batemans Bay model"""
Expand Down Expand Up @@ -498,7 +498,7 @@ def test_runFloodPopulationImpactFunction(self):
#print myResult

msg = 'Result not as expected: %s' % myResult
assert '2479' in myResult, msg # This is the expected impact number
assert '2480' in myResult, msg # This is the expected impact number

def test_runFloodPopulationImpactFunction_scaling(self):
"""Flood function runs in GUI with 5x5km population data
Expand Down Expand Up @@ -546,7 +546,7 @@ def test_runFloodPopulationImpactFunction_scaling(self):
msg = 'Result not as expected: %s' % myResult

# Check numbers are OK (within expected errors from resampling)
assert '10481' in myResult, msg
assert '10484' in myResult, msg
assert '2312' in myResult, msg # These are expected impact number

def test_Issue47(self):
Expand Down
5 changes: 5 additions & 0 deletions storage/raster.py
Expand Up @@ -343,12 +343,17 @@ def get_data(self, nan=True, scaling=None):
# Read from raster file
A = self.band.ReadAsArray()

# Convert to double precision (issue #75)
A = numpy.array(A, dtype=numpy.float64)

# Self check
M, N = A.shape
msg = ('Dimensions of raster array do not match those of '
'raster file %s' % self.filename)
assert M == self.rows, msg
assert N == self.columns, msg

# Handle no data value
if nan is False:
pass
else:
Expand Down

0 comments on commit 197503a

Please sign in to comment.