def parseConfig(config_file):
    config_parser = ConfigParser.RawConfigParser()
    config_parser.read(config_file)

    data = { 'K'     : 2,
             'L'     : 0,
             'gt'    : None,
             'alpha' : None,
             'beta'  : None,
             'gamma' : None }

    if config_parser.sections() == []:
        raise IOError("Invalid configuration file.")
    if config_parser.has_section('Ground Truth'):
        config.readVisualization(config_parser, 'Ground Truth', os.path.dirname(config_file), options)
        config.readFilter(config_parser, 'Ground Truth', os.path.dirname(config_file), options)
        config.readAlgorithm(config_parser, 'Ground Truth', os.path.dirname(config_file), options)
        config.readMgsSamples(config_parser, 'Ground Truth', os.path.dirname(config_file), options)
        data['gt'] = config.readVector(config_parser, 'Ground Truth', 'gt', float)
        data['L'] = len(data['gt'])
        data['alpha'], data['beta'], data['gamma'] = \
            config.getParameters(config_parser, 'Ground Truth', os.path.dirname(config_file), data['K'], data['L'])
        config.readStrategy(config_parser, 'Ground Truth', options)
        result = loadResult()
        if not result['states']:
            result['states'] = config.readSeeds(config_parser, 'Ground Truth', 'seeds')
        result = sample(result, data)
    if config_parser.has_section('Experiment'):
        config.readVisualization(config_parser, 'Experiment', os.path.dirname(config_file), options)
        config.readFilter(config_parser, 'Experiment', os.path.dirname(config_file), options)
        config.readAlgorithm(config_parser, 'Experiment', os.path.dirname(config_file), options)
        config.readMgsSamples(config_parser, 'Experiment', os.path.dirname(config_file), options)
        data['L'] = int(config_parser.get('Experiment', 'bins'))
        data['alpha'], data['beta'], data['gamma'] = \
            config.getParameters(config_parser, 'Experiment', os.path.dirname(config_file), data['K'], data['L'])
        config.readStrategy(config_parser, 'Experiment', options)
        result = loadResult()
        result = sample(result, data)
    if options['video']:
        save_video()
    if options['save']:
        saveResult(result)
    else:
        if options['savefig']:
            importMatplotlib('Agg')
            from matplotlib.pyplot import savefig
            vis.plotSampling(result, options, data)
#            savefig(options['savefig'], bbox_inches='tight', pad_inches=0)
            savefig(options['savefig'])
        else:
            importMatplotlib()
            from matplotlib.pyplot import show
            vis.plotSampling(result, options, data)
            show()
Exemplo n.º 2
0
def parseConfig(config_file):
    config_parser = ConfigParser.RawConfigParser()
    config_parser.read(config_file)

    if config_parser.sections() == []:
        raise IOError("Invalid configuration file.")
    if config_parser.has_section('Counts'):
        config.readVisualization(config_parser, 'Counts', os.path.dirname(config_file), options)
        config.readAlgorithm(config_parser, 'Counts', os.path.dirname(config_file), options)
        config.readMgsSamples(config_parser, 'Counts', os.path.dirname(config_file), options)
        counts = config.readCounts(config_parser, 'Counts')
        K, L   = len(counts), len(counts[0])
        alpha, beta, gamma = config.getParameters(config_parser, 'Counts', os.path.dirname(config_file), K, L)
        result = call_posterior(counts, alpha, beta, gamma)
        if options['save']:
            saveResult(result)
        else:
            if options['savefig']:
                importMatplotlib('Agg')
                from matplotlib.pyplot import savefig
                vis.plotBinning(result, options)
                savefig(options['savefig'], bbox_inches='tight', pad_inches=0)
            else:
                importMatplotlib()
                from matplotlib.pyplot import show
                vis.plotBinning(result, options)
                show()
    if config_parser.has_section('Trials'):
        config.readVisualization(config_parser, 'Trials', os.path.dirname(config_file), options)
        config.readAlgorithm(config_parser, 'Trials', os.path.dirname(config_file), options)
        config.readMgsSamples(config_parser, 'Trials', os.path.dirname(config_file), options)
        binsize   = config_parser.getint('Trials', 'binsize')
        timings   = config.readMatrix(config_parser, 'Trials', 'timings', int)
        srange    = None
        if config_parser.has_option('Trials', 'range'):
            srange = config.readVector(config_parser, 'Trials', 'range', int)
        x, counts = timingsToCounts(timings, binsize, srange)
        K, L   = len(counts), len(counts[0])
        alpha, beta, gamma = config.getParameters(config_parser, 'Trials', os.path.dirname(config_file), K, L)
        result    = call_posterior(counts, alpha, beta, gamma)
        if options['save']:
            saveResult(result)
        else:
            if options['savefig']:
                importMatplotlib('Agg')
                from matplotlib.pyplot import savefig
                vis.plotBinningSpikes(x, timings, result, options)
                savefig(options['savefig'], bbox_inches='tight', pad_inches=0)
            else:
                importMatplotlib()
                from matplotlib.pyplot import show
                vis.plotBinningSpikes(x, timings, result, options)
                show()
Exemplo n.º 3
0
                    '.log',
                    format='%(levelname)s - %(asctime)s: %(message)s',
                    level=logging.DEBUG)

global Waypoints, NewWaypoint, enMision, distanciaAnewWayp, distanciaLlegadaWayp, modo, velocidadBote, actualAvoid, limiteBateria, modoAvoid, avoidDistancia, home, limite_distancia, limite_distancia2
separador = "----------------"
Waypoints = []
NewWaypointEv = []
enMision = 0
distanciaAnewWayp = 0
actualAvoid = 0
modo = "INICIO"
modoAvoid = "NORMAL"
home = []

config.getParameters()
distanciaLlegadaWayp = config.distanciaLlegadaWayp
limiteBateria = config.limiteBateria
velocidadBote = config.velocidadBote
limite_distancia = config.limite_distancia
limite_distancia2 = config.limite_distancia2
avoidDistancia = config.avoidDistancia


def clearMission(vehiculo):

    ##    se cancela la mision del vehiculo;param vehiculo ;return

    # mensj("Se cancela mision.",0)
    cmds = vehiculo.commands
    vehiculo.commands.clear()