coastalimagelib/supportfunctions.py
def formatArgusFile(cams, folder, epoch, folder_tag = True, file_ext = '.raw', **kwargs):
    """
    Generates filenames in Argus convention based on the epoch
    time at the start of collection and provided camera tags.
    Also generates the name of the merged file of all cameras
    to save after rectification (although this function doesn't
    need to be used solely prior to a rectification task).

    Args:
        cams (list of strings): camera tag for each camera
        epoch (int): epoch/ UTC time at start of collection,
            MUST be an integer
        folder (string): folder where files are/ will be located.
    Keywork Argument:
        'outFileBase'(str): this defines the output file name base,
            default is input file name without camera info
                - overwrites the automatic argus file naming convention
                - add full file name and file extension
        'folder_tag'(bool): set to 'False' if folders
            should not be included in full file path
    Returns:
        paths (list of strings): string of fullfile names in Argus
            convention for each camera
        outFile (string): out filename of the merged file of all cameras;
            used if going into a rectification task

    Note: day_folder (eg: '304_Oct.31/') should not be included in the
        "folder" string, as it changes depending on the epoch time.
        The day_folder will be generated in this function.

    """

    t = dt.datetime.utcfromtimestamp(int(epoch))

    year_start = dt.datetime(t.year, 1, 1)

    jul_str = str((t - year_start).days + 1).zfill(3)
    day_str = t.strftime("%a")
    mon_str = t.strftime("%b")

    day_folder = os.path.join((jul_str
                              + "_"
                              + mon_str
                              + "."
                              + str(t.day).zfill(2)),
                              "")
    file = (
        str(epoch)
        + "."
        + day_str
        + "."
        + mon_str
        + "."
        + str(t.day).zfill(2)
        + "_"
        + str(t.hour).zfill(2)
        + "_"
        + str(t.minute).zfill(2)
        + "_"
        + str(t.second).zfill(2)
        + ".GMT."
        + str(t.year)
        + ".argus02b."
    )

    if folder_tag:
        paths = [
            os.path.join(folder, cams[i], (day_folder + file + cams[i] + file_ext))
            for i in range(len(cams))
        ]
    else:
        paths = [
            os.path.join((file + cams[i] + file_ext))
            for i in range(len(cams))
        ]

    out_path = kwargs.get("outFileBase", "")
    outFile = (
        out_path
        + str(t.day).zfill(2)
        + "_"
        + str(t.hour).zfill(2)
        + "_"
        + str(t.minute).zfill(2)
        + "_merged.avi"
    )

    return paths, outFile

    Generates filenames in Argus convention based on the epoch
    time at the start of collection and provided camera tags.
    Also generates the name of the merged file of all cameras
    to save after rectification (although this function doesn't
    need to be used solely prior to a rectification task).

    Args:
        cams (list of strings): camera tag for each camera
        epoch (int): epoch/ UTC time at start of collection,
            MUST be an integer
        folder (string): folder where files are/ will be located.
    Keywork Argument:
        'outFileBase'(str): this defines the output file name base,
            default is input file name without camera info
                - overwrites the automatic argus file naming convention
                - add full file name and file extension
        'folder_tag'(bool): set to 'False' if folders
            should not be included in full file path
    Returns:
        paths (list of strings): string of fullfile names in Argus
            convention for each camera
        outFile (string): out filename of the merged file of all cameras;
            used if going into a rectification task

    Note: day_folder (eg: '304_Oct.31/') should not be included in the
        "folder" string, as it changes depending on the epoch time.
        The day_folder will be generated in this function.

    
Generates filenames in Argus convention based on the epoch
time at the start of collection and provided camera tags.
Also generates the name of the merged file of all cameras
to save after rectification (although this function doesn't
need to be used solely prior to a rectification task).
Generates filenames in Argus convention based on the epoch time at the start of collection and provided camera tags . Also generates the name of the merged file of all cameras to save after rectification ( although this function doesn ' t need to be used solely prior to a rectification task ) .
def formatArgusFile(cams, folder, epoch, folder_tag = True, file_ext = '.raw', **kwargs):
    t = dt.datetime.utcfromtimestamp(int(epoch))
    year_start = dt.datetime(t.year, 1, 1)
    jul_str = str((t - year_start).days + 1).zfill(3)
    day_str = t.strftime("%a")
    mon_str = t.strftime("%b")
    day_folder = os.path.join((jul_str
                              + "_"
                              + mon_str
                              + "."
                              + str(t.day).zfill(2)),
                              "")
    file = (
        str(epoch)
        + "."
        + day_str
        + "."
        + mon_str
        + "."
        + str(t.day).zfill(2)
        + "_"
        + str(t.hour).zfill(2)
        + "_"
        + str(t.minute).zfill(2)
        + "_"
        + str(t.second).zfill(2)
        + ".GMT."
        + str(t.year)
        + ".argus02b."
    )
    if folder_tag:
        paths = [
            os.path.join(folder, cams[i], (day_folder + file + cams[i] + file_ext))
            for i in range(len(cams))
        ]
    else:
        paths = [
            os.path.join((file + cams[i] + file_ext))
            for i in range(len(cams))
        ]
    out_path = kwargs.get("outFileBase", "")
    outFile = (
        out_path
        + str(t.day).zfill(2)
        + "_"
        + str(t.hour).zfill(2)
        + "_"
        + str(t.minute).zfill(2)
        + "_merged.avi"
    )
    return paths, outFile
def formatArgusFile ( cams , folder , epoch , folder_tag = True , file_ext = '.raw' , ** kwargs ) : t = dt . datetime . utcfromtimestamp ( int ( epoch ) ) year_start = dt . datetime ( t . year , 1 , 1 ) jul_str = str ( ( t - year_start ) . days + 1 ) . zfill ( 3 ) day_str = t . strftime ( "%a" ) mon_str = t . strftime ( "%b" ) day_folder = os . path . join ( ( jul_str + "_" + mon_str + "." + str ( t . day ) . zfill ( 2 ) ) , "" ) file = ( str ( epoch ) + "." + day_str + "." + mon_str + "." + str ( t . day ) . zfill ( 2 ) + "_" + str ( t . hour ) . zfill ( 2 ) + "_" + str ( t . minute ) . zfill ( 2 ) + "_" + str ( t . second ) . zfill ( 2 ) + ".GMT." + str ( t . year ) + ".argus02b." ) if folder_tag : paths = [ os . path . join ( folder , cams [ i ] , ( day_folder + file + cams [ i ] + file_ext ) ) for i in range ( len ( cams ) ) ] else : paths = [ os . path . join ( ( file + cams [ i ] + file_ext ) ) for i in range ( len ( cams ) ) ] out_path = kwargs . get ( "outFileBase" , "" ) outFile = ( out_path + str ( t . day ) . zfill ( 2 ) + "_" + str ( t . hour ) . zfill ( 2 ) + "_" + str ( t . minute ) . zfill ( 2 ) + "_merged.avi" ) return paths , outFile
Generates filenames in Argus convention based on the epoch
time at the start of collection and provided camera tags.
Generates filenames in Argus convention based on the epoch time at the start of collection and provided camera tags .
"""
    Generates filenames in Argus convention based on the epoch
    time at the start of collection and provided camera tags.
    Also generates the name of the merged file of all cameras
    to save after rectification (although this function doesn't
    need to be used solely prior to a rectification task).

    Args:
        cams (list of strings): camera tag for each camera
        epoch (int): epoch/ UTC time at start of collection,
            MUST be an integer
        folder (string): folder where files are/ will be located.
    Keywork Argument:
        'outFileBase'(str): this defines the output file name base,
            default is input file name without camera info
                - overwrites the automatic argus file naming convention
                - add full file name and file extension
        'folder_tag'(bool): set to 'False' if folders
            should not be included in full file path
    Returns:
        paths (list of strings): string of fullfile names in Argus
            convention for each camera
        outFile (string): out filename of the merged file of all cameras;
            used if going into a rectification task

    Note: day_folder (eg: '304_Oct.31/') should not be included in the
        "folder" string, as it changes depending on the epoch time.
        The day_folder will be generated in this function.

    """
paths (list of strings): string of fullfile names in Argus
convention for each camera
outFile (string): out filename of the merged file of all cameras;
used if going into a rectification task
paths ( list of strings ) : string of fullfile names in Argus convention for each camera outFile ( string ) : out filename of the merged file of all cameras ; used if going into a rectification task
cams
camera tag for each camera
camera tag for each camera
folder
folder where files are/ will be located.
folder where files are / will be located .
epoch
epoch/ UTC time at start of collection,
MUST be an integer
epoch / UTC time at start of collection MUST be an integer
folder_tag
file_ext