# Path: wradlib/georef/polar.py
# def spherical_to_xyz(
#     r, phi, theta, sitecoords, re=None, ke=4.0 / 3.0, squeeze=False, strict_dims=False
# ):
# def spherical_to_proj(r, phi, theta, sitecoords, proj=None, re=None, ke=4.0 / 3.0):
# def centroid_to_polyvert(centroid, delta):
# def spherical_to_polyvert(r, phi, theta, sitecoords, proj=None):
# def spherical_to_centroids(r, phi, theta, sitecoords, proj=None):
# def _check_polar_coords(r, az):
# def _is_sorted(x):
# def _get_range_resolution(x):
# def _get_azimuth_resolution(x):
# def sweep_centroids(nrays, rscale, nbins, elangle):
# def maximum_intensity_projection(
#     data, r=None, az=None, angle=None, elev=None, autoext=True
# ):
# 
# 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 collections
import numpy as np
import xarray as xr
from wradlib.georef import polar
from wradlib.util import has_import, import_optional
    """
    proj = kwargs.pop("proj", "None")
    re = kwargs.pop("re", None)
    ke = kwargs.pop("ke", 4.0 / 3.0)

    # adding xyz aeqd-coordinates
    site = (
        obj.coords["longitude"].values,
        obj.coords["latitude"].values,
        obj.coords["altitude"].values,
    )

    if site == (0.0, 0.0, 0.0):
        re = 6378137.0

    # create meshgrid to overcome dimension problem with spherical_to_xyz
    r, az = np.meshgrid(obj["range"], obj["azimuth"])

    # GDAL OSR, convert to this proj
    if has_import(osr) and isinstance(proj, osr.SpatialReference):
        xyz = polar.spherical_to_proj(
            r, az, obj["elevation"], site, proj=proj, re=re, ke=ke
        )
    # other proj, convert to aeqd
    elif proj:
        xyz, dst_proj = polar.spherical_to_xyz(
            r, az, obj["elevation"], site, re=re, ke=ke, squeeze=True
        )
    # proj, convert to aeqd and add offset
    else:

# Path: wradlib/georef/polar.py
# def spherical_to_xyz(
#     r, phi, theta, sitecoords, re=None, ke=4.0 / 3.0, squeeze=False, strict_dims=False
# ):
# def spherical_to_proj(r, phi, theta, sitecoords, proj=None, re=None, ke=4.0 / 3.0):
# def centroid_to_polyvert(centroid, delta):
# def spherical_to_polyvert(r, phi, theta, sitecoords, proj=None):
# def spherical_to_centroids(r, phi, theta, sitecoords, proj=None):
# def _check_polar_coords(r, az):
# def _is_sorted(x):
# def _get_range_resolution(x):
# def _get_azimuth_resolution(x):
# def sweep_centroids(nrays, rscale, nbins, elangle):
# def maximum_intensity_projection(
#     data, r=None, az=None, angle=None, elev=None, autoext=True
# ):
# 
# 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/xarray.py
import collections
import numpy as np
import xarray as xr
from wradlib.georef import polar
from wradlib.util import has_import, import_optional

    """
    proj = kwargs.pop("proj", "None")
    re = kwargs.pop("re", None)
    ke = kwargs.pop("ke", 4.0 / 3.0)

    # adding xyz aeqd-coordinates
    site = (
        obj.coords["longitude"].values,
        obj.coords["latitude"].values,
        obj.coords["altitude"].values,
    )

    if site == (0.0, 0.0, 0.0):
        re = 6378137.0

    # create meshgrid to overcome dimension problem with spherical_to_xyz
    r, az = np.meshgrid(obj["range"], obj["azimuth"])

    # GDAL OSR, convert to this proj
    if has_import(osr) and isinstance(proj, osr.SpatialReference):
        xyz = polar.spherical_to_proj(
            r, az, obj["elevation"], site, proj=proj, re=re, ke=ke
        )
    # other proj, convert to aeqd
    elif proj:
        xyz, dst_proj = polar.spherical_to_xyz(
            r, az, obj["elevation"], site, re=re, ke=ke, squeeze=True
        )
    # proj, convert to aeqd and add offset
    else:

        xyz, dst_proj = polar.spherical_to_xyz(