本文整理汇总了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
示例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)
示例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)
示例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)
示例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()
示例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
示例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
示例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
示例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
示例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)
示例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')
示例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
示例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)
示例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
示例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)