def save(sel_filename, version, time, scans, no_sensors, duration, sensors,
    scale_factors=None):
    """Create HAWC2 sel-file

    Parameters
    ----------
    sel_filename : str
        Filename
    version : str
        Version tag
    time : datetime.datetime
        Date and time of creation
    scans : int
        Number of scans/observations/rows
    no_sensors : int
        Number of sensors/channels/columns
    duration : int, float
        Duration of simulation
    sensors : array_like
        List of (name, unit, description)-tuples
    scale_factors : array_like, optional
        Array of scale factors. Only for BINARY format
    """
    lines = []
    linesep = '_' * 120
    lines.append(linesep)
    lines.append('  Version ID : %s' % version)
    lines.append(' ' * 60 + 'Time : %s' % time.strftime('%H:%M:%S'))
    lines.append(' ' * 60 + 'Date : %s' % time.strftime('%d:%m.%Y'))
    lines.append(linesep)
    lines.append('  Result file : %s.dat' % sel_filename[:-4])
    lines.append(linesep)
    lines.append('   Scans    Channels    Time [sec]      Format')
    lines.append('   %8s    %3s       %8.3f       %s' % (scans, no_sensors,
        duration, ('BINARY', 'ASCII')[scale_factors is None]))
    lines.append('')
    lines.append('  Channel   Variable Description               ')
    lines.append('')
    for nr, sensor in enumerate(sensors, 1):
        name, unit, description = sensor
        lines.append('  %4s      %-30s %-10s %s' % (nr, name[:30], unit[:10
            ], description[:512]))
    lines.append(linesep)
    if scale_factors is not None:
        lines.append('Scale factors:')
        for sf in scale_factors:
            lines.append('  %.5E' % sf)
    with open(sel_filename, 'w', encoding='utf-8') as f:
        f.write('\n'.join(lines))
