Use max_concurrency option for dem, georef, and ortho modules

pull/889/head
Dakota Benjamin 2018-07-01 19:24:37 -04:00
rodzic 4262c64840
commit 37504a2a6c
3 zmienionych plików z 18 dodań i 13 usunięć

Wyświetl plik

@ -72,13 +72,15 @@ class ODMApp(ecto.BlackBox):
'georeferencing': ODMGeoreferencingCell(gcp_file=p.args.gcp,
use_exif=p.args.use_exif,
verbose=p.args.verbose),
'dem': ODMDEMCell(verbose=p.args.verbose),
'dem': ODMDEMCell(max_concurrency=p.args.max_concurrency,
verbose=p.args.verbose),
'orthophoto': ODMOrthoPhotoCell(resolution=p.args.orthophoto_resolution,
t_srs=p.args.orthophoto_target_srs,
no_tiled=p.args.orthophoto_no_tiled,
compress=p.args.orthophoto_compression,
bigtiff=p.args.orthophoto_bigtiff,
build_overviews=p.args.build_overviews,
max_concurrency=p.args.max_concurrency,
verbose=p.args.verbose)
}

Wyświetl plik

@ -13,6 +13,7 @@ from opendm.cropper import Cropper
class ODMDEMCell(ecto.Cell):
def declare_params(self, params):
params.declare("verbose", 'print additional messages to console', False)
params.declare("max_concurrency", "Number of threads", context.num_cores)
def declare_io(self, params, inputs, outputs):
inputs.declare("tree", "Struct with paths", [])
@ -44,12 +45,12 @@ class ODMDEMCell(ecto.Cell):
# Setup terrain parameters
terrain_params_map = {
'flatnonforest': (1, 3),
'flatforest': (1, 2),
'complexnonforest': (5, 2),
'flatnonforest': (1, 3),
'flatforest': (1, 2),
'complexnonforest': (5, 2),
'complexforest': (10, 2)
}
terrain_params = terrain_params_map[args.dem_terrain_type.lower()]
terrain_params = terrain_params_map[args.dem_terrain_type.lower()]
slope, cellsize = terrain_params
# define paths and create working directories
@ -62,7 +63,7 @@ class ODMDEMCell(ecto.Cell):
if not io.file_exists(pc_classify_marker) or rerun_cell:
log.ODM_INFO("Classifying {} using {}".format(tree.odm_georeferencing_model_laz, args.pc_classify))
commands.classify(tree.odm_georeferencing_model_laz,
commands.classify(tree.odm_georeferencing_model_laz,
args.pc_classify == "smrf",
slope,
cellsize,
@ -70,7 +71,7 @@ class ODMDEMCell(ecto.Cell):
initialDistance=args.dem_initial_distance,
verbose=args.verbose
)
with open(pc_classify_marker, 'w') as f:
with open(pc_classify_marker, 'w') as f:
f.write('Classify: {}\n'.format(args.pc_classify))
f.write('Slope: {}\n'.format(slope))
f.write('Cellsize: {}\n'.format(cellsize))
@ -87,7 +88,7 @@ class ODMDEMCell(ecto.Cell):
rerun_cell:
products = []
if args.dsm: products.append('dsm')
if args.dsm: products.append('dsm')
if args.dtm: products.append('dtm')
radius_steps = [args.dem_resolution]
@ -96,7 +97,7 @@ class ODMDEMCell(ecto.Cell):
for product in products:
commands.create_dems(
[tree.odm_georeferencing_model_laz],
[tree.odm_georeferencing_model_laz],
product,
radius=map(str, radius_steps),
gapfill=True,
@ -116,7 +117,7 @@ class ODMDEMCell(ecto.Cell):
'COMPRESS': 'LZW',
'BLOCKXSIZE': 512,
'BLOCKYSIZE': 512,
'NUM_THREADS': 'ALL_CPUS'
'NUM_THREADS': self.params.max_concurrency
})
else:
log.ODM_WARNING('Found existing outputs in: %s' % odm_dem_root)

Wyświetl plik

@ -18,6 +18,7 @@ class ODMOrthoPhotoCell(ecto.Cell):
params.declare("bigtiff", 'Make BigTIFF orthophoto', 'IF_SAFER')
params.declare("build_overviews", 'Build overviews', False)
params.declare("verbose", 'print additional messages to console', False)
params.declare("max_concurrency", "number of threads", context.num_cores)
def declare_io(self, params, inputs, outputs):
inputs.declare("tree", "Struct with paths", [])
@ -125,7 +126,8 @@ class ODMOrthoPhotoCell(ecto.Cell):
'png': tree.odm_orthophoto_file,
'tiff': tree.odm_orthophoto_tif,
'log': tree.odm_orthophoto_tif_log,
'max_memory': max(5, (100 - virtual_memory().percent) / 2)
'max_memory': max(5, (100 - virtual_memory().percent) / 2),
'threads': self.params.max_concurrency
}
system.run('gdal_translate -a_ullr {ulx} {uly} {lrx} {lry} '
@ -135,7 +137,7 @@ class ODMOrthoPhotoCell(ecto.Cell):
'{predictor} '
'-co BLOCKXSIZE=512 '
'-co BLOCKYSIZE=512 '
'-co NUM_THREADS=ALL_CPUS '
'-co NUM_THREADS={threads} '
'-a_srs \"{proj}\" '
'--config GDAL_CACHEMAX {max_memory}% '
'{png} {tiff} > {log}'.format(**kwargs))
@ -149,7 +151,7 @@ class ODMOrthoPhotoCell(ecto.Cell):
'BIGTIFF': self.params.bigtiff,
'BLOCKXSIZE': 512,
'BLOCKYSIZE': 512,
'NUM_THREADS': 'ALL_CPUS'
'NUM_THREADS': self.params.max_concurrency
})
if self.params.build_overviews: