How to use the wradlib.trafo.rvp_to_dbz function in wradlib

To help you get started, we’ve selected a few wradlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github v4lli / meteocool / backend / dwd / dwd2geojson.py View on Github external
return (64, 64, 64, int(50/5*factor))
    if dbz < 0:
        return (0x00, 0x00, 0x00, 0)

feature_list = []
rows = 0
for row in data[0]:
    cols = 0
    for pixel in row:
        cols = cols + 1
        if pixel == -9999:
            # this means no data
            continue

        try:
            pixels[cols-1,rows] = dbz2color(wradlib.trafo.rvp_to_dbz(pixel))
        except IndexError:
            print("okay but why wtf IndexError cols=%d rows=%d" % (cols, rows))
            continue

    rows = rows + 1

print("biggest index row=%d col=%d" % (rows, cols))

#img.show()
img.save(sys.argv[2])
github v4lli / meteocool / backend / dwd / dwd2png.py View on Github external
data = wradlib.io.radolan.read_radolan_composite(sys.argv[1])
    # data is mm/5m, we convert it to dbz here: https://plot.ly/~ToniBois/1783.embed
    # https://www.dwd.de/DE/leistungen/radarniederschlag/rn_info/download_niederschlagsbestimmung.pdf?__blob=publicationFile&v=4

    feature_list = []
    rows = 0
    for row in reversed(data[0]):
        cols = 0
        for pixel in row:
            cols = cols + 1
            if pixel == -9999:
                # this means no data
                continue

            try:
                pixels[cols - 1, rows] = dbz2color(wradlib.trafo.rvp_to_dbz(pixel))
            except IndexError:
                print("okay but why wtf IndexError cols=%d rows=%d" % (cols, rows))
                continue

        rows = rows + 1

    print("biggest index row=%d col=%d" % (rows, cols))

    # img.show()
    img.save(sys.argv[2])
github v4lli / meteocool / backend / dwd / push.py View on Github external
def get_rain_peaks(forecast_maps, max_ahead, xy, user_ahead=0, user_intensity=10, debug=False):
    timeframe = user_ahead
    max_intensity = 0
    peak_mins = 0

    if debug:
        logging.warn("max_ahead=%d", max_ahead)

    while timeframe <= max_ahead:
        intensity = rvp_to_dbz(forecast_maps[timeframe][0][outx][outy])
        if debug:
            logging.warn("timeframe=%d max_ahead=%d intensity=%d" % (timeframe, max_ahead, intensity))
        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
github v4lli / meteocool / backend / dwd / push.py View on Github external
else:
                #logging.warn("interpolatedSpeed=%f < 20km/h -> OK" % interpolatedSpeed)
                pass

        # user position in grid
        outy, outx = wrl.georef.get_radolan_coords(lon, lat)
        outy = int(outy + 523.4622)
        outx = int(outx + 4658.645)

        if outx < 0 or outx >= gridsize or outy < 0 or outy >= gridsize:
            logging.warn("NOT PUSHING for client %s because it's outside the grid: %f,%f", token, lat, lon)
            continue

        # get forecasted value from grid
        data = forecast_maps[ahead]
        reported_intensity = rvp_to_dbz(forecast_maps[ahead][0][outx][outy])

        debug = False
        if token == "34b62a22f70bec18457590b6c08b61612060bdca39f6941a917e0d75dd8b05cc" or token == "dafe95e4498deb188efb76dcf6927d9b3c3e265371e2b4d4f87d23fc0ef8cf79" or token == "9081b779ae46cca7a785a5db631120cc007abc663056981bdc9534f9329c38d4":
            ahead = 45
            lang = "de"
            debug = True

        # 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][outx][outy])
                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
github v4lli / meteocool / backend / dwd / push.py View on Github external
# get forecasted value from grid
        data = forecast_maps[ahead]
        reported_intensity = rvp_to_dbz(forecast_maps[ahead][0][outx][outy])

        debug = False
        if token == "34b62a22f70bec18457590b6c08b61612060bdca39f6941a917e0d75dd8b05cc" or token == "dafe95e4498deb188efb76dcf6927d9b3c3e265371e2b4d4f87d23fc0ef8cf79" or token == "9081b779ae46cca7a785a5db631120cc007abc663056981bdc9534f9329c38d4":
            ahead = 45
            lang = "de"
            debug = True

        # 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][outx][outy])
                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:
            logging.warn("%s: intensity %d > %d matches in %d min forecast (type=%s)" % (token, reported_intensity, intensity, ahead, source))

            # fancy message generation
            max_intensity, peak_mins, total_mins = get_rain_peaks(forecast_maps, max_ahead, [outx, outy], ahead, intensity)

            if lang == "de":
                message_dict = {