9 from __future__
import print_function
13 from opals
import pyDM
18 class Kernel(pyDM.PointKernelEx):
22 if sys.version_info >= (3, 0):
25 super(Kernel, self).__init__()
30 def leafChanged(self, leaf, localTree):
31 print(
"process tile with id = %d" % leaf.id() )
36 def process(self, pt, neighbours):
40 for n
in neighbours.points():
45 pt.info().set(0, neighbours.sizePoint())
46 if neighbours.sizePoint() > 0:
47 zmean = zsum / float(neighbours.sizePoint())
48 pt.info().set(1, zmean)
55 def DM_spatial_processing(filename, maxOutput=1000):
57 dm = pyDM.Datamanager.load(filename,
False,
False)
59 print(
"Unable to open ODM '" + odm +
"'")
63 lf = pyDM.AddInfoLayoutFactory()
64 lf.addColumn(pyDM.ColumnType.int32,
"_pcount")
65 lf.addColumn(pyDM.ColumnType.float_,
"_zmean")
66 layout = lf.getLayout()
67 kernelLayout = lf.getLayout()
71 query = pyDM.QueryDescriptor(
"sphere(r=1)")
77 print(
"Ready to append attribute '_pcount' to '%s'" % filename)
79 print(
"Number of tiles to process = %d" % dm.getPointIndex().sizeLeaf())
84 start = datetime.datetime.now()
89 processor = pyDM.ProcessorEx(dm, query,
None, layout,
False,
None,
None,
False)
92 diff = datetime.datetime.now() - start
93 print(
"Processing took %.2f [s]" % diff.total_seconds() )
101 if len(sys.argv) == 1:
102 print(
"ODM parameter missing")
105 DM_spatial_processing(sys.argv[1])