Skip to content

Commit

Permalink
tidy up the saving and cleaning of temporarily cached files (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepearson authored Jan 29, 2024
1 parent 15af8ce commit 7fce3ea
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/geofabrics/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,9 +928,13 @@ def run(self):
self.raw_dem.clip_lidar()

# Save a cached copy of DEM to temporary memory cache
cached_file = temp_folder / "raw_lidar_clipped.nc"
self.logger.info(f"Save temp raw DEM to netCDF: {cached_file}")
self.raw_dem.save_and_load_dem(cached_file)
temp_file = temp_folder / f"raw_lidar_clipped.nc"
self.logger.info(f"Save temp raw DEM to netCDF: {temp_file}")
self.raw_dem.save_and_load_dem(temp_file)

# Remove previous cached file and replace with new one
cached_file.unlink()
cached_file = temp_file

# Add a coarse DEM if significant area without LiDAR and a coarse DEM
if self.check_vector_or_raster(key="coarse_dems", api_type="raster"):
Expand All @@ -952,7 +956,7 @@ def run(self):
self.raw_dem.add_coarse_dem(coarse_dem_path, area_threshold)

temp_file = temp_folder / f"raw_dem_{coarse_dem_path.stem}.nc"
self.logger.info(f"Save temp raw DEM to netCDF: {cached_file}")
self.logger.info(f"Save temp raw DEM to netCDF: {temp_file}")
self.raw_dem.save_and_load_dem(temp_file)

# Remove previous cached file and replace with new one
Expand Down

0 comments on commit 7fce3ea

Please sign in to comment.