# 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 numpy as np
from wradlib.georef import projection
from wradlib.util import has_import, import_optional
    ----------
    xyz : :class:`numpy:numpy.ndarray`
        Array of shape (..., 3). Contains cartesian coordinates.
    alt : float
        Altitude (in meters)
        defaults to 0.
    proj : :py:class:`gdal:osgeo.osr.SpatialReference`)
        projection of the source coordinates (aeqd) with spheroid model
        defaults to None.
    ke : float
        Adjustment factor to account for the refractivity gradient that
        affects radar beam propagation. In principle this is wavelength-
        dependent. The default of 4/3 is a good approximation for most
        weather radar wavelengths

    Returns
    -------
    r : :class:`numpy:numpy.ndarray`
        Array of xyz.shape. Contains the radial distances.
    theta: :class:`numpy:numpy.ndarray`
        Array of xyz.shape. Contains the elevation angles.
    phi : :class:`numpy:numpy.ndarray`
        Array of xyz.shape. Contains the azimuthal angles.
    """

    # get the approximate radius of the projection's ellipsoid
    # for the latitude_of_center, if no projection is given assume
    # spherical earth
    try:
        lat0 = proj.GetProjParm("latitude_of_center")

# 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/rect.py
import numpy as np
from wradlib.georef import projection
from wradlib.util import has_import, import_optional

    ----------
    xyz : :class:`numpy:numpy.ndarray`
        Array of shape (..., 3). Contains cartesian coordinates.
    alt : float
        Altitude (in meters)
        defaults to 0.
    proj : :py:class:`gdal:osgeo.osr.SpatialReference`)
        projection of the source coordinates (aeqd) with spheroid model
        defaults to None.
    ke : float
        Adjustment factor to account for the refractivity gradient that
        affects radar beam propagation. In principle this is wavelength-
        dependent. The default of 4/3 is a good approximation for most
        weather radar wavelengths

    Returns
    -------
    r : :class:`numpy:numpy.ndarray`
        Array of xyz.shape. Contains the radial distances.
    theta: :class:`numpy:numpy.ndarray`
        Array of xyz.shape. Contains the elevation angles.
    phi : :class:`numpy:numpy.ndarray`
        Array of xyz.shape. Contains the azimuthal angles.
    """

    # get the approximate radius of the projection's ellipsoid
    # for the latitude_of_center, if no projection is given assume
    # spherical earth
    try:
        lat0 = proj.GetProjParm("latitude_of_center")

        re = projection.get_earth_radius(lat0, proj)