diff --git a/hazimp/jobs/jobs.py b/hazimp/jobs/jobs.py index d72607a..c52b616 100644 --- a/hazimp/jobs/jobs.py +++ b/hazimp/jobs/jobs.py @@ -633,10 +633,11 @@ def __init__(self): def __call__(self, context, attribute_label, file_list, clip_exposure2all_hazards=False, - file_format=None, variable=None, no_data_value=None): + file_format=None, variable=None, + no_data_value=None, scaling_factor=None): """ Load one or more files and get the value for all the - exposure points. All files have to be of the same attribute. + exposure points. All files have to be of the same attribute and unit. Alternatively a numeric array of the raster data can be passed in. :param context: The context instance, used to move data around. @@ -645,6 +646,8 @@ def __call__(self, context, attribute_label, file_list, clippped to the hazard data, so no hazard values are ignored. :param file_list: A list of files or a single file to be loaded. :param no_data_value: Values in the raster that represent no data. + :param scaling_factor: An optional scaling factor to apply to + the raster values. Context return: exposure_att: Add the file values into this dictionary. @@ -673,8 +676,8 @@ def __call__(self, context, attribute_label, file_list, file_list = misc.mod_file_list(file_list, variable) file_data, extent = raster_module.files_raster_data_at_points( - context.exposure_long, - context.exposure_lat, file_list) + context.exposure_long, context.exposure_lat, + file_list, scaling_factor) file_data[file_data == no_data_value] = np.nan context.exposure_att[attribute_label] = file_data diff --git a/hazimp/raster.py b/hazimp/raster.py index 56ea9e3..6430da4 100755 --- a/hazimp/raster.py +++ b/hazimp/raster.py @@ -98,12 +98,14 @@ def from_file(cls, filename): return instance - def raster_data_at_points(self, lon, lat): + def raster_data_at_points(self, lon, lat, scaling_factor=None): """ Get data at lat lon points of the raster. :param lon: A 1D array of the longitude of the points. :param lat: A 1D array of the latitude of the points. + :param scaling_factor: An optional scaling factor to + apply to the values. :returns: A numpy array, First dimension being the points/sites. """ @@ -150,6 +152,9 @@ def read_cell(i, x, y): values = numpy.where(values == self.no_data_value, numpy.nan, values) + if scaling_factor: + values *= scaling_factor + return values def extent(self): @@ -166,13 +171,14 @@ def extent(self): return min_long, min_lat, max_long, max_lat -def files_raster_data_at_points(lon, lat, files): +def files_raster_data_at_points(lon, lat, files, scaling_factor=None): """ Get data at lat lon points, based on a set of files :param files: A list of files. :param lon: A 1D array of the longitude of the points. :param lat: A 1d array of the latitude of the points. + :param scaling_factor: An optional scaling factor to apply to the values. :returns: reshaped_data, max_extent reshaped_data: A numpy array, shape (sites, hazards) or shape (sites), for one hazard. @@ -185,7 +191,7 @@ def files_raster_data_at_points(lon, lat, files): max_extent = None for filename in files: a_raster = Raster.from_file(filename) - results = a_raster.raster_data_at_points(lon, lat) + results = a_raster.raster_data_at_points(lon, lat, scaling_factor) data.append(results) # Working out the maximum extent diff --git a/hazimp/templates/__init__.py b/hazimp/templates/__init__.py index 1244629..5bf6d38 100644 --- a/hazimp/templates/__init__.py +++ b/hazimp/templates/__init__.py @@ -24,7 +24,8 @@ from hazimp.config_build import add_job from hazimp.templates.earthquake import _earthquake_v1_reader from hazimp.templates.flood import (_flood_fabric_v2_reader, - _flood_contents_v2_reader) + _flood_contents_v2_reader, + _flood_impact_reader) from hazimp.templates.wind import (_wind_v4_reader, _wind_v5_reader, _wind_nc_reader) @@ -63,5 +64,6 @@ def _reader2(config: dict) -> list: EARTHQUAKEV1: _earthquake_v1_reader, FLOODFABRICV2: _flood_fabric_v2_reader, FLOODCONTENTSV2: _flood_contents_v2_reader, - SURGENC: _surge_nc_reader + SURGENC: _surge_nc_reader, + FLOODIMPACT: _flood_impact_reader } diff --git a/hazimp/templates/constants.py b/hazimp/templates/constants.py index aacb3f3..f51a9d6 100644 --- a/hazimp/templates/constants.py +++ b/hazimp/templates/constants.py @@ -8,6 +8,7 @@ FLOODFABRICV2 = 'flood_fabric_v2' FLOODCONTENTSV2 = 'flood_contents_v2' +FLOODIMPACT = 'flood_impact' SURGENC = 'surge_nc' diff --git a/hazimp/templates/flood.py b/hazimp/templates/flood.py index 0c52bf1..34f7cee 100644 --- a/hazimp/templates/flood.py +++ b/hazimp/templates/flood.py @@ -64,8 +64,8 @@ def _flood_impact_reader(config: dict) -> list: add_job(job_insts, LOADCSVEXPOSURE, atts) atts = find_attributes(config, [HAZARDRASTER]) + atts.setdefault('attribute_label', WATER_DEPTH) - atts['attribute_label'] = WATER_DEPTH add_job(job_insts, LOADRASTER, atts) vuln_atts = find_attributes(config, VULNFILE) @@ -79,7 +79,7 @@ def _flood_impact_reader(config: dict) -> list: atts = {'vul_functions_in_exposure': { vulnerability_set_id: - 'SURGE_VULNERABILITY_FUNCTION_ID'}} + 'FLOOD_VULNERABILITY_FUNCTION_ID'}} add_job(job_insts, SIMPLELINKER, atts) if VULNMETHOD in vuln_atts: diff --git a/resources/flood_structural_vul_curves_2024.xml b/resources/flood_structural_vul_curves_2024.xml index 363207b..5ed2421 100644 --- a/resources/flood_structural_vul_curves_2024.xml +++ b/resources/flood_structural_vul_curves_2024.xml @@ -4,67 +4,67 @@ - -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 + -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 0.03 0.04 0.05 0.06 0.33 0.355 0.38 0.38 0.38 0.388 0.396 0.404 0.412 0.42 0.452 0.484 0.516 0.548 0.58 0.582 0.584 0.586 0.588 0.59 0.606 0.622 0.638 0.654 0.67 0.692 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 0.22 0.227142857 0.234285714 0.241428571 0.248571429 0.255714286 0.262857143 0.27 0.32 0.37 0.42 0.47 0.485 0.5 0.514285714 0.528571429 0.542857143 0.557142857 0.571428571 0.585714286 0.6 0.605714286 0.611428571 0.617142857 0.622857143 0.628571429 0.634285714 0.64 0.645714286 0.651428571 0.657142857 0.662857143 0.668571429 0.674285714 0.68 0.68 0.68 0.68 0.68 0.68 0.68 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 + -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 0 0 0 3.89E-17 0.07 0.075 0.08 0.085 0.09 0.096 0.102 0.108 0.114 0.12 0.122 0.124 0.126 0.128 0.13 0.132 0.134 0.136 0.138 0.14 0.145714286 0.151428571 0.157142857 0.162857143 0.168571429 0.174285714 0.18 0.2325 0.285 0.3375 0.39 0.4 0.41 0.424285714 0.438571429 0.452857143 0.467142857 0.481428571 0.495714286 0.51 0.517142857 0.524285714 0.531428571 0.538571429 0.545714286 0.552857143 0.56 0.567142857 0.574285714 0.581428571 0.588571429 0.595714286 0.602857143 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 + -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 0 0 0 2.22E-17 0.04 0.045 0.05 0.05 0.05 0.052 0.054 0.056 0.058 0.06 0.066 0.072 0.078 0.084 0.09 0.09 0.09 0.09 0.09 0.09 0.0975 0.105 0.1125 0.12 0.18 0.24 0.3 0.36 0.375 0.39 0.403 0.416 0.429 0.442 0.455 0.468 0.481 0.494 0.507 0.52 0.532727273 0.545454545 0.558181818 0.570909091 0.583636364 0.596363636 0.609090909 0.621818182 0.634545455 0.647272727 0.66 0.66 0.66 0.66 0.66 0.66 0.66 0.66 0.66 0.66 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 + -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 0 0.016666667 0.033333333 0.05 0.27 0.295 0.32 0.32 0.32 0.326 0.332 0.338 0.344 0.35 0.362 0.374 0.386 0.398 0.41 0.422 0.434 0.446 0.458 0.47 0.485 0.5 0.515 0.53 0.57 0.61 0.65 0.69 0.69 0.69 0.695 0.7 0.705 0.71 0.715 0.72 0.725 0.73 0.735 0.74 0.746363636 0.752727273 0.759090909 0.765454545 0.771818182 0.778181818 0.784545455 0.790909091 0.797272727 0.803636364 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 - -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 + -0.3 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4.0 4.1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 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 0.01 0.02 0.03 0.04 0.4 0.415 0.43 0.43 0.43 0.438 0.446 0.454 0.462 0.47 0.498 0.526 0.554 0.582 0.61 0.614 0.618 0.622 0.626 0.63 0.654 0.678 0.702 0.726 0.75 0.768 0.786 0.804 0.822 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.84 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 diff --git a/tests/test_raster.py b/tests/test_raster.py index b4a1ff1..c37f4ed 100755 --- a/tests/test_raster.py +++ b/tests/test_raster.py @@ -39,6 +39,7 @@ from numpy import asarray, allclose, nan from hazimp.raster import Raster, recalc_max, files_raster_data_at_points +from tests import CWD class TestRaster(unittest.TestCase): @@ -195,6 +196,17 @@ def test3_recalc_max(self): max_extent = recalc_max(old_max_extent, extent) self.assertEqual(old_max_extent, max_extent) + def test4_raster_scaling_factor(self): + files = [str(CWD / 'data/basic_raster.aai')] + + longitude = asarray([0.5, 2.6, 1.3]) + latitude = asarray([9.3, 9.5, 9.5]) + + data, _ = files_raster_data_at_points( + longitude, latitude, files, 0.01) + actual = numpy.array([0.01, numpy.nan, 0.02]) + numpy.testing.assert_equal(data, actual) + if __name__ == "__main__": Suite = unittest.makeSuite(TestRaster, 'test')