def process(tr, lowcut, highcut, filt_order, samp_rate, debug,<EOL>starttime=False, clip=False, length=<NUM_LIT>,<EOL>seisan_chan_names=False, ignore_length=False, fill_gaps=True):
<EOL>if highcut and highcut >= <NUM_LIT:0.5> * samp_rate:<EOL><INDENT>raise IOError('<STR_LIT>')<EOL><DEDENT>if starttime:<EOL><INDENT>if isinstance(starttime, dt.date) or isinstance(starttime,<EOL>dt.datetime):<EOL><INDENT>starttime = UTCDateTime(starttime)<EOL><DEDENT>day = starttime.date<EOL><DEDENT>else:<EOL><INDENT>day = tr.stats.starttime.date<EOL><DEDENT>debug_print(<EOL>'<STR_LIT>' + tr.stats.station + '<STR_LIT:.>' + tr.stats.channel, <NUM_LIT:2>, debug)<EOL>if debug >= <NUM_LIT:5>:<EOL><INDENT>tr.plot()<EOL><DEDENT>gappy = False<EOL>if isinstance(tr.data, np.ma.MaskedArray):<EOL><INDENT>gappy = True<EOL>gaps, tr = _fill_gaps(tr)<EOL><DEDENT>qual = _check_daylong(tr)<EOL>if not qual:<EOL><INDENT>msg = ("<STR_LIT>",<EOL>"<STR_LIT>" + tr.stats.station + "<STR_LIT:.>" +<EOL>tr.stats.channel)<EOL>raise ValueError(msg)<EOL><DEDENT>tr = tr.detrend('<STR_LIT>')<EOL>debug_print('<STR_LIT>' + str(len(tr.data)) + '<STR_LIT>' +<EOL>tr.stats.station + '<STR_LIT:.>' + tr.stats.channel +<EOL>'<STR_LIT>', <NUM_LIT:0>, debug)<EOL>padded = False<EOL>if clip:<EOL><INDENT>tr = tr.trim(starttime, starttime + length, nearest_sample=True)<EOL><DEDENT>if float(tr.stats.npts / tr.stats.sampling_rate) != length and clip:<EOL><INDENT>debug_print('<STR_LIT>' + tr.stats.station + '<STR_LIT:.>' + tr.stats.channel +<EOL>'<STR_LIT>', <NUM_LIT:2>, debug)<EOL>if tr.stats.endtime - tr.stats.starttime < <NUM_LIT> * lengthand not ignore_length:<EOL><INDENT>raise NotImplementedError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(<EOL>tr.stats.station, tr.stats.channel,<EOL>tr.stats.endtime - tr.stats.starttime, length))<EOL><DEDENT>pre_pad_secs = tr.stats.starttime - starttime<EOL>post_pad_secs = (starttime + length) - tr.stats.endtime<EOL>if pre_pad_secs > <NUM_LIT:0> or post_pad_secs > <NUM_LIT:0>:<EOL><INDENT>padded = True<EOL>pre_pad = np.zeros(int(pre_pad_secs * tr.stats.sampling_rate))<EOL>post_pad = np.zeros(int(post_pad_secs * tr.stats.sampling_rate))<EOL>debug_print(str(tr), <NUM_LIT:2>, debug)<EOL>debug_print(<EOL>"<STR_LIT>" %<EOL>(pre_pad_secs, post_pad_secs), <NUM_LIT:1>, debug)<EOL>tr.data = np.concatenate([pre_pad, tr.data, post_pad])<EOL>tr.stats.starttime -= len(pre_pad) * tr.stats.delta<EOL>debug_print(str(tr), <NUM_LIT:2>, debug)<EOL><DEDENT>if len(tr.data) == (length * tr.stats.sampling_rate) + <NUM_LIT:1>:<EOL><INDENT>tr.data = tr.data[<NUM_LIT:1>:len(tr.data)]<EOL><DEDENT>if not tr.stats.sampling_rate * length == tr.stats.npts:<EOL><INDENT>raise ValueError('<STR_LIT>' +<EOL>tr.stats.station + '<STR_LIT:.>' + tr.stats.channel)<EOL><DEDENT>debug_print('<STR_LIT>'<EOL>% len(tr.data), <NUM_LIT:0>, debug)<EOL><DEDENT>if tr.stats.sampling_rate != samp_rate:<EOL><INDENT>debug_print('<STR_LIT>', <NUM_LIT:1>, debug)<EOL>tr.resample(samp_rate)<EOL><DEDENT>tr = tr.detrend('<STR_LIT>')    <EOL>if highcut and lowcut:<EOL><INDENT>debug_print('<STR_LIT>', <NUM_LIT:1>, debug)<EOL>tr.data = bandpass(tr.data, lowcut, highcut,<EOL>tr.stats.sampling_rate, filt_order, True)<EOL><DEDENT>elif highcut:<EOL><INDENT>debug_print('<STR_LIT>', <NUM_LIT:1>, debug)<EOL>tr.data = lowpass(tr.data, highcut, tr.stats.sampling_rate,<EOL>filt_order, True)<EOL><DEDENT>elif lowcut:<EOL><INDENT>debug_print('<STR_LIT>', <NUM_LIT:1>, debug)<EOL>tr.data = highpass(tr.data, lowcut, tr.stats.sampling_rate,<EOL>filt_order, True)<EOL><DEDENT>else:<EOL><INDENT>debug_print('<STR_LIT>', <NUM_LIT:2>, debug)<EOL><DEDENT>if seisan_chan_names:<EOL><INDENT>tr.stats.channel = tr.stats.channel[<NUM_LIT:0>] + tr.stats.channel[-<NUM_LIT:1>]<EOL><DEDENT>if tr.stats.starttime.day != day and clip:<EOL><INDENT>debug_print("<STR_LIT>".format(<EOL>tr.stats.starttime), <NUM_LIT:2>, debug)<EOL><DEDENT>if padded:<EOL><INDENT>debug_print("<STR_LIT>", <NUM_LIT:1>, debug)<EOL>debug_print(str(tr), <NUM_LIT:2>, debug)<EOL>pre_pad = np.zeros(int(pre_pad_secs * tr.stats.sampling_rate))<EOL>post_pad = np.zeros(int(post_pad_secs * tr.stats.sampling_rate))<EOL>pre_pad_len = len(pre_pad)<EOL>post_pad_len = len(post_pad)<EOL>debug_print("<STR_LIT>" %<EOL>(pre_pad_len, len(tr.data) - post_pad_len), <NUM_LIT:1>, debug)<EOL>tr.data = np.concatenate(<EOL>[pre_pad, tr.data[pre_pad_len: len(tr.data) - post_pad_len],<EOL>post_pad])<EOL>debug_print(str(tr), <NUM_LIT:2>, debug)<EOL><DEDENT>if float(tr.stats.npts / tr.stats.sampling_rate) != length and clip:<EOL><INDENT>debug_print('<STR_LIT>' + tr.stats.station + '<STR_LIT:.>' + tr.stats.channel +<EOL>'<STR_LIT>', <NUM_LIT:1>, debug)<EOL>tr = tr.trim(starttime, starttime + length, pad=True, fill_value=<NUM_LIT:0>,<EOL>nearest_sample=True)<EOL>if len(tr.data) == (length * tr.stats.sampling_rate) + <NUM_LIT:1>:<EOL><INDENT>tr.data = tr.data[<NUM_LIT:1>:len(tr.data)]<EOL><DEDENT>if not tr.stats.sampling_rate * length == tr.stats.npts:<EOL><INDENT>raise ValueError('<STR_LIT>' +<EOL>tr.stats.station + '<STR_LIT:.>' + tr.stats.channel)<EOL><DEDENT><DEDENT>if gappy:<EOL><INDENT>tr = _zero_pad_gaps(tr, gaps, fill_gaps=fill_gaps)<EOL><DEDENT>if debug > <NUM_LIT:4>:<EOL><INDENT>tr.plot()<EOL><DEDENT>return tr<EOL>
Basic function to process data, usually called by dayproc or shortproc.

Functionally, this will bandpass, downsample and check headers and length
of trace to ensure files start when they should and are the correct length.
This is a simple wrapper on obspy functions, we include it here to provide
a system to ensure all parts of the dataset are processed in the same way.

.. note:: Usually this function is called via dayproc or shortproc.

:type tr: obspy.core.trace.Trace
:param tr: Trace to process
:type lowcut: float
:param lowcut: Low cut in Hz, if set to None and highcut is set, will use \
    a lowpass filter.
:type highcut: float
:param highcut: High cut in Hz, if set to None and lowcut is set, will \
    use a highpass filter.
:type filt_order: int
:param filt_order: Number of corners for filter.
:type samp_rate: float
:param samp_rate: Desired sampling rate in Hz.
:type debug: int
:param debug: Debug output level from 0-5, higher numbers = more output.
:type starttime: obspy.core.utcdatetime.UTCDateTime
:param starttime: Desired start of trace
:type clip: bool
:param clip: Whether to expect, and enforce a set length of data or not.
:type length: float
:param length: Use to set a fixed length for data from the given starttime.
:type seisan_chan_names: bool
:param seisan_chan_names:
    Whether channels are named like seisan channels (which are two letters
    rather than SEED convention of three) - defaults to True.
:type ignore_length: bool
:param ignore_length: See warning in dayproc.
:type fill_gaps: bool
:param fill_gaps: Whether to pad any gaps found with zeros or not.

:return: Processed trace.
:type: :class:`obspy.core.stream.Trace`

.. note::
    If your data contain gaps you should *NOT* fill those gaps before
    using the pre-process functions. The pre-process functions will fill
    the gaps internally prior to processing, process the data, then re-fill
    the gaps with zeros to ensure correlations are not incorrectly
    calculated within gaps. If your data have gaps you should pass a merged
    stream without the `fill_value` argument (e.g.: `tr = tr.merge()`).