def get_rain_peaks(forecast_maps, max_ahead, xy, user_ahead=0, user_intensity=10): timeframe = user_ahead max_intensity = 0 peak_mins = 0 while timeframe <= max_ahead: intensity = rvp_to_dbz(forecast_maps[timeframe][0][xy[0]][xy[1]]) if intensity > max_intensity: peak_mins = timeframe max_intensity = intensity if intensity < user_intensity: break timeframe += 5 return max_intensity, peak_mins, timeframe-user_ahead
def test_rvp_to_dbz(self): self.assertTrue(np.allclose(trafo.rvp_to_dbz(self.rvp), self.dbz))
def test_rvp_to_dbz(self): assert np.allclose(trafo.rvp_to_dbz(self.rvp), self.dbz)
if interpolatedSpeed > 10: logging.warn("%s: not pushing for client because of too high interpolated speed %f (orig=%f)" % (token, interpolatedSpeed, travelmodeSpeed)) continue else: logging.warn("interpolatedSpeed=%f < 20km/h -> OK" % interpolatedSpeed) # XXX check lat/lon against the bounds of the dwd data here # to avoid useless calculations here # user position in grid result = closest_node((lon, lat), linearized_grid) xy = (int(result / gridsize), int(result % gridsize)) # get forecasted value from grid data = forecast_maps[ahead] reported_intensity = rvp_to_dbz(forecast_maps[ahead][0][xy[0]][xy[1]]) # also check timeframes BEFORE the configured ahead value if reported_intensity < intensity: timeframe = ahead - 5 while timeframe > 0: previous_intensity = rvp_to_dbz(forecast_maps[timeframe][0][xy[0]][xy[1]]) if previous_intensity >= intensity: logging.warn("%s: no match for old ahead value, but %d >= %d for lower ahead=%d!" % (token, previous_intensity, intensity, timeframe)) reported_intensity = previous_intensity ahead = timeframe timeframe -= 5 logging.warn("%d >? %d" % (reported_intensity, intensity)) if reported_intensity >= intensity: