coeff = kwargs.pop('nc', int(np.ceil(np.sqrt(len(x))))) from pygimli.frameworks import harmfitNative return harmfitNative(u, x=x, nc=coeff, xc=xi, err=None)[0] if 'spline' in method: if pg.optImport("scipy", requiredFor="use interpolate splines."): from scipy import interpolate tck = interpolate.splrep(x, u, s=0) return interpolate.splev(xi, tck, der=0) else: return xi * 0. if len(args) == 2: # args curve, t curve = args[0] t = args[1] return interpolateAlongCurve(curve, t, **kwargs) if __name__ == '__main__': # no need to import matplotlib. pygimli's show does # import pygimli as pg import pygimli.meshtools as mt elec = np.arange(11.) topo = np.array([[0., 0.], [3., 2.], [4., 2.], [6., 1.], [10., 1.]]) pg.plt.plot(topo[:, 0], topo[:, 1]) p = mt.tapeMeasureToCoordinates(topo, elec) pg.plt.plot(p[:, 0], p[:, 1], 'o') pg.plt.gca().set_aspect(1) pg.wait()
if 'harmonic' in method: coeff = kwargs.pop('nc', int(np.ceil(np.sqrt(len(x))))) from pygimli.frameworks import harmfitNative return harmfitNative(u, x=x, nc=coeff, xc=xi, err=None)[0] if 'spline' in method: if pg.optImport("scipy", requiredFor="use interpolate splines."): from scipy import interpolate tck = interpolate.splrep(x, u, s=0) return interpolate.splev(xi, tck, der=0) else: return xi*0. if len(args) == 2: # args curve, t curve = args[0] t = args[1] return interpolateAlongCurve(curve, t, **kwargs) if __name__ == '__main__': # no need to import matplotlib. pygimli's show does # import pygimli as pg import pygimli.meshtools as mt elec = np.arange(11.) topo = np.array([[0., 0.], [3., 2.], [4., 2.], [6., 1.], [10., 1.]]) pg.plt.plot(topo[:, 0], topo[:, 1]) p = mt.tapeMeasureToCoordinates(topo, elec) pg.plt.plot(p[:, 0], p[:, 1], 'o') pg.plt.gca().set_aspect(1) pg.wait()