<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(self, filename, format='tar'):
 """ Write template. :type filename: str :param filename: Filename to write to, if it already exists it will be opened and appended to, otherwise it will be created. :type format: str :param format: Format to write to, either 'tar' (to retain metadata), or any obspy supported waveform format to just extract the waveform. .. rubric:: Example Template a: 3 channels; lowcut: 2.0 Hz; highcut: 8.0 Hz; sampling rate 100 Hz; filter order: 4; process length: 3600 s Template a: 3 channels; lowcut: 2.0 Hz; highcut: 8.0 Hz; sampling rate 100 Hz; filter order: 4; process length: 3600 s """

        if format == 'tar':
            Tribe(templates=[self]).write(filename=filename)
        else:
            self.st.write(filename, format=format)
        return self