import json


def set_frame_time(infile, instrument, subarray, target_acq_mode=False):
    """Assign the appropriate frame time based on the instrument and
    subarray. For now, modes are implied.

    Parameters
    ----------
    infile: str
        The path to the data file.
    instrument : str
        The instrument : ``miri``, ``niriss``, ``nirspec``, or
        ``nircam``
    subarray : str
        The subarray
    target_acq_mode : bool
        Whether this is for TA or not.

    Returns
    -------
    frame_time : float
        The frame time for this instrument/subarray combo.
    """

    # Read in dict with frame times
    with open(infile) as f:
        frame_time = json.load(f)['frame_time']

    if target_acq_mode:
        frame_time = frame_time[instrument]['ta'][subarray]
    else:
        frame_time = frame_time[instrument][subarray]

    return frame_time