Coverage for pygeodesy/heights.py : 92%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
L{HeightIDWcosineForsytheAndoyerLambert}, L{HeightIDWcosineLaw}, L{HeightIDWdistanceTo}, L{HeightIDWequirectangular}, L{HeightIDWeuclidean}, L{HeightIDWflatLocal}, L{HeightIDWflatPolar}, L{HeightIDWhaversine}, L{HeightIDWhubeny}, L{HeightIDWkarney}, L{HeightIDWthomas}, L{HeightIDWvincentys}, L{HeightLinear}, L{HeightLSQBiSpline} and L{HeightSmoothBiSpline} to interpolate the height of C{LatLon} locations or separate lat-/longitudes from a set of C{LatLon} points with known heights.
Classes L{HeightCubic} and L{HeightLinear} require package U{numpy <https://PyPI.org/project/numpy>}, classes L{HeightLSQBiSpline} and L{HeightSmoothBiSpline} require package U{scipy<https://SciPy.org>} and classes L{HeightIDWdistanceTo} -iff used with L{ellipsoidalKarney.LatLon} points- and L{HeightIDWkarney} requires I{Charles Karney's} U{geographiclib<https://PyPI.org/project/geographiclib>} to be installed.
Typical usage is as follows. First create an interpolator from a given set of C{LatLon} points with known heights, called C{knots}.
C{hinterpolator = HeightXyz(knots, **options)}
Get the interpolated height of other C{LatLon} location(s) with
C{h = hinterpolator(ll)}
or
C{h0, h1, h2, ... = hinterpolator(ll0, ll1, ll2, ...)}
or
C{hs = hinterpolator(lls)} # C{list, tuple, generator, ...}
For separate lat-/longitudes invoke the C{.height} method
C{h = hinterpolator.height(lat, lon)}
or
C{h0, h1, h2, ... = hinterpolator.height(lats, lons)} # C{list, ...}
The C{knots} do not need to be ordered for any of the height interpolators.
Errors from C{scipy} as raised as L{SciPyError}s. Warnings issued by C{scipy} can be thrown as L{SciPyWarning} exceptions, provided Python C{warnings} are filtered accordingly, see L{SciPyWarning}.
@see: U{SciPy<https://docs.SciPy.org/doc/scipy/reference/interpolate.html>}. '''
isscalar, len2, map1, map2, \ property_RO, _xinstanceof _SciPyIssue cosineLaw_, euclidean_, flatPolar_, haversine_, \ _scale_rad, thomas_, vincentys_
'''Height interpolator C{Height...} or interpolation issue. '''
# return list of floats, not numpy.float64s
# dtermine return type and convert lli C{LatLon}s to list raise _AssertionError('type(%s): %r' % ('*llis', llis))
else: # of 0, 2 or more llis
raise _insufficientError(m, Error=Error, llis=n)
# return single float, not numpy.float64 raise _AssertionError('len(%r): %s != 1' % (ais, len(ais)))
# return tuple of floats, not numpy.float64s
# convert lli C{LatLon}s to tuples or C{NumPy} arrays of # C{SciPy} sphericals and determine the return type
# create an insufficient Error instance t = 'insufficient, need %s' % (need,) return Error(txt=t, **name_value)
# clip, order and remove duplicates
# map (lat, lon, h) to (x, y, h) in radians, offset as # x: 0 <= lon <= PI2, y: 0 <= lat <= PI if off is True # else x: -PI <= lon <= PI, y: -PI_2 <= lat <= PI_2 else: # undo offset (max(0.0, radiansPI( ll.lat + 90.0)) - yf), ll.height raise HeightError(_item_(name, i), ll, txt=str(x))
# convert knot C{LatLon}s to tuples or C{NumPy} arrays and C{SciPy} sphericals raise _insufficientError(m, knots=n)
'''(INTERNAL) Interpolator base class. '''
def __call__(self, *args): # PYCHOK no cover '''(INTERNAL) I{Must be overloaded}. ''' notOverloaded(self, '__call__', *args)
def adjust(self): '''Get the adjust setting (C{bool} or C{None} if not applicable). '''
def datum(self): '''Get the datum (L{Datum} or C{None} if not applicable). '''
def _ev(self, *args): # PYCHOK no cover '''(INTERNAL) I{Must be overloaded}. ''' notOverloaded(self, self._ev, *args)
except Exception as x: raise _SciPyIssue(x)
else: # format a LenError, but raise an Error e = LenError(self.__class__, lats=n, lons=m, txt=None) raise e if Error is LenError else Error(str(e))
def kmin(self): '''Get the minimum number of knots (C{int}). '''
'''(INTERNAL) Import C{numpy} and C{scipy}. ''' if throwarnings: # raise SciPyWarnings, but ... # ... not if scipy has been imported already import sys if 'scipy' not in sys.modules: import warnings warnings.filterwarnings('error')
def wrap(self): '''Get the wrap setting (C{bool} or C{None} if not applicable). '''
'''Height interpolator based on C{SciPy} U{interp2d<https://docs.SciPy.org/ doc/scipy/reference/generated/scipy.interpolate.interp2d.html>} C{kind='cubic'}. '''
'''New L{HeightCubic} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or invalid B{C{knot}}.
@raise ImportError: Package C{numpy} or C{scipy} not found or not installed.
@raise SciPyError: A C{scipy.interpolate.interp2d} issue.
@raise SciPyWarning: A C{scipy.interpolate.interp2d} warning as exception. '''
except Exception as x: raise _SciPyIssue(x)
self.name = name
'''Interpolate the height for one or several locations.
@arg llis: The location or locations (C{LatLon}, ... or C{LatLon}s).
@return: A single interpolated height (C{float}) or a list or tuple of interpolated heights (C{float}s).
@raise HeightError: Insufficient number of B{C{llis}} or an invalid B{C{lli}}.
@raise SciPyError: A C{scipy.interpolate.interp2d} issue.
@raise SciPyWarning: A C{scipy.interpolate.interp2d} warning as exception. '''
# to make SciPy .interp2d signature(x, y), single (x, y) # match SciPy .ev signature(ys, xs), flipped multiples
'''Interpolate the height for one or several lat-/longitudes.
@arg lats: Latitude or latitudes (C{degrees} or C{degrees}s). @arg lons: Longitude or longitudes (C{degrees} or C{degrees}s).
@return: A single interpolated height (C{float}) or a list of interpolated heights (C{float}s).
@raise HeightError: Insufficient or non-matching number of B{C{lats}} and B{C{lons}}.
@raise SciPyError: A C{scipy.interpolate.interp2d} issue.
@raise SciPyWarning: A C{scipy.interpolate.interp2d} warning as exception. '''
'''Height interpolator based on C{SciPy} U{interp2d<https://docs.SciPy.org/ doc/scipy/reference/generated/scipy.interpolate.interp2d.html>} C{kind='linear}. '''
'''New L{HeightLinear} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}}.
@raise ImportError: Package C{numpy} or C{scipy} not found or not installed.
@raise SciPyError: A C{scipy.interpolate.interp2d} issue.
@raise SciPyWarning: A C{scipy.interpolate.interp2d} warning as exception. '''
if _FOR_DOCS: __call__ = HeightCubic.__call__ height = HeightCubic.height
'''(INTERNAL) Base class for U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) height interpolators. '''
'''New L{_HeightIDW} interpolator. ''' self.name = name
'''Interpolate the height for one or several locations.
@arg llis: The location or locations (C{LatLon}, ... or C{LatLon}s).
@return: A single interpolated height (C{float}) or a list or tuple of interpolated heights (C{float}s).
@raise HeightError: Insufficient number of B{C{llis}}, an invalid B{C{lli}} or an L{fidw} issue. '''
'''(INTERNAL) Set the datum. '''
'''Must be overloaded. ''' raise NotImplementedError('method: %s' % (self._distances.__name__,))
# return angular distances from func_
# return angular distances from func_
# interpolate height at (x, y) radians or degrees except ValueError as x: raise HeightError(str(x))
def beta(self): '''Get the inverse distance power (C{int}). '''
def beta(self, beta): '''Set the inverse distance power.
@arg beta: New inverse distance power (C{int} 1, 2, or 3).
@raise HeightError: Invalid B{C{beta}}. '''
'''Interpolate the height for one or several lat-/longitudes.
@arg lats: Latitude or latitudes (C{degrees} or C{degrees}s). @arg lons: Longitude or longitudes (C{degrees} or C{degrees}s).
@return: A single interpolated height (C{float}) or a list of interpolated heights (C{float}s).
@raise HeightError: Insufficient or non-matching number of B{C{lats}} and B{C{lons}} or an L{fidw} issue. '''
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians} from function L{cosineAndoyerLambert_}.
@see: L{HeightIDWcosineForsytheAndoyerLambert}, L{HeightIDWdistanceTo}, L{HeightIDWflatLocal}, L{HeightIDWhubeny}, L{HeightIDWthomas}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}. '''
'''New L{HeightIDWcosineAndoyerLambert} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{knots}}' datum (L{Datum}). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg wrap: Wrap and L{unrollPI} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{beta}}.
@raise TypeError: Invalid B{C{datum}}. '''
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians} from function L{cosineForsytheAndoyerLambert_}.
@see: L{HeightIDWcosineAndoyerLambert}, L{HeightIDWdistanceTo}, L{HeightIDWflatLocal}, L{HeightIDWhubeny}, L{HeightIDWthomas}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}. '''
'''New L{HeightIDWcosineForsytheAndoyerLambert} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{knots}}' datum (L{Datum}). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg wrap: Wrap and L{unrollPI} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{beta}}.
@raise TypeError: Invalid B{C{datum}}. '''
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians} from function L{cosineLaw_}.
@see: L{HeightIDWequirectangular}, L{HeightIDWeuclidean}, L{HeightIDWflatPolar}, L{HeightIDWhaversine}, L{HeightIDWvincentys}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}.
@note: See note at function L{vincentys_}. '''
'''New L{HeightIDWcosineLaw} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg wrap: Wrap and L{unrollPI} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{beta}}. '''
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the distance from the points' C{LatLon.distanceTo} method, conventionally in C{meter}.
@see: L{HeightIDWcosineAndoyerLambert}, L{HeightIDWcosineForsytheAndoyerLambert}, L{HeightIDWflatPolar}, L{HeightIDWkarney}, L{HeightIDWthomas}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}. '''
'''New L{HeightIDWdistanceTo} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg name: Optional name for this height interpolator (C{str}). @kwarg distanceTo_kwds: Optional keyword arguments for the B{C{points}}' C{LatLon.distanceTo} method.
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{beta}}.
@raise ImportError: Package U{GeographicLib <https://PyPI.org/project/geographiclib>} missing iff B{C{points}} are L{ellipsoidalKarney.LatLon}s.
@note: All B{C{points}} I{must} be instances of the same ellipsoidal or spherical C{LatLon} class, I{not checked however}. ''' n, self._ks = len2(knots) if n < self._kmin: raise _insufficientError(self._kmin, knots=n)
self.beta = beta if name: self.name = name if distanceTo_kwds: self._distanceTo_kwds = distanceTo_kwds
'''Interpolate the height for one or several locations.
@arg llis: The location or locations (C{LatLon}, ... or C{LatLon}s).
@return: A single interpolated height (C{float}) or a list or tuple of interpolated heights (C{float}s).
@raise HeightError: Insufficient number of B{C{llis}}, an invalid B{C{lli}} or an L{fidw} issue. ''' _as, llis = _allis2(llis) return _as(map(self._hIDW, llis))
'''Interpolate the height for one or several lat-/longitudes.
@raise HeightError: Not implemented. ''' return HeightError('not implemented: %s.%s' % (self.classname, self.height.__name__))
# interpolate height at point lli try: kwds = self._distanceTo_kwds ds = (k.distanceTo(lli, **kwds) for k in self._ks) return fidw(self._hs, ds, beta=self._beta) except ValueError as x: raise HeightError(str(x))
def _hs(self): # see HeightIDWkarney for k in self._ks: yield k.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians squared} like function L{equirectangular_}.
@see: L{HeightIDWeuclidean}, L{HeightIDWflatPolar}, L{HeightIDWhaversine}, L{HeightIDWvincentys}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}. '''
'''New L{HeightIDWequirectangular} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg adjust: Adjust the wrapped, unrolled longitudinal delta by the cosine of the mean latitude (C{bool}). @kwarg wrap: Wrap and L{unrollPI} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}}. ''' adjust=adjust)
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians} from function L{euclidean_}.
@see: L{HeightIDWcosineLaw}, L{HeightIDWequirectangular}, L{HeightIDWhaversine}, L{HeightIDWvincentys}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}. '''
'''New L{HeightIDWeuclidean} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg adjust: Adjust the longitudinal delta by the cosine of the mean latitude for B{C{adjust}}=C{True}. @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{beta}}. '''
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians squared} like function L{flatLocal_}/L{hubeny_}.
@see: L{HeightIDWcosineAndoyerLambert}, L{HeightIDWcosineForsytheAndoyerLambert}, L{HeightIDWdistanceTo}, L{HeightIDWhubeny}, L{HeightIDWthomas}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}. '''
'''New L{HeightIDWflatLocal}/L{HeightIDWhubeny} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{knots}}' datum (L{Datum}). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg wrap: Wrap and L{unrollPI} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{beta}}.
@raise TypeError: Invalid B{C{datum}}. '''
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians} from function L{flatPolar_}.
@see: L{HeightIDWcosineLaw}, L{HeightIDWequirectangular}, L{HeightIDWeuclidean}, L{HeightIDWhaversine}, L{HeightIDWvincentys}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}. '''
'''New L{HeightIDWflatPolar} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg wrap: Wrap and L{unrollPI} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{beta}}. '''
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians} from function L{haversine_}.
@see: L{HeightIDWcosineLaw}, L{HeightIDWequirectangular}, L{HeightIDWeuclidean}, L{HeightIDWflatPolar}, L{HeightIDWvincentys}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}.
@note: See note at function L{vincentys_}. '''
'''New L{HeightIDWhaversine} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg wrap: Wrap and L{unrollPI} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an B{C{knot}} or B{C{beta}}. '''
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
if _FOR_DOCS: __doc__ = HeightIDWflatLocal.__doc__ __init__ = HeightIDWflatLocal.__init__ __call__ = HeightIDWflatLocal.__call__ height = HeightIDWflatLocal.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{degrees} from I{Charles F. F. Karney's} U{GeographicLib<https://PyPI.org/project/geographiclib>} U{Geodesic <https://geographiclib.sourceforge.io/1.49/python/code.html>} Inverse method.
@see: L{HeightIDWcosineAndoyerLambert}, L{HeightIDWcosineForsytheAndoyerLambert}, L{HeightIDWdistanceTo}, L{HeightIDWflatLocal}, L{HeightIDWhubeny}, L{HeightIDWthomas}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}. '''
'''New L{HeightIDWkarney} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{knots}}' datum (L{Datum}). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg wrap: Wrap and L{unroll180} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}}, B{C{datum}} or B{C{beta}}.
@raise ImportError: Package U{GeographicLib <https://PyPI.org/project/geographiclib>} missing.
@raise TypeError: Invalid B{C{datum}}. ''' raise _insufficientError(self._kmin, knots=n)
self.name = name
# non-negative I{angular} distance in C{degrees}
def _hs(self): # see HeightIDWdistanceTo
'''Interpolate the height for one or several locations.
@arg llis: The location or locations (C{LatLon}, ... or C{LatLon}s).
@return: A single interpolated height (C{float}) or a list or tuple of interpolated heights (C{float}s).
@raise HeightError: Insufficient number of B{C{llis}}, an invalid B{C{lli}} or an L{fidw} issue. ''' raise HeightError(_item_('llis', i), ll, txt=str(x))
if _FOR_DOCS: height = _HeightIDW.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians} from function L{thomas_}.
@see: L{HeightIDWcosineAndoyerLambert}, L{HeightIDWcosineForsytheAndoyerLambert}, L{HeightIDWdistanceTo}, L{HeightIDWflatLocal}, L{HeightIDWhubeny}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}. '''
'''New L{HeightIDWthomas} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{knots}}' datum (L{Datum}). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg wrap: Wrap and L{unrollPI} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{beta}}.
@raise TypeError: Invalid B{C{datum}}. '''
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
'''Height interpolator using U{Inverse Distance Weighting <https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW) and the I{angular} distance in C{radians} from function L{vincentys_}.
@see: L{HeightIDWcosineLaw}, L{HeightIDWequirectangular}, L{HeightIDWeuclidean}, L{HeightIDWflatPolar}, L{HeightIDWhaversine}, U{IDW<https://www.Geo.FU-Berlin.DE/en/v/soga/Geodata-analysis/ geostatistics/Inverse-Distance-Weighting/index.html>} and U{SHEPARD_INTERP_2D<https://People.SC.FSU.edu/~jburkardt/c_src/ shepard_interp_2d/shepard_interp_2d.html>}.
@note: See note at function L{vincentys_}. '''
'''New L{HeightIDWvincentys} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg beta: Inverse distance power (C{int} 1, 2, or 3). @kwarg wrap: Wrap and L{unrollPI} longitudes (C{bool}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{beta}}. '''
if _FOR_DOCS: __call__ = _HeightIDW.__call__ height = _HeightIDW.height
'''Height interpolator using C{SciPy} U{LSQSphereBivariateSpline <https://docs.SciPy.org/doc/scipy/reference/generated/scipy. interpolate.LSQSphereBivariateSpline.html>}. '''
'''New L{HeightLSQBiSpline} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg weight: Optional weight or weights for each B{C{knot}} (C{scalar} or C{scalar}s). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{weight}}.
@raise LenError: Number of B{C{knots}} and B{C{weight}}s don't match.
@raise ImportError: Package C{numpy} or C{scipy} not found or not installed.
@raise SciPyError: A C{LSQSphereBivariateSpline} issue.
@raise SciPyWarning: A C{LSQSphereBivariateSpline} warning as exception. '''
raise HeightError(weight=w) raise LenError(HeightLSQBiSpline, weight=m, knots=n) raise HeightError(_item_(weight=w.find(m)), m) ts, ps, eps=EPS, w=w).ev raise _SciPyIssue(x)
self.name = name
'''Interpolate the height for one or several locations.
@arg llis: The location or locations (C{LatLon}, ... or C{LatLon}s).
@return: A single interpolated height (C{float}) or a list or tuple of interpolated heights (C{float}s).
@raise HeightError: Insufficient number of B{C{llis}} or an invalid B{C{lli}}.
@raise SciPyError: A C{LSQSphereBivariateSpline} issue.
@raise SciPyWarning: A C{LSQSphereBivariateSpline} warning as exception. '''
'''Interpolate the height for one or several lat-/longitudes.
@arg lats: Latitude or latitudes (C{degrees} or C{degrees}s). @arg lons: Longitude or longitudes (C{degrees} or C{degrees}s).
@return: A single interpolated height (C{float}) or a list of interpolated heights (C{float}s).
@raise HeightError: Insufficient or non-matching number of B{C{lats}} and B{C{lons}}.
@raise SciPyError: A C{LSQSphereBivariateSpline} issue.
@raise SciPyWarning: A C{LSQSphereBivariateSpline} warning as exception. '''
'''Height interpolator using C{SciPy} U{SmoothSphereBivariateSpline <https://docs.SciPy.org/doc/scipy/reference/generated/scipy. interpolate.SmoothSphereBivariateSpline.html>}. '''
'''New L{HeightSmoothBiSpline} interpolator.
@arg knots: The points with known height (C{LatLon}s). @kwarg s: The spline smoothing factor (C{4}). @kwarg name: Optional name for this height interpolator (C{str}).
@raise HeightError: Insufficient number of B{C{knots}} or an invalid B{C{knot}} or B{C{s}}.
@raise ImportError: Package C{numpy} or C{scipy} not found or not installed.
@raise SciPyError: A C{SmoothSphereBivariateSpline} issue.
@raise SciPyWarning: A C{SmoothSphereBivariateSpline} warning as exception. '''
eps=EPS, s=s).ev except Exception as x: raise _SciPyIssue(x)
self.name = name
'''Interpolate the height for one or several locations.
@arg llis: The location or locations (C{LatLon}, ... or C{LatLon}s).
@return: A single interpolated height (C{float}) or a list or tuple of interpolated heights (C{float}s).
@raise HeightError: Insufficient number of B{C{llis}} or an invalid B{C{lli}}.
@raise SciPyError: A C{SmoothSphereBivariateSpline} issue.
@raise SciPyWarning: A C{SmoothSphereBivariateSpline} warning as exception. '''
'''Interpolate the height for one or several lat-/longitudes.
@arg lats: Latitude or latitudes (C{degrees} or C{degrees}s). @arg lons: Longitude or longitudes (C{degrees} or C{degrees}s).
@return: A single interpolated height (C{float}) or a list of interpolated heights (C{float}s).
@raise HeightError: Insufficient or non-matching number of B{C{lats}} and B{C{lons}}.
@raise SciPyError: A C{SmoothSphereBivariateSpline} issue.
@raise SciPyWarning: A C{SmoothSphereBivariateSpline} warning as exception. '''
# **) MIT License # # Copyright (C) 2016-2020 -- mrJean1 at Gmail -- All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. |