Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.

Commit

Permalink
Fix randomizer example
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontaigu committed Oct 4, 2020
1 parent c4ab401 commit eb54a46
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions examples/field-randomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@


def main(args):
print(args.exclude)

files = [args.in_path] if args.in_path.is_file() else list(args.in_path.glob("*.la[s-z]"))

if args.out_path.suffix and len(files) > 1:
Expand All @@ -19,7 +17,7 @@ def main(args):

las = pylas.read(path)

dimensions = (dim for dim in las.point_format.dimensions if dim not in args.exclude)
dimensions = (dim for dim in las.point_format.dimensions if dim.name not in args.exclude)
for dimension in dimensions:
print(f"\t{dimension.name}", end='')
if dimension.kind == pylas.DimensionKind.FloatingPoint:
Expand All @@ -34,7 +32,10 @@ def main(args):
las[dimension.name] = np.random.randint(dimension.min, dimension.max + 1, len(las.points), type_str)
print()

las.write(args.out_path / path.name)
if args.out_path.suffix:
las.write(args.out_path)
else:
las.write(args.out_path / path.name)


if __name__ == '__main__':
Expand Down
9 changes: 6 additions & 3 deletions examples/recursive-split.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import sys
from pathlib import Path
from typing import List
from typing import Optional

Expand Down Expand Up @@ -36,7 +37,7 @@ def main():
parser.add_argument("input_file")
parser.add_argument("output_dir")
parser.add_argument("size", type=tuple_size, help="eg: 50x64.17")
parser.add_argument("--points-per-iter", default=10**6)
parser.add_argument("--points-per-iter", default=10**6, type=int)

args = parser.parse_args()

Expand All @@ -57,7 +58,7 @@ def main():
print(f"{count / file.header.point_count * 100}%")

# For performance we need to use copy
# so that the arrays underlying arrays are contiguous
# so that the underlying arrays are contiguous
x, y = points.x.copy(), points.y.copy()

point_piped = 0
Expand All @@ -67,7 +68,8 @@ def main():

if np.any(mask):
if writers[i] is None:
writers[i] = pylas.open(f"{sys.argv[2]}/output_{i}.laz",
output_path = Path(sys.argv[2]) / f"output_{i}.laz"
writers[i] = pylas.open(output_path,
mode='w',
header=file.header)
sub_points = points[mask]
Expand All @@ -77,6 +79,7 @@ def main():
if point_piped == len(points):
break
count += len(points)
print(f"{count / file.header.point_count * 100}%")
finally:
for writer in writers:
if writer is not None:
Expand Down

0 comments on commit eb54a46

Please sign in to comment.