code: def write(tsdict, outfile, start=None, end=None, name='gwpy', run=0,
            compression=257, compression_level=6):
      
      # set frame header metadata
      if not start:
          starts = {LIGOTimeGPS(tsdict[key].x0.value) for key in tsdict}
          if len(starts) != 1:
              raise RuntimeError("Cannot write multiple TimeSeries to a single "
                                 "frame with different start times, "
                                 "please write into different frames")
          start = list(starts)[0]
      if not end:
          ends = {tsdict[key].span[1] for key in tsdict}
          if len(ends) != 1:
              raise RuntimeError("Cannot write multiple TimeSeries to a single "
                                 "frame with different end times, "
                                 "please write into different frames")
          end = list(ends)[0]
      duration = end - start
      start = LIGOTimeGPS(start)
      ifos = {ts.channel.ifo for ts in tsdict.values() if
              ts.channel and ts.channel.ifo and
              hasattr(frameCPP, 'DETECTOR_LOCATION_{0}'.format(ts.channel.ifo))}
  
      # create frame
      frame = io_gwf.create_frame(time=start, duration=duration, name=name,
                                  run=run, ifos=ifos)
  
      # append channels
      for i, key in enumerate(tsdict):
          try:
              # pylint: disable=protected-access
              ctype = tsdict[key].channel._ctype or 'proc'
          except AttributeError:
              ctype = 'proc'
          append_to_frame(frame, tsdict[key].crop(start, end),
                          type=ctype, channelid=i)
  
      # write frame to file
      io_gwf.write_frames(outfile, [frame], compression=compression,
                          compression_level=compression_level)
docs: Write data to a GWF file using the frameCPP API