# Path: wradlib/georef/misc.py
# def bin_altitude(r, theta, sitealt, re, ke=4.0 / 3.0):
# def bin_distance(r, theta, sitealt, re, ke=4.0 / 3.0):
# def site_distance(r, theta, binalt, re=None, ke=4.0 / 3.0):
# 
# Path: wradlib/georef/projection.py
# def create_osr(projname, **kwargs):
# def proj4_to_osr(proj4str):
# def reproject(*args, **kwargs):
# def get_default_projection():
# def epsg_to_osr(epsg=None):
# def wkt_to_osr(wkt=None):
# def get_earth_radius(latitude, sr=None):
# def get_earth_projection(model="ellipsoid"):
# def get_radar_projection(sitecoords):
# def get_extent(coords):
#         C = np.asanyarray(args[0])
#         C = C.reshape(-1, numCols)
#             X, Y = (np.asanyarray(arg) for arg in args)
#             X, Y, Z = (np.asanyarray(arg) for arg in args)
#             C = np.concatenate(
#                 [X.ravel()[:, None], Y.ravel()[:, None], Z.ravel()[:, None]], axis=1
#             )
#             C = np.concatenate([X.ravel()[:, None], Y.ravel()[:, None]], axis=1)
#         X = trans[:, 0].reshape(xshape)
#         Y = trans[:, 1].reshape(yshape)
#             Z = trans[:, 2].reshape(zshape)
# 
# Path: wradlib/util.py
# def has_import(module):
#     return not isinstance(module, OptionalModuleStub)
# 
# def import_optional(module):
#     """Allowing for lazy loading of optional wradlib modules or dependencies.
# 
#     This function removes the need to satisfy all dependencies of wradlib
#     before being able to work with it.
# 
#     Parameters
#     ----------
#     module : str
#              name of the module
# 
#     Returns
#     -------
#     mod : object
#           if module is present, returns the module object, on ImportError
#           returns an instance of `OptionalModuleStub` which will raise an
#           AttributeError as soon as any attribute is accessed.
# 
#     Examples
#     --------
#     Trying to import a module that exists makes the module available as normal.
#     You can even use an alias. You cannot use the '*' notation, or import only
#     select functions, but you can simulate most of the standard import syntax
#     behavior.
#     >>> m = import_optional('math')
#     >>> m.log10(100)
#     2.0
# 
#     Trying to import a module that does not exists, does not produce
#     any errors. Only when some function is used, the code triggers an error
#     >>> m = import_optional('nonexistentmodule')  # noqa
#     >>> m.log10(100)  #doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     AttributeError: Module 'nonexistentmodule' is not installed.
#     <BLANKLINE>
#     You tried to access function/module/attribute 'log10'
#     from module 'nonexistentmodule'.
#     This module is optional right now in wradlib.
#     You need to separately install this dependency.
#     Please refer to https://docs.wradlib.org/en/stable/installation.html#optional-dependencies
#     for further instructions.
#     """
#     try:
#         mod = importlib.import_module(module)
#     except ImportError:
#         mod = OptionalModuleStub(module)
# 
#     return mod


import warnings
import numpy as np
from wradlib.georef import misc, projection
from wradlib.util import has_import, import_optional
    if angle is None:
        angle = 0.0

    if elev is None:
        elev = 0.0

    if autoext:
        # the ranges need to go 'one bin further', assuming some regularity
        # we extend by the distance between the preceding bins.
        x = np.append(d1, d1[-1] + (d1[-1] - d1[-2]))
        # the angular dimension is supposed to be cyclic, so we just add the
        # first element
        y = np.append(d2, d2[0])
    else:
        # no autoext basically is only useful, if the user supplied the correct
        # dimensions himself.
        x = d1
        y = d2

    # roll data array to specified azimuth, assuming equidistant azimuth angles
    ind = (d2 >= angle).nonzero()[0][0]
    data = np.roll(data, ind, axis=0)

    # build cartesian range array, add delta to last element to compensate for
    # open bound (np.digitize)
    dc = np.linspace(-np.max(d1), np.max(d1) + 0.0001, num=d1.shape[0] * 2 + 1)

    # get height values from polar data and build cartesian height array
    # add delta to last element to compensate for open bound (np.digitize)
    hp = np.zeros((y.shape[0], x.shape[0]))

# Path: wradlib/georef/misc.py
# def bin_altitude(r, theta, sitealt, re, ke=4.0 / 3.0):
# def bin_distance(r, theta, sitealt, re, ke=4.0 / 3.0):
# def site_distance(r, theta, binalt, re=None, ke=4.0 / 3.0):
# 
# Path: wradlib/georef/projection.py
# def create_osr(projname, **kwargs):
# def proj4_to_osr(proj4str):
# def reproject(*args, **kwargs):
# def get_default_projection():
# def epsg_to_osr(epsg=None):
# def wkt_to_osr(wkt=None):
# def get_earth_radius(latitude, sr=None):
# def get_earth_projection(model="ellipsoid"):
# def get_radar_projection(sitecoords):
# def get_extent(coords):
#         C = np.asanyarray(args[0])
#         C = C.reshape(-1, numCols)
#             X, Y = (np.asanyarray(arg) for arg in args)
#             X, Y, Z = (np.asanyarray(arg) for arg in args)
#             C = np.concatenate(
#                 [X.ravel()[:, None], Y.ravel()[:, None], Z.ravel()[:, None]], axis=1
#             )
#             C = np.concatenate([X.ravel()[:, None], Y.ravel()[:, None]], axis=1)
#         X = trans[:, 0].reshape(xshape)
#         Y = trans[:, 1].reshape(yshape)
#             Z = trans[:, 2].reshape(zshape)
# 
# Path: wradlib/util.py
# def has_import(module):
#     return not isinstance(module, OptionalModuleStub)
# 
# def import_optional(module):
#     """Allowing for lazy loading of optional wradlib modules or dependencies.
# 
#     This function removes the need to satisfy all dependencies of wradlib
#     before being able to work with it.
# 
#     Parameters
#     ----------
#     module : str
#              name of the module
# 
#     Returns
#     -------
#     mod : object
#           if module is present, returns the module object, on ImportError
#           returns an instance of `OptionalModuleStub` which will raise an
#           AttributeError as soon as any attribute is accessed.
# 
#     Examples
#     --------
#     Trying to import a module that exists makes the module available as normal.
#     You can even use an alias. You cannot use the '*' notation, or import only
#     select functions, but you can simulate most of the standard import syntax
#     behavior.
#     >>> m = import_optional('math')
#     >>> m.log10(100)
#     2.0
# 
#     Trying to import a module that does not exists, does not produce
#     any errors. Only when some function is used, the code triggers an error
#     >>> m = import_optional('nonexistentmodule')  # noqa
#     >>> m.log10(100)  #doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     AttributeError: Module 'nonexistentmodule' is not installed.
#     <BLANKLINE>
#     You tried to access function/module/attribute 'log10'
#     from module 'nonexistentmodule'.
#     This module is optional right now in wradlib.
#     You need to separately install this dependency.
#     Please refer to https://docs.wradlib.org/en/stable/installation.html#optional-dependencies
#     for further instructions.
#     """
#     try:
#         mod = importlib.import_module(module)
#     except ImportError:
#         mod = OptionalModuleStub(module)
# 
#     return mod


# Path: wradlib/georef/polar.py
import warnings
import numpy as np
from wradlib.georef import misc, projection
from wradlib.util import has_import, import_optional

    if angle is None:
        angle = 0.0

    if elev is None:
        elev = 0.0

    if autoext:
        # the ranges need to go 'one bin further', assuming some regularity
        # we extend by the distance between the preceding bins.
        x = np.append(d1, d1[-1] + (d1[-1] - d1[-2]))
        # the angular dimension is supposed to be cyclic, so we just add the
        # first element
        y = np.append(d2, d2[0])
    else:
        # no autoext basically is only useful, if the user supplied the correct
        # dimensions himself.
        x = d1
        y = d2

    # roll data array to specified azimuth, assuming equidistant azimuth angles
    ind = (d2 >= angle).nonzero()[0][0]
    data = np.roll(data, ind, axis=0)

    # build cartesian range array, add delta to last element to compensate for
    # open bound (np.digitize)
    dc = np.linspace(-np.max(d1), np.max(d1) + 0.0001, num=d1.shape[0] * 2 + 1)

    # get height values from polar data and build cartesian height array
    # add delta to last element to compensate for open bound (np.digitize)
    hp = np.zeros((y.shape[0], x.shape[0]))

    hc = misc.bin_altitude(x, elev, 0, re=6370040.0)