Exemplo n.º 1
0
def process_energy_ts(energy, area, policy):
    mi = MEASUREMENT_INTERVAL_SUBSAMPLE if policy.subsample else MEASUREMENT_INTERVAL
    debug_figure_energy(energy, area)

    if area.mode == 'find':
        em = ExperimentModel(
            Repeat(
                Situation('high', min=1.4, d_min=.1),
                Situation('before', max=1.5, d_min=.1),
                Situation('insert', min=1.4, max=5, d_min=.01, d_max=2.0),
                Situation('between', max=1.2, d_min=2.0, d_max=10.0),
                Situation('find', min=1.1, max=5, d_max=2.0),
                Situation('after_find', max=7.0, d_min=0.1, d_max=10.0),
            ),
            t0=policy.tmin,
            delta_t=mi,
            tmax=policy.tmax,
        )
    else:
        em = ExperimentModel(
            Repeat(
                Situation('high', min=1.4, d_min=.1),
                Situation('before', max=1.5, d_min=.1),
                Situation('insert', min=1.4, max=5, d_min=.01, d_max=2.0),
                Situation('between', max=1.2, d_min=2.0, d_max=20.0),
            ),
            t0=policy.tmin,
            delta_t=mi,
            tmax=policy.tmax,
        )

    tsums = []
    esums = []
    ots = []
    baseline = 0

    for m in em.match(energy):
        #print("xxx {}".format(m.situation.name))
        if m.situation.name in ('before', 'between', 'after_find'):
            baseline = m.v_average

        elif m.situation.name == 'insert' and area.mode == 'insert':
            ots.append(m.t0)
            tsums.append(m.d)
            esums.append(m.v_sum * mi - baseline * m.d)

        elif m.situation.name == 'find' and area.mode == 'find':
            #print("find t0={} d={} v_sum={} baseline={}".format(m.t0, m.d, m.v_sum, baseline))
            ots.append(m.t0)
            tsums.append(m.d / FINDS_AT_ONCE)
            esums.append((m.v_sum * mi - baseline * m.d) / FINDS_AT_ONCE)

    return [tsums], [esums], [ots]
Exemplo n.º 2
0
def process_energy_ts(energy, area, policy):
    mi = MEASUREMENT_INTERVAL_SUBSAMPLE if policy.subsample else MEASUREMENT_INTERVAL
    debug_figure_energy(energy, area)

    if area.mode == 'find':
        em = ExperimentModel(
                Repeat(
                    Situation('high', min=1.4, d_min=.1),
                    Situation('before', max=1.5, d_min=.1),
                    Situation('insert', min=1.4, max=5, d_min=.01, d_max=2.0),
                    Situation('between', max=1.2, d_min=2.0, d_max=10.0),
                    Situation('find', min=1.1, max=5, d_max=2.0),
                    Situation('after_find', max=7.0, d_min=0.1, d_max=10.0),
                ),
                t0 = policy.tmin, delta_t = mi,
            tmax = policy.tmax,
        )
    else:
        em = ExperimentModel(
                Repeat(
                    Situation('high', min=1.4, d_min=.1),
                    Situation('before', max=1.5, d_min=.1),
                    Situation('insert', min=1.4, max=5, d_min=.01, d_max=2.0),
                    Situation('between', max=1.2, d_min=2.0, d_max=20.0),
                ),
                t0 = policy.tmin, delta_t = mi,
            tmax = policy.tmax,
        )

    tsums = []
    esums = []
    ots = []
    baseline = 0

    for m in em.match(energy):
        #print("xxx {}".format(m.situation.name))
        if m.situation.name in ('before', 'between', 'after_find'):
            baseline = m.v_average

        elif m.situation.name == 'insert' and area.mode == 'insert':
            ots.append(m.t0)
            tsums.append(m.d)
            esums.append(m.v_sum * mi - baseline * m.d)

        elif m.situation.name == 'find' and area.mode == 'find':
            #print("find t0={} d={} v_sum={} baseline={}".format(m.t0, m.d, m.v_sum, baseline))
            ots.append(m.t0)
            tsums.append(m.d / FINDS_AT_ONCE)
            esums.append((m.v_sum * mi - baseline * m.d) / FINDS_AT_ONCE)

    return [tsums], [esums], [ots]
Exemplo n.º 3
0
def process_energy_ts_erase(energy, area, policy):
    mi = MEASUREMENT_INTERVAL_SUBSAMPLE if policy.subsample else MEASUREMENT_INTERVAL

    # fixd-width moving average for smoothness,
    # also serves as a band stop filter for timer ticks
    energy = np_moving_average(energy, int(0.0136 / mi))

    debug_figure_energy(energy, area)

    em = ExperimentModel(
            Situation('start', max = 1.2),
            t0 = policy.tmin,
            tmax = policy.tmax,
            delta_t = mi,
    )
    baseline = 0
    for m in em.match(energy):
        baseline = m.v_average
    print("baseline=", baseline)

    em = ExperimentModel(
            Situation('start', max = baseline + .2),
            Repeat(
                Situation('prep', min=baseline + .05, d_min=0.01, d_max=0.1),
                Situation('between', max=baseline + .1, d_min=0.05, d_max=0.2),
                Situation('exp', min=baseline + .05, d_min=0.01, d_max=0.1),
                Situation('after', max=baseline + .1, d_min=0.4, d_max=0.6),
            ),
            t0 = policy.tmin, delta_t = mi,
            tmax = policy.tmax,
        )

    tsums = []
    esums = []
    ots = []
    for m in em.match(energy):
        #print('-- {} {}-{} -> {} - {}'.format(m.situation.name, m.t0, m.t0+m.d, m.v_sum, baseline))
        if m.situation.name == 'exp':
            ots.append(m.t0)
            tsums.append(m.d)
            esums.append(m.v_sum * mi - baseline * m.d)
        elif m.situation.name in ('idle', 'start', 'between', 'after'):
            #print("---- setting baseline: ", m.situation.name, m.v_average)
            baseline = m.v_average

    print('/process_energy_ts_erase')

    return [tsums], [esums], [ots]
Exemplo n.º 4
0
def process_energy_teenylime(energy, area, policy):
    mi = MEASUREMENT_INTERVAL_SUBSAMPLE if policy.subsample else MEASUREMENT_INTERVAL
    debug_figure_energy(energy, area)

    em = ExperimentModel(
            Situation('power-on', d_max=.02),
            Situation('start', max=.25, d_max=.05),
            t0 = policy.tmin, delta_t = mi,
            tmax = policy.tmax,
            )

    baseline = 0
    for m in em.match(energy):
        baseline = m.v_average
    print("baseline=", baseline)

    b = baseline
    em = ExperimentModel(
            Situation('power-on', d_max=.02),
            Situation('start', max=0.25, d_max=.05),
            Repeat(
                Situation('between', max = b + .1),
                Situation('exp', min = b + .05),
            ),
            t0 = policy.tmin, delta_t = mi,
            tmax = policy.tmax,
        )

    tsums = []
    esums = []
    ots = []
    for m in em.match(energy):
        print("---- found: {} {}...{}".format(m.situation.name, m.t0, m.t0 + m.d))
        if m.situation.name == 'exp':
            print('-- {} {}-{} -> {} - {}'.format(m.situation.name, m.t0, m.t0+m.d, m.v_sum * mi, m.d*baseline))
            ots.append(m.t0)
            tsums.append(m.d)
            esums.append(m.v_sum * mi - baseline * m.d)
        elif m.situation.name == 'between':
            print("---- correcting baseline: ", m.situation.name, m.v_average)
            baseline = m.v_average
    return [tsums], [esums], [ots]
Exemplo n.º 5
0
def process_energy_ts_erase(energy, area, policy):
    mi = MEASUREMENT_INTERVAL_SUBSAMPLE if policy.subsample else MEASUREMENT_INTERVAL

    # fixd-width moving average for smoothness,
    # also serves as a band stop filter for timer ticks
    energy = np_moving_average(energy, int(0.0136 / mi))

    debug_figure_energy(energy, area)

    em = ExperimentModel(
        Situation('start', max=1.2),
        t0=policy.tmin,
        tmax=policy.tmax,
        delta_t=mi,
    )
    baseline = 0
    for m in em.match(energy):
        baseline = m.v_average
    print("baseline=", baseline)

    em = ExperimentModel(
        Situation('start', max=baseline + .2),
        Repeat(
            Situation('prep', min=baseline + .05, d_min=0.01, d_max=0.1),
            Situation('between', max=baseline + .1, d_min=0.05, d_max=0.2),
            Situation('exp', min=baseline + .05, d_min=0.01, d_max=0.1),
            Situation('after', max=baseline + .1, d_min=0.4, d_max=0.6),
        ),
        t0=policy.tmin,
        delta_t=mi,
        tmax=policy.tmax,
    )

    tsums = []
    esums = []
    ots = []
    for m in em.match(energy):
        #print('-- {} {}-{} -> {} - {}'.format(m.situation.name, m.t0, m.t0+m.d, m.v_sum, baseline))
        if m.situation.name == 'exp':
            ots.append(m.t0)
            tsums.append(m.d)
            esums.append(m.v_sum * mi - baseline * m.d)
        elif m.situation.name in ('idle', 'start', 'between', 'after'):
            #print("---- setting baseline: ", m.situation.name, m.v_average)
            baseline = m.v_average

    print('/process_energy_ts_erase')

    return [tsums], [esums], [ots]
Exemplo n.º 6
0
def process_energy_teenylime(energy, area, policy):
    mi = MEASUREMENT_INTERVAL_SUBSAMPLE if policy.subsample else MEASUREMENT_INTERVAL
    debug_figure_energy(energy, area)

    em = ExperimentModel(
        Situation('power-on', d_max=.02),
        Situation('start', max=.25, d_max=.05),
        t0=policy.tmin,
        delta_t=mi,
        tmax=policy.tmax,
    )

    baseline = 0
    for m in em.match(energy):
        baseline = m.v_average
    print("baseline=", baseline)

    b = baseline
    em = ExperimentModel(
        Situation('power-on', d_max=.02),
        Situation('start', max=0.25, d_max=.05),
        Repeat(
            Situation('between', max=b + .1),
            Situation('exp', min=b + .05),
        ),
        t0=policy.tmin,
        delta_t=mi,
        tmax=policy.tmax,
    )

    tsums = []
    esums = []
    ots = []
    for m in em.match(energy):
        print("---- found: {} {}...{}".format(m.situation.name, m.t0,
                                              m.t0 + m.d))
        if m.situation.name == 'exp':
            print('-- {} {}-{} -> {} - {}'.format(m.situation.name, m.t0,
                                                  m.t0 + m.d, m.v_sum * mi,
                                                  m.d * baseline))
            ots.append(m.t0)
            tsums.append(m.d)
            esums.append(m.v_sum * mi - baseline * m.d)
        elif m.situation.name == 'between':
            print("---- correcting baseline: ", m.situation.name, m.v_average)
            baseline = m.v_average
    return [tsums], [esums], [ots]