예제 #1
0
def main():
    shaper_path = "/home/standardheld/Documents/Github/shaperConfig/Example/shaper_ssh.toml"
    output_path = "/home/standardheld/CLUSTER2/"
    #compose_path = "/home/marcel/shaper/shaperConfig/Example/docker-compose.yml"
    #shaper_path = "/home/marcel/shaper/shaperConfig/Example/shaper_ssh.toml"
    #output_path = "/home/marcel/CONFIGS/"
    #parser = ParserYAML(shaper_path, compose_path)
    #config = parser.create_config()

    generator = ConfigurationManager(load_shaper_config(shaper_path),
                                     output_path)
    print("Done.")
    generator.create_projects()
    """
예제 #2
0
    def setUp(self):
        # Get execution argument to test a chosen trajectory, with a given file path of xml configuration:
        configuration_file_path = "../TDBP_parameters.xml"

        # Object instance to read parameters from xml.
        self.param = ConfigurationManager(configuration_file_path)

        measure_resolution = self.param.get_string_parameter(
            "General/OutputData/measure_resolution_octave_module")
        if measure_resolution != "yes":
            print "To run this test you have to configure measurement of resolution with oct2py."
            self.skipTest(MyTestCase)
            sys.exit()

        # Get number of cores to parallel processing.
        self.n_cores = self.param.get_int_parameter(
            "General/OutputData/number_cores_used")

        self.get_theoretical_resolution()
        # Using 10% of error.
        self.percentage = 10.0
        self.percentage_rotated = 20.0
예제 #3
0
def main(argv):
    if not os.path.exists(LOG_FILE_PATH):
        os.makedirs(LOG_FILE_PATH)

    logging.basicConfig(level=logging.DEBUG)

    settingsManager = ConfigurationManager('./config.ini')
    zeroPointManager = ZeroPointManager('./zero_points.xml')
    application = QApplication()
    turnTableController = TurnTableController(
        settingsManager=settingsManager, zeroPointManager=zeroPointManager)
    turnTableController.start()

    exitStatusCode = application.exec_()
    logging.debug(f"Exit Status Code: {exitStatusCode}")

    sys.exit(exitStatusCode)
class Test_Parameter(unittest.TestCase):
    """
    Unittest for class ConfigurationManager.

    Attributes
    ----------
    None-.
    
    Methods
    -------
    testGetElement
    testGetElementAsString
    testGetElementAsInt
    testGetElementAsFloat
    testElementExists
    """
    
    def setUp(self):
        self.p = ConfigurationManager("../TDBP_parameters.xml")

    def testGetElement(self):
        parameter = self.p.get_object_parameter("./AirplaneTrajectory/NomAircraft/look_angle")
        self.assertEqual(parameter.tag,"look_angle")
        self.assertRaises(Exception, self.p.get_object_parameter,"./Im_not_exist")
        
    def testGetElementAsString(self):    
        parameter = self.p.get_string_parameter("./AirplaneTrajectory/NomAircraft/look_angle")
        self.assertEqual(parameter, "30")
    
    def testGetElementAsInt(self):    
        parameter = self.p.get_int_parameter("./AirplaneTrajectory/NomAircraft/look_angle")
        self.assertEqual(parameter, 30)
        
    def testGetElementAsFloat(self):    
        parameter = self.p.get_float_parameter("./AirplaneTrajectory/NomAircraft/look_angle")
        self.assertEqual(parameter, 30.0)
        
    def testElementExists(self):    
        parameter = self.p.parameter_exists("./AirplaneTrajectory/NomAircraft/look_angle")
        self.assertTrue(parameter)
        
        parameter = self.p.parameter_exists("FALSE")
        self.assertFalse(parameter)
    def test_get(self):
        config = ConfigurationManager(config_filepath='../../config.json')
        self.assertIsNotNone(config)

        self.assertEqual("127.0.0.1", config.get("p2p")["seed_peers"][0])
예제 #6
0
from PyQt5 import QtCore, QtGui, QtWidgets, QtNetwork
from PyQt5.QtCore import pyqtSlot

from UIClientMainWindow import Ui_clientMainWindow
from MainQueryDialogue import MainQueryDialogue

from Querier import DatabaseQuerier, ElasticSearchQuerier, RestApiQuerier
from DomainTypes import QueryType, QuerierThread
from ConfigurationManager import ConfigurationManager
from ContextTraceHighlighter import ContextTraceHighlighter
from Utilities import *

logger = logging.getLogger(__name__)

cfg = ConfigurationManager()


class ClientMainWindow(QtWidgets.QMainWindow):
    querierstarted = QtCore.pyqtSignal()
    hlcDatabaseQueryLaunched = QtCore.pyqtSignal(int, str)
    tdsDatabaseQueryLaunched = QtCore.pyqtSignal(int, str)
    elasticsearchQueryLaunched = QtCore.pyqtSignal(int, str)
    restApiQueryLaunched = QtCore.pyqtSignal(int, str)

    def __init__(self):
        super(ClientMainWindow, self).__init__()
        self.ui = Ui_clientMainWindow()
        self.ui.setupUi(self)

        self.ui.detailsDock.hide()
예제 #7
0
if __name__ == '__main__':

    # Check for existence of input argument 1 and 2:
    if len(sys.argv) != 3:
        raise Exception(
            "Incorrect input. You must add command-line arguments with xml configuration path (relative), a valid trajectory: nominal trajectory, no nominal trajectory or accelerated trajectory.\n"
        )
        sys.exit()
    else:
        # Get execution argument to test a chosen trajectory, with a given file path of xml configuration:
        configuration_file_path = sys.argv[1]
        test_trajectory = sys.argv[2]

    # Object instance to read parameters from xml.
    param = ConfigurationManager(configuration_file_path)

    # Get number of cores to parallel processing.
    n_cores = param.get_int_parameter("General/OutputData/number_cores_used")
    print "Number of cores to be used during focusing: ", n_cores

    # Run the chosen trajectory.
    if test_trajectory == "nominal trajectory":
        test_nominal_trajectory(param, n_cores)
    elif test_trajectory == "no nominal trajectory":
        test_no_nominal_trajectory(param, n_cores)
    elif test_trajectory == "accelerated trajectory":
        test_accelerated_trajectory(param, n_cores)
    else:
        raise Exception(
            "Incorrect trajectory. Valid trajectories are: nominal trajectory, no nominal trajectory or accelerated trajectory.\n"
 def setUp(self):
     self.p = ConfigurationManager("../TDBP_parameters.xml")
예제 #9
0
 def setUp(self):
     self.param = ConfigurationManager("../TDBP_parameters.xml")
     self.traj_nom = AirplaneTrajectory(self.param)
     self.traj_no_nom = AirplaneTrajectory(self.param)
     self.traj_acc = AirplaneTrajectory(self.param)
예제 #10
0
class Test_AirplaneTrajectory(unittest.TestCase):
    """
    Unittest class for AirplaneTrajectory.
    
    Attributes
    ----------
    param: object (ConfigurationManager instance).
      ConfigurationManager instance to read parameters from file.
    traj_nom: object (AirplaneTrajectory instance).
      AirplaneTrajectory instance for nominal trajectory.
    traj_no_nom: object (AirplaneTrajectory instance).
      AirplaneTrajectory instance for no nominal trajectory.
    traj_acc: object (AirplaneTrajectory instance).
      AirplaneTrajectory instance for no nominal accelerated trajectory.

    Methods
    -------
    test_generate_MRU_nom
    test_generate_MRU_no_nom
    test_generate_MRUV_x
    """

    def setUp(self):
        self.param = ConfigurationManager("../TDBP_parameters.xml")
        self.traj_nom = AirplaneTrajectory(self.param)
        self.traj_no_nom = AirplaneTrajectory(self.param)
        self.traj_acc = AirplaneTrajectory(self.param)

    def test_generate_MRU_nom(self):
        """
        Check if all items in x axis have the same spatial difference (for nominal uniform trajectory)
        flight_y and flight_z must be zero.
        
        flight_vx must be constant over all trajectory, and flight_vy and flight_vz must be zero.
        """
        l_spatial_diff = []
        vel = self.param.get_float_parameter("./AirplaneTrajectory/NomAircraft/v_nom")
        self.traj_nom.generate_MRU_nominal()
        
        # get spatial difference between two coordinates in x.

        for i in range(np.size(self.traj_nom.flight_x)):
            if i!=self.traj_nom.flight_x.size - 1: # Border condition
                spatial_diff = self.traj_nom.flight_x[i] - self.traj_nom.flight_x[i+1]
                l_spatial_diff.append(spatial_diff)
            
        # verify if every spatial difference is almost the same. So we have an equally spaced trajectory over x.
        for i in range(len(l_spatial_diff)):
            if i!=len(l_spatial_diff) - 1: # Border condition
                self.assertAlmostEqual(l_spatial_diff[i], l_spatial_diff[i+1])

        # Check for 0 deviation over y and z axis.
        self.assertTrue(all(i == 0.0 for i in self.traj_nom.flight_y))
        self.assertTrue(all(i == 0.0 for i in self.traj_nom.flight_z))

        # check uniform velocity over x axis.
        self.assertEqual(self.traj_nom.flight_vx[0], vel)
        self.assertTrue(all(i == self.traj_nom.flight_vx[0] for i in self.traj_nom.flight_vx))

        # All velocities in y and z axis must be zero.
        self.assertTrue(all(i == 0.0 for i in self.traj_nom.flight_vy))
        self.assertTrue(all(i == 0.0 for i in self.traj_nom.flight_vz))
        
        
    def test_generate_MRU_no_nom(self):
        """
        Check if all items in x, y and z axis have the same spatial difference (for non nominal uniform trajectory)
        
        flight_vx, flight_vy, flight_vz must be constant over all trajectoryflight_vx.
        """
        # Lists of spatial differences between 2 points in trajectory.
        l_spatial_diffx = []
        l_spatial_diffy = []
        l_spatial_diffz = []
        
        # Get velocity and create Non-uniform trajectory.
        self.traj_no_nom.generate_MRU_no_nominal()
        
        # get spatial difference between two coordinates in xy,z.
        for i in range(np.size(self.traj_no_nom.flight_x)):
            if i!=self.traj_no_nom.flight_x.size - 1: # Border condition
                spatial_diffx = self.traj_no_nom.flight_x[i] - self.traj_no_nom.flight_x[i+1]
                spatial_diffy = self.traj_no_nom.flight_y[i] - self.traj_no_nom.flight_y[i+1]
                spatial_diffz = self.traj_no_nom.flight_z[i] - self.traj_no_nom.flight_z[i+1]
                l_spatial_diffx.append(spatial_diffx)
                l_spatial_diffy.append(spatial_diffy)
                l_spatial_diffz.append(spatial_diffz)
            
        # verify if every spatial difference is almost the same. So we have an equally spaced trajectory (i.e linear) over x, y and z.
        for i in range(len(l_spatial_diffx)):
            if i!=len(l_spatial_diffx) - 1: # Border condition
                self.assertAlmostEqual(l_spatial_diffx[i], l_spatial_diffx[i+1])
                self.assertAlmostEqual(l_spatial_diffy[i], l_spatial_diffy[i+1])
                self.assertAlmostEqual(l_spatial_diffz[i], l_spatial_diffz[i+1])

        # Get round values with 7 decimals to compare and compare uniformity of velocities.
        vxc = np.around(self.traj_no_nom.flight_vx[0], decimals=7) 
        vyc = np.around(self.traj_no_nom.flight_vy[0], decimals=7) 
        vzc = np.around(self.traj_no_nom.flight_vz[0], decimals=7) 

        self.assertTrue(all(i ==vxc for i in np.around(self.traj_no_nom.flight_vx, decimals=7)))
        self.assertTrue(all(i ==vyc for i in np.around(self.traj_no_nom.flight_vy, decimals=7)))
        self.assertTrue(all(i ==vzc for i in np.around(self.traj_no_nom.flight_vz, decimals=7)))

    def test_generate_MRUV_x(self):
        """
        Check if all items in flight_x have an incremental spatial difference (for non nominal non uniform velocity). Items in flight_y and flight_z must be zero.
        
        Check if all items in flight_vx, flight_vy and flight_vz have the same spatial difference (for constant increment of velocity).
        
        flight_ax must be greater than zero, flight_ax, flight_ax must be zero (constant acceleration over x axis).
        """

        # Lists of spatial differences between 2 points in trajectory.
        l_spatial_diffx = []
        l_spatial_diffy = []
        l_spatial_diffz = []

        # Lists of spatial differences between 2 points in velocity.
        l_spatial_diffvx = []
        l_spatial_diffvy = []
        l_spatial_diffvz = []

        # Check for different initial and nominal velocities to have an accelerated trajectory.
        self.assertGreater(self.traj_acc.v_nom, self.traj_acc.v_init)

        # Create Non-uniform accelerated trajectory.
        self.traj_acc.generate_MRUV_x_axis()

        # Get spatial difference between two spatial coordinates in x,y,z.
        for i in range(np.size(self.traj_acc.flight_x)):
            if i!=self.traj_acc.flight_x.size - 1: # Border condition
                spatial_diffx = self.traj_acc.flight_x[i] - self.traj_acc.flight_x[i+1]
                spatial_diffy = self.traj_acc.flight_y[i] - self.traj_acc.flight_y[i+1]
                spatial_diffz = self.traj_acc.flight_z[i] - self.traj_acc.flight_z[i+1]
                l_spatial_diffx.append(spatial_diffx)
                l_spatial_diffy.append(spatial_diffy)
                l_spatial_diffz.append(spatial_diffz)

        # Verify if every coordinate difference in x axis is increased over trajectory. Verify if every coordinate over y and z axis are equal to zero.
        for i in range(len(l_spatial_diffx)):
            if i!=len(l_spatial_diffx) - 1: # Border condition
                self.assertGreater(l_spatial_diffx[i], l_spatial_diffx[i+1])
                self.assertEqual(l_spatial_diffy[i], 0.0)
                self.assertEqual(l_spatial_diffz[i], 0.0)

        # Get spatial difference between two velocities in x,y,z.
        for i in range(np.size(self.traj_acc.flight_vx)):
            if i!=self.traj_acc.flight_vx.size - 1: # Border condition
                spatial_diffvx = self.traj_acc.flight_vx[i] - self.traj_acc.flight_vx[i+1]
                spatial_diffvy = self.traj_acc.flight_vy[i] - self.traj_acc.flight_vy[i+1]
                spatial_diffvz = self.traj_acc.flight_vz[i] - self.traj_acc.flight_vz[i+1]
                l_spatial_diffvx.append(spatial_diffvx)
                l_spatial_diffvy.append(spatial_diffvy)
                l_spatial_diffvz.append(spatial_diffvz)

        # Verify if every velocity difference is almost the same. So we have an linear velocity over x, y and z.
        for i in range(len(l_spatial_diffvx)):
            if i!=len(l_spatial_diffvx) - 1: # Border condition
                self.assertAlmostEqual(l_spatial_diffvx[i], l_spatial_diffvx[i+1]) 
                self.assertAlmostEqual(l_spatial_diffvy[i], l_spatial_diffvy[i+1]) 
                self.assertAlmostEqual(l_spatial_diffvz[i], l_spatial_diffvz[i+1]) 

        # Check for flight_ax greater than zero, flight_ax, flight_ax equals to zero (constant acceleration over x axis).
        self.assertGreater(self.traj_acc.flight_ax, 0.0)
        self.assertEquals(self.traj_acc.flight_ay, 0.0)
        self.assertEquals(self.traj_acc.flight_az, 0.0)
예제 #11
0
class Test_SoftSAR(unittest.TestCase):
    """
    Class for testing SoftSAR module.
    
    Methods
    -------
    get_theoretical_resolution
    test_nominal_trajectory
    test_no_nominal_trajectory
    test_accelerated_trajectory
    """
    def setUp(self):
        # Get execution argument to test a chosen trajectory, with a given file path of xml configuration:
        configuration_file_path = "../TDBP_parameters.xml"

        # Object instance to read parameters from xml.
        self.param = ConfigurationManager(configuration_file_path)

        measure_resolution = self.param.get_string_parameter(
            "General/OutputData/measure_resolution_octave_module")
        if measure_resolution != "yes":
            print "To run this test you have to configure measurement of resolution with oct2py."
            self.skipTest(MyTestCase)
            sys.exit()

        # Get number of cores to parallel processing.
        self.n_cores = self.param.get_int_parameter(
            "General/OutputData/number_cores_used")

        self.get_theoretical_resolution()
        # Using 10% of error.
        self.percentage = 10.0
        self.percentage_rotated = 20.0

    def get_theoretical_resolution(self):
        """
        Get Theoretical resolution -3dB in range and azimuth for unique target in SAR image.
        range resolution: (0.886*c)/(2*B)
        azimuth resolution: (0.886*lambda)/(4*tan(beamwidth/2))

        Parameters
        ----------
        None.

        Returns
        -------
        range_resolution: float
          Range resolution (-3dB).
        azimuthh_resolution: float
          azimuthh resolution (-3dB).
        K: float
          Absolute constant calibration.
        """

        # Get parameters to obtain resolution.
        c = self.param.get_float_parameter("Radar/c")
        sar_B = self.param.get_float_parameter("Radar/B")
        # Using look angle instead squint angle because flat ground.
        sar_look_angle = (self.param.get_float_parameter(
            "AirplaneTrajectory/NomAircraft/look_angle") * np.pi) / 180.

        sar_f0 = self.param.get_float_parameter("Radar/f0")
        sar_beamwidth = (self.param.get_float_parameter("Radar/beamwidth") *
                         np.pi) / 180.
        sar_lambda = c / sar_f0

        self.range_resolution_3dB = (0.886 * c) / (2 * np.sin(sar_look_angle) *
                                                   sar_B)
        self.azimuth_resolution_3dB = (0.886 * sar_lambda) / (
            4 * np.tan(sar_beamwidth / 2))

    def test_nominal_trajectory(self):
        """
        Verify if image resolution has a maximum error of 10% with respect to the expected theoretical resolution in nominal trajectory.
        """

        # Call SoftSAR processor to obtain image resolution.
        range_resolution, azimuth_resolution, K = SoftSAR.test_nominal_trajectory(
            self.param, self.n_cores)

        # Computing percentage error in both directions.
        percentage_range_error = (
            np.abs(self.range_resolution_3dB - range_resolution) *
            100) / range_resolution
        percentage_azimuth_error = (
            np.abs(self.azimuth_resolution_3dB - azimuth_resolution) *
            100) / azimuth_resolution

        # Verify if error is less than 10% in both directions.
        self.assertLessEqual(percentage_range_error, self.percentage)
        self.assertLessEqual(percentage_azimuth_error, self.percentage)

    def test_no_nominal_trajectory(self):
        """
        Verify if image resolution has a maximum error of 10% with respect to the expected theoretical resolution in no nominal trajectory.
        """

        # Call SoftSAR processor to obtain image resolution.
        range_resolution, azimuth_resolution, K = SoftSAR.test_no_nominal_trajectory(
            self.param, self.n_cores)

        # Computing percentage error in both directions.
        percentage_range_error = (
            np.abs(self.range_resolution_3dB - range_resolution) *
            100) / range_resolution
        percentage_azimuth_error = (
            np.abs(self.azimuth_resolution_3dB - azimuth_resolution) *
            100) / azimuth_resolution

        # Verify if error is less than 10% in both directions.
        self.assertLessEqual(percentage_range_error, self.percentage_rotated)
        self.assertLessEqual(percentage_azimuth_error, self.percentage_rotated)

    def test_measure_resolution_ok(self):
        """
        Verify if "General/OutputData/measure_resolution_octave_module" is set to yes in xml configuration file.
        """

        measure_resolution = self.param.get_string_parameter(
            "General/OutputData/measure_resolution_octave_module")
        self.assertEqual(measure_resolution, "yes")

    def test_accelerated_trajectory(self):
        """
        Verify if image resolution has a maximum error of 10% with respect to the expected theoretical resolution in accelerated trajectory.
        """

        # Call SoftSAR processor to obtain image resolution.
        range_resolution, azimuth_resolution, K = SoftSAR.test_accelerated_trajectory(
            self.param, self.n_cores)

        # Computing percentage error in both directions.
        percentage_range_error = (
            np.abs(self.range_resolution_3dB - range_resolution) *
            100) / range_resolution
        percentage_azimuth_error = (
            np.abs(self.azimuth_resolution_3dB - azimuth_resolution) *
            100) / azimuth_resolution

        # Verify if error is less than 10% in both directions.
        self.assertLessEqual(percentage_range_error, self.percentage)
        self.assertLessEqual(percentage_azimuth_error, self.percentage)
예제 #12
0
import pickle
import csv
from evaluation import evaluate

# deserialization of classifier object
classifier_file = open("classifier_data",'rb')
classifier = pickle.load(classifier_file)
classifier_file.close()

# deserialization of parametrizer object
parametrizer_file = open("parametrizer_data",'rb')
parametrizer = pickle.load(parametrizer_file)
parametrizer_file.close()

# testing
test_manager = ConfigurationManager(join(getcwd(),"test"))
test_filenames = test_manager.training_data(0)
for filename in test_manager.test_data(0):
    test_filenames.append(filename)
test_data = get_samples_matrix(test_filenames, parametrizer)

prediction = classifier.predict(test_data)

#Writing to csv file
with open('results.csv', 'w',newline='') as csvfile:
    result_writer=csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL)
    for i,file in enumerate(test_filenames):
        file=file[(len(file)-7):]
        probability=max(prediction[i])
        answer = where(prediction[i,:]==probability)[0][0]
        result_writer.writerow([file] + [answer] + [probability])
예제 #13
0
Adicionada a chamada ao diálogo de ajuste da escala.

Revision 1.1  2012/10/24 17:50:08  diogenes-silva
Adicionado o drop-down para escolher "versus" ou "e" entre os sensores e agora intervalo e número de medições são botões Radio.

'''

import register_application
import sys
import codecs

from ConfigurationManager import ConfigurationManager

sys.stdout = codecs.getwriter('utf-8')(sys.__stdout__)

config = ConfigurationManager()

conectores = (u'INT', u'EXT1', u'EXT2')
tipos = (u'Onda Sonora', u'Nível Sonoro', u'Voltagem', u'Resistência', u'pH',
         u'Temperatura', u'Luz', u'Pêndulo')
unidades = (u'', u'', u'V', u'', u'', u'ºC', u'', u'º')

config.restrict('sensor1_tipo', tipos)
config.restrict('sensor2_tipo', tipos)
config.restrict('sensor1_conector', conectores)
config.restrict('sensor2_conector', conectores + (u'Tempo', ))
#config.restrict('sensores_relacao', ('versus', 'e'))

config.setEnabledWhen('sensor1_calibrar', sensor1_tipo=(u'Pêndulo', ))
config.setEnabledWhen('sensor2_calibrar', sensor2_tipo=(u'Pêndulo', ))
config.setEnabledWhen('sensor2_tipoVisivel', sensor2_conector=conectores)
예제 #14
0
from ConfigurationManager import ConfigurationManager
from os.path import join
from os import getcwd
from MFCCParametrizer import MFCCParametrizer
from ANNClassifier import ANNClassifier
from ResultHandler import ResultHandler
from numpy import asarray
from utilities import *

# Main program loop
configuration_manager = ConfigurationManager(join(getcwd(), "train"))
result_handler = ResultHandler(
    asarray(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']))
setup_results_file = open("setup_results_file.txt", 'a')

for loop_enforcer in range(0, 1):
    for nb_neurons_in_1_layer in [220, 230, 240]:  # Best result yet: 220
        for nb_neurons_in_2_layer in [110, 115, 120]:  # Best result yet: 110
            for shuffle in [True]:
                for max_iter in [200]:
                    for alpha in [0.0001]:
                        for appendEnergy in [False]:
                            for winlen in [0.025]:
                                for winstep in [0.01]:
                                    for numcep in [18]:
                                        for nfilt in [26]:
                                            for nfft in [
                                                    512
                                            ]:  #1024 gives 6.5% better results but increases computing times by 16.7%
                                                for preemph in [
                                                        0.97
예제 #15
0
 def test_start(self):
     bcprot = smartBrainCoin(ConfigurationManager())
from ConfigurationManager import ConfigurationManager
from os import getcwd
from os.path import join

manager = ConfigurationManager(join(getcwd(),"train"))
print("number of all people:")
print(len(manager.persons))
print("train data:")
print(len(manager.training_data(0)))
print(manager.training_data(2))
print("test data:")
print(len(manager.test_data(0)))
print(manager.test_data(0))