Skip to content

Commit

Permalink
Update imports for command line tools
Browse files Browse the repository at this point in the history
  • Loading branch information
grantbrown committed Mar 24, 2014
1 parent a7022b6 commit 52362a8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
11 changes: 5 additions & 6 deletions laspy/tools/lascopy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from laspy.file import File
from laspy.util import Format
import laspy
import argparse


Expand Down Expand Up @@ -39,7 +38,7 @@ def copy_data(self):
file_version = self.args.file_version[0]
point_format = self.args.point_format[0]
try:
inFile = File(self.args.in_file[0], mode = "r")
inFile = laspy.file.File(self.args.in_file[0], mode = "r")
except Exception, error:
print("There was an error reading in the input file: ")
print(error)
Expand Down Expand Up @@ -91,12 +90,12 @@ def copy_data(self):
new_header.data_format_id = point_format

old_data_rec_len = new_header.data_record_length
old_std_rec_len = Format(old_point_format).rec_len
old_std_rec_len = laspy.util.Format(old_point_format).rec_len
diff = old_data_rec_len - old_std_rec_len
if (diff > 0):
print("Extra Bytes Detected.")

new_header.data_record_length = Format(point_format).rec_len + ((diff > 0)*diff)
new_header.data_record_length = laspy.util.Format(point_format).rec_len + ((diff > 0)*diff)
evlrs = inFile.header.evlrs
if file_version != "1.4" and old_file_version == "1.4":
print("Warning: input file has version 1.4, and output file does not. This may cause trunctation of header data.")
Expand All @@ -108,7 +107,7 @@ def copy_data(self):
if (file_version == "1.3" and len(inFile.header.evlrs) > 1):
print("Too many EVLRs for format 1.3, keeping the first one.")
evlrs = inFile.header.evlrs[0]
outFile = File(self.args.out_file[0], header = new_header, mode = "w", vlrs = inFile.header.vlrs, evlrs = evlrs)
outFile = laspy.file.File(self.args.out_file[0], header = new_header, mode = "w", vlrs = inFile.header.vlrs, evlrs = evlrs)
if outFile.point_format.rec_len != outFile.header.data_record_length:
pass
except Exception, error:
Expand Down
4 changes: 2 additions & 2 deletions laspy/tools/lasexplorer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from laspy.file import File
import laspy
import code


Expand Down Expand Up @@ -30,7 +30,7 @@ def setup(self):
# Try to read in file
print("Reading: " + self.args.in_file[0])
try:
inFile = File(self.args.in_file[0], mode = self.args.mode)
inFile = laspy.file.File(self.args.in_file[0], mode = self.args.mode)
self.inFile = inFile
READ_SUCCESS = True
print("Read successful, file object is called inFile")
Expand Down
8 changes: 4 additions & 4 deletions laspy/tools/lasnoise.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
from laspy.file import File
import laspy
import numpy as np
from math import floor
import math

def main():
parser =argparse.ArgumentParser(description = """Open a file in rw mode and add random noise to X Y and Z.""")
Expand All @@ -19,11 +19,11 @@ def main():



inFile = File(args.in_file[0], mode = "rw")
inFile = laspy.file.File(args.in_file[0], mode = "rw")

def gen_noise(pct, length, amt):
out = np.zeros(length)
indices = np.random.random_integers(0,length-1, floor(float(pct)/100*length))
indices = np.random.random_integers(0,length-1, math.floor(float(pct)/100*length))
vals = np.random.random_integers(-amt,amt, len(indices))
out[indices] += vals
return(out)
Expand Down
4 changes: 2 additions & 2 deletions laspy/tools/lasvalidate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from laspy.file import File
import laspy
import numpy as np
import argparse
import logging
Expand Down Expand Up @@ -111,7 +111,7 @@ def test3(self, inFile):

def validate(self):
print("Reading in file: " + self.args.in_file[0])
inFile = File(self.args.in_file[0], mode = "r")
inFile = laspy.file.File(self.args.in_file[0], mode = "r")
self.test1(inFile)
self.test2(inFile)
self.test3(inFile)
Expand Down
6 changes: 3 additions & 3 deletions laspy/tools/lasverify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from laspy import file as File
import laspy
import argparse

class lasverify():
Expand Down Expand Up @@ -28,8 +28,8 @@ def verify(self):

## Try to open both files in read mode.
try:
inFile1 = File.File(file_1,mode= "r")
inFile2 = File.File(file_2,mode= "r")
inFile1 = laspy.file.File.File(file_1,mode= "r")
inFile2 = laspy.file.File.File(file_2,mode= "r")
except Exception, error:
print("Error reading in files:")
print(error)
Expand Down
4 changes: 2 additions & 2 deletions laspy/tools/lasviewer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from laspy.file import File
import laspy

class lasview():
def __init__(self):
Expand All @@ -24,7 +24,7 @@ def setup(self):
self.mode = self.args.mode
self.dim = self.args.dimension
try:
inFile = File(self.args.in_file[0], mode = "r")
inFile = laspy.file.File(self.args.in_file[0], mode = "r")
self.inFile = inFile
except Exception, error:
print("Error while reading file:")
Expand Down

0 comments on commit 52362a8

Please sign in to comment.