当前位置: 首页>>代码示例>>Python>>正文


Python DataContainer.generateIndex方法代码示例

本文整理汇总了Python中pyphant.core.DataContainer.generateIndex方法的典型用法代码示例。如果您正苦于以下问题:Python DataContainer.generateIndex方法的具体用法?Python DataContainer.generateIndex怎么用?Python DataContainer.generateIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyphant.core.DataContainer的用法示例。


在下文中一共展示了DataContainer.generateIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mra

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import generateIndex [as 别名]
 def mra(self, field, subscriber=0):
     dim = field.dimensions[-1]
     try:
         scale = quantities.Quantity(self.paramScale.value.encode('utf-8'))
     except:
         scale = float(self.paramScale.value)
     numb_edge = 100.0/self.paramNumb_edge.value
     d = scipy.diff(dim.data)
     numpy.testing.assert_array_almost_equal(d.min(), d.max(),4)
     sigmaMax = scale/(d[0]*dim.unit)
     if len(field.data.shape)>1:
         p_e = []
         inc = 100./len(field.data)
         acc = 0.
         for field1d in field:
             try:
                 p_e.append(mra1d(dim, field1d, sigmaMax, numb_edge))
             except MraError:
                 p_e.append((([],[]),([],[])))
             acc += inc
             subscriber %= acc
         minima, maxima = zip(*p_e)
         n_min, pos_min, err_min = pos_error_to_data_container(minima)
         n_max, pos_max, err_max = pos_error_to_data_container(maxima)
         dims_min = [DataContainer.generateIndex(0,n_min), field.dimensions[0]]
         dims_max = [DataContainer.generateIndex(0,n_max), field.dimensions[0]]
     else:
         (pos_min, err_min), (pos_max, err_max) = mra1d(dim, field, sigmaMax, numb_edge)
         dims_min = [DataContainer.generateIndex(0,len(pos_min))]
         dims_max = [DataContainer.generateIndex(0,len(pos_max))]
         subscriber %= 100.
     minima = DataContainer.FieldContainer(pos_min.transpose(),
                                           error = err_min.transpose(),
                                           unit = dim.unit,
                                           dimensions = dims_min,
                                           mask = numpy.isnan(pos_min).transpose(),
                                           longname="%s of the local %s of %s" % (dim.longname,"minima",field.longname),
                                           shortname="%s_{min}" % dim.shortname)
     maxima = DataContainer.FieldContainer(pos_max.transpose(),
                                           error = err_max.transpose(),
                                           unit = dim.unit,
                                           dimensions = dims_max,
                                           mask = numpy.isnan(pos_max).transpose(),
                                           longname="%s of the local %s of %s" % (dim.longname,"maxima",field.longname),
                                           shortname="%s_{max}" % dim.shortname)
     roots = DataContainer.SampleContainer([minima, maxima],
                                            longname="%s of the local %s of %s" % (dim.longname,"extrema",field.longname),
                                            shortname="%s_{extrem}" % dim.shortname)
     if self.paramLongname.value != 'default':
         roots.longname = self.paramLongname.value
     if self.paramSymbol.value != 'default':
         roots.shortname = self.paramSymbol.value
     roots.seal()
     return roots
开发者ID:gclos,项目名称:pyphant1,代码行数:56,代码来源:MRA.py

示例2: testTableIncludingNanAndErrors

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import generateIndex [as 别名]
 def testTableIncludingNanAndErrors(self):
     X,LAMB = numpy.meshgrid(numpy.linspace(-1.5,1.5,self.n),
                             numpy.linspace(-1.0,1.0,self.m))
     self.lambDim = LAMB[:,0]
     self.xDim = numpy.linspace(-1.5,1.5,self.n)
     lambField = DC.FieldContainer(self.lambDim,
                                   unit = '1 V / m**3',
                                   longname='parameter',
                                   shortname=r'\lambda')
     xField = DC.FieldContainer(self.xDim,
                                unit = '1 m',
                                longname = 'position',
                                shortname = 'x')
     x0,curv,mask = Helpers.fixedPoints(lambField.data,kappa1=self.kappa1)
     fixedPoints = DC.FieldContainer(numpy.array(x0).transpose(),
                                     unit = xField.unit,
                                     dimensions=[DC.generateIndex(0,3), lambField],
                                     longname = 'position of the local extrema of electric potential',
                                     shortname = 'x_0',
                                     attributes={'title':'testTableIncludingNanAndErrors'})
     fixedPoints.error = 0.1 * fixedPoints.data
     fixedPoints.seal()
     visualizer = self.visualizer(fixedPoints,show=False)
     filename = os.path.join(self.tmpdir,'pyphant-'+DC.parseId(fixedPoints.id)[0]+'%s.%s' % (visualizer.name,outputFormat))
     visualizer.figure.savefig(filename.replace(' ',''))
开发者ID:zklaus,项目名称:pyphant1,代码行数:27,代码来源:TestChart.py

示例3: testRoots

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import generateIndex [as 别名]
 def testRoots(self):
     """
     Test the correct computation of all local extrema
     for a bistable potential.
     """
     #Prepare dimensions
     self.prepareDimensions()
     lambField = DC.FieldContainer(
         self.lambDim,
         unit='1 V / m**3',
         longname='parameter',
         shortname='\lambda'
         )
     xField = DC.FieldContainer(
         self.xDim[0],
         unit='1 m',
         longname='position',
         shortname='x'
         )
     #Prepare potential
     V = []
     for i in xrange(len(lambField.data)):
         u = xField.data
         V.append(
             -lambField.data[i] / 2 * u ** 2 + u ** 4 / 4 - u * self.kappa1
             )
     self.V = DC.FieldContainer(
         numpy.array(V), unit='1 V', dimensions=[lambField, xField],
         longname = 'electric potential',
         shortname = r'\varphi'
         )
     #Predict result
     x0, curv, mask = fixedPoints(lambField.data, kappa1=self.kappa1)
     x0 = numpy.where(curv > 0, x0, numpy.NaN)
     data = x0[:, ::2]
     dims = [DC.generateIndex(0, 2), lambField]
     expectedResult = DC.FieldContainer(
         data.transpose(),
         unit=xField.unit,
         mask=numpy.isnan(data).transpose(),
         dimensions=dims,
         longname='position of the local extrema of electric potential',
         shortname='x_0'
         )
     #Configure worker
     w = MRA.MRA(None)
     w.paramScale.value = "1.0m"
     #Retrieve result from worker
     result = copy.deepcopy(w.mra(self.V))['x_{min}']
     result.error=None
     self.test(result,expectedResult,1e-2,1e-2)
开发者ID:GitEdit,项目名称:pyphant1,代码行数:53,代码来源:TestMRA.py

示例4: testNegligibleNoise

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import generateIndex [as 别名]
 def testNegligibleNoise(self):
     """Tests the merging of abscissae data in case of negliglible deviation."""
     worker = OA.OscAbsorptionCalculator()
     worker.paramClipping.value = 0
     self.sampleC['I'].dimensions[-1].data += 1e-8*numpy.random.randn(self.n)
     self.sampleC.seal()
     result = worker.calcAbsorption(self.sampleC)
     expectedDim = [DC.generateIndex(1,self.m),
                    DC.FieldContainer(self.x,longname='position',shortname='x',unit='1m')]
     expectedResult = DC.FieldContainer(numpy.ones((self.m,self.n),'float')-self.I.data,
                                        dimensions=expectedDim,
                                        longname=u'absorption',
                                        shortname=ur'\tilde{A}')
     self.assertEqual(result,expectedResult)
开发者ID:gclos,项目名称:pyphant1,代码行数:16,代码来源:TestOscAbsorption.py

示例5: testCalculation

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import generateIndex [as 别名]
 def testCalculation(self):
     """Tests the correct calculation of absorption without clipping.
     It is assumed, that the dark reference intensity is equal to zero,
     while white reference intensity is equal to one."""
     worker = OA.OscAbsorptionCalculator()
     worker.paramClipping.value = 0
     self.sampleC.seal()
     result = worker.calcAbsorption(self.sampleC)
     expectedDim = [DC.generateIndex(1,self.m),
                    DC.FieldContainer(self.x,longname='position',shortname='x',unit='1m')]
     expectedResult = DC.FieldContainer(numpy.ones((self.m,self.n),'float')-self.I.data,
                                        dimensions=expectedDim,
                                        longname=u'absorption',
                                        shortname=ur'\tilde{A}')
     self.assertEqual(result,expectedResult)
开发者ID:gclos,项目名称:pyphant1,代码行数:17,代码来源:TestOscAbsorption.py

示例6: testRoots

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import generateIndex [as 别名]
 def testRoots(self):
     """Test the correct computation of all local extrema for a bistable potential."""
     #Prepare dimensions
     self.prepareDimensions()
     lambField = DC.FieldContainer(self.lambDim,
                                   unit = '1 V / m**3',
                                   longname='parameter',
                                   shortname='\lambda')
     xField = DC.FieldContainer(self.xDim[0],
                                unit = '1 m',
                                longname = 'position',
                                shortname = 'x')
     #Prepare potential
     V = []
     for i in xrange(len(lambField.data)):
         u = xField.data
         V.append(-lambField.data[i]/2* u**2 + u**4/4-u*self.kappa1)
     self.V = DC.FieldContainer(numpy.array(V),unit='1 V',dimensions=[lambField,xField],
                                longname = 'electric potential',
                                shortname=r'\varphi')
     #Predict result
     x0,curv,mask = fixedPoints(lambField.data,kappa1=self.kappa1)
     error = 1.0/curv.transpose()
     error[:] =numpy.nan
     data = x0.transpose()
     expectedResult = DC.FieldContainer(data,
                                        unit = xField.unit,
                                        mask = numpy.isnan(data),
                                        dimensions=[DC.generateIndex(0,3),lambField],
                                        longname = 'position of the local extrema of electric potential',
                                        shortname = 'x_0')
     #Configure worker
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'both'
     #Retrieve result from worker
     result = w.locate(self.V)
     self.test(result,expectedResult)
开发者ID:GitEdit,项目名称:pyphant1,代码行数:39,代码来源:TestExtremumFinder.py


注:本文中的pyphant.core.DataContainer.generateIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。