def create_filename(time, ext, tag=None, number=None):
    """Create a file name based upon an input time, a given tag and extension.

    Args:
        time: A time string
        tag: A tag string
        ext: The extension to be used for the constructed filename
        number: A number (possibly None) to differentiate identical filenames

    Returns:
        The constructed filename.
    """
    tag_text = "" if tag==None else "_" + tag
    if number == None:
        new_filename = time + tag_text + "." + ext
    else:
        new_filename = time + "_" + str(number) + tag_text + "." + ext
    return new_filename