wradlib.georef.polar.spherical_to_polyvert

wradlib.georef.polar.spherical_to_polyvert(r, phi, theta, sitecoords, proj=None)

Generate 3-D polygon vertices directly from spherical coordinates (r, phi, theta).

This is an alternative to centroid_to_polyvert which does not use centroids, but generates the polygon vertices by simply connecting the corners of the radar bins.

Both azimuth and range arrays are assumed to be equidistant and to contain only unique values. For further information refer to the documentation of spherical_to_xyz.

Parameters:
  • r (numpy.ndarray) – Array of ranges [m]; r defines the exterior boundaries of the range bins! (not the centroids). Thus, values must be positive!

  • phi (numpy.ndarray) – Array of azimuth angles containing values between 0° and 360°. The angles are assumed to describe the pointing direction fo the main beam lobe! The first angle can start at any values, but make sure the array is sorted continuously positively clockwise and the angles are equidistant. An angle if 0 degree is pointing north.

  • theta (float) – Elevation angle of scan

  • sitecoords (sequence) – the lon/lat/alt coordinates of the radar location

  • proj (osgeo.osr.SpatialReference) – Destination Projection

Returns:

  • output (numpy.ndarray) – A 3-d array of polygon vertices with shape(num_vertices, num_vertex_nodes, 2). The last dimension carries the xyz-coordinates either in aeqd or given proj.

  • proj (osgeo.osr.SpatialReference) – only returned if proj is None

Examples

>>> import wradlib.georef as georef  # noqa
>>> import numpy as np
>>> from matplotlib import collections
>>> import matplotlib.pyplot as pl
>>> #pl.interactive(True)
>>> # define the polar coordinates and the site coordinates in lat/lon
>>> r = np.array([50., 100., 150., 200.]) * 1000
>>> # _check_polar_coords fails in next line
>>> # az = np.array([0., 45., 90., 135., 180., 225., 270., 315., 360.])
>>> az = np.array([0., 45., 90., 135., 180., 225., 270., 315.])
>>> el = 1.0
>>> sitecoords = (9.0, 48.0, 0)
>>> polygons, proj = georef.spherical_to_polyvert(r, az, el, sitecoords)
>>> # plot the resulting mesh
>>> fig = pl.figure()
>>> ax = fig.add_subplot(111)
>>> #polycoll = mpl.collections.PolyCollection(vertices,closed=True, facecolors=None)  # noqa
>>> polycoll = collections.PolyCollection(polygons[...,:2], closed=True, facecolors='None')  # noqa
>>> ret = ax.add_collection(polycoll, autolim=True)
>>> pl.autoscale()
>>> pl.show()