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


Python convolution.convolve方法代码示例

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


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

示例1: setup_method

# 需要导入模块: from astropy import convolution [as 别名]
# 或者: from astropy.convolution import convolve [as 别名]
def setup_method(self, method):
        np.random.seed(1000)  # so we always get the same images.

        self.min_, self.stretch_, self.Q = 0, 5, 20  # asinh

        width, height = 85, 75
        self.width = width
        self.height = height

        shape = (width, height)
        image_r = np.zeros(shape)
        image_g = np.zeros(shape)
        image_b = np.zeros(shape)

        # pixel locations, values and colors
        points = [[15, 15], [50, 45], [30, 30], [45, 15]]
        values = [1000, 5500, 600, 20000]
        g_r = [1.0, -1.0, 1.0, 1.0]
        r_i = [2.0, -0.5, 2.5, 1.0]

        # Put pixels in the images.
        for p, v, gr, ri in zip(points, values, g_r, r_i):
            image_r[p[0], p[1]] = v*pow(10, 0.4*ri)
            image_g[p[0], p[1]] = v*pow(10, 0.4*gr)
            image_b[p[0], p[1]] = v

        # convolve the image with a reasonable PSF, and add Gaussian background noise
        def convolve_with_noise(image, psf):
            convolvedImage = convolve(image, psf, boundary='extend', normalize_kernel=True)
            randomImage = np.random.normal(0, 2, image.shape)
            return randomImage + convolvedImage

        psf = Gaussian2DKernel(2.5)
        self.image_r = convolve_with_noise(image_r, psf)
        self.image_g = convolve_with_noise(image_g, psf)
        self.image_b = convolve_with_noise(image_b, psf) 
开发者ID:holzschu,项目名称:Carnets,代码行数:38,代码来源:test_lupton_rgb.py

示例2: smooth

# 需要导入模块: from astropy import convolution [as 别名]
# 或者: from astropy.convolution import convolve [as 别名]
def smooth(y, box_pts, window='flat'):
  # https://scipy-cookbook.readthedocs.io/items/SignalSmooth.html
  if window is 'flat':
    box = np.ones(box_pts)
  elif window is 'blackman':
    box =  np.blackman(box_pts)
  else:
    raise ValueError('unknown window')
  box /= np.sum(box)
  y_smooth = astroconv.convolve(y, box, boundary='extend') # also: None, fill, wrap, extend
  return y_smooth 
开发者ID:calico,项目名称:basenji,代码行数:13,代码来源:basenji_data_hic_read.py

示例3: smooth_magseries_gaussfilt

# 需要导入模块: from astropy import convolution [as 别名]
# 或者: from astropy.convolution import convolve [as 别名]
def smooth_magseries_gaussfilt(mags, windowsize, windowfwhm=7):
    '''This smooths the magseries with a Gaussian kernel.

    Parameters
    ----------

    mags : np.array
        The input mags/flux time-series to smooth.

    windowsize : int
        This is a odd integer containing the smoothing window size.

    windowfwhm : int
        This is an odd integer containing the FWHM of the applied Gaussian
        window function.

    Returns
    -------

    np.array
        The smoothed mag/flux time-series array.

    '''

    convkernel = Gaussian1DKernel(windowfwhm, x_size=windowsize)
    smoothed = convolve(mags, convkernel, boundary='extend')
    return smoothed 
开发者ID:waqasbhatti,项目名称:astrobase,代码行数:29,代码来源:trends.py

示例4: _smooth_acf

# 需要导入模块: from astropy import convolution [as 别名]
# 或者: from astropy.convolution import convolve [as 别名]
def _smooth_acf(acf, windowfwhm=7, windowsize=21):
    '''This returns a smoothed version of the ACF.

    Convolves the ACF with a Gaussian of given `windowsize` and `windowfwhm`.

    Parameters
    ----------

    acf : np.array
        The auto-correlation function array to smooth.

    windowfwhm : int
        The smoothing window Gaussian kernel's FWHM .

    windowsize : int
        The number of input points to apply the smoothing over.

    Returns
    -------

    np.array
        Smoothed version of the input ACF array.

    '''

    convkernel = Gaussian1DKernel(windowfwhm, x_size=windowsize)
    smoothed = convolve(acf, convkernel, boundary='extend')

    return smoothed 
开发者ID:waqasbhatti,项目名称:astrobase,代码行数:31,代码来源:macf.py

示例5: smooth

# 需要导入模块: from astropy import convolution [as 别名]
# 或者: from astropy.convolution import convolve [as 别名]
def smooth(y, box_pts):
    try:
        from astropy.convolution import convolve
    except ImportError:
        raise ImportError("The astropy module is required to use this function")
    box = np.ones(box_pts) / box_pts
    # also: None, fill, wrap, extend
    y_smooth = convolve(y, box, boundary="extend")
    return y_smooth 
开发者ID:mirnylab,项目名称:cooltools,代码行数:11,代码来源:numutils.py

示例6: image_std

# 需要导入模块: from astropy import convolution [as 别名]
# 或者: from astropy.convolution import convolve [as 别名]
def image_std(image, radius):
    """
    Calculates the standard deviation of an image, using a moving window of 
    specified radius. Uses astropy's convolution library'
    
    Arguments:
    -----------
    image: np.array
        2D array containing the pixel intensities of a single-band image
    radius: int
        radius defining the moving window used to calculate the standard deviation. 
        For example, radius = 1 will produce a 3x3 moving window.
        
    Returns:    
    -----------
    win_std: np.array
        2D array containing the standard deviation of the image
        
    """  
    
    # convert to float
    image = image.astype(float)
    # first pad the image
    image_padded = np.pad(image, radius, 'reflect')
    # window size
    win_rows, win_cols = radius*2 + 1, radius*2 + 1
    # calculate std with uniform filters
    win_mean = convolve(image_padded, np.ones((win_rows,win_cols)), boundary='extend',
                        normalize_kernel=True, nan_treatment='interpolate', preserve_nan=True)
    win_sqr_mean = convolve(image_padded**2, np.ones((win_rows,win_cols)), boundary='extend',
                        normalize_kernel=True, nan_treatment='interpolate', preserve_nan=True)
    win_var = win_sqr_mean - win_mean**2
    win_std = np.sqrt(win_var)
    # remove padding
    win_std = win_std[radius:-radius, radius:-radius]

    return win_std 
开发者ID:kvos,项目名称:CoastSat,代码行数:39,代码来源:SDS_tools.py


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