def run(self): """ Maps color range to distance and applies results to bisected strip """ self._stop = False #distance change if not utils.withinAccuracyRange(self.distance, self.leds.distance): self.distance = self.leds.distance self.count = int( utils.mapRange(self.distance, self.leds.getMinDistance(), self.leds.getMaxDistance(), 30, 5)) self.size = int( utils.mapRange(self.distance, self.leds.getMinDistance(), self.leds.getMaxDistance(), 3, 10)) self.rMax = int( utils.mapRange(self.distance, self.leds.getMinDistance(), self.leds.getMaxDistance(), 0, 255)) self.bMax = int( utils.mapRange(self.distance, self.leds.getMinDistance(), self.leds.getMaxDistance(), 255, 0)) #animation self.startTime = time.time() self.pingCount += 1 while not self.waitForPing(): self.randomizeSquares()
def drawMouth(): global smilePercent if smilePercent < 0: radius = utils.mapRange(abs(smilePercent), 0, 100, 0.3, 0.9) pygame.draw.arc(screen, (100, 200, 200), (57, 300, 540, 400), 1.57 - radius, 1.57 + radius, 20) # smile else: radius = utils.mapRange(abs(smilePercent), 0, 100, 0.3, 1.3) pygame.draw.arc(screen, (100, 200, 200), (57, -30, 540, 400), 4.7 - radius, 4.7 + radius, 20)
def run(self): """ Maps color range to distance and applies results to bisected strip """ self._stop = False #fade to back on init if self.init: self.brightness = self.leds.getBrightness() self.init = False b = self.leds.getBrightness() utils.transitionBrightness(b, 0, self.fade) self.leds.setBrightness(self.brightness) #distance change if not utils.withinAccuracyRange(self.distance, self.leds.distance): self.distance = self.leds.distance self.colors = self.colorPairs[int( utils.mapRange(self.distance, self.leds.getMinDistance(), self.leds.getMaxDistance(), 3, 0))] #animation self.startTime = time.time() #animation while not self.waitForPing(): self.wave()
def run(self): self._stop = False self.max = self.leds.getBrightness() #distance change if not utils.withinAccuracyRange(self.distance, self.leds.distance): self.distance = self.leds.distance self.steps = int( utils.mapRange(self.distance, self.leds.getMinDistance(), self.leds.getMaxDistance(), 10, 30)) self.hold = int( utils.mapRange(self.distance, self.leds.getMinDistance(), self.leds.getMaxDistance(), 0, 0.2)) #switch to random blue color on every 4th ping if self.pingCount % 4 == 0: self.blue = utils.randomBlue() self.pingCount += 1 #run pulse animation self.pulse()
def run(self): self._stop = False #distance change if not utils.withinAccuracyRange(self.distance, self.leds.distance): self.distance = self.leds.distance self.destination = int(utils.mapRange(self.distance, self.leds.getMinDistance(), self.leds.getMaxDistance(), self.sections-1, 0)) #change colors every set interval if self.pingCount % 60 == 0: self.fillSections() self.pingCount += 1 #leap animation self.leap()
def run(self): """ Maps color range to distance and applies results to bisected strip """ self._stop = False #distance change if not utils.withinAccuracyRange(self.distance, self.leds.distance): self.distance = self.leds.distance self.pixel = int( utils.mapRange(self.distance, 0.0, self.leds.getMaxDistance(), 50.0, self.leds.numPixels() - 1)) #animation self.startTime = time.time() self.bottomSection(self.pixel) self.topSection(self.pixel)
def run(self): self._stop = False #distance change if not utils.withinAccuracyRange(self.distance, self.leds.distance): self.distance = self.leds.distance index = int( utils.mapRange(self.distance, self.leds.getMinDistance(), self.leds.getMaxDistance(), len(self.colors) - 1, 0)) self.color = self.colors[index] #animation self.startTime = time.time() if not self._started: self.startAnimation() else: self.alternate()
rrvp = [reals[i] for i in idxs] rxpp = [rxpt[i] for i in idxs] rypp = [rypt[i] for i in idxs] preds = [np.abs(predictions[i][0]) for i in range(len(rrvp))] perf = [np.abs(predictions[i][0] - rrvp[i]) for i in range(len(rrvp))] perf_pct = [predictions[i][0] / rrvp[i] for i in range(len(rrvp))] perf_mse = [(predictions[i][0] - rrvp[i])**2 for i in range(len(rrvp))] perf_mae = [ np.abs(predictions[i][0] - rrvp[i]) for i in range(len(rrvp)) ] pu = np.max(perf) pl = np.min(perf) perfp = [utils.mapRange(x, pl, pu, lr, ur) for x in perf] perf_mse = np.mean(perf_mse) perf_mae = np.mean(perf_mae) print('Median', np.median(perf)) print('MSE', perf_mse) print('MAE', perf_mae) print('Max Err', np.max(np.abs(perf))) loss_arr.append(single_loss.item()) mse_arr.append(perf_mse) mae_arr.append(perf_mae) # writer.writerow(["Location", "$n_l$", "n_n", "$p_d$", "MSE", "MAE", "Loss STD"]) del inp_stack del out_stack