def extract_rxp(filename, tmpDir, sbet=None): ''' Extract pointcloud data from raw RXP file to ascii GZ file for further processing ''' print "\n#{}: Opening rxp file {}".format(time.strftime('%X %x'), filename) rxp = RXPFile() if sbet is None: print "\n#{}: Opening rxp file {}".format(time.strftime('%X %x'), filename) rxp.open(filename) else: print "\n#{}: Opening rxp file {} with sbet {}".format(time.strftime('%X %x'), filename, sbet) rxp.open_w_sbet(filename, sbet) results = [] while True: args = rxp.read(SKIP, FILTER) if(args == 0): break results.append(write_extracted(args[0], args[1], args[2], tmpDir)) return [filename, results]
from scanifc import RXPFile import sys import os if __name__ == '__main__': # Get command line arguments, else fail if(len(sys.argv) != 3): print "{} takes two arguments".format(sys.argv[0]) print "Usage: python rxpSplitter.py *.rxp seconds" exit(0) # The rxp file to process filename = sys.argv[1] sec_split = sys.argv[2] # Create directory for split files # inDir/basename_split/ -split rxp files inDir, basename = os.path.split(filename) # Check if split directory exists, if not make it splitDir = os.path.join(inDir, "{}_split".format(basename)) if not os.path.exists(splitDir): os.makedirs(splitDir) rxp = RXPFile() rxp.open(filename) rxp.split_rxp(1, splitDir, True) rxp.close()
os.makedirs(tmpDir) if(PROC_SBET): # The associated SBET file for this RXP filename_sbet = sys.argv[2] basename_sbet = os.path.basename(filename_sbet) # ''' # Initialize processing pool pool = mp.Pool(processes=PROC_CNT) if pool is None: raise Exception("Failed to initialize processing pool.") print "\n#{}: Processing pool initialized with {} workers.".format(time.strftime('%X %x'), PROC_CNT) print "\n#{}: Opening rxp file to split: {}".format(time.strftime('%X %x'), basename) rxp = RXPFile() rxp.open(filename) # ''' print "\n#{}: Spliting rxp file {}".format(time.strftime('%X %x'), basename) rxps_split = rxp.split_rxp(PROC_CNT*2, tmpDir) rxp.close() # ''' # Process the split rxps results = None if(PROC_SBET): results = [pool.apply_async(extract_rxp, args=[rxps, tmpDir, filename_sbet]) for rxps in rxps_split] else: results = [pool.apply_async(extract_rxp, args=[rxps, tmpDir]) for rxps in rxps_split] pool.close() # no more jobs for work pool pool.join() # blocks here until all jobs finish processing