From db7a839df09a92ffc78f6f245acc0ae74668998b Mon Sep 17 00:00:00 2001 From: Panos Date: Fri, 5 May 2023 15:15:56 +0200 Subject: [PATCH] corrected mistake in Hazard_update branch for writing a fiat model --- hydromt_fiat/fiat.py | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/hydromt_fiat/fiat.py b/hydromt_fiat/fiat.py index 5abb294d..64b183b5 100644 --- a/hydromt_fiat/fiat.py +++ b/hydromt_fiat/fiat.py @@ -283,16 +283,35 @@ def write(self): """Method to write the complete model schematization and configuration to file.""" self.logger.info(f"Writing model data to {self.root}") - # if self.hazard: - # exposure_output_path = "./hazard/*.nc" - - # self.config["hazard"] = [ - # { - # "type": "vector", - # "dbase_file": exposure_output_path, - # "crs": self.hazard.raster.crs, - # } - # ] + # Save the vulnerability and exposure data in the tables variable. + # Check if data exist + if self.vulnerability: + vulnerability_output_path = "./vulnerability/vulnerability_curves.csv" + self.tables.append( + ( + self.vulnerability.get_table(), + vulnerability_output_path, + {"index": False, "header": False}, + ) + ) + + # Store the vulnerability settings in the config file. + self.config["vulnerability"] = {"dbase_file": vulnerability_output_path} + + if self.exposure: + exposure_output_path = "./exposure/exposure.csv" + self.tables.append( + (self.exposure.exposure_db, exposure_output_path, {"index": False}) + ) + + # Store the exposure settings in the config file. + self.config["exposure"] = [ + { + "type": "vector", + "dbase_file": exposure_output_path, + "crs": self.exposure.crs, + } + ] if self.config: # try to read default if not yet set self.write_config()