def testKernel2dModelDefault(self): print("*******************************************************") print("* Kernel2dModel Circular Gauss *") print("*******************************************************") m = Kernel2dModel() self.assertTrue(m.npchain, 4) x1 = numpy.arange(101, dtype=float) / 25.0 - 2.02 x = x1.copy() x = numpy.append(x, x1 + 0.01, 0).reshape(101, 2) print(x) p = m.parameters print(m) print(x[40, :]) m.testPartial([x[40, :]], p) for k in range(4): print("%d %-12s %-12s" % (k, m.getParameterName(k), m.getParameterUnit(k))) p = numpy.asarray([1.0, 1.01, 3.0, 1.2], dtype=float) part = m.partial(x, p) nump = m.numPartial(x, p) assertAAE(part, nump, 4) mc = m.copy() mc.parameters = p m.parameters = p assertAAE(m.result(x), mc.result(x)) self.assertTrue(isinstance(mc.kernel, Gauss))
def testKernel2dModelCosine(self): print("*******************************************************") print("* Kernel2dModel Elliptic Cosine *") print("*******************************************************") m = Kernel2dModel(kernel=Cosine(), shape=2) self.assertTrue(m.npchain, 5) x1 = numpy.arange(101, dtype=float) / 25.0 - 2.02 x = x1.copy() x = numpy.append(x, x1 + 0.01, 0).reshape(101, 2) p = m.parameters print(m) m.testPartial([[0.1, 0.2]], p) for k in range(m.npbase): print("%d %-12s %-12s" % (k, m.getParameterName(k), m.getParameterUnit(k))) p = numpy.asarray([1.0, 1.01, 3.0, 1.2, 2.0], dtype=float) part = m.partial(x, p) nump = m.numPartial(x, p) assertAAE(part, nump, 4) mc = m.copy() mc.parameters = p m.parameters = p assertAAE(m.result(x), mc.result(x)) self.assertTrue(isinstance(mc.kernel, Cosine))
def testKernel2dModel3( self, plot=False ): x = numpy.asarray( [[-1.0, -0.8], [-0.6, -0.4], [-0.2, 0.0], [0.2, 0.4], [0.6, 0.8], [1.0, -1.0], [-0.8, -0.6], [-0.4, -0.2], [0.0, 0.2], [0.4, 0.6], [0.8, 1.0]] ) print( "******KERNEL2D ROTATED********************" ) m = Kernel2dModel( shape=3 ) self.assertTrue( m.npchain == 6 ) self.assertTrue( m.npbase == 6 ) p = [-1.1, 0.5, 0.04, 1.2, 1.3, 1.1] self.stdModeltest( m, p, plot=plot )
def testKernel2dModel1( self, plot=False ): x = numpy.asarray( [[-1.0, -0.8], [-0.6, -0.4], [-0.2, 0.0], [0.2, 0.4], [0.6, 0.8], [1.0, -1.0], [-0.8, -0.6], [-0.4, -0.2], [0.0, 0.2], [0.4, 0.6], [0.8, 1.0]] ) print( "******KERNEL2D CIRCULAR********************" ) m = Kernel2dModel( ) self.assertTrue( m.npchain == 4 ) self.assertTrue( m.npbase == 4 ) p = [-1.1, 0.5, 0.04, 1.2] self.stdModeltest( m, p, plot=plot )
def testKernel2dModel2( self, plot=False ): x = numpy.asarray( [[-1.0, -0.8], [-0.6, -0.4], [-0.2, 0.0], [0.2, 0.4], [0.6, 0.8], [1.0, -1.0], [-0.8, -0.6], [-0.4, -0.2], [0.0, 0.2], [0.4, 0.6], [0.8, 1.0]] ) print( "******KERNEL2D ELLIPTIC********************" ) m = Kernel2dModel( shape=2, fixed={0:1} ) self.assertTrue( m.npmax == 5 ) self.assertTrue( m.npchain == 4 ) self.assertTrue( m.npbase == 4 ) p = [0.5, 0.04, 1.2, 1.4] self.stdModeltest( m, p, plot=plot )