def initializeDB(self, metadata, engine):

		taskInfos = TaskInfo.dbDesign(metadata)
		inputFiles = InputFile.dbDesign(metadata)
		outputFiles = OutputFile.dbDesign(metadata)
		arguments = Argument.dbDesign(metadata)
		gridTasks = GridTask.dbDesign(metadata)
		hosts = Host.dbDesign(metadata)
		taskGroups = TaskGroup.dbDesign(metadata)

		metadata.create_all(engine)
except:
    print ("database already exists")

    engine.execute("USE DistributedController") # select new db

    mySessionClass = sessionmaker(bind=engine)
    mySession = mySessionClass()


    metadata = MetaData()

    taskInfos = TaskInfo.dbDesign(metadata)

    inputFiles = InputFile.dbDesign(metadata)

    outputFiles = OutputFile.dbDesign(metadata)

    arguments = Argument.dbDesign(metadata)

    gridTasks = GridTask.dbDesign(metadata)

    taskGroups = TaskGroup.dbDesign(metadata)

    metadata.create_all(engine)


    #create task group
    taskGroup = TaskGroup.TaskGroup(indexFile, postProcessScript)
    mySession.add(taskGroup)
    mySession.commit()
        truth_file_names = listFilesInDir( folder, 'txt' )
        for filename in truth_file_names :
            truth = TruthFile.read( folder + '\\' + filename )
            tgt_true[ ind ].append( TruthFile.Aircraft( truth, beacon = TGT_BEACON ) )
            own_true[ ind ].append( TruthFile.Aircraft( truth, beacon = OWN_BEACON ) )

errors = []
for ind, folder in enumerate( output_folders ) :
    if folder != '' :
        hist_errors = TrkErrors.HistErrors()

        output_file_names = listFilesInDir( folder, 'txt' )
        truth_ind = 0
        for filename in output_file_names :
            output = OutputFile.read( folder + "\\" + filename )
            trk = OutputFile.Track( output, rack_id = 1, track_type = 2  );
            if trk.dataIsGood :
                truth_ind = int( math.floor( ( int( filename.split( '.' )[ 0 ][ 3: ] ) - 1 ) / N_MONTE_CARLO ) )
                err = TrkErrors.Errors( own_true[ ind ][ truth_ind ], tgt_true[ ind ][ truth_ind ], trk, True )
                hist_errors = hist_errors + err.hist_errors
            #if ind % N_MONTE_CARLO == 0 and ind > 0 :
            #    truth_ind += 1
        errors.append( hist_errors )

n = len( errors )

# Plot horizontal position error
gs = gridspec.GridSpec( 1, n ) 
plt.figure( 1 )
for i in range( n ) :
Example #4
0
    def run(self):
        """ run is the main function managing the key value store.

        When called, it takes in user input, which it uses to exit the program,
        save, or undo the changes made. run also handles the modifications to
        the key value store itself as run is where the changes from insert,
        delete, and update are made to the running key store. Additionally, the
        variables necessary to allow for saving and undoing changes are
        maintained here. Finally, if the program is exited with exit or quit
        changes are saved to file.

        No keyword arguments or return value.
        """

        # This section handles user input and passes it to
        # the handleInput function to change the key value
        # store.
        toSave = True
        while True:
            n = input("Now we can do awesome stuff! You can exit the program "
                      "with exit or quit if you"
                      " want your changes saved, or with abort if you don't. "
                      "You can also save your changes with save and undo"
                      " them with undo! \n")
            # Handle exiting the program here
            if n == "quit" or n == "abort" or n == "exit":
                if n == "abort":
                    toSave = False
                break
            if len(n) == 0:
                continue
            # Handle saving and undoing changes here
            if n == "save":
                self.invokeSave()
                self.reset()
                self.isNewDBFile = False
                continue
            elif n == "undo":
                self.invokeUndo()
                self.reset()
                continue
            else:
                # handle input here
                handleValue = self.handleInput(n.lower())

                # Check the type of return value. If the value is of type
                # None, the key value store is to be updated. The actual
                # renaming, insertion, deletion, and updating happens here.
                if handleValue is not None:
                    if type(handleValue) == renamed:
                        if handleValue.original is not None:
                            self.handleRenamed(handleValue)
                    elif type(handleValue) == Insert:
                        newRow = handleValue.handleInserts(self.dynamicDB)
                        # We keep track of all row that have been inserted since
                        # the last save/undo or loading the program to either
                        # write them to the file or to reverse these changes.
                        self.insertedRows.update(newRow)
                        self.dynamicDB.update(newRow)
                        for key in newRow:
                            print("Successfully inserted ", key, ": ",
                                  newRow[key]['data'], "\n")
                    elif type(handleValue) == Delete:
                        row = handleValue.handleDeletes(self.dynamicDB)
                        for item in row:
                            self.dynamicDB[item]['isFree'] = 'true'
                            # These are in the storage file, so
                            # we should erase them.
                            if 'position' in self.dynamicDB[item]:
                                self.deletedKeys.append(item)
                            else:
                                # This was a new row, so we do not
                                # want to write this to the file.
                                del self.insertedRows[item]
                            # If there were rows updated, we
                            # want to make sure these aren't
                            # written to the file because they
                            # were deleted.
                            if item in self.updatedRows:
                                del self.updatedRows[item]
                            print("Successfully deleted ", item, ": ",
                                  self.dynamicDB[item]['data'], "\n")
                    elif type(handleValue) == Update:
                        updatedRow, replacedRow = handleValue.handleUpdates(
                            self.dynamicDB)
                        if updatedRow is not None and len(updatedRow) > 0:
                            for key in updatedRow:
                                # If this is a new row (inserted after loading
                                # the storage file), then we simply change the
                                # inserted value.
                                if key in self.insertedRows:
                                    self.insertedRows[key] = updatedRow[key]
                                else:
                                    self.updatedRows.update(updatedRow)
                                    if key not in self.replacedRows:
                                        self.replacedRows.update(replacedRow)
                                print("Successfully updated ", key, ": ",
                                      self.dynamicDB[key]['data'], "\n")
        # If the user specified to exit or quit, we save the changes. We don't
        # use invokeSave() as that involves unnecessary updating.
        if toSave:
            OutputFile.saveChanges(self.isNewDBFile, self.storageFile,
                                   self.dynamicDB, self.deletedKeys,
                                   self.insertedRows, self.updatedRows,
                                   self.maximumPosition)
if (flag == "ASC") or (flag == "DESC") or (flag == "asc") or (flag == "desc"):
        correctFlag = True

if (correctFlag == False):
        print("Incorrect sort flag. Please type in only ASC or DESC");
        print("Please restart application and try again.");
        os._exit(0);

sortedArray = Sort.quickSort(sortArray, flag);

#Split Content
del key[:];
del firstName[:];
del lastName[:];

for line in sortedArray:
        splitVals = line.split(',');
        key.append(splitVals[0]);
        
        nameSplit = splitVals[1].split(' ');
        firstName.append(nameSplit[0]);
        lastName.append(nameSplit[1]);

#OutputFile
outputFileDir = 'Files/lab3Output.txt'
OutputFile.writeFile(key, firstName, lastName, outputFileDir);

#PrintOutFile
print("First 15 and Last 15 Sorted Names")
TerminalPrint.PrintOutFile();
                   #'C:\\Users\\pkhomchuk\\My Projects\\UAS - FAA Software\\Tracker\\Radar_3D_4'
                   #'C:\\Users\\pkhomchuk\\My Projects\\UAS - FAA Delivery\\UAS - FAA Software\\Tracker\\Maneuver',
                   #'C:\\Users\\pkhomchuk\\My Projects\\UAS - FAA Delivery\\UAS - FAA Software\\Tracker\\Straight',
                   #'C:\\Users\\pkhomchuk\\My Projects\\UAS - FAA Delivery\\UAS - FAA Software\\Tracker\s\55',
                   '' )

TGT_BEACON = 2332
NMI2FT = 6076.11548

def listFilesInDir( dir, ext ) :
    os.chdir( dir )
    return glob.glob( '*.' + ext )

errors = []
for ind, folder in enumerate( output_folders ) :
    if folder != '' :
        residual_rng_rate = []

        output_file_names = listFilesInDir( folder, 'txt' )
        truth_ind = 0
        for filename in output_file_names :
            output = OutputFile.read( folder + "\\" + filename )
            trk = OutputFile.Track( output, beacon = TGT_BEACON, sensor = 'radar' );
            if trk.dataIsGood :
                residuals = np.ndarray.tolist( NMI2FT * np.transpose( trk.residuals ))
                residual_rng_rate += residuals[ 0 ]

plt.figure( 1 )
plt.boxplot( residual_rng_rate )

plt.show()
import math

truth_file_name = 'C:\\Users\\pkhomchuk\\My Projects\\UAS encounters\\MIT_LL\\55\\truth_mit_ll_19235.txt'
output_file_name = 'C:\\Users\\pkhomchuk\\My Projects\\UAS - FAA Software\\Tracker\\Radar_4D_1\\out4.txt'

NMI2FT = 6076.11548
KNOTS2FT_PER_MIN = NMI2FT / 60

OWN_BEACON = 2331
TGT_BEACON = 2332

truth = TruthFile.read( truth_file_name )
tgt_true = TruthFile.Aircraft( truth, beacon = TGT_BEACON )
own_true = TruthFile.Aircraft( truth, beacon = OWN_BEACON )

output = OutputFile.read( output_file_name )
trk = OutputFile.Track( output, beacon = TGT_BEACON, sensor = 'radar' );

tgt_true_pos_own_enu = ct.geod2enu( own_true.pos_geod, tgt_true.pos_geod )
tgt_true_pos_sph = ct.enu2sph( tgt_true_pos_own_enu )

plt.figure( 1 )
plt.plot( tgt_true_pos_own_enu[ :, ct.EAST ], tgt_true_pos_own_enu[ :, ct.NORTH ], 'g-' )
plt.xlabel( 'East [nmi]' )
plt.ylabel( 'North [nmi]' )
plt.grid()

gs = gridspec.GridSpec( 1, 2 ) 
plt.figure( 2 )
plt.subplot( gs[ 0 ] )
plt.plot( trk.time, 3600 * trk.residuals[ :, 3 ], 'g-' )
Example #8
0
if (flag == "ASC") or (flag == "DESC") or (flag == "asc") or (flag == "desc"):
    correctFlag = True

if (correctFlag == False):
    print("Incorrect sort flag. Please type in only ASC or DESC")
    print("Please restart application and try again.")
    os._exit(0)

sortedArray = Sort.quickSort(sortArray, flag)

#Split Content
del key[:]
del firstName[:]
del lastName[:]

for line in sortedArray:
    splitVals = line.split(',')
    key.append(splitVals[0])

    nameSplit = splitVals[1].split(' ')
    firstName.append(nameSplit[0])
    lastName.append(nameSplit[1])

#OutputFile
outputFileDir = 'Files/lab3Output.txt'
OutputFile.writeFile(key, firstName, lastName, outputFileDir)

#PrintOutFile
print("First 15 and Last 15 Sorted Names")
TerminalPrint.PrintOutFile()
Example #9
0
        truth_file_names = listFilesInDir(folder, 'txt')
        for filename in truth_file_names:
            truth = TruthFile.read(folder + '\\' + filename)
            tgt_true[ind].append(TruthFile.Aircraft(truth, beacon=TGT_BEACON))
            own_true[ind].append(TruthFile.Aircraft(truth, beacon=OWN_BEACON))

errors = []
for ind, folder in enumerate(output_folders):
    if folder != '':
        hist_errors = TrkErrors.HistErrors()

        output_file_names = listFilesInDir(folder, 'txt')
        truth_ind = 0
        for filename in output_file_names:
            output = OutputFile.read(folder + "\\" + filename)
            trk = OutputFile.Track(output, rack_id=1, track_type=2)
            if trk.dataIsGood:
                truth_ind = int(
                    math.floor(
                        (int(filename.split('.')[0][3:]) - 1) / N_MONTE_CARLO))
                err = TrkErrors.Errors(own_true[ind][truth_ind],
                                       tgt_true[ind][truth_ind], trk, True)
                hist_errors = hist_errors + err.hist_errors
            #if ind % N_MONTE_CARLO == 0 and ind > 0 :
            #    truth_ind += 1
        errors.append(hist_errors)

n = len(errors)

# Plot horizontal position error