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


Python quantities.unit函数代码示例

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


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


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