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


Python DataContainer.parseId方法代码示例

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


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

示例1: testVisualization

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
    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,代码行数:29,代码来源:TestImageVisualizer.py

示例2: saveDataContainer

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
 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,代码行数:36,代码来源:H5FileHandler.py

示例3: testTableIncludingNanAndErrors

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [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

示例4: loadSample

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
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,代码行数:34,代码来源:PyTablesPersister.py

示例5: testIntersectionXVector

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
 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,代码行数:28,代码来源:TestChart.py

示例6: loadField

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
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,代码行数:57,代码来源:PyTablesPersister.py

示例7: saveResult

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
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,代码行数:15,代码来源:PyTablesPersister.py

示例8: getNodeAndTypeFromId

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
 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,代码行数:17,代码来源:H5FileHandler.py

示例9: execute

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
 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,代码行数:17,代码来源:External.py

示例10: testVisualization

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
 def testVisualization(self):
     X = numpy.linspace(-1.5,1.5,self.n)
     self.lambDim = 1.0
     xField = DC.FieldContainer(X,
                                unit = '1 m',
                                longname = 'position',
                                shortname = 'x')
     self.V = DC.FieldContainer(-self.lambDim/2* X**2 + X**4/4-X*self.kappa1,
                                unit='1 V',dimensions=[xField],
                                longname = 'electric potential',
                                shortname=r'\varphi',
                                attributes={'title':'testVisualization'})
     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,代码行数:18,代码来源:TestChart.py

示例11: restoreResultsToWorkers

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
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,代码行数:21,代码来源:PyTablesPersister.py

示例12: eval

# 需要导入模块: from pyphant.core import DataContainer [as 别名]
# 或者: from pyphant.core.DataContainer import parseId [as 别名]
        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,代码行数:33,代码来源:PyTablesPersister.py


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