import json


def set_t_frame(infile, ins, sub, ta=False):
    """ Assign the appropriate frame time based on the ins
    and subarray. For now, modes are implied.

    Parameters
    ----------
    infile: str
        The path to the data file.
    ins : str
        The instrument : 'miri', 'niriss', 'nirspec', or 
        'nircam'.
    sub : str
        The subarray -- too lazy to write out the options 
        here.
    ta : bool   
        Whether this is for TA or not.

    Returns
    -------
    t_frame : float
        The frame time for this ins/sub combo.
    """
    
    # Read in dict with frame times
    with open(infile) as f:
        frame_time = json.load(f)['frame_time']
    
    if ta:
        t_frame = frame_time[ins]['ta'][sub]
    else:
        t_frame = frame_time[ins][sub]

    return t_frame