Skip to content

Commit

Permalink
added "del model" (#386)
Browse files Browse the repository at this point in the history
* added "del model"

* added logging shutdown to ensure that scenario can be deleted right after run

---------

Co-authored-by: Panos Athanasiou <Panos.Athanasiou@deltares.nl>
  • Loading branch information
GundulaW and panosatha authored Mar 13, 2024
1 parent 7e4c006 commit c87d8b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions flood_adapt/object_model/hazard/hazard.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ def write_water_level_map(self):
model = SfincsAdapter(model_root=self.simulation_paths[0], site=self.site)
zsmax = model.read_zsmax()
zsmax.to_netcdf(self.results_dir.joinpath("max_water_level_map.nc"))
del model

def plot_wl_obs(self):
"""Plot water levels at SFINCS observation points as html
Expand Down
5 changes: 5 additions & 0 deletions flood_adapt/object_model/scenario.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gc
import logging
import os
from pathlib import Path
Expand Down Expand Up @@ -151,3 +152,7 @@ def close_root_logger_handlers():
for handler in handlers:
handler.close()
root_logger.removeHandler(handler)

# Use garbage collector to ensure file handles are properly cleaned up
gc.collect()
logging.shutdown()

0 comments on commit c87d8b7

Please sign in to comment.