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


Python signal.savgol_filter方法代码示例

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


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

示例1: smear

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def smear(self, sw):
        _logger.debug('smearing the beam by {:.2e} m'.format(sw))
        self.equidist()
        sn = (sw / self.ds).astype(int)
        if sn < 2:
            return
        if not sn % 2:
            sn += 1

        for attr in self.params():
            if attr is 's':
                continue
            val = getattr(self, attr)
            val = savgol_filter(val, sn, 2, mode='nearest')

            if attr in ['E', 'I', 'beta_x', 'beta_y', 'emit_x', 'emit_y', 'sigma_E']:
                # print('attribute {:s} < 0, setting to 0'.format(attr))
                val[val < 0] = 0
            #    val = convolve(val,spike,mode='same')
            setattr(self, attr, val) 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:22,代码来源:beam.py

示例2: CAE_dataset_feed_dict

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def CAE_dataset_feed_dict(prefix,np_path_box,dataset_name):
    path_box_list=np.load(np_path_box)
    (image_height, image_width) = image_size_map[dataset_name]
    former_paths,gray_paths,back_paths,boxes,class_indexes=split_path_boxes(prefix,path_box_list,dataset_name,image_height,image_width)

    f_imgs=[]
    g_imgs=[]
    b_imgs=[]
    for f_path,g_path,b_path,box in zip(former_paths,gray_paths,back_paths,boxes):
        f_imgs.append(box_image_crop(f_path,box))
        g_imgs.append(box_image_crop(g_path,box))
        b_imgs.append(box_image_crop(b_path,box))

    return f_imgs,g_imgs,b_imgs,class_indexes

# def score_smoothing(score):
#     score_len=score.shape[0]//9
#     if score_len%2==0:
#         score_len+=1
#     score=savgol_filter(score,score_len,3)
#
#     return score
# 
开发者ID:fjchange,项目名称:object_centric_VAD,代码行数:25,代码来源:util.py

示例3: find_angle_graph

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def find_angle_graph(velocity, vertical_velocity, interp=False):
    angle = []

    for i in range(len(velocity)):
        if velocity[i] == 0:
            angle.append(angle[-1])
        else:
            ratio = max(-1, min(vertical_velocity[i] / velocity[i], 1))
            angle.append(asin(ratio))

    angle = savgol_filter(angle, 5, 1)

    if interp:
        angle = savgol_filter(angle, 11, 1)
        return ss.medfilt(angle, kernel_size=7)

    return angle 
开发者ID:shahar603,项目名称:SpaceXtract,代码行数:19,代码来源:analyse_raw_telemetry.py

示例4: find_peak_vextors_eagerly

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def find_peak_vextors_eagerly(price, offest=0):
    """
    (饥渴的)在 MACD 上坡的时候查找更多的极值点
    """
    xn = price

    # pass 0
    window_size, poly_order = 5, 1
    yy_sg = savgol_filter(xn, window_size, poly_order)

    # pass 1
    x_tp_min, x_tp_max = signal.argrelextrema(yy_sg, np.less)[0], signal.argrelextrema(yy_sg, np.greater)[0]
    n = int(len(price) / (len(x_tp_min) + len(x_tp_max))) * 2

    # peakutils 似乎一根筋只能查最大极值,通过曲线反相的方式查找极小点
    mirrors = (yy_sg * -1) + np.mean(price) * 2

    # pass 2 使用 peakutils 查找
    x_tp_max = peakutils.indexes(yy_sg, thres=0.01 / max(price), min_dist=n)
    x_tp_min = peakutils.indexes(mirrors, thres=0.01 / max(price), min_dist=n)

    return x_tp_min + offest, x_tp_max + offest 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:24,代码来源:QAAnalysis_signal.py

示例5: test_sg_filter_trivial

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def test_sg_filter_trivial():
    """ Test some trivial edge cases for savgol_filter()."""
    x = np.array([1.0])
    y = savgol_filter(x, 1, 0)
    assert_equal(y, [1.0])

    # Input is a single value.  With a window length of 3 and polyorder 1,
    # the value in y is from the straight-line fit of (-1,0), (0,3) and
    # (1, 0) at 0. This is just the average of the three values, hence 1.0.
    x = np.array([3.0])
    y = savgol_filter(x, 3, 1, mode='constant')
    assert_almost_equal(y, [1.0], decimal=15)

    x = np.array([3.0])
    y = savgol_filter(x, 3, 1, mode='nearest')
    assert_almost_equal(y, [3.0], decimal=15)

    x = np.array([1.0] * 3)
    y = savgol_filter(x, 3, 1, mode='wrap')
    assert_almost_equal(y, [1.0, 1.0, 1.0], decimal=15) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:22,代码来源:test_savitzky_golay.py

示例6: get_dVdI

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def get_dVdI(self):
        """
        Gets the internal dVdI parameter, to decide weather the differential resistance (dV/dI) is calculated or not.
        
        Parameters
        ----------
        None
        
        Returns
        -------
        status: bool
            Status if numerical derivative is calculated.
        func: function
            Function to calculate numerical derivative, e.g. scipy.signal.savgol_filter (default), numpy.gradient, ...
        *args: array_likes
            Arguments for derivation function.
        **kwargs: dictionary_likes
            Keyword arguments for derivation function.
        """
        return self._dVdI, self._numder_func, self._numder_args, self._numder_kwargs 
开发者ID:qkitgroup,项目名称:qkit,代码行数:22,代码来源:transport.py

示例7: plot_epoch_y_curves_correlation

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def plot_epoch_y_curves_correlation(metric_dict, title, xlabel, ylabel, foldername, x_log, y_log, smoothing=False,
                                    filename=None, max_iter=None):
    plt.figure()
    for config, values in metric_dict.items():
        if smoothing:
            values = [savgol_filter(value, 11, 3) for value in values]

        plt.plot(np.arange(len(values)), values, label=config)
    ax = plt.gca()
    if x_log:
        ax.set_xscale('log')
    if y_log:
        ax.set_yscale('log')
    plt.title(title)
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.legend()

    plt.grid(True, which="both", ls="-", alpha=0.5)
    plt.tight_layout()
    folder_path = os.path.join(os.getcwd(), foldername)
    os.makedirs(folder_path, exist_ok=True)
    filepath = os.path.join(folder_path, '{}.pdf'.format(filename)),
    plt.savefig(filepath[0])
    plt.close() 
开发者ID:automl,项目名称:nasbench-1shot1,代码行数:27,代码来源:plot_results.py

示例8: transform

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def transform(self,X):
        """Detrend each column of X

        Parameters
        ----------
        X : DataFrame in `traces` structure [n_samples, n_traces]

        Returns
        -------
        Xt : DataFrame in `traces` structure [n_samples, n_traces]
            The detrended data.
        """
        self.fit_params = {}
        X_new = X.copy()
        for col in X.columns:
            tmp_data = X[col].values.astype(np.double)
            sgf = savgol_filter(tmp_data, self.window, self.order)
            self.fit_params[col] = dict(sgf=sgf)
            X_new[col] = tmp_data - sgf

        return X_new 
开发者ID:AllenInstitute,项目名称:neuroglia,代码行数:23,代码来源:calcium.py

示例9: getdata

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def getdata(name):
    all_results = []

    for i in range(0, 50):
        f = open(name + str(i) + ".csv", "r")
        results = []
        time = []

        for line in f:
            step, reward = (line.replace("\n", "")).split(",")
            results.append(float(reward))
            time.append(float(step))
        results = signal.savgol_filter(results, 7, 3, axis=-1)
        all_results.append(results)

    return all_results, time


# Load the data. 
开发者ID:ashedwards,项目名称:ILPO,代码行数:21,代码来源:plot_acrobot.py

示例10: _h_smooth_curve

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def _h_smooth_curve(curve, window=5, pol_degree=3):
    '''smooth curves using the savgol_filter'''

    if curve.shape[0] < window:
        # nothing to do here return an empty array
        return np.full_like(curve, np.nan)

    # consider the case of one (widths) or two dimensions (skeletons, contours)
    if curve.ndim == 1:
        smoothed_curve = savgol_filter(curve, window, pol_degree)
    else:
        smoothed_curve = np.zeros_like(curve)
        for nn in range(curve.ndim):
            smoothed_curve[:, nn] = savgol_filter(
                curve[:, nn], window, pol_degree)

    return smoothed_curve 
开发者ID:ver228,项目名称:tierpsy-tracker,代码行数:19,代码来源:smooth.py

示例11: smoothSkeletons

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def smoothSkeletons(
        skeleton,
        length_resampling=131,
        smooth_win=11,
        pol_degree=3):
    xx = savgol_filter(skeleton[:, 0], smooth_win, pol_degree)
    yy = savgol_filter(skeleton[:, 1], smooth_win, pol_degree)

    ii = np.arange(xx.size)
    ii_new = np.linspace(0, xx.size - 1, length_resampling)

    fx = interp1d(ii, xx)
    fy = interp1d(ii, yy)

    xx_new = fx(ii_new)
    yy_new = fy(ii_new)

    skel_new = np.vstack((xx_new, yy_new)).T
    return skel_new 
开发者ID:ver228,项目名称:tierpsy-tracker,代码行数:21,代码来源:getIntensityProfile.py

示例12: plot_log

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def plot_log(x, y, save_name, key):
	fig = plt.figure()
	plt.title(key)
	plt.xlabel("iter")
	plt.ylabel(key)
	if key in ["loss"]:
		plt.axis([x[0], x[-1], 0, 2.5])
	if key in ["loss_rpn_bbox_fpn2", "loss_rpn_bbox_fpn3", "loss_rpn_bbox_fpn4", "loss_rpn_bbox_fpn5", "loss_rpn_bbox_fpn6"]:
		plt.axis([x[0], x[-1], 0, 0.01])
	if key in ["loss_rpn_cls_fpn2", "loss_rpn_cls_fpn3", "loss_rpn_cls_fpn4", "loss_rpn_cls_fpn5", "loss_rpn_cls_fpn6"]:
		plt.axis([x[0], x[-1], 0, 0.02])
	if key in ["loss_char_bbox"]:
		plt.axis([x[0], x[-1], 0, 0.05])
	if key in ["loss_global_mask", "loss_char_mask"]:
		plt.axis([x[0], x[-1], 0, 0.4])
	if key in ["accuracy_cls"]:
		plt.axis([x[0], x[-1], 0.9, 1])
	if key in ["loss_char_bbox"]:
		plt.axis([x[0], x[-1], 0, 0.01])
	plt.plot(x, y, 'r-', lw=2)
	plt.plot(x, smooth(y, 20), 'g-', lw=2)
	# plt.plot(x, savgol_filter(y, 51, 3), 'g-', lw=2)

	fig.savefig(save_name) 
开发者ID:lvpengyuan,项目名称:masktextspotter.caffe2,代码行数:26,代码来源:vis_log.py

示例13: smooth_filter

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def smooth_filter(kpts):
    if len(kpt_queue) < 6:
        kpt_queue.append(kpts)
        return kpts

    queue_length = len(kpt_queue)
    if queue_length == 20:
        kpt_queue.pop(0)
    kpt_queue.append(kpts)

    # transpose to shape (17, 2, num, 50) 关节点、横纵坐标、每帧人数、帧数
    transKpts = np.array(kpt_queue).transpose(1,2,3,0)

    window_length = queue_length - 1 if queue_length % 2 == 0 else queue_length - 2
    # array, window_length越大越好, polyorder
    result = savgol_filter(transKpts, window_length, 3).transpose(3, 0, 1, 2) #shape(frame_num, human_num, 17, 2)

    # return the 2rd last frame
    return result[-2]


##### load model 
开发者ID:lxy5513,项目名称:hrnet,代码行数:24,代码来源:smooth_sg.py

示例14: generateRegressionMap

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def generateRegressionMap(self):
        """Uses the fast marching method to generate an image of how the grain regresses from the core map. The map
        is stored under self.regressionMap."""
        masked = np.ma.MaskedArray(self.coreMap, self.mask)
        cellSize = 1 / self.mapDim
        self.regressionMap = skfmm.distance(masked, dx=cellSize) * 2
        maxDist = np.amax(self.regressionMap)
        self.wallWeb = self.unNormalize(maxDist)
        faceArea = []
        polled = []
        valid = np.logical_not(self.mask)
        for i in range(int(maxDist * self.mapDim) + 2):
            polled.append(i / self.mapDim)
            faceArea.append(self.mapToArea(np.count_nonzero(np.logical_and(self.regressionMap > (i / self.mapDim), valid))))
        self.faceArea = savgol_filter(faceArea, 31, 5)
        self.faceAreaFunc = interpolate.interp1d(polled, self.faceArea) 
开发者ID:reilleya,项目名称:openMotor,代码行数:18,代码来源:grain.py

示例15: smooth_filter

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import savgol_filter [as 别名]
def smooth_filter(kpts):
    if len(kpt_queue) < 6:
        kpt_queue.append(kpts)
        return kpts

    queue_length = len(kpt_queue)
    if queue_length == 50:
        kpt_queue.pop(0)
    kpt_queue.append(kpts)

    # transpose to shape (17, 2, num, 50) 关节点、横纵坐标、每帧人数、帧数
    transKpts = np.array(kpt_queue).transpose(1, 2, 3, 0)

    window_length = queue_length - 1 if queue_length % 2 == 0 else queue_length - 2
    # array, window_length越大越好, polyorder 
    result = savgol_filter(transKpts, window_length, 3).transpose(3, 0, 1, 2)  # shape(frame_num, human_num, 17, 2)

    # 返回倒数第几帧
    return result[-3]


##### load model 
开发者ID:zh-plus,项目名称:video-to-pose3D,代码行数:24,代码来源:SGfilter.py


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