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

Python utils.dump函数代码示例

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

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



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

示例1: getCellPath

    def getCellPath(self, populationType, instanceId):
        ''' Given a population type and instanceId, return its path '''
        try:
            path = self.populationDict[populationType][1]
        except KeyError as e:
            utils.dump("ERROR"
                    , [ "Population type `{0}` not found".format(populationType)
                        , "Availale population in network are "
                        , self.populationDict.keys()
                    ]
                    )
            raise KeyError("Missing population type : {}".format(populationType))
        except Exception as e:
            raise e

        try:
            path = path[instanceId]
        except KeyError as e:
            msg = "Population type {} has no instance {}".format(
                    populationType
                    , instanceId
                    )
            utils.dump("ERROR"
                    , [msg , "Available instances are" , path.keys() ]
                    )
            raise KeyError(msg)

        # Now get the path from moose path
        path = path.path
        if not re.match(r'(\/\w+)+', path):
            raise UserWarning("{} is not a valid path".format(path))
        return path 
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:32,代码来源:NetworkML.py


示例2: simulate

    def simulate( self, simTime, simDt = 1e-3, plotDt = None ):
        '''Simulate the cable '''

        if plotDt is None:
            plotDt = simDt / 2
        self.simDt = simDt
        self.plotDt = plotDt
        self.setupDUT( )
 
        # Setup clocks 
        utils.dump("STEP", "Setting up the clocks ... ")
        moose.setClock( 0, self.simDt )
        moose.setClock( 1, self.simDt )
        moose.setClock( 2, self.simDt )

        ## Use clocksc
        moose.useClock( 0, '/cable/##'.format(self.cablePath), 'process' )
        moose.useClock( 1, '/cable/##'.format(self.cablePath), 'init' )
        moose.useClock( 2, '{}/##'.format(self.tablePath), 'process' )

        utils.dump("STEP"
                , [ "Simulating cable for {} sec".format(simTime)
                    , " simDt: %s, plotDt: %s" % ( self.simDt, self.plotDt )
                    ]
                )
        self.setupHSolve( )
        moose.reinit( )
        utils.verify( )
        moose.start( simTime )
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:29,代码来源:rallpacks_passive_cable.py


示例3: __init__

    def __init__(self, path, length, diameter, args):
        """ Initialize moose-compartment """
        self.mc_ = None
        self.path = path
        # Following values are taken from Upi's chapter on Rallpacks
        self.RM = args.get('RM', 4.0)
        self.RA = args.get('RA', 1.0)
        self.CM = args.get('CM', 0.01)
        self.Em = args.get('Em', -0.065)
        self.diameter = diameter
        self.compLength = length
        self.computeParams( )

        try:
            self.mc_ = moose.Compartment(self.path)
            self.mc_.length = self.compLength
            self.mc_.diameter = self.diameter
            self.mc_.Ra = self.Ra
            self.mc_.Rm = self.Rm
            self.mc_.Cm = self.Cm
            self.mc_.Em = self.Em
            self.mc_.initVm = self.Em

        except Exception as e:
            utils.dump("ERROR"
                    , [ "Can't create compartment with path %s " % path
                        , "Failed with error %s " % e
                        ]
                    )
            raise
开发者ID:hrani,项目名称:moose-core,代码行数:30,代码来源:moose_sim.py


示例4: addProperties

    def addProperties(self, pre_segment_path, post_segment_path, props, options):
        '''Add properties 
        '''
        synName = options['syn_name']
        source = options['source']
        target = options['target']
        weight = options['weight']
        threshold = options['threshold']
        propDelay = options['prop_delay']

        synapse = props.attrib.get('synapse_type', None)
        if not synapse: 
            utils.dump("WARN"
                    , "Synapse type {} not found.".format(synapse)
                    , frame = inspect.currentframe()
                    )
            raise UserWarning("Missing parameter synapse_type")

        synName = synapse
        weight_override = float(props.attrib['weight'])
        if 'internal_delay' in props.attrib:
            delay_override = float(props.attrib['internal_delay'])
        else: delay_override = propDelay
        if weight_override != 0.0:
            self.connectUsingSynChan(synName
                    , pre_segment_path
                    , post_segment_path
                    , weight_override
                    , threshold, delay_override
                    )
        else: pass
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:31,代码来源:NetworkML.py


示例5: createInputs

    def createInputs(self):

        """ createInputs

        Create inputs as given in NML file and attach them to moose.
        """

        for inputs in self.network.findall(".//{"+nmu.nml_ns+"}inputs"):
            units = inputs.attrib['units']

            # This dict is to be passed to function which attach an input
            # element to moose.
            factors = {}

            # see pg 219 (sec 13.2) of Book of Genesis
            if units == 'Physiological Units':
                factors['Vfactor'] = 1e-3 # V from mV
                factors['Tfactor'] = 1e-3 # s from ms
                factors['Ifactor'] = 1e-6 # A from microA
            else:
                utils.dump("NOTE", "We got {0}".format(units))
                factors['Vfactor'] = 1.0
                factors['Tfactor'] = 1.0
                factors['Ifactor'] = 1.0

            for inputElem in inputs.findall(".//{"+nmu.nml_ns+"}input"):
                self.attachInputToMoose(inputElem, factors) 
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:27,代码来源:NetworkML.py


示例6: plotVector

 def plotVector(self, vector, plotname):
     ''' Saving input vector to a file '''
     name = plotname.replace('/', '_')
     fileName = os.path.join(self.plotPaths, name)+'.eps'
     utils.dump("DEBUG"
             , "Saving vector to a file {}".format(fileName)
             )
     plt.vlines(vector, 0, 1)
     plt.savefig(fileName)
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:9,代码来源:NetworkML.py


示例7: createChannel

def createChannel(species, path, **kwargs):
    """Create a channel """
    if species == 'na':
        return sodiumChannel( path, **kwargs)
    elif species == 'ca':
        channel.Xpower = 4
    else:
        utils.dump("FATAL", "Unsupported channel type: {}".format(species))
        raise RuntimeError("Unsupported species of chanel")
开发者ID:pgleeson,项目名称:moose-core,代码行数:9,代码来源:rallpacks_cable_hhchannel.py


示例8: recordAt

 def recordAt(self, depth, index):
     """ Parameter index is python list-like index. Index -1 is the last
     elements in the list 
     """
     utils.dump("RECORD", "Adding probe at index {} and depth {}".format(index, depth))
     c = self.cable[depth][index]
     t = moose.Table("{}/output_at_{}".format(self.tablePath, index))
     moose.connect(t, "requestOut", c, "getVm")
     return t
开发者ID:neurord,项目名称:moose-core,代码行数:9,代码来源:rallpacks_tree_cable.py


示例9: makeCable

 def makeCable( self, args ):
     ''' Make a cable out of n compartments '''
     for i in range( self.ncomp ):
         compPath = '{}/comp{}'.format( self.cablePath, i)
         l = self.length / self.ncomp
         d = self.diameter
         c = comp.MooseCompartment( compPath, l, d, args )
         self.cable.append(c)
     self.connect( )
     utils.dump( "STEP"
             , "Passive cable is connected and ready for simulation." 
             )
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:12,代码来源:rallpacks_passive_cable.py


示例10: simulate

    def simulate( self, simTime):
        '''Simulate the cable '''

        self.setupDUT( )
        utils.dump("STEP"
                ,  "Simulating cable for {} sec".format(simTime)
                )
        moose.reinit( )
        self.setupHSolve( )
        t = time.time()
        moose.start( simTime )
        st = time.time()
        return st-t
开发者ID:BhallaLab,项目名称:benchmarks,代码行数:13,代码来源:moose_sim.py


示例11: createProjection

    def createProjection(self, projection):
        projectionName = projection.attrib["name"]
        utils.dump("INFO", "Projection {0}".format(projectionName))
        source = projection.attrib["source"]
        target = projection.attrib["target"]
        self.projectionDict[projectionName] = (source,target,[])

        # TODO: Assuming that only one element <synapse_props> under
        # <projection> element.
        synProps = projection.find(".//{"+nmu.nml_ns+"}synapse_props")
        options = self.addSyapseProperties(projection, synProps, source, target)

        connections = projection.findall(".//{"+nmu.nml_ns+"}connection")
        [self.addConnection(c, projection, options) for c in connections]
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:14,代码来源:NetworkML.py


示例12: buildCable

 def buildCable(self, args):
     """ Build binary cable """
     self.args = args
     self.buildParameterLists()
     # Cable is a list of lists.
     self.cable = list()
     for n, (l, d) in enumerate(zip(self.compLengthList, self.compDiamList)):
         utils.dump("STEP", "Binary tree level {}: length {}, diameter {}".format(n, l, d))
         noOfCompartments = pow(2, n)
         compartmentList = []
         for i in range(noOfCompartments):
             compPath = "{}/comp_{}_{}".format(self.cablePath, n, i)
             m = comp.MooseCompartment(compPath, l, d, args)
             compartmentList.append(m.mc_)
         self.cable.append(compartmentList)
     self.connectCable()
开发者ID:neurord,项目名称:moose-core,代码行数:16,代码来源:rallpacks_tree_cable.py


示例13: configureSynChan

    def configureSynChan(self, synObj, synParams={}):
        '''Configure synapse. If no parameters are given then use the default
        values. 

        '''
        assert(isinstance(synObj, moose.SynChan))
        utils.dump("SYNAPSE"
                , "Configuring SynChan"
                )
        synObj.tau1 = synParams.get('tau1', 5.0)
        synObj.tau2 = synParams.get('tau2', 1.0)
        synObj.Gk = synParams.get('Gk', 1.0)
        synObj.Ek = synParams.get('Ek', 0.0)
        synObj.synapse.num = synParams.get('synapse_num', 1)
        synObj.synapse.delay = synParams.get('delay', 1.0)
        synObj.synapse.weight = synParams.get('weight', 1.0)
        return synObj
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:17,代码来源:NetworkML.py


示例14: simulate

    def simulate(self, simTime, simDt, plotDt=None):
        """Simulate the cable 
        """
        self.simDt = simDt
        self.setupDUT()

        # Setup clocks
        moose.setClock(0, self.simDt)

        # Use clocks
        moose.useClock(0, "/##", "process")
        moose.useClock(0, "/##", "init")

        utils.dump("STEP", ["Simulating cable for {} sec".format(simTime), " simDt: %s" % self.simDt])
        utils.verify()
        moose.reinit()
        self.setupSolver()
        moose.start(simTime)
开发者ID:neurord,项目名称:moose-core,代码行数:18,代码来源:rallpacks_tree_cable.py


示例15: connectWrapper

 def connectWrapper(self, src, srcF, dest, destF, messageType='Single'):
     """
     Wrapper around moose.connect 
     """
     utils.dump("INFO"
             , "Connecting ({4})`\n\t{0},{1}`\n\t`{2},{3}".format(
                 src.path
                 , srcF
                 , dest.path
                 , destF
                 , messageType
                 )
             , frame = inspect.currentframe()
             )
     try:
         res = moose.connect(src, srcF, dest, destF, messageType)
         assert res, "Failed to connect"
     except Exception as e:
         utils.dump("ERROR", "Failed to connect.")
         raise e
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:20,代码来源:NetworkML.py


示例16: makeNewSynapse

    def makeNewSynapse(self, synName, postcomp, synNameFull):
        '''This function creates a new synapses onto postcomp.

        SpikeGen is spikeGenerator (presynaptic). SpikeGen connects to SynChan,
        a synaptic channel which connects to post-synaptic compartment.

        SpikeGen models the pre-synaptic events.
        '''
        synPath = "%s/%s" % (self.libraryPath, synName)
        utils.dump("SYNAPSE"
                , "Creating {} with path {} onto compartment {}".format(
                    synName
                    , synPath
                    , postcomp.path
                    )
                )
        # if channel does not exist in library load it from xml file
        if not moose.exists(synPath):
            utils.dump("SYNAPSE"
                    , "Synaptic Channel {} does not exists. {}".format(
                        synPath, "Loading is from XML file"
                        )
                    )
            cmlR = ChannelML.ChannelML(self.nml_params)
            cmlR.readChannelMLFromFile(synName+'.xml')

        # deep copies the library synapse to an instance under postcomp named as
        # <arg3>
        if config.disbleCopyingOfObject:
            utils.dump("WARN"
                    , "Copying existing SynChan ({}) to {}".format(
                        synPath
                        , postcomp
                        )
                    )
            synid = moose.copy(moose.Neutral(synPath), postcomp, synNameFull)
        else:
            synid = synPath
        
        syn = moose.SynChan(synid)
        syn = self.configureSynChan(syn, synParams={})
        childmgblock = utils.get_child_Mstring(syn,'mgblock')

        # connect the post compartment to the synapse
        # If NMDA synapse based on mgblock, connect to mgblock
        if childmgblock.value == 'True': 
            mgblock = moose.Mg_block(syn.path+'/mgblock')
            self.connectWrapper(postcomp, "channel", mgblock, "channel")
        # if SynChan or even NMDAChan, connect normally
        else: 
            self.connectWrapper(postcomp,"channel", syn, "channel")
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:51,代码来源:NetworkML.py


示例17: readNetworkMLFromFile

    def readNetworkMLFromFile(self, filename, cellSegmentDict, params={}):
    

        """ readNetworkML

        specify tweak
        params = {
            'excludePopulations':[popname1,...]
            , 'excludeProjections':[projname1,...]
            , 'onlyInclude':{'includePopulation':(popname,[id1,...])
            ,'includeProjections':(projname1,...)
            }
        }

        If excludePopulations is present, then excludeProjections must also be
        present. Thus if you exclude some populations, ensure that you exclude
        projections that refer to those populations also!  Though for
        onlyInclude, you may specify only included cells and this reader will
        also keep cells connected to those in onlyInclude.  This reader first
        prunes the exclude-s, then keeps the onlyInclude-s and those that are
        connected.  Use 'includeProjections' if you want to keep some
        projections not connected to the primary 'includePopulation' cells but
        connected to secondary cells that connected to the primary ones: e.g.
        baseline synapses on granule cells connected to 'includePopulation'
        mitrals; these synapses receive file based pre-synaptic events, not
        presynaptically connected to a cell.

        """

        utils.dump("INFO", "reading file %s ... " % filename)
        tree = ET.parse(filename)
        root_element = tree.getroot()
        utils.dump("INFO", "Tweaking model ... ")
        utils.tweak_model(root_element, params)
        utils.dump("INFO", "Loading model into MOOSE ... ")
        return self.readNetworkML(
                root_element
               , cellSegmentDict
               , params
               , root_element.attrib['lengthUnits']
               )
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:41,代码来源:NetworkML.py


示例18: readNetworkML

    def readNetworkML(self, network, cellSegmentDict , params={}
        , lengthUnits="micrometer"):

        """
        This returns
         populationDict = {
           'populationName1':(cellname
           , {int(instanceid1):moosecell, ...F}) , ...
           }

         projectionDict = {
            'projectionName1':(source,target
            ,[(syn_name1,pre_seg_path,post_seg_path),...])
            , ...
            }
        """

        if lengthUnits in ['micrometer','micron']:
            self.length_factor = 1e-6
        else:
            self.length_factor = 1.0
        self.network = network
        self.cellSegmentDict = cellSegmentDict
        self.params = params
        utils.dump("STEP", "Creating populations ... ")
        self.createPopulations() 

        utils.dump("STEP", "Creating connections ... ")
        self.createProjections() 

        # create connections
        utils.dump("STEP", "Creating inputs in %s .. " % self.elecPath)

        # create inputs (only current pulse supported)
        self.createInputs() 
        return (self.populationDict, self.projectionDict)
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:36,代码来源:NetworkML.py


示例19: addConnection

    def addConnection(self, connection, projection, options):

        """
        This function adds connection
        """
        synName = options['syn_name']
        source = options['source']
        target = options['target']
        weight = options['weight']
        threshold = options['threshold']
        propDelay = options['prop_delay']
        projectionName = projection.attrib['name']

        pre_cell_id = connection.attrib['pre_cell_id']
        post_cell_id = connection.attrib['post_cell_id']

        if 'file' not in pre_cell_id:
            # source could be 'mitrals', self.populationDict[source][0] would be
            # 'mitral'
            pre_cell_id = int(pre_cell_id)
            post_cell_id = int(post_cell_id)
            pre_cell_name = self.populationDict[source][0]
            pre_segment_id = connection.attrib.get('pre_segment_id', 0)
            pre_segment_path = "{0}/{1}".format(
                    self.getCellPath(source, pre_cell_id)
                    , self.cellSegmentDict[pre_cell_name][pre_segment_id][0]
                    )
        else:
            # I've removed extra excitation provided via files, so below comment
            # doesn't apply.  'file[+<glomnum>]_<filenumber>' # glomnum is for
            # mitral_granule extra excitation from unmodelled sisters.
            pre_segment_path = "{}_{}".format(
                    pre_cell_id 
                    , connection.attrib['pre_segment_id']
                    )

        # target could be 'PGs', self.populationDict[target][0] would be 'PG'
        post_cell_name = self.populationDict[target][0]
        post_segment_id = connection.attrib.get('post_segment_id', '0')

        post_segment_path = "{}/{}".format(
                self.getCellPath(target, post_cell_id)
                , self.cellSegmentDict[post_cell_name][post_segment_id][0]
                )

        try:
            self.projectionDict[projectionName][2].append(
                    (synName , pre_segment_path, post_segment_path)
                    )
        except KeyError as e:
            utils.dump("ERR", "Failed find key {0}".format(e)
                    , frame = inspect.currentframe())
            print(self.projectionDict.keys())
            sys.exit(0)

        properties = connection.findall('./{'+nmu.nml_ns+'}properties')
        if len(properties) == 0:
            self.connectUsingSynChan(synName, pre_segment_path, post_segment_path
                    , weight, threshold, propDelay
                    )
        else:
            [self.addProperties(pre_segment_path, post_segment_path, p, options) 
                    for p in properties]
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:63,代码来源:NetworkML.py


示例20: connect

 def connect( self ):
     ''' Connect the cable '''
     utils.dump('STEP', 'Connecting cable ...')
     for i, c1 in enumerate( self.cable[:-1] ):
         c2 = self.cable[i+1].mc_
         c1.mc_.connect('axial', c2, 'raxial')
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:6,代码来源:rallpacks_passive_cable.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python translator.parse_m3u函数代码示例发布时间:2022-05-27
下一篇:
Python NeuroML.NeuroML类代码示例发布时间: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