Trace.taper(max_percentage, type='hann', max_length=None, side='both', **kwargs)[source]

Taper the trace.

Optional (and sometimes necessary) options to the tapering function can be provided as kwargs. See respective function definitions in Supported Methods section below.

  • type (str) – Type of taper to use for detrending. Defaults to 'hann'. See the Supported Methods section below for further details.

  • max_percentage (None, float) – Decimal percentage of taper at one end (ranging from 0. to 0.5).

  • max_length (None, float) – Length of taper at one end in seconds.

  • side (str) – Specify if both sides should be tapered (default, “both”) or if only the left half (“left”) or right half (“right”) should be tapered.


To get the same results as the default taper in SAC, use max_percentage=0.05 and leave type as hann.


If both max_percentage and max_length are set to a float, the shorter tape length is used. If both max_percentage and max_length are set to None, the whole trace will be tapered.


This operation is performed in place on the actual data arrays. The raw data is not accessible anymore afterwards. To keep your original data, use copy() to create a copy of your trace object. This also makes an entry with information on the applied processing in stats.processing of this trace.

Supported Methods


Cosine taper, for additional options like taper percentage see: obspy.signal.invsim.cosine_taper().


Modified Bartlett-Hann window. (uses: scipy.signal.windows.barthann())


Bartlett window. (uses: scipy.signal.windows.bartlett())


Blackman window. (uses: scipy.signal.windows.blackman())


Minimum 4-term Blackman-Harris window. (uses: scipy.signal.windows.blackmanharris())


Bohman window. (uses: scipy.signal.windows.bohman())


Boxcar window. (uses: scipy.signal.windows.boxcar())


Dolph-Chebyshev window. (uses: scipy.signal.windows.chebwin())


Flat top window. (uses: scipy.signal.windows.flattop())


Gaussian window with standard-deviation std. (uses: scipy.signal.windows.gaussian())


Generalized Gaussian window. (uses: scipy.signal.windows.general_gaussian())


Hamming window. (uses: scipy.signal.windows.hamming())


Hann window. (uses: scipy.signal.windows.hann())


Kaiser window with shape parameter beta. (uses: scipy.signal.windows.kaiser())


Minimum 4-term Blackman-Harris window according to Nuttall. (uses: scipy.signal.windows.nuttall())


Parzen window. (uses: scipy.signal.windows.parzen())


Slepian window. (uses: scipy.signal.windows.slepian())


Triangular window. (uses: scipy.signal.windows.triang())