code: def taper_timeseries(tsdata, tapermethod=None, return_lal=False):
      
      if tapermethod is None:
          raise ValueError("Must specify a tapering method (function was called"
                           "with tapermethod=None)")
      if tapermethod not in taper_map.keys():
          raise ValueError("Unknown tapering method %s, valid methods are %s" % \
                           (tapermethod, ", ".join(taper_map.keys())))
      if tsdata.dtype not in (float32, float64):
          raise TypeError("Strain dtype must be float32 or float64, not "
                      + str(tsdata.dtype))
      taper_func = taper_func_map[tsdata.dtype]
      # make a LAL TimeSeries to pass to the LALSim function
      ts_lal = tsdata.astype(tsdata.dtype).lal()
      if taper_map[tapermethod] is not None:
          taper_func(ts_lal.data, taper_map[tapermethod])
      if return_lal:
          return ts_lal
      else:
          return TimeSeries(ts_lal.data.data[:], delta_t=ts_lal.deltaT,
                            epoch=ts_lal.epoch)
docs: Taper either or both ends of a time series using wrapped
      LALSimulation functions
  
      Parameters
      ----------
      tsdata : TimeSeries
          Series to be tapered, dtype must be either float32 or float64
      tapermethod : string
          Should be one of ('TAPER_NONE', 'TAPER_START', 'TAPER_END',
          'TAPER_STARTEND', 'start', 'end', 'startend') - NB 'TAPER_NONE' will
          not change the series!
      return_lal : Boolean
          If True, return a wrapped LAL time series object, else return a
          PyCBC time series.