• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python core.DataContainer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testDistanceMappingInvertedStringDyDx

 def testDistanceMappingInvertedStringDyDx(self):
     """
     Consider two features, which are divided by a vertical line.
     The respective distances increase by dx for each column counted
     from the centre line.
     """
     self.dydx = 0.01
     self.yDim = DataContainer.FieldContainer(
         numpy.linspace(-self.dydx,self.dydx,self.dim),
         unit = '1m',
         longname= 'height',
         shortname='h')
     referenceField = DataContainer.FieldContainer(
         numpy.logical_not(stringFeature(self.dim,distanceToBorder=0)),
         dimensions = [self.xDim, self.yDim],
         unit = '1',
         longname='Inverted String Feature',
         shortname='S')
     referenceField.seal()
     result = self.worker.calculateDistanceMap(referenceField)
     #Compute result afoot
     afoot = numpy.zeros(referenceField.data.shape,'f')
     dx = numpy.diff(referenceField.dimensions[0].data)[0]
     for i in xrange(referenceField.data.shape[1]):
         afoot[:,i]= dx * abs(5-i)
     afootC=DataContainer.FieldContainer(afoot, unit=self.xDim.unit,
                                        dimensions = map(copy.deepcopy,referenceField.dimensions))
     DataContainer.assertEqual(afootC, result)
开发者ID:gclos,项目名称:pyphant1,代码行数:28,代码来源:TestDistanceMapper.py


示例2: mra

 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,代码行数:54,代码来源:MRA.py


示例3: loadSample

def loadSample(h5, resNode):
    result = DataContainer.SampleContainer.__new__(
        DataContainer.SampleContainer
        )
    result.longname = unicode(h5.getNodeAttr(resNode, "longname"), 'utf-8')
    result.shortname = unicode(h5.getNodeAttr(resNode, "shortname"), 'utf-8')
    result.creator = unicode(h5.getNodeAttr(resNode, "creator"), 'utf-8')
    result.machine = unicode(h5.getNodeAttr(resNode, "machine"), 'utf-8')
    result.attributes = {}
    for key in resNode._v_attrs._v_attrnamesuser:
        if key not in _reservedAttributes:
            result.attributes[key] = h5.getNodeAttr(resNode, key)
    columns = []
    for resId in h5.getNodeAttr(resNode, "columns"):
        nodename = "/results/" + resId
        hash, uriType = DataContainer.parseId(
            h5.getNodeAttr(nodename, "TITLE")
            )
        if uriType == 'sample':
            loader = loadSample
        elif uriType == 'field':
            loader = loadField
        else:
            raise KeyError(
                "Unknown UriType %s in saving result %s." % (
                    uriType, result.id
                    )
                )
        columns.append(loader(h5, h5.getNode(nodename)))
    result.columns = columns
    result.seal(resNode._v_title)
    return result
开发者ID:GitEdit,项目名称:pyphant1,代码行数:32,代码来源:PyTablesPersister.py


示例4: saveDataContainer

 def saveDataContainer(self, result):
     """
     Saves a given DataContainer instance to the HDF5 file.
     The DataContainer has to be sealed or at least provide a valid
     emd5 in its '.id' attribute.
     A HDF5 group path that points to the location the DC was stored at
     is returned.
     result -- sealed DC instance
     """
     dcHash, uriType = DataContainer.parseId(result.id)
     resId = u"result_" + dcHash
     try:
         resultGroup = self.handle.getNode("/results/" + resId)
     except tables.NoSuchNodeError:
         try:
             resultGroup = self.handle.createGroup(
                 "/results", resId, result.id.encode("utf-8")
                 )
         except tables.NoSuchNodeError:
             self.handle.createGroup('/', 'results')
             resultGroup = self.handle.createGroup(
                 "/results", resId, result.id.encode("utf-8")
                 )
         if uriType == 'field':
             self.saveField(resultGroup, result)
         elif uriType == 'sample':
             self.saveSample(resultGroup, result)
         else:
             raise KeyError(
                 "Unknown UriType %s in saving result %s." % (
                     uriType, result.id
                     )
                 )
     return resId
开发者ID:GitEdit,项目名称:pyphant1,代码行数:34,代码来源:H5FileHandler.py


示例5: loadField

def loadField(h5, resNode):
    longname = unicode(h5.getNodeAttr(resNode, "longname"), 'utf-8')
    shortname = unicode(h5.getNodeAttr(resNode, "shortname"), 'utf-8')
    try:
        creator = unicode(h5.getNodeAttr(resNode, "creator"), 'utf-8')
        machine = unicode(h5.getNodeAttr(resNode, "machine"), 'utf-8')
    except:
        from pyphant.core.Helpers import emd52dict
        emd5dict = emd52dict(resNode._v_title)
        creator = emd5dict['creator']
        machine = emd5dict['machine']
    data = scipy.array(resNode.data.read())

    def loads(inputList):
        if type(inputList) == type([]):
            try:
                return map(lambda s: eval(s), inputList)
            except:
                return map(lambda s: unicode(s, 'utf-8'), inputList)
        else:
            return map(loads, inputList)
    if data.dtype.char == 'S':
        data = scipy.array(loads(data.tolist()))
    attributes = {}
    for key in resNode.data._v_attrs._v_attrnamesuser:
        attributes[key] = h5.getNodeAttr(resNode.data, key)
    try:
        error = scipy.array(resNode.error.read())
    except tables.NoSuchNodeError:
        error = None
    try:
        mask = scipy.array(resNode.mask.read())
    except tables.NoSuchNodeError:
        mask = None
    unit = eval(unicode(h5.getNodeAttr(resNode, "unit"), 'utf-8'))
    try:
        dimTable = resNode.dimensions
        dimensions = [
            loadField(
                h5,
                h5.getNode(
                    "/results/result_" + DataContainer.parseId(row['id'])[0]
                    )
                )
            for row in dimTable.iterrows()
            ]
    except tables.NoSuchNodeError:
        dimensions = DataContainer.INDEX
    result = DataContainer.FieldContainer(data, unit, error, mask,
                                          dimensions, longname, shortname,
                                          attributes)
    result.creator = creator
    result.machine = machine
    result.seal(resNode._v_title)
    return result
开发者ID:GitEdit,项目名称:pyphant1,代码行数:55,代码来源:PyTablesPersister.py


示例6: saveResult

def saveResult(result, h5):
    hash, uriType = DataContainer.parseId(result.id)
    resId = u"result_"+hash
    try:
        resultGroup = h5.getNode("/results/"+resId)
    except tables.NoSuchNodeError, e:
        resultGroup = h5.createGroup("/results", resId, result.id.encode("utf-8"))
        if uriType=='field':
            saveField(h5, resultGroup, result)
        elif uriType=='sample':
            saveSample(h5, resultGroup, result)
        else:
            raise KeyError, "Unknown UriType %s in saving result %s." % (uriType, result.id)
开发者ID:gclos,项目名称:pyphant1,代码行数:13,代码来源:PyTablesPersister.py


示例7: getNodeAndTypeFromId

 def getNodeAndTypeFromId(self, dcId):
     """
     Returns a tuple (HDF5 node, uriType) for the given
     DataContainer emd5.
     dcId -- emd5 of the DataContainer
     """
     dcHash, uriType = DataContainer.parseId(dcId)
     try:
         resNode = self.handle.getNode("/results/result_" + dcHash)
     except (AttributeError, tables.NoSuchNodeError):
         raise AttributeError("Container %s not found in file %s."
                              % (dcId, self.filename))
     if isinstance(uriType, unicode):
         uriType = uriType.encode('utf-8')
     return (resNode, uriType)
开发者ID:GitEdit,项目名称:pyphant1,代码行数:15,代码来源:H5FileHandler.py


示例8: execute

 def execute(self):
     dialog = wx.FileDialog(None,message='Choose file for saving the data', defaultDir=os.getcwd(),
                           style=wx.SAVE | wx.OVERWRITE_PROMPT,
                            wildcard = "Comma separated values (*.csv)|*.csv|Plain text (*.dat)|*.dat")
     if dialog.ShowModal() == wx.ID_OK:
         path = dialog.GetPath()
         print "Selected:",path
     else:
         print "Nothing was selected."
     dialog.Destroy()
     hash, uriType = DataContainer.parseId(self.dataContainer.id)
     if uriType == u"field":
         self.saveField(path)
     elif uriType == u"sample":
         self.saveSample(path)
开发者ID:gclos,项目名称:pyphant1,代码行数:15,代码来源:External.py


示例9: restoreResultsToWorkers

def restoreResultsToWorkers(recipeGroup, workers, h5):
    for workerGroup in recipeGroup:
        for plugGroup in workerGroup.plugs:
            plug=workers[workerGroup._v_name].getPlug(plugGroup._v_name)
            try:
                resId = plugGroup._v_attrs.result
                resNode = h5.getNode("/results/"+resId)
                hash, uriType = DataContainer.parseId(resNode._v_title)
                if uriType==u'field':
                    result=loadField(h5, resNode)
                elif uriType==u'sample':
                    _logger.info("Trying to load sample data...")
                    result=loadSample(h5, resNode)
                    _logger.info("...successfully loaded.")
                else:
                    raise TypeError, "Unknown result uriType in <%s>"%resNode._v_title
                plug._result = result
            except (AttributeError, tables.NoSuchNodeError), e:
                _logger.info( "Exception: "+str(e) )
开发者ID:gclos,项目名称:pyphant1,代码行数:19,代码来源:PyTablesPersister.py


示例10: extract

 def extract(self, field, subscriber=0):
     if not hasattr(self, 'paramDim0'):
         self.refreshParams()
     params = [str(eval('self.paramDim%i.value' %i))
               for i in range(len(field.dimensions))]
     for dim, arg in enumerate(params):
         if arg.startswith('#'):
             step = None
             if arg == '#:':
                 start = 0
                 end = len(field.dimensions[dim].data)
             elif arg[1] == ':':
                 start = 0
                 end   = long(arg[2:]) + 1
             elif arg[-1] == ':':
                 start = long(arg[1: -1])
                 end = len(field.dimensions[dim].data)
             else:
                 ind = map(long, arg[1:].split(':'))
                 start = ind[0]
                 if len(ind) == 1:
                     end = ind[0] + 1
                 elif len(ind) >= 2:
                     end = ind[1] + 1
                 if len(ind) == 3:
                     step = ind[2]
                 if len(ind) > 3:
                     raise ValueError("Illegal slice with "
                                      "more than two colons.")
             params[dim] = slice(start, end, step)
         else:
             s = DataContainer.slice2ind(arg, field.dimensions[dim])
             params[dim] = slice(s.start,
                                 min(s.stop + 1,
                                     len(field.dimensions[dim].data)),
                                 s.step)
     result = copy.deepcopy(field[params])
     result.seal()
     return result
开发者ID:gclos,项目名称:pyphant1,代码行数:39,代码来源:Slicing.py


示例11: eval

        data = scipy.array(loads(data.tolist()))
    attributes = {}
    for key in resNode.data._v_attrs._v_attrnamesuser:
        attributes[key]=h5.getNodeAttr(resNode.data,key)
    try:
        error = scipy.array(resNode.error.read())
    except tables.NoSuchNodeError, e:
        error = None
    try:
        mask = scipy.array(resNode.mask.read())
    except tables.NoSuchNodeError, e:
        mask = None
    unit = eval(unicode(h5.getNodeAttr(resNode, "unit"), 'utf-8'))
    try:
        dimTable = resNode.dimensions
        dimensions = [loadField(h5, h5.getNode("/results/result_"+DataContainer.parseId(row['id'])[0]))
                      for row in dimTable.iterrows()]
    except tables.NoSuchNodeError, e:
        dimensions = DataContainer.INDEX
    result = DataContainer.FieldContainer(data, unit, error, mask,
                                          dimensions, longname, shortname,
                                          attributes)
    result.creator = creator
    result.machine = machine
    result.seal(resNode._v_title)
    return result

def loadSample(h5, resNode):
    result = DataContainer.SampleContainer.__new__(DataContainer.SampleContainer)
    result.longname = unicode(h5.getNodeAttr(resNode, "longname"), 'utf-8')
    result.shortname = unicode(h5.getNodeAttr(resNode, "shortname"), 'utf-8')
开发者ID:gclos,项目名称:pyphant1,代码行数:31,代码来源:PyTablesPersister.py


示例12: testTableIncludingNanAndErrors

 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,代码行数:25,代码来源:TestChart.py


示例13: testParabelArray

 def testParabelArray(self):
     x = numpy.array([-2,-1,0,1,2],'float')
     field = numpy.array([(x-0.2)**2-0.5,(x+0.1)**2])
     inputField = DC.FieldContainer(field,
                                    error=numpy.resize(numpy.repeat(0.1,len(field)),field.shape),
                                    dimensions=[DC.FieldContainer(numpy.array([1,2]),
                                                                  longname='type',shortname=r'\theta'),
                                                DC.FieldContainer(x,longname='position',shortname='x')],
                                    longname='parabel',
                                    shortname='f')
     def error(y):
         error  = inputField.error[0,0] / (y[1]-2*y[2]+y[3])**2
         error *= numpy.abs(y[2]-y[3]) + numpy.abs(y[1]-y[3]) + numpy.abs(y[1]-y[2])
         return error
     expectedResult = DC.FieldContainer(numpy.array([[0.2,-0.1]]),
                                        longname = 'position of the local minima of parabel',
                                        shortname = 'x_0',
                                        error = numpy.array([[error(field[0]),error(field[1])]]))
     expectedResult.dimensions[-1] = DC.FieldContainer(numpy.array([1,2]),
                                                       longname='type',
                                                       shortname=r'\theta')
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'minima'
     #Retrieve result from worker
     result = w.locate(inputField)
     DC.assertEqual(result,expectedResult)
开发者ID:GitEdit,项目名称:pyphant1,代码行数:26,代码来源:TestExtremumFinder.py


示例14: testMinima

 def testMinima(self):
     """Test the correct computation of all local minima for a bistable potential."""
     #Predict result
     x0,curv,mask = fixedPoints(numpy.array([self.LAMBDA]),kappa1=self.kappa1)
     expectedResult = DC.FieldContainer(numpy.extract(curv[0]>0,x0[0]),
                                        unit = self.xField.unit,
                                        longname = 'position of the local minima of electric potential',
                                        shortname = 'x_0')
     #Retrieve result from worker
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'minima'
     result = w.locate(self.V)
     #Testing
     DC.assertEqual(result,expectedResult)
开发者ID:GitEdit,项目名称:pyphant1,代码行数:14,代码来源:TestExtremumFinder.py


示例15: testIntersectionXVector

 def testIntersectionXVector(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')
     #Prepare potential
     V = []
     for i in xrange(len(lambField.data)):
         u = X[i]
         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',
                                attributes={'title':'testIntersectionXVector'})
     self.V.seal()
     visualizer = self.visualizer(self.V,show=False)
     filename = os.path.join(self.tmpdir,'pyphant-'+DC.parseId(self.V.id)[0]+'%s.%s' % (visualizer.name,outputFormat))
     visualizer.figure.savefig(filename.replace(' ',''))
开发者ID:zklaus,项目名称:pyphant1,代码行数:26,代码来源:TestChart.py


示例16: testVisualization

    def testVisualization(self):
        X,LAMB = numpy.meshgrid(numpy.linspace(-1.5,1.5,self.n),
                                numpy.linspace(-1.0,1.0,self.m))
        self.lambDim = numpy.linspace(-1.0,1.0,self.m)
        self.xDim = numpy.linspace(-1.5,1.5,self.n)
        lambField = DC.FieldContainer(self.lambDim,
                                      unit = '1 V / m**3',
                                      longname='parameter',
                                      shortname='\lambda')
        xField = DC.FieldContainer(self.xDim,
                                   unit = '1 m',
                                   longname = 'position',
                                   shortname = 'x')
        #Prepare potential
        V = []
        for i in xrange(len(lambField.data)):
            u = X[i]
            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')

        self.V.seal()
        #Visualise result
        visualizer = ImageVisualizer(self.V,show=False)
        filename = os.path.join(self.tmpdir,'pyphant-'+DC.parseId(self.V.id)[0]+'.pdf')
        visualizer.figure.savefig(filename)
开发者ID:zklaus,项目名称:pyphant1,代码行数:27,代码来源:TestImageVisualizer.py


示例17: testParabel

 def testParabel(self):
     x = numpy.array([-2,-1,0,1,2],'float')+0.1
     y = x**2
     inputField = DC.FieldContainer(y,
                                    error=numpy.repeat(0.1,len(y)),
                                    dimensions=[DC.FieldContainer(x,longname='abscissae',shortname='x')],
                                    longname='parabel',
                                    shortname='f')
     error  = inputField.error[slice(0,1)] / (y[1]-2*y[2]+y[3])**2
     error *= numpy.abs(y[2]-y[3]) + numpy.abs(y[1]-y[3]) + numpy.abs(y[1]-y[2])
     expectedResult = DC.FieldContainer(numpy.array([0.0]),
                                        longname = 'position of the local minimum of parabel',
                                        shortname = 'x_0',
                                        error = error)
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'minima'
     #Retrieve result from worker
     result = w.locate(inputField)
     DC.assertEqual(result,expectedResult)
开发者ID:GitEdit,项目名称:pyphant1,代码行数:19,代码来源:TestExtremumFinder.py


示例18: testParabelSymmetricallyBoxedMinimum

 def testParabelSymmetricallyBoxedMinimum(self):
     x = numpy.array([-2,-1,0,1,2],'float')-0.5
     y = x**2
     inputField = DC.FieldContainer(y,
                                    error=numpy.repeat(0.1,len(y)),
                                    dimensions=[DC.FieldContainer(x,longname='abscissae',shortname='x')],
                                    longname='parabel',
                                    shortname='f'
                                    )
     expectedResult = DC.FieldContainer(numpy.array([0.0]),
                                        longname = 'position of the local minimum of parabel',
                                        shortname = 'x_0',
                                        error = numpy.array([0.1])
                                        )
     w = EF.ExtremumFinder(None)
     w.paramExtremum.value=u'minima'
     #Retrieve result from worker
     result = w.locate(inputField)
     DC.assertEqual(result,expectedResult)
开发者ID:GitEdit,项目名称:pyphant1,代码行数:19,代码来源:TestExtremumFinder.py


示例19: testRoots

 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,代码行数:51,代码来源:TestMRA.py


示例20: testNegligibleNoise

 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,代码行数:14,代码来源:TestOscAbsorption.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python DataContainer.FieldContainer类代码示例发布时间:2022-05-27
下一篇:
Python explore.cartesian_product函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap