cosine_taper(npts, p=0.1, freqs=None, flimit=None, halfcosine=True, sactaper=False)[source]

Cosine Taper.

  • npts (int) Number of points of cosine taper.
  • p (float) Decimal percentage of cosine taper (ranging from 0 to 1). Default is 0.1 (10%) which tapers 5% from the beginning and 5% form the end.
  • freqs (NumPy ndarray) Frequencies as, for example, returned by fftfreq
  • flimit (list or tuple of floats) The list or tuple defines the four corner frequencies (f1, f2, f3, f4) of the cosine taper which is one between f2 and f3 and tapers to zero for f1 < f < f2 and f3 < f < f4.
  • halfcosine (bool) If True the taper is a half cosine function. If False it is a quarter cosine function.
  • sactaper (bool) If set to True the cosine taper already tapers at the corner frequency (SAC behavior). By default, the taper has a value of 1.0 at the corner frequencies.
Return type:

float NumPy ndarray


Cosine taper array/vector of length npts.


>>> tap = cosine_taper(100, 1.0)
>>> tap2 = 0.5 * (1 + np.cos(np.linspace(np.pi, 2 * np.pi, 50)))
>>> np.allclose(tap[0:50], tap2)
>>> npts = 100
>>> p = 0.1
>>> tap3 = cosine_taper(npts, p)
>>> (tap3[int(npts*p/2):int(npts*(1-p/2))]==np.ones(int(npts*(1-p)))).all()