def write_filter(arr, fname, norm=False):
    """
    Convert convolution array into SExtractor-readable file.
    """
    file = open(fname, 'w')
    if norm:
        arr /= arr.sum()
        file.write('CONV NONORM\n')
    else:
        file.write('CONV NORM\n')
    for row in arr.astype('str'):
        line = ' '.join(row)
        file.write(line)
        file.write('\n')
    file.close()
