ingenieroariel / geonode-safe

Web based version of SAFE. More information available at http://inasafe.org
Other
2 stars 0 forks source link

Integrid interpolation test fails #9

Open ingenieroariel opened 12 years ago

ingenieroariel commented 12 years ago
======================================================================
ERROR: Population exposure to individual MMI levels can be computed
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/geonode-safe/geonode_safe/tests/test_api.py", line 437, in test_earthquake_exposure_plugin
    raise Exception(msg)
Exception: The server returned the error message: Intergrid interpolation not yet implemented

Link to test code:

https://github.com/ingenieroariel/geonode-safe/blob/master/geonode_safe/tests/test_api.py#L380

Ole's comments were:

The two tests you mention both have to with the current way of automatically rescaling rasters that represent density when they are resampled.

As you know, the issue is that rasters that represent samples of a surface, such as a flood level or earthquake ground shaking, can be resampled without any modification and just represent a finer version of the same surface. However, rasters that represent densities (e.g. people per cell) must be scaled by (h_1/h_0)^2 where h_0 is the the original cellsize and h_1 is the resampled cellsize to reflect the true quantities. For example if population numbers are given on a 4x4 km grid (h_0=4) which is then resampled to a 2x2 km grid (h_1=2), then each cell represents only (2/4)^2 = 1/4 of the population.

We do this by keeping track of the original resolution when the layer is loaded in keyword named 'resolution' and the resampled resolution when used. The relevant methods are

Raster.get_data() - which takes care of the scaling if needed and required
Raster.get_resolution() - which allows the caller to get either actual resolution or native (original) resolution

In Inasafe, the tests for this have been moved to test_clipper.py and test_dock.py