def testGeoid(self, G, grid, llh3, crop=None, eps=None, kind=None): # MCCABE 13 # test geoid G(grid) for (lat, lon, height, eps) if scipy or G is GeoidKarney: e_max = 0 eps = eps or self._epsHeight f = self.failed - self.known g = G(grid, kind=kind or self._kind, crop=crop) s = '%s.height(%%s) kind %s' % (g, g.kind) try: for lat, lon, expected in llh3: t = s % (fStr((lat, lon), prec=3),) try: h = g.height(lat, lon) e = abs(h - expected) if e_max < e: e_max = e self.test(t, h, expected, fmt='%.3f', known=e < eps) except GeoidError as x: self.test(t, str(x), '%.3f' % (expected,), known=G not in (GeoidKarney, GeoidPGM)) except RangeError as x: self.test(t, str(x), '%.3f' % (expected,), known=bool(crop)) except KeyboardInterrupt as x: self.printf(repr(x), nl=1) f = self.failed - self.known - f if f > 0 or e_max > 0: h = '' if g.hits is None else ', hits %s' % (g.hits,) t = '%s.height() kind %s%s, eps max (in %s FAILED)' % (g, g.kind, h, f) x = eps if f > 0 else e_max self.test(t, e_max, x, fmt='%.3f', known=e_max < eps, nl=1, nt=1) # print('%r\n\n%r' % (g, getattr(g, 'pgm', None))) if coverage: for a in ('highest', 'lowerleft', 'lowerright', 'lowest', 'upperleft', 'upperright'): t = fStr(getattr(g, a)(), prec=3) self.test('%s.%s()' % (g, a), t, t, known=True) for p in ('dtype', 'knots', 'mean', 'nBytes', 'scipy', 'smooth', 'stdev'): # , 'pgm' t = ''.join(reprs((getattr(g, p),), prec=3)) self.test('%s.%s' % (g, p), t, t, known=True) for a in ('_g2ll2', '_ll2g2'): t = getattr(g, a)(180, 360) self.test('%s.%s(180, 360)' % (g, a), t, t, known=True) for t in ((LatLon_(-10, -100), LatLon_(10, 100)), ( (-10, -100), (10, 100))): t = g._swne(t) self.test('%s.%s' % (g, '_swne'), t, '(-10.0, -100.0, 10.0, 100.0)') t = g.toStr() self.test('%s.%s' % (g, 'toStr'), t, t, known=True, nt=1) self.testCopy(g) else: n, _ = len2(llh3) self.skip('no scipy', n=n)
def testGeoid(self, G, grid, llh3, crop=None, eps=None, kind=None): # test geoid G(grid) for (lat, lon, height, eps) if scipy or G is GeoidKarney: e_max = 0 eps = eps or self._epsHeight f = self.failed - self.known g = G(grid, kind=kind or self._kind, crop=crop) s = '%s.height(%%s) kind %s' % (g, g.kind) try: for lat, lon, expected in llh3: t = s % (fStr((lat, lon), prec=3), ) try: h = g.height(lat, lon) e = abs(h - expected) if e_max < e: e_max = e self.test(t, h, expected, fmt='%.3f', known=e < eps) except GeoidError as x: self.test(t, str(x), '%.3f' % (expected, ), known=G not in (GeoidKarney, GeoidPGM)) except RangeError as x: self.test(t, str(x), '%.3f' % (expected, ), known=bool(crop)) except KeyboardInterrupt as x: self.printf(repr(x), nl=1) f = self.failed - self.known - f if f > 0 or e_max > 0: h = '' if g.hits is None else ', hits %s' % (g.hits, ) t = '%s.height() kind %s%s, eps max (in %s FAILED)' % ( g, g.kind, h, f) x = eps if f > 0 else e_max self.test(t, e_max, x, fmt='%.3f', known=e_max < eps, nl=1, nt=1) # print('%r\n\n%r' % (g, getattr(g, 'pgm', None))) if coverage: # for test coverage for a in ('highest', '_llh3minmax', 'lowest', 'lowerright', 'upperleft'): t = fStr(getattr(g, a)(), prec=3) self.test('%s.%s' % (g, a), t, t, known=True) t = g.toStr() self.test('%s.%s' % (g, 'toStr'), t, t, known=True, nt=1) else: n, _ = len2(llh3) self.skip('no scipy', n=n)