コード例 #1
0
def calibrate_sensor(sensor, measurements, verbose):
    parameters = PARAMETERS[sensor]
    if verbose:
        print "found %d records" % len(measurements)

    flt_meas, flt_idx = utils.filter_meas(measurements,
                                          parameters.noise_window,
                                          parameters.noise_threshold)
    if verbose:
        print "remaining %d after low pass" % len(flt_meas)
    p0 = utils.get_min_max_guess(flt_meas, parameters.sensor_ref)
    cp0, np0 = utils.scale_measurements(flt_meas, p0)
    print "initial guess : avg %f std %f" % (np0.mean(), np0.std())

    def err_func(p, meas, y):
        cp, np = utils.scale_measurements(meas, p)
        err = y * scipy.ones(len(meas)) - np
        return err

    p1, success = scipy.optimize.leastsq(err_func,
                                         p0[:],
                                         args=(flt_meas,
                                               parameters.sensor_ref))
    cp1, np1 = utils.scale_measurements(flt_meas, p1)

    print "optimized guess : avg %f std %f" % (np1.mean(), np1.std())

    utils.print_xml(p1, sensor, parameters.sensor_res)
    print ""

    utils.plot_results(measurements, flt_idx, flt_meas, cp0, np0, cp1, np1,
                       parameters.sensor_ref)
コード例 #2
0
ファイル: __init__.py プロジェクト: OpenUAS/wasp
def calibrate_sensor(sensor, measurements, verbose):
    parameters = PARAMETERS[sensor]
    if verbose:
       print "found %d records" % len(measurements)

    flt_meas, flt_idx = utils.filter_meas(measurements, parameters.noise_window, parameters.noise_threshold)
    if verbose:
        print "remaining %d after low pass" % len(flt_meas)
    p0 = utils.get_min_max_guess(flt_meas, parameters.sensor_ref)
    cp0, np0 = utils.scale_measurements(flt_meas, p0)
    print "initial guess : avg %f std %f" % (np0.mean(), np0.std())

    def err_func(p,meas,y):
        cp, np = utils.scale_measurements(meas, p)
        err = y*scipy.ones(len(meas)) - np
        return err

    p1, success = scipy.optimize.leastsq(err_func, p0[:], args=(flt_meas, parameters.sensor_ref))
    cp1, np1 = utils.scale_measurements(flt_meas, p1)

    print "optimized guess : avg %f std %f" % (np1.mean(), np1.std())

    utils.print_xml(p1, sensor, parameters.sensor_res)
    print ""

    utils.plot_results(measurements, flt_idx, flt_meas, cp0, np0, cp1, np1, parameters.sensor_ref)
コード例 #3
0
 def err_func(p, meas, y):
     cp, np = utils.scale_measurements(meas, p)
     err = y * scipy.ones(len(meas)) - np
     return err
コード例 #4
0
ファイル: __init__.py プロジェクト: OpenUAS/wasp
 def err_func(p,meas,y):
     cp, np = utils.scale_measurements(meas, p)
     err = y*scipy.ones(len(meas)) - np
     return err