Loading [MathJax]/extensions/tex2jax.js
infoMultiFileDemo.py
Author
jo, gm
Date
23.10.2018
1 import opals
2 from opals import Info
3 #
4 # Run opalsInfo and query multiple statistic object for each input file
5 # (output is disabled)
6 #
7 inf = Info.Info(inFile=["strip??.laz"], screenLogLevel=opals.Types.LogLevel.none)
8 inf.enduranceMode = True # make sure that all files are processed even if one isn't readable
9  # (no exception is thrown)
10 inf.run()
11 stats = inf.statistic
12 #
13 # attribute statistics
14 #
15 print(f"Individual statistics of {len(stats)} files")
16 for a in stats:
17  if a.isSetErrorMessage():
18  # if an error occurred the error message member is set and dataset object will
19  # most likely not contain any useful information (except filename)
20  print(f"\tError occurred while during file {a.getFilename()}")
21  print(f"\t\t{a.getErrorMessage()}")
22  else:
23  print(f"\tDetails on file {a.getFilename()}")
24  box = a.getBoundingBox()
25  print(f"\t\t{a.getPointCount()} points with bounding box ({', '.join([ '%.3f' % d for d in box])})")
26 
27 #
28 # Re-run and acquire a single merged statistic object
29 #
30 inf.merge = True
31 inf.run()
32 assert(len(inf.statistic) == 1) # we will only get one statistic object
33 merged_stats = inf.statistic[0]
34 print("\nMerged statistics of all files:")
35 print(f"\tDetails on files {merged_stats.getFilename()}")
36 box = merged_stats.getBoundingBox()
37 print(f"\t\t{merged_stats.getPointCount()} points with bounding box ({', '.join(['%.3f' % d for d in box])})")