def add_axis_to_dic(dic, adic, n):
    """
    Add an axis dictionary (adic) to a NMRPipe dictionary (dic) as axis n.
    """
    fn = ['FDF2', 'FDF1', 'FDF3', 'FDF4'][n]
    dic[fn + 'SW'] = float(adic['sw'])
    dic[fn + 'OBS'] = float(adic['obs'])
    dic[fn + 'CAR'] = float(adic['car'] / adic['obs'])
    dic[fn + 'LABEL'] = adic['label']
    if adic['complex']:
        dic[fn + 'QUADFLAG'] = 0.0
    else:
        dic[fn + 'QUADFLAG'] = 1.0
    if adic['complex'] and n != 0:
        psize = adic['size'] / 2.0
    else:
        psize = adic['size'] / 1.0
    osize = psize
    if adic['time']:
        dic[fn + 'TDSIZE'] = psize
        dic[fn + 'FTFLAG'] = 0.0
    else:
        dic[fn + 'FTSIZE'] = psize
        dic[fn + 'FTFLAG'] = 1.0
    dic[fn + 'APOD'] = dic[fn + 'TDSIZE']
    if n == 0 or dic['FD2DPHASE'] != 1:
        dic[fn + 'CENTER'] = int(psize / 2.0) + 1.0
    else:
        dic[fn + 'CENTER'] = int(psize / 4.0) + 1
        osize = psize / 2.0
    dic[fn + 'ORIG'] = dic[fn + 'CAR'] * dic[fn + 'OBS'] - dic[fn + 'SW'] * (
        osize - dic[fn + 'CENTER']) / osize
    if n == 0:
        dic['FDSIZE'] = psize
        dic['FDREALSIZE'] = psize
    if n == 1:
        dic['FDSPECNUM'] = float(adic['size'])
        if adic['encoding'] == 'complex':
            dic['FDF1AQSIGN'] = 0
        if adic['encoding'] == 'states':
            dic['FDF1AQSIGN'] = 0
        elif adic['encoding'] == 'states-tppi':
            dic['FDF1AQSIGN'] = 16
    if n == 2:
        if adic['complex']:
            dic['FDF3SIZE'] = psize * 2
        else:
            dic['FDF3SIZE'] = psize
    if n == 3:
        if adic['complex']:
            dic['FDF4SIZE'] = psize * 2
        else:
            dic['FDF3SIZE'] = psize
    return dic
