def co_downsample_to(deltat): decimators = {} newtr = None try: while True: tr = yield newtr ratio = deltat / tr.deltat rratio = round(ratio) if abs(rratio - ratio)/ratio > 0.0001: raise util.UnavailableDecimation('ratio = %g' % ratio) deci_seq = tuple( x for x in util.decitab(int(rratio)) if x != 1 ) if deci_seq not in decimators: decimators[deci_seq] = chain( *[ co_downsample(q) for q in deci_seq ] ) newtr = decimators[deci_seq].send( tr ) except GeneratorExit: for g in decimators.values(): g.close()
def co_downsample_to(deltat): decimators = {} newtr = None try: while True: tr = yield newtr ratio = deltat / tr.deltat rratio = round(ratio) if abs(rratio - ratio) / ratio > 0.0001: raise util.UnavailableDecimation('ratio = %g' % ratio) deci_seq = tuple(x for x in util.decitab(int(rratio)) if x != 1) if deci_seq not in decimators: decimators[deci_seq] = chain( *[co_downsample(q) for q in deci_seq]) newtr = decimators[deci_seq].send(tr) except GeneratorExit: for g in decimators.values(): g.close()
def co_downsample_to(target, deltat): decimators = {} try: while True: tr = (yield) ratio = deltat / tr.deltat rratio = round(ratio) if abs(rratio - ratio) / ratio > 0.0001: raise util.UnavailableDecimation('ratio = %g' % ratio) deci_seq = tuple(x for x in util.decitab(int(rratio)) if x != 1) if deci_seq not in decimators: pipe = target for q in deci_seq[::-1]: pipe = co_downsample(pipe, q) decimators[deci_seq] = pipe decimators[deci_seq].send(tr) except GeneratorExit: for g in decimators.values(): g.close()
def co_downsample_to(target, deltat): decimators = {} try: while True: tr = (yield) ratio = deltat / tr.deltat rratio = round(ratio) if abs(rratio - ratio)/ratio > 0.0001: raise util.UnavailableDecimation('ratio = %g' % ratio) deci_seq = tuple( x for x in util.decitab(int(rratio)) if x != 1 ) if deci_seq not in decimators: pipe = target for q in deci_seq[::-1]: pipe = co_downsample(pipe, q) decimators[deci_seq] = pipe decimators[deci_seq].send( tr ) except GeneratorExit: for g in decimators.values(): g.close()