How to use the wradlib.georef 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 / push.py View on Github external
logging.warn("travel mode not supported for this client")
        else:
            # if the interpolated speed is still above ~20 km/h, don't push
            # XXX accuracy beachten
            m_diff = (datetime.datetime.utcnow()-last_updated).total_seconds() / 60
            # cool down by 0.35 km/h per minute
            interpolatedSpeed = max(travelmodeSpeed - m_diff*0.35, 0)
            if interpolatedSpeed > 30:
                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)
                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
github wradlib / wradlib / wradlib / vis.py View on Github external
"If using projection, r must be given as "
                          "array with units m.")
            proj = None
        r = np.arange(data.shape[1], dtype=np.float)
        r += (r[1] - r[0]) / 2.

    if np.isscalar(elev):
        elev = np.ones_like(az) * elev

    da = georef.create_xarray_dataarray(data, r=r, phi=az, theta=elev,
                                        site=site, proj=proj,
                                        sweep_mode='azimuth_surveillance',
                                        rf=rf,
                                        **kw_spherical)

    da = georef.georeference_dataset(da, proj=proj)

    # fallback to proj=None for GDAL OSR
    if isinstance(proj, osr.SpatialReference):
        proj = None

    pm = da.wradlib.plot_ppi(ax=ax, fig=fig, func=func,
                             proj=proj, **kwargs)

    return pl.gca(), pm
github wradlib / wradlib / wradlib / io.py View on Github external
numpy ndarray of raster coordinates
    values : :func:`numpy:numpy.array`
        numpy 2darray of raster values

    Examples
    --------

    See :ref:`notebooks/beamblockage/wradlib_beamblock.ipynb` and
    :ref:`notebooks/visualisation/wradlib_overlay.ipynb`

    """

    dataset = open_raster(filename, driver=driver)

    if 'spacing' in kwargs or 'size' in kwargs:
        dataset1 = georef.resample_raster_dataset(dataset, **kwargs)
    else:
        dataset1 = dataset

    # we have to flipud data, because raster data is origin "upper left"
    values = np.flipud(georef.read_gdal_values(dataset1))
    coords = np.flipud(georef.read_gdal_coordinates(dataset1,
                                                    mode='centers',
                                                    z=False))

    # close dataset
    dataset1 = None

    return coords, values
github wradlib / wradlib / wradlib / vis.py View on Github external
az = np.arange(data.shape[0], dtype=np.float)
        az += (az[1] - az[0]) / 2.

    if r is None:
        if proj and proj != 'cg':
            warnings.warn("Parameter `r` is None, falling back to `proj=None`."
                          "If using projection, r must be given as "
                          "array with units m.")
            proj = None
        r = np.arange(data.shape[1], dtype=np.float)
        r += (r[1] - r[0]) / 2.

    if np.isscalar(elev):
        elev = np.ones_like(az) * elev

    da = georef.create_xarray_dataarray(data, r=r, phi=az, theta=elev,
                                        site=site, proj=proj,
                                        sweep_mode='azimuth_surveillance',
                                        rf=rf,
                                        **kw_spherical)

    da = georef.georeference_dataset(da, proj=proj)

    # fallback to proj=None for GDAL OSR
    if isinstance(proj, osr.SpatialReference):
        proj = None

    pm = da.wradlib.plot_ppi(ax=ax, fig=fig, func=func,
                             proj=proj, **kwargs)

    return pl.gca(), pm
github wradlib / wradlib / wradlib / io.py View on Github external
@util.deprecated(georef.extract_raster_dataset)
def read_raster_data(filename, driver=None, **kwargs):
    """Read raster data

    Reads raster data files supported by GDAL. If driver is not given,
    GDAL tries to autodetect the file format. Works well in most cases.

    .. seealso:: http://www.gdal.org/formats_list.html

    Resamples data on the fly if special keyword arguments are given

    .. versionadded:: 0.6.0

    Parameters
    ----------
    filename : string
        filename of raster file
github wradlib / wradlib / wradlib / vpr.py View on Github external
maxrange : float
        maximum range (same unit as gridcoords)

    Returns
    -------
    output : tuple of three Boolean arrays each of length (num grid points)

    """
    # distances of 3-D grid nodes from radar site (center)
    dist_from_rad = np.sqrt(((gridcoords - center) ** 2).sum(axis=-1))
    # below the radar
    below = gridcoords[:, 2] < (georef.bin_altitude(dist_from_rad, minelev, 0,
                                                    re=6371000) +
                                center[:, 2])
    # above the radar
    above = gridcoords[:, 2] > (georef.bin_altitude(dist_from_rad, maxelev, 0,
                                                    re=6371000) +
                                center[:, 2])
    # out of range
    out_of_range = dist_from_rad > maxrange
    return below, above, out_of_range