Esempio n. 1
0
def save_data(df, truth, output_path, truth_path, verbose, force):
    """Save data to the OUTPUT_PATH."""
    if os.path.exists(output_path) or os.path.exists(truth_path):
        if not force:
            if verbose:
                print('Not overwriting "%s"/"%s" as --force is not passed.' %
                      (output_path, truth_path))
            output_path = seqfile.findNextFile(prefix=output_path, base=1)
            truth_path = seqfile.findNextFile(prefix=truth_path, base=1)

            if verbose:
                print('Instead, writing to "%s"/"%s"' %
                      (output_path, truth_path))
        else:
            if verbose:
                print('Overwriting "%s"/"%s"' % (output_path, truth_path))
    else:
        if verbose:
            print('Writing output to "%s"/"%s"' % (output_path, truth_path))

    df.to_csv(output_path, index=False)
    truth.to_csv(output_path, index=False)
Esempio n. 2
0
def main(): #Saves data to csv file and plots data vs time
    t=0
    incoming=0
    line1=[]


    RPM=[]   #initialize data
    Time=[]
    data={"Time":Time,"RPM":RPM}

    iTime=time.time()
    try:
            ArduinoSerial = serial.Serial(port='COM9', baudrate=115200)# NUMBER 0 ###############  NUMBER 0
            #### Check COM in use with arduino app  ######
            ArduinoSerial.flushInput()
            print('Recording Data...')
            print('Press Ctrl c to finish recording')
            ii=0
            while 1:
                ser_bytes = ArduinoSerial.readline() #reads data from arduino
                incoming = str(ser_bytes[0:len(ser_bytes)-2].decode("utf-8")) #has -2 to get rid of '\n'
                [a,t]=sepIncoming(incoming) #if more sensors used have to edit function
                A=a
                t=str(int(t)/1000)

                data["Time"].append(t)
                data["RPM"].append(A)


##                line1=live_plotter_xy(tim,Adata,PortA,line1) # NUMBER 5.1 ###################### NUMBER 5.1
##                ii+=1
##                if ii>120:    #set time to take data
##                    break

    except:
        if time.time()-iTime < 2:
            print('There was an error, check connections and restart')
        else:
            in_path = os.path.expanduser('~\Documents\Aero Reasearch\JR3-vs-ATI-Testing\Tachometer\\tach_data')  ######Edit where file saves here ##########
            dataName=seqfile.findNextFile(in_path, prefix='tach_data_', suffix='.csv')
            out_path = dataName #saves file here
            data.to_csv(out_path)

            print('Data saved to {}\n'.format(dataName))
            plotter(data["Time"],data["RPM"],'RPM','Plot 1')
Esempio n. 3
0
    def run(self):
        if self.task is None:  #after you hit start it does this
            self.widgets['btn_start'].setText('Stop')
            self.data = self.data[0:0]  # clear all data
            axis = self.widgets['axis']
            if axis.lines:
                axis.lines = []
                axis.set_prop_cycle(None)

            loop = asyncio.get_event_loop()
            filter_num = self.widgets['filter'].value()
            self.task = loop.create_task(self.show_data(filter_num))
        else:  #when you hit stop it does this
            self.task.cancel()
            self.widgets['btn_start'].setText('Start')
            in_path = os.path.expanduser('~\PycharmProjects\jr3 data')
            dataName = seqfile.findNextFile(in_path,
                                            prefix='jr3_data_',
                                            suffix='.csv')
            out_path = dataName  #saves file here
            self.data.to_csv(out_path)
            self.task = None
Esempio n. 4
0
    if options.format == "img":
        formats = ["img"]
    elif options.format == "h264":
        formats = ["h264"]
    elif options.format == "all":
        formats = ["img", "h264"]

    if options.all:
        client_numbers = range(1, options.clients + 1)
    else:
        client_numbers = [options.clients]

    # Program the benchmarks for the client and format combination
    benchmark_runs = itertools.product(client_numbers, formats)

    # Open the file for storing the results
    results_file = seqfile.findNextFile(".",
                                        options.label,
                                        ".txt",
                                        maxattempts=100)

    results = open(results_file, "w")
    results.write("clients,format,cpu,mem_used,bw,fps,lat\n")

    for br in benchmark_runs:
        run(br[0], br[1], options.measurements, results, options.basecomp,
            options.key, options.requrl, options.browserhost,
            options.browserurl)

    results.close()
Esempio n. 5
0
    # Make one image per visibility
    future_model_list = [
        rsexecute.execute(create_image_from_visibility)(
            fvis,
            npixel=npixel,
            frequency=frequency,
            nchan=nfreqwin,
            cellsize=cellsize,
            phasecentre=phasecentre,
            polarisation_frame=PolarisationFrame("stokesI"))
        for fvis in future_bvis_list
    ]

    filename = seqfile.findNextFile(prefix='atmospheric_simulation_%s_' %
                                    socket.gethostname(),
                                    suffix='.csv')
    print('Saving results to %s' % filename)
    plotfile = seqfile.findNextFile(prefix='atmospheric_simulation_%s_' %
                                    socket.gethostname(),
                                    suffix='.png')

    epoch = time.strftime("%Y-%m-%d %H:%M:%S")

    time_started = time.time()

    # Now loop over all scenarios
    print("")
    print("***** Starting loop over scenarios ******")
    print("")
    results = []
Esempio n. 6
0
                   vmax=1.0,
                   vmin=0.0)

        plt.savefig('PB_rascil.png')
        plt.show(block=False)
        if export_images:
            export_image_to_fits(pb, 'PB_rascil.fits')

    # Construct the voltage patterns
    print("Constructing voltage patterns")
    vp_list, vp_coeffs = create_voltage_patterns_coeffs(vp)

    results = []

    filename = seqfile.findNextFile(prefix='surface_simulation_%s_' %
                                    socket.gethostname(),
                                    suffix='.csv')
    print('Saving results to %s' % filename)
    plotfile = seqfile.findNextFile(prefix='surface_simulation_%s_' %
                                    socket.gethostname(),
                                    suffix='.jpg')

    epoch = time.strftime("%Y-%m-%d %H:%M:%S")

    time_started = time.time()

    # Now loop over all surface errors
    print("")
    print("***** Starting loop over scenarios ******")
    print("")
    for se in ses:
Esempio n. 7
0
    time.sleep(5)

    print("Processing graph")
    start = time.time()
    future = client.compute(sum_psf_graph)
    wait(future)
    results['time sum psf'] = time.time() - start

    value = future.result()
    assert value.shape[0] == shape[0] and value.shape[1] == shape[1], \
        "Shape of result %s not as requested %s" % (value.shape, shape)
    results['max psf'] = numpy.max(value)

    nworkers = len(client.scheduler_info()['workers'])
    assert nworkers == nworkers_requested, "Number of workers %d not as requested %d" % (
        nworkers, nworkers_requested)

    results['nworkers'] = nworkers

    filename = seqfile.findNextFile(prefix='pseudoinvert_%s_' %
                                    results['hostname'],
                                    suffix='.csv')
    print('Saving results to %s' % filename)
    write_header(filename, fieldnames)
    write_results(filename, fieldnames, results)
    client.shutdown()
    print("Final state")
    pp.pprint(results)

    exit()