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

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

示例1: __init__

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def __init__(self,alpha_max,Tg,xi):

gamma=0.9+(0.05-xi)/(0.3+6*xi)

eta1=0.02+(0.05-xi)/(4+32*xi)

eta1=eta1 if eta1>0 else 0

eta2=1+(0.05-xi)/(0.08+1.6*xi)

eta2=eta2 if eta2>0.55 else 0.55

T=np.linspace(0,6,601)

alpha=[]

for t in T:

if t<0.1:

alpha.append(np.interp(t,[0,0.1],[0.45*alpha_max,eta2*alpha_max]))

elif t

alpha.append(eta2*alpha_max)

elif t<5*Tg:

alpha.append((Tg/t)**gamma*eta2*alpha_max)

else:

alpha.append((eta2*0.2**gamma-eta1*(t-5*Tg))*alpha_max)

self.__spectrum={'T':T,'alpha':alpha}

开发者ID:zhuoju36,项目名称:StructEngPy,代码行数:20,

示例2: spectrum_analysis

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def spectrum_analysis(model,n,spec):

"""

sepctrum analysis

params:

n: number of modes to use\n

spec: a list of tuples (period,acceleration response)

"""

freq,mode=eigen_mode(model,n)

M_=np.dot(mode.T,model.M)

M_=np.dot(M_,mode)

K_=np.dot(mode.T,model.K)

K_=np.dot(K_,mode)

C_=np.dot(mode.T,model.C)

C_=np.dot(C_,mode)

d_=[]

for (m_,k_,c_) in zip(M_.diag(),K_.diag(),C_.diag()):

sdof=SDOFSystem(m_,k_)

T=sdof.omega_d()

d_.append(np.interp(T,spec[0],spec[1]*m_))

d=np.dot(d_,mode)

#CQC

return d

开发者ID:zhuoju36,项目名称:StructEngPy,代码行数:25,

示例3: nan_helper

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def nan_helper(y):

"""Helper to handle indices and logical indices of NaNs.

Input:

- y, 1d numpy array with possible NaNs

Output:

- nans, logical indices of NaNs

- index, a function, with signature indices= index(logical_indices),

to convert logical indices of NaNs to 'equivalent' indices

Example:

>>> # linear interpolation of NaNs

>>> nans, x= nan_helper(y)

>>> y[nans]= np.interp(x(nans), x(~nans), y[~nans])

"""

return np.isnan(y), lambda z: z.nonzero()[0]

开发者ID:BruceBinBoxing,项目名称:Deep_Learning_Weather_Forecasting,代码行数:18,

示例4: test_control_curve_interpolated_json

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_control_curve_interpolated_json(use_parameters):

# this is a little hack-y, as the parameters don't provide access to their

# data once they've been initalised

if use_parameters:

model = load_model("reservoir_with_cc_param_values.json")

else:

model = load_model("reservoir_with_cc.json")

reservoir1 = model.nodes["reservoir1"]

model.setup()

path = os.path.join(os.path.dirname(__file__), "models", "control_curve.csv")

control_curve = pd.read_csv(path)["Control Curve"].values

values = [-8, -6, -4]

@assert_rec(model, reservoir1.cost)

def expected_cost(timestep, si):

# calculate expected cost manually and compare to parameter output

volume_factor = reservoir1._current_pc[si.global_id]

cc = control_curve[timestep.index]

return np.interp(volume_factor, [0.0, cc, 1.0], values[::-1])

model.run()

开发者ID:pywr,项目名称:pywr,代码行数:22,

示例5: test_circular_control_curve_interpolated_json

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_circular_control_curve_interpolated_json():

# this is a little hack-y, as the parameters don't provide access to their

# data once they've been initalised

model = load_model("reservoir_with_circular_cc.json")

reservoir1 = model.nodes["reservoir1"]

model.setup()

path = os.path.join(os.path.dirname(__file__), "models", "control_curve.csv")

control_curve = pd.read_csv(path)["Control Curve"].values

values = [-8, -6, -4]

@assert_rec(model, reservoir1.cost)

def expected_cost(timestep, si):

# calculate expected cost manually and compare to parameter output

volume_factor = reservoir1._current_pc[si.global_id]

cc = control_curve[timestep.index]

return np.interp(volume_factor, [0.0, cc, 1.0], values[::-1])

model.run()

开发者ID:pywr,项目名称:pywr,代码行数:19,

示例6: colormap

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def colormap(x, m=None, M=None, center=0, colors=None):

'''color a grayscale array (currently red/blue by sign)'''

if center is None:

center = 0

if colors is None:

colors = np.array(((0, 0.7, 1),

(0, 0, 0),

(1, 0, 0)),

dtype=float)

if x.shape[-1] == 1:

x = x[..., 0]

x = scale_values(x, min=m, max=M, center=center)

y = np.empty(x.shape + (3,))

for c in xrange(3):

y[..., c] = np.interp(x, (0, 0.5, 1), colors[:, c])

return y

开发者ID:hjimce,项目名称:Depth-Map-Prediction,代码行数:18,

示例7: cor_2_1d

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def cor_2_1d(cor, H, W):

bon_ceil_x, bon_ceil_y = [], []

bon_floor_x, bon_floor_y = [], []

n_cor = len(cor)

for i in range(n_cor // 2):

xys = panostretch.pano_connect_points(cor[i*2],

cor[(i*2+2) % n_cor],

z=-50, w=W, h=H)

bon_ceil_x.extend(xys[:, 0])

bon_ceil_y.extend(xys[:, 1])

for i in range(n_cor // 2):

xys = panostretch.pano_connect_points(cor[i*2+1],

cor[(i*2+3) % n_cor],

z=50, w=W, h=H)

bon_floor_x.extend(xys[:, 0])

bon_floor_y.extend(xys[:, 1])

bon_ceil_x, bon_ceil_y = sort_xy_filter_unique(bon_ceil_x, bon_ceil_y, y_small_first=True)

bon_floor_x, bon_floor_y = sort_xy_filter_unique(bon_floor_x, bon_floor_y, y_small_first=False)

bon = np.zeros((2, W))

bon[0] = np.interp(np.arange(W), bon_ceil_x, bon_ceil_y, period=W)

bon[1] = np.interp(np.arange(W), bon_floor_x, bon_floor_y, period=W)

bon = ((bon + 0.5) / H - 0.5) * np.pi

return bon

开发者ID:sunset1995,项目名称:HorizonNet,代码行数:25,

示例8: test_zero_dimensional_interpolation_point

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_zero_dimensional_interpolation_point(self):

x = np.linspace(0, 1, 5)

y = np.linspace(0, 1, 5)

x0 = np.array(.3)

assert_almost_equal(np.interp(x0, x, y), x0)

xp = np.array([0, 2, 4])

fp = np.array([1, -1, 1])

actual = np.interp(np.array(1), xp, fp)

assert_equal(actual, 0)

assert_(isinstance(actual, np.float64))

actual = np.interp(np.array(4.5), xp, fp, period=4)

assert_equal(actual, 0.5)

assert_(isinstance(actual, np.float64))

开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,

示例9: test_interpolate_index_values

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_interpolate_index_values(self):

s = Series(np.nan, index=np.sort(np.random.rand(30)))

s[::3] = np.random.randn(10)

vals = s.index.values.astype(float)

result = s.interpolate(method='index')

expected = s.copy()

bad = isna(expected.values)

good = ~bad

expected = Series(np.interp(vals[bad], vals[good],

s.values[good]),

index=s.index[bad])

assert_series_equal(result[bad], expected)

# 'values' is synonymous with 'index' for the method kwarg

other_result = s.interpolate(method='values')

assert_series_equal(other_result, result)

assert_series_equal(other_result[bad], expected)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:24,

示例10: sample_posterior

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def sample_posterior(self, x, n=1):

r"""

Generates :code:`n` samples from the estimated posterior

distribution for the input vector :code:`x`. The sampling

is performed by the inverse CDF method using the estimated

CDF obtained from the :code:`cdf` member function.

Arguments:

x(np.array): Array of shape `(n, m)` containing `n` inputs for which

to predict the conditional quantiles.

n(int): The number of samples to generate.

Returns:

Tuple (xs, fs) containing the :math: `x`-values in `xs` and corresponding

values of the posterior CDF :math: `F(x)` in `fs`.

"""

y_pred, qs = self.cdf(x)

p = np.random.rand(n)

y = np.interp(p, qs, y_pred)

return y

开发者ID:atmtools,项目名称:typhon,代码行数:25,

示例11: interp_batch

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def interp_batch(total_batch_x):

interp_batch_x = total_batch_x.copy()

N_batch = total_batch_x.shape[0]

for n in range(N_batch):

temp_idx = np.where(total_batch_x[n,0,:,1]==1)[0]

t1 = int(temp_idx[-1])

temp_idx = np.where(total_batch_x[n,0,:,2]==1)[0]

t2 = int(temp_idx[0])

if t2-t1<=1:

continue

interp_t = np.array(range(t1+1,t2))

for k in range(total_batch_x.shape[1]):

#temp_std = np.std(total_batch_x[n,k,total_batch_x[n,k,:,0]!=0,0])

temp_std1 = np.std(total_batch_x[n,k,total_batch_x[n,0,:,1]!=0,0])

temp_std2 = np.std(total_batch_x[n,k,total_batch_x[n,0,:,2]!=0,0])

x_p = [t1,t2]

f_p = [total_batch_x[n,k,t1,0],total_batch_x[n,k,t2,0]]

#interp_batch_x[n,k,t1+1:t2,0] = np.interp(interp_t,x_p,f_p)#+np.random.normal(0, temp_std, t2-t1-1)

interp_batch_x[n,k,t1+1:t2,0] = np.interp(interp_t,x_p,f_p)+np.random.normal(0, (temp_std1+temp_std2)*0.5, t2-t1-1)

return interp_batch_x

开发者ID:GaoangW,项目名称:TNT,代码行数:24,

示例12: interp_batch

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def interp_batch(total_batch_x):

interp_batch_x = total_batch_x.copy()

N_batch = total_batch_x.shape[0]

for n in range(N_batch):

temp_idx = np.where(total_batch_x[n,0,:,1]==1)[0]

t1 = int(temp_idx[-1])

temp_idx = np.where(total_batch_x[n,0,:,2]==1)[0]

t2 = int(temp_idx[0])

if t2-t1<=1:

continue

interp_t = np.array(range(t1+1,t2))

for k in range(total_batch_x.shape[1]):

#temp_std = np.std(total_batch_x[n,k,total_batch_x[n,k,:,0]!=0,0])

temp_std1 = np.std(total_batch_x[n,k,total_batch_x[n,0,:,1]!=0,0])

temp_std2 = np.std(total_batch_x[n,k,total_batch_x[n,0,:,2]!=0,0])

x_p = [t1,t2]

f_p = [total_batch_x[n,k,t1,0],total_batch_x[n,k,t2,0]]

#*************************************

#interp_batch_x[n,k,t1+1:t2,0] = np.interp(interp_t,x_p,f_p)+np.random.normal(0, temp_std, t2-t1-1)

#*************************************

interp_batch_x[n,k,t1+1:t2,0] = np.interp(interp_t,x_p,f_p)+np.random.normal(0, (temp_std1+temp_std2)*0.5, t2-t1-1)

return interp_batch_x

开发者ID:GaoangW,项目名称:TNT,代码行数:24,

示例13: test_complex_interp

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_complex_interp(self):

# test complex interpolation

x = np.linspace(0, 1, 5)

y = np.linspace(0, 1, 5) + (1 + np.linspace(0, 1, 5))*1.0j

x0 = 0.3

y0 = x0 + (1+x0)*1.0j

assert_almost_equal(np.interp(x0, x, y), y0)

# test complex left and right

x0 = -1

left = 2 + 3.0j

assert_almost_equal(np.interp(x0, x, y, left=left), left)

x0 = 2.0

right = 2 + 3.0j

assert_almost_equal(np.interp(x0, x, y, right=right), right)

# test complex periodic

x = [-180, -170, -185, 185, -10, -5, 0, 365]

xp = [190, -190, 350, -350]

fp = [5+1.0j, 10+2j, 3+3j, 4+4j]

y = [7.5+1.5j, 5.+1.0j, 8.75+1.75j, 6.25+1.25j, 3.+3j, 3.25+3.25j,

3.5+3.5j, 3.75+3.75j]

assert_almost_equal(np.interp(x, xp, fp, period=360), y)

开发者ID:ryfeus,项目名称:lambda-packs,代码行数:23,

示例14: linear_interpolation

​点赞 6

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def linear_interpolation(x, xp, fp, **kwargs):

"""Multi-dimensional linear interpolation.

Returns the multi-dimensional piecewise linear interpolant to a function with

given discrete data points (xp, fp), evaluated at x.

Note that *N and *M indicate zero or more dimensions.

Args:

x: An array of shape [*N], the x-coordinates of the interpolated values.

xp: An np.array of shape [D], the x-coordinates of the data points, must be

increasing.

fp: An np.array of shape [D, *M], the y-coordinates of the data points.

**kwargs: Keywords for np.interp.

Returns:

An array of shape [*N, *M], the interpolated values.

"""

yp = fp.reshape([fp.shape[0], -1]).transpose()

y = np.stack([np.interp(x, xp, zp, **kwargs) for zp in yp]).transpose()

return y.reshape(x.shape[:1] + fp.shape[1:]).astype(np.float32)

开发者ID:tensorflow,项目名称:tensor2tensor,代码行数:23,

示例15: _convert_to_torque_from_pwm

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def _convert_to_torque_from_pwm(self, pwm, true_motor_velocity):

"""Convert the pwm signal to torque.

Args:

pwm: The pulse width modulation.

true_motor_velocity: The true motor velocity at the current moment. It is

used to compute the back EMF voltage and the viscous damping.

Returns:

actual_torque: The torque that needs to be applied to the motor.

observed_torque: The torque observed by the sensor.

"""

observed_torque = np.clip(

self._torque_constant *

(np.asarray(pwm) * self._voltage / self._resistance),

-OBSERVED_TORQUE_LIMIT, OBSERVED_TORQUE_LIMIT)

# Net voltage is clipped at 50V by diodes on the motor controller.

voltage_net = np.clip(

np.asarray(pwm) * self._voltage -

(self._torque_constant + self._viscous_damping) *

np.asarray(true_motor_velocity), -VOLTAGE_CLIPPING, VOLTAGE_CLIPPING)

current = voltage_net / self._resistance

current_sign = np.sign(current)

current_magnitude = np.absolute(current)

# Saturate torque based on empirical current relation.

actual_torque = np.interp(current_magnitude, self._current_table,

self._torque_table)

actual_torque = np.multiply(current_sign, actual_torque)

actual_torque = np.multiply(self._strength_ratios, actual_torque)

return actual_torque, observed_torque

开发者ID:utra-robosoccer,项目名称:soccer-matlab,代码行数:32,

示例16: _convert_to_torque_from_pwm

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def _convert_to_torque_from_pwm(self, pwm, current_motor_velocity):

"""Convert the pwm signal to torque.

Args:

pwm: The pulse width modulation.

current_motor_velocity: The motor velocity at the current time step.

Returns:

actual_torque: The torque that needs to be applied to the motor.

observed_torque: The torque observed by the sensor.

"""

observed_torque = np.clip(

self._torque_constant * (pwm * self._voltage / self._resistance),

-OBSERVED_TORQUE_LIMIT, OBSERVED_TORQUE_LIMIT)

# Net voltage is clipped at 50V by diodes on the motor controller.

voltage_net = np.clip(pwm * self._voltage -

(self._torque_constant + self._viscous_damping)

* current_motor_velocity,

-VOLTAGE_CLIPPING, VOLTAGE_CLIPPING)

current = voltage_net / self._resistance

current_sign = np.sign(current)

current_magnitude = np.absolute(current)

# Saturate torque based on empirical current relation.

actual_torque = np.interp(current_magnitude, self._current_table,

self._torque_table)

actual_torque = np.multiply(current_sign, actual_torque)

return actual_torque, observed_torque

开发者ID:utra-robosoccer,项目名称:soccer-matlab,代码行数:30,

示例17: test_control_curve_interpolated

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_control_curve_interpolated(model, use_parameters):

m = model

m.timestepper.delta = 200

s = m.nodes['Storage']

o = m.nodes['Output']

s.connect(o)

cc = ConstantParameter(model, 0.8)

values = [20.0, 5.0, 0.0]

if use_parameters:

# Create the parameter using parameters for the values

parameters = [ConstantParameter(model, v) for v in values]

s.cost = p = ControlCurveInterpolatedParameter(model, s, cc, parameters=parameters)

else:

# Create the parameter using a list of values

s.cost = p = ControlCurveInterpolatedParameter(model, s, cc, values)

@assert_rec(model, p)

def expected_func(timestep, scenario_index):

v = s.initial_volume

c = cc.value(timestep, scenario_index)

if c == 1.0 and v == 100.0:

expected = values[1]

elif c == 0.0 and v == 0.0:

expected = values[1]

else:

expected = np.interp(v/100.0, [0.0, c, 1.0], values[::-1])

return expected

for control_curve in (0.0, 0.8, 1.0):

cc.set_double_variables(np.array([control_curve,]))

for initial_volume in (0.0, 10.0, 50.0, 80.0, 90.0, 100.0):

s.initial_volume = initial_volume

model.run()

开发者ID:pywr,项目名称:pywr,代码行数:38,

示例18: gen_reg_from_xy

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def gen_reg_from_xy(xy, w):

xy = xy[np.argsort(xy[:, 0])]

return np.interp(np.arange(w), xy[:, 0], xy[:, 1], period=w)

开发者ID:sunset1995,项目名称:HorizonNet,代码行数:5,

示例19: _resample_numpy

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def _resample_numpy(signal, desired_length):

resampled_signal = np.interp(

np.linspace(0.0, 1.0, desired_length, endpoint=False), # where to interpolate

np.linspace(0.0, 1.0, len(signal), endpoint=False), # known positions

signal, # known data points

)

return resampled_signal

开发者ID:neuropsychology,项目名称:NeuroKit,代码行数:9,

示例20: __call__

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def __call__(self, env, agent, step):

value = np.interp(step,

[1, self.total_steps],

[self.start_value, self.stop_value])

self.setter(env, agent, value)

开发者ID:chainer,项目名称:chainerrl,代码行数:7,

示例21: __getitem__

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def __getitem__(self, query):

"""Given query, returns the interpolated function value."""

return np.interp(query, self.inputs, self.outputs)

开发者ID:zykls,项目名称:whynot,代码行数:5,

示例22: test_exceptions

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_exceptions(self):

assert_raises(ValueError, interp, 0, [], [])

assert_raises(ValueError, interp, 0, [0], [1, 2])

assert_raises(ValueError, interp, 0, [0, 1], [1, 2], period=0)

assert_raises(ValueError, interp, 0, [], [], period=360)

assert_raises(ValueError, interp, 0, [0], [1, 2], period=360)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,

示例23: test_basic

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_basic(self):

x = np.linspace(0, 1, 5)

y = np.linspace(0, 1, 5)

x0 = np.linspace(0, 1, 50)

assert_almost_equal(np.interp(x0, x, y), x0)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,

示例24: test_right_left_behavior

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_right_left_behavior(self):

# Needs range of sizes to test different code paths.

# size ==1 is special cased, 1 < size < 5 is linear search, and

# size >= 5 goes through local search and possibly binary search.

for size in range(1, 10):

xp = np.arange(size, dtype=np.double)

yp = np.ones(size, dtype=np.double)

incpts = np.array([-1, 0, size - 1, size], dtype=np.double)

decpts = incpts[::-1]

incres = interp(incpts, xp, yp)

decres = interp(decpts, xp, yp)

inctgt = np.array([1, 1, 1, 1], dtype=float)

dectgt = inctgt[::-1]

assert_equal(incres, inctgt)

assert_equal(decres, dectgt)

incres = interp(incpts, xp, yp, left=0)

decres = interp(decpts, xp, yp, left=0)

inctgt = np.array([0, 1, 1, 1], dtype=float)

dectgt = inctgt[::-1]

assert_equal(incres, inctgt)

assert_equal(decres, dectgt)

incres = interp(incpts, xp, yp, right=2)

decres = interp(decpts, xp, yp, right=2)

inctgt = np.array([1, 1, 1, 2], dtype=float)

dectgt = inctgt[::-1]

assert_equal(incres, inctgt)

assert_equal(decres, dectgt)

incres = interp(incpts, xp, yp, left=0, right=2)

decres = interp(decpts, xp, yp, left=0, right=2)

inctgt = np.array([0, 1, 1, 2], dtype=float)

dectgt = inctgt[::-1]

assert_equal(incres, inctgt)

assert_equal(decres, dectgt)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:39,

示例25: test_scalar_interpolation_point

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_scalar_interpolation_point(self):

x = np.linspace(0, 1, 5)

y = np.linspace(0, 1, 5)

x0 = 0

assert_almost_equal(np.interp(x0, x, y), x0)

x0 = .3

assert_almost_equal(np.interp(x0, x, y), x0)

x0 = np.float32(.3)

assert_almost_equal(np.interp(x0, x, y), x0)

x0 = np.float64(.3)

assert_almost_equal(np.interp(x0, x, y), x0)

x0 = np.nan

assert_almost_equal(np.interp(x0, x, y), x0)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,

示例26: test_non_finite_behavior

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_non_finite_behavior(self):

x = [1, 2, 2.5, 3, 4]

xp = [1, 2, 3, 4]

fp = [1, 2, np.inf, 4]

assert_almost_equal(np.interp(x, xp, fp), [1, 2, np.inf, np.inf, 4])

fp = [1, 2, np.nan, 4]

assert_almost_equal(np.interp(x, xp, fp), [1, 2, np.nan, np.nan, 4])

开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,

示例27: test_if_len_x_is_small

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_if_len_x_is_small(self):

xp = np.arange(0, 10, 0.0001)

fp = np.sin(xp)

assert_almost_equal(np.interp(np.pi, xp, fp), 0.0)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,

示例28: test_period

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def test_period(self):

x = [-180, -170, -185, 185, -10, -5, 0, 365]

xp = [190, -190, 350, -350]

fp = [5, 10, 3, 4]

y = [7.5, 5., 8.75, 6.25, 3., 3.25, 3.5, 3.75]

assert_almost_equal(np.interp(x, xp, fp, period=360), y)

x = np.array(x, order='F').reshape(2, -1)

y = np.array(y, order='C').reshape(2, -1)

assert_almost_equal(np.interp(x, xp, fp, period=360), y)

开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,

示例29: get_brain_regions

​点赞 5

# 需要导入模块: import numpy [as 别名]

# 或者: from numpy import interp [as 别名]

def get_brain_regions(xyz, channels_positions=SITES_COORDINATES, brain_atlas=brat, display=False):

"""

:param xyz: numpy array of 3D coordinates corresponding to a picked track or a trajectory

the deepest point is considered the tip.

:param channels:

:param DISPLAY:

:return:

"""

"""

this is the depth along the probe (from the first point which is the deepest labeled point)

Due to the blockiness, depths may not be unique along the track so it has to be prepared

"""

d = atlas.cart2sph(xyz[:, 0] - xyz[0, 0], xyz[:, 1] - xyz[0, 1], xyz[:, 2] - xyz[0, 2])[0]

ind_depths = np.argsort(d)

d = np.sort(d)

iid = np.where(np.diff(d) >= 0)[0]

ind_depths = ind_depths[iid]

d = d[iid]

"""

Interpolate channel positions along the probe depth and get brain locations

"""

xyz_channels = np.zeros((channels_positions.shape[0], 3))

for m in np.arange(3):

xyz_channels[:, m] = np.interp(channels_positions[:, 1] / 1e6,

d[ind_depths], xyz[ind_depths, m])

brain_regions = brain_atlas.regions.get(brat.get_labels(xyz_channels))

"""

Get the best linear fit probe trajectory using points cloud

"""

track = atlas.Trajectory.fit(xyz)

return brain_regions, track

开发者ID:int-brain-lab,项目名称:ibllib,代码行数:37,

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

pythoninterp error_Python numpy.interp方法代码示例相关推荐

  1. python中np zeros_Python numpy.zeros方法代码示例

    本文整理汇总了Python中numpy.zeros方法的典型用法代码示例.如果您正苦于以下问题:Python numpy.zeros方法的具体用法?Python numpy.zeros怎么用?Pyth ...

  2. fmod函数python_python fmod函数_Python numpy.fmod方法代码示例

    本文整理汇总了Python中numpy.fmod方法的典型用法代码示例.如果您正苦于以下问题:Python numpy.fmod方法的具体用法?Python numpy.fmod怎么用?Python ...

  3. python fmod函数_Python numpy.fmod方法代码示例

    本文整理汇总了Python中numpy.fmod方法的典型用法代码示例.如果您正苦于以下问题:Python numpy.fmod方法的具体用法?Python numpy.fmod怎么用?Python ...

  4. python fsolve说明_Python optimize.fsolve方法代码示例

    本文整理汇总了Python中scipy.optimize.fsolve方法的典型用法代码示例.如果您正苦于以下问题:Python optimize.fsolve方法的具体用法?Python optim ...

  5. doc python 颜色_Python wordcloud.ImageColorGenerator方法代码示例

    本文整理汇总了Python中wordcloud.ImageColorGenerator方法的典型用法代码示例.如果您正苦于以下问题:Python wordcloud.ImageColorGenerat ...

  6. python中的scaler_Python preprocessing.MaxAbsScaler方法代码示例

    本文整理汇总了Python中sklearn.preprocessing.MaxAbsScaler方法的典型用法代码示例.如果您正苦于以下问题:Python preprocessing.MaxAbsSc ...

  7. python paperclip_Python pyplot.sca方法代码示例

    本文整理汇总了Python中matplotlib.pyplot.sca方法的典型用法代码示例.如果您正苦于以下问题:Python pyplot.sca方法的具体用法?Python pyplot.sca ...

  8. python res_Python models.resnet152方法代码示例

    本文整理汇总了Python中torchvision.models.resnet152方法的典型用法代码示例.如果您正苦于以下问题:Python models.resnet152方法的具体用法?Pyth ...

  9. python scipy.stats.norm.cdf_Python stats.norm方法代码示例

    本文整理汇总了Python中scipy.stats.norm方法的典型用法代码示例.如果您正苦于以下问题:Python stats.norm方法的具体用法?Python stats.norm怎么用?P ...

最新文章

  1. [Js-Spring]Spring与IoC(控制反转,Inversion of Control)
  2. 自己实现spring核心功能 一
  3. SQLite3.8.4.2在Windows平台下的编译和使用
  4. .NetCoreLinuxDockerPortainer踩坑历险记
  5. java9-1.类,抽象类,接口的综合小练习
  6. Python的正则匹配
  7. 虚拟化系列-Windows server 2012 备份管理
  8. 设置表格表头字体_Excel双栏和三栏斜线表头制作技巧
  9. WF3设计时性能II
  10. 阿里旺旺垃圾消息分析及解决方案探讨
  11. Android studio报错:Gradle‘s dependency cache may be corrupt (this sometimes occurs after a network
  12. python歌词统计_Python大佬分析了15万歌词,告诉你民谣歌手们到底在唱什么
  13. 去吧!设计模式之桥接模式
  14. valhalla 插件_Java 15:密封类使Valhalla更加接近
  15. 关于如何连接网络打印机
  16. Verilog专题(二十二)Lemmings1
  17. 通过php执行mysql语句进行学生成绩表的增删改查
  18. Java猿社区—ShardingSphere之广播表与绑定表
  19. 知识分享,海外推广的渠道有哪些,如何正确的选择
  20. Computer Organization and Architecture 10th - William Stallings

热门文章

  1. python部署工具fabric
  2. MySQL的几个character_set变量的说明
  3. 【SQL Sever】将SQL Sever中的一个数据表的数据导出为insert语句
  4. ASP.NET MVC5使用AjaxHelp
  5. 代码简洁(注意事项)
  6. DDD~DDD从零起步架构说明
  7. NVelocity系列:NVelocity配置详解
  8. 好老婆的作息时间(做女人真悲哀 ……)
  9. 【IT旁观者】喜羊羊与唐三藏
  10. 程序员谨防加班猝死之十大建议