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

Python quantities.unit函数代码示例

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

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



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

示例1: __getitem__

    def __getitem__(self, time):

        if isinstance(time, tuple):
            assert len(time) == 2
            start = unit(time[0])
            stop = unit(time[1])
            
            if start < self._time[0]:
                assert False, 'Time out of bounds'
            if stop > self._time[-1]:
                assert False, 'Time out of bounds'
                
                
            #print start
            #print stop
            mask = np.logical_and((start < self._time), (self._time < stop))
            #print  np.nonzero(mask)[0]
            if len(np.nonzero(mask)[0]) < 2: 
                assert False
            return Trace_FixedDT(time=self._time[ np.nonzero(mask)[0] ],
                                  data=self._data[ np.nonzero(mask)[0] ]
                          )    
                    
        
        assert isinstance(time, pq.quantity.Quantity), "Times Shoudl be quanitity. Found: %s %s"%(time, type(time) )
        # Rebase the Time:
        time.rescale(self._time.units)
        interpolator = interp1d(self._time.magnitude, self._data.magnitude)
        dMag = interpolator(time.magnitude)
        return dMag * self._data.units
开发者ID:unidesigner,项目名称:morphforge,代码行数:30,代码来源:traceFixedDT.py


示例2: plot_curve

    def plot_curve(cls, ax, curve, chl, state, infpower=None, *args, **kwargs):

        V = np.linspace(-80,50)*unit('mV')
        #V = StdLimits.get_default_voltage_array().rescale('mV')

        (alpha, beta) = chl.get_alpha_beta_at_voltage(V, state)
        (inf, tau) = InfTauCalculator.alpha_beta_to_inf_tau(alpha, beta)
        infpower = (np.power(inf, infpower) if infpower else None)
        plot_what_lut = {
            Curve.Alpha: (alpha, 'Rate Constant', None),
            Curve.Beta: (beta, 'Rate Constant', None),
            Curve.Inf: (inf, 'Steady-State', None),
            Curve.InfPowered: (infpower, 'Steady-State', None),
            Curve.Tau: (tau, 'Time-Constant', 'ms'),
            }
        (plot_what, y_label, y_unit) = plot_what_lut[curve]

            # print kwargs

        if isinstance(ax, QuantitiesAxisNew):

            ax.plot(V, plot_what, *args, **kwargs)
            ax.set_xlabel('Voltage')
            ax.set_ylabel(y_label)

            if y_unit:
                ax.set_yunit(unit(y_unit))
        else:

            ax.plot(V, plot_what, *args, **kwargs)
            ax.set_xlabel('Voltage (mV)')
            ax.set_ylabel(y_label)
开发者ID:bmerrison,项目名称:morphforge,代码行数:32,代码来源:mmalphabeta.py


示例3: __init__

 def __init__(self, name, conductance, reversalpotential, mechanism_id=None):
     if not mechanism_id:
         mechanism_id = "StdLeakChl"
     MembraneMechanism.__init__(self, mechanism_id=mechanism_id)
     self.name = name
     self.conductance = unit(conductance)
     self.reversalpotential = unit(reversalpotential)
开发者ID:unidesigner,项目名称:morphforge,代码行数:7,代码来源:mmleak.py


示例4: __init__

 def __init__(self, name, ion, equation, conductance, reversalpotential, mechanism_id, statevars={}):    
     MembraneMechanism.__init__(self, mechanism_id=mechanism_id)
     self.name = name
     self.ion = ion
     self.eqn = equation
     self.conductance = unit(conductance)        
     self.statevars = dict([ (s, (sDict['alpha'], sDict['beta'])) for s, sDict in statevars.iteritems()])
     self.reversalpotential = unit(reversalpotential)
开发者ID:unidesigner,项目名称:morphforge,代码行数:8,代码来源:mmalphabeta.py


示例5: __init__

    def __init__(self, ion, equation, conductance, reversalpotential, statevars_new={}, **kwargs):
        super(MM_InfTauInterpolatedChannel, self).__init__(**kwargs)


        self.ion = ion
        self.eqn = equation
        self.conductance = unit(conductance)
        self.reversalpotential = unit(reversalpotential)
        self.statevars_new = statevars_new.copy()
开发者ID:bmerrison,项目名称:morphforge,代码行数:9,代码来源:core.py


示例6: getDefaults

 def getDefaults(cls):
     defs =  { NeuronSimulationSettings.dt: unit("0.01:ms"), 
               NeuronSimulationSettings.tstop: unit("500:ms"), 
               NeuronSimulationSettings.cvode: True }
     
     # Check we have defaults for all parameters:
     for p in NeuronSimulationSettings.allparams: 
         assert p in defs
     
     return defs
开发者ID:unidesigner,项目名称:morphforge,代码行数:10,代码来源:neuronsimulationsettings.py


示例7: linspace

    def linspace(cls, start, stop, num, endpoint=True):
        start = unit(start)
        stop = unit(stop)

        # Lets us the same base unit:
        stop = 1.0 * stop
        stop.units = start.units

        vals = np.linspace(start.magnitude, stop.magnitude, num=num, endpoint=endpoint)
        return vals * start.units
开发者ID:bmerrison,项目名称:morphforge,代码行数:10,代码来源:wrappers.py


示例8: get_defaults

    def get_defaults(cls):
        defs = {NEURONSimulationSettings.dt: unit('0.01:ms'),
                NEURONSimulationSettings.tstop: unit('500:ms'),
                NEURONSimulationSettings.cvode: True}

        # Check we have defaults for all parameters:
        for parameter in NEURONSimulationSettings.allparams:
            assert parameter in defs

        return defs
开发者ID:bmerrison,项目名称:morphforge,代码行数:10,代码来源:neuronsimulationsettings.py


示例9: linspace

    def linspace(cls, start, stop, num, endpoint=True):
        from morphforge.core.quantities import unit

        start = unit(start)
        stop = unit(stop)

        # Lets us the same base unit:
        stop = 1.0 * stop
        stop.units = start.units

        vals = np.linspace(start.magnitude, stop.magnitude, num=num, endpoint=endpoint)
        return vals * start.units
开发者ID:unidesigner,项目名称:morphforge,代码行数:12,代码来源:wrappers.py


示例10: __init__

    def __init__(self, name, ion, equation, conductance, reversalpotential, statevars, beta2threshold, **kwargs):
        super(StdChlAlphaBetaBeta, self).__init__(name=name, **kwargs)

        # self.name = name
        self.ion = ion
        self.eqn = equation
        self.conductance = unit(conductance)

        self.beta2threshold = unit(beta2threshold)

        self.statevars = dict(
            [(s, (sDict["alpha"], sDict["beta1"], sDict["beta2"])) for s, sDict in statevars.iteritems()]
        )
        self.reversalpotential = unit(reversalpotential)
开发者ID:bmerrison,项目名称:morphforge,代码行数:14,代码来源:mmalphabetabeta.py


示例11: __init__

    def __init__(self, name, ion, equation, conductance, reversalpotential, statevars=None, **kwargs):
        super(StdChlAlphaBeta, self).__init__(name=name, **kwargs)
        # TODO: FIXED DEFAULT PARAMETER 'statevars'
        if statevars is None:
            statevars = {}
        
        self.ion = ion
        self.eqn = equation
        self.conductance = unit(conductance)
        self.statevars = dict([(s, (sDict['alpha'], sDict['beta'])) for s, sDict in statevars.iteritems()])
        self.reversalpotential = unit(reversalpotential)

        self.conductance = self.conductance.rescale('S/cm2')
        self.reversalpotential = self.reversalpotential.rescale('mV')
开发者ID:bmerrison,项目名称:morphforge,代码行数:14,代码来源:mmalphabeta.py


示例12: arange

    def arange(cls, start, stop, step):
        # print start, stop, step
        start = unit(start)
        stop = unit(stop)
        step = unit(step)

        # Lets us the same base unit:
        stop = 1.0 * stop
        step = 1.0 * step
        stop.units = start.units
        step.units = start.units

        vals = np.arange(start.magnitude, stop.magnitude, step=step.magnitude)
        return vals * start.units
开发者ID:bmerrison,项目名称:morphforge,代码行数:14,代码来源:wrappers.py


示例13: __init__

    def __init__(self, name, ion, equation, conductance, reversalpotential, statevars, beta2threshold, mechanism_id):

        MembraneMechanism.__init__(self, mechanism_id=mechanism_id)

        self.name = name
        self.ion = ion
        self.eqn = equation
        self.conductance = unit(conductance)

        self.beta2threshold = unit(beta2threshold)

        self.statevars = dict(
            [(s, (sDict["alpha"], sDict["beta1"], sDict["beta2"])) for s, sDict in statevars.iteritems()]
        )
        self.reversalpotential = unit(reversalpotential)
开发者ID:unidesigner,项目名称:morphforge,代码行数:15,代码来源:mmalphabetabeta.py


示例14: arange

    def arange(cls, start, stop, step):
        from morphforge.core.quantities import unit

        start = unit(start)
        stop = unit(stop)
        step = unit(step)

        # Lets us the same base unit:
        stop = 1.0 * stop
        step = 1.0 * step
        stop.units = start.units
        step.units = start.units

        vals = np.arange(start.magnitude, stop.magnitude, step=step.magnitude)
        return vals * start.units
开发者ID:unidesigner,项目名称:morphforge,代码行数:15,代码来源:wrappers.py


示例15: PlotCurve

 def PlotCurve(cls, ax, curve, chl, state, infpower=None, *args, **kwargs):
     
     V = StdLimits.getDefaultVoltageArray().rescale("mV")
     
     alpha,beta = chl.getAlphaBetaAtVoltage(V, state)
     inf,tau = InfTauCalculator.AlphaBetaToInfTau(alpha,beta)
     infpower = np.power(inf, infpower) if infpower else None
     plot_what_LUT = { 
                  Curve.Alpha :     ( alpha,    "Rate Constant", None ), 
                  Curve.Beta :      ( beta,     "Rate Constant", None ),
                  Curve.Inf :       ( inf,      "Steady-State",  None ),
                  Curve.InfPowered :( infpower, "Steady-State",  None ),
                  Curve.Tau :       ( tau,      "Time-Constant", "ms" ),
                  }
     plot_what, y_label, y_unit = plot_what_LUT[curve]
     
     #print kwargs
     
     if isinstance(ax, QuantitiesAxisNew):
         
         ax.plot(V,plot_what, *args,**kwargs)
         ax.set_xlabel("Voltage")
         ax.set_ylabel(y_label)
         
         if y_unit:
             ax.set_yunit( unit(y_unit) )
         
     else:
         ax.plot(V,plot_what, *args,**kwargs)
         ax.set_xlabel("Voltage (mV)")
         ax.set_ylabel(y_label)
开发者ID:unidesigner,项目名称:morphforge,代码行数:31,代码来源:mmalphabeta.py


示例16: summarise_Overview

    def summarise_Overview(self):
        from reportlab.platypus import Paragraph, Table, PageBreak
        localElements = []
        
        localElements.append( Paragraph("Overview", self.reportlabconfig.styles['Heading1'] ) )
        
        
        # Cells:
        ########
        localElements.append( Paragraph("Cells", self.reportlabconfig.styles['Heading2'] ) )
        tableHeader = ['Cell',  'Total Surface Area', 'Sections', 'Segments','Active Channels (id,[Name])']
        data = [tableHeader, ]
        
        for cell in self.simulation.getCells():
            a = sum([ s.getArea() for s in cell.morphology]) * unit("1:um2")
            nSections = len( cell.morphology )
            nSegments = sum( [cell.getSegmenter().getNumSegments(section) for section in cell.morphology] )
            activeMechs = cell.getBiophysics().getAllMechanismsAppliedToCell()
            activeChlList = "\n".join( ["%s [%s]"%(am.getMechanismID(), am.name) for am in activeMechs] )
            data.append( [ cell.name, a, nSections, nSegments, activeChlList ] )
        
        localElements.append( Table(data, style=self.reportlabconfig.defaultTableStyle) )
 
        
        # Stimulae: CC
        ###############
        if self.simulation.getCurrentClamps():
            localElements.append( Paragraph("Current Clamps", self.reportlabconfig.styles['Heading2'] ) )
            tableHeader = ['Name', 'Location', 'Delay', 'Amplitude', 'Duration']
            data = [tableHeader, ]
            for cc in self.simulation.getCurrentClamps():
                cellname = cc.celllocation.cell.name
                data.append( [ cc.name, cellname, cc.delay, cc.amp, cc.dur ] )
            
            localElements.append( Table(data, style=self.reportlabconfig.defaultTableStyle) )
                
        
        # Stimulae: VC
        ###############
        if self.simulation.getVoltageClamps():
            localElements.append( Paragraph("Voltage Clamps", self.reportlabconfig.styles['Heading2'] ) )
            tableHeader = ['Name', 'Location', 'Dur1', 'Dur2', 'Dur3', 'Amp1','Amp2','Amp3']
            data = [tableHeader, ]
            for vc in self.simulation.getVoltageClamps():
                cellname = vc.celllocation.cell.name
                data.append( [ vc.name, cellname, vc.dur1, vc.dur2, vc.dur3, vc.amp1, vc.amp2, vc.amp3 ] )
            
            localElements.append( Table(data, style=self.reportlabconfig.defaultTableStyle) )
            
        
        # Finish Up:        
        localElements.append( PageBreak() )
        return localElements
开发者ID:unidesigner,项目名称:morphforge,代码行数:53,代码来源:simsummariser.py


示例17: __init__

    def __init__(self, name, ion, equation, permeability, intracellular_concentration, extracellular_concentration, temperature, beta2threshold,  statevars, **kwargs):
        super( StdChlCalciumAlphaBetaBeta, self).__init__(name=name, **kwargs)

        self.ion = ion

        self.permeability = unit(permeability)
        self.intracellular_concentration = unit(intracellular_concentration)
        self.extracellular_concentration = unit(extracellular_concentration)

        self.eqn = equation
        self.statevars = dict([(s, (sDict['alpha'], sDict['beta1'], sDict['beta2'])) for s, sDict in statevars.iteritems()])
        self.beta2threshold = unit(beta2threshold)

        self.F = unit('96485.3365:C/mol')
        self.R = unit('8.314421:J/(K mol)')
        self.CaZ = unit('2:')
        self.T = unit(temperature)
开发者ID:bmerrison,项目名称:morphforge,代码行数:17,代码来源:mmcalciumalphabetabeta.py


示例18: getVoltageClampTrace

 def getVoltageClampTrace(cls, V, chl, duration, cellArea, t=np.arange(0,300,0.1) * unit("1:ms"), ) :
     
     from scipy.integrate import odeint
     
     vInMv = V.rescale("mV").magnitude
     
     stateNames = chl.statevars.keys()
     nStates = len(stateNames)
     m_inf, m_tau =  InfTauCalculator.evaluateInfTauForV( chl.statevars[stateNames[0]], V)
     m_tauMS = m_tau.rescale("ms").magnitude
     
     infTaus = [ InfTauCalculator.evaluateInfTauForV( chl.statevars[stateName], V)  for stateName in stateNames ]
     infTausMS = [ (inf, tau.rescale("ms").magnitude)  for (inf,tau) in infTaus ]
     
     stateToIndex = dict( [ (state,index) for state,index in enumerate(stateNames) ] ) 
     
     def odeFunc(y,t0):
         res = [None] * nStates
         for i in range(0,nStates):
             stateInf,stateTau = infTausMS[i]
             stateVal = y[i]
             dState = ( stateInf - stateVal ) / stateTau
             res[i] = dState
         return res
     
     # Run the ODE for each variable:            
     t = t.rescale("ms").magnitude
     y0 = np.zeros( (nStates, ) )
     res = odeint(func=odeFunc, y0=y0, t= t  )
     
     stateFunctor = sympy.lambdify( stateNames, sympy.sympify(chl.eqn)  )
     stateData = [ res[:,i] for i in range(0,nStates) ]
     
     stateEquationEvaluation = stateFunctor( *stateData )
     
     cellDensity = (chl.conductance * cellArea)
     iChl =  (chl.conductance * cellArea)  * stateEquationEvaluation * (V- chl.reversalpotential) 
     
     return Trace_FixedDT( time=t * unit("1:ms"), data=iChl.rescale("pA")  )
开发者ID:unidesigner,项目名称:morphforge,代码行数:39,代码来源:mmalphabeta.py


示例19: get_voltage_clamp_trace

    def get_voltage_clamp_trace(cls, V, chl, duration, cell_area, t=np.arange(0, 300, 0.1) * unit("1:ms")):
        from scipy.integrate import odeint
        import sympy

        v_in_mv = V.rescale("mV").magnitude

        state_names = chl.statevars.keys()
        n_states = len(state_names)
        (m_inf, m_tau) = InfTauCalculator.evaluate_inf_tau_for_v(chl.statevars[state_names[0]], V)
        m_tau_ms = m_tau.rescale("ms").magnitude

        inf_taus = [InfTauCalculator.evaluate_inf_tau_for_v(chl.statevars[stateName], V) for stateName in state_names]
        inf_taus_ms = [(inf, tau.rescale("ms").magnitude) for (inf, tau) in inf_taus]

        state_to_index = dict([(state, index) for state, index in enumerate(state_names)])

        def odeFunc(y, t0):
            res = [None] * n_states
            for i in range(0, n_states):
                state_inf, state_tau = inf_taus_ms[i]
                state_val = y[i]
                d_state = (state_inf - state_val) / state_tau
                res[i] = d_state
            return res

        # run the ODE for each variable:
        t = t.rescale("ms").magnitude
        y0 = np.zeros((n_states))
        res = odeint(func=odeFunc, y0=y0, t=t)

        state_functor = sympy.lambdify(state_names, sympy.sympify(chl.eqn))
        state_data = [res[:, i] for i in range(0, n_states)]

        state_equation_evaluation = state_functor(*state_data)

        cell_density = chl.conductance * cell_area
        i_chl = chl.conductance * cell_area * state_equation_evaluation * (V - chl.reversalpotential)

        return TraceFixedDT(time=t * unit("1:ms"), data=i_chl.rescale("pA"))
开发者ID:bmerrison,项目名称:morphforge,代码行数:39,代码来源:mmalphabetabeta.py


示例20: build_voltageclamp_soma_simulation

def build_voltageclamp_soma_simulation(env, V, mech_builder, morphology):
    sim = env.Simulation(name='SimXX')
    cell = sim.create_cell(name='Cell1', morphology=morphology)

    cell.apply_channel( channel=mech_builder(env=sim.environment))


    sim.record( cell, what=cell.Recordables.MembraneVoltage, name='SomaVoltage' , cell_location=cell.soma)

    vc = sim.create_voltageclamp(
        name='Stim1',
        amp1=unit('-81.5:mV'),
        amp2=unit(V),
        amp3=unit('-81.5:mV'),
        dur1=unit('100:ms'),
        dur2=unit('100:ms'),
        dur3=unit('100:ms'),
        cell_location=cell.soma,
        )
    sim.record(vc, what=vc.Recordables.Current, name='VCCurrent')
    return sim
开发者ID:bmerrison,项目名称:morphforge,代码行数:21,代码来源:voltageclampchannel.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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