From 3d96c7ccbe2997c1e7ab1da86e616b873d3f7c3f Mon Sep 17 00:00:00 2001 From: Ole Nielsen Date: Fri, 28 Oct 2011 21:40:33 +0700 Subject: [PATCH] A bugger - messy issue. See issue #171 --- .../plugins/earthquake/allen_fatality_model.py | 16 +++++++++++----- impact/plugins/flood/HKV_flood_study.py | 16 ++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/impact/plugins/earthquake/allen_fatality_model.py b/impact/plugins/earthquake/allen_fatality_model.py index e87fe6e..4ad6b36 100644 --- a/impact/plugins/earthquake/allen_fatality_model.py +++ b/impact/plugins/earthquake/allen_fatality_model.py @@ -32,14 +32,20 @@ def run(layers, population = layers[1] # Scale resampled population density + current_res = population.get_resolution()[0] - native_res = float(population.get_keywords()['resolution']) + keywords = population.get_keywords() + if 'resolution' in keywords: + # Clunky - see issue #171 + native_res = float(keywords['resolution']) - #print 'current res', current_res - #print 'native res', native_res + #print 'current res', current_res + #print 'native res', native_res - scaling = (current_res / native_res) ** 2 - #print 'scaling', scaling + scaling = (current_res / native_res) ** 2 + #print 'scaling', scaling + else: + scaling = 1 # Extract data H = intensity.get_data(nan=0) diff --git a/impact/plugins/flood/HKV_flood_study.py b/impact/plugins/flood/HKV_flood_study.py index d30b69b..ad46095 100644 --- a/impact/plugins/flood/HKV_flood_study.py +++ b/impact/plugins/flood/HKV_flood_study.py @@ -39,14 +39,18 @@ def run(layers): # Scale resampled population density # FIXME (Ole) - TODO current_res = population.get_resolution()[0] - native_res = float(population.get_keywords()['resolution']) + keywords = population.get_keywords() + if 'resolution' in keywords: + # Clunky - see issue #171 + native_res = float(keywords['resolution']) - #print 'current res', current_res - #print 'native res', native_res - - scaling = (current_res / native_res) ** 2 - #print 'scaling', scaling + #print 'current res', current_res + #print 'native res', native_res + scaling = (current_res / native_res) ** 2 + #print 'scaling', scaling + else: + scaling = 1 # Extract data as numeric arrays D = inundation.get_data(nan=0.0) # Depth