<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def aap_to_bp (ant1, ant2, pol):
 """Create a basepol from antenna numbers and a CASA polarization code."""


    if ant1 < 0:
        raise ValueError ('first antenna is below 0: %s' % ant1)
    if ant2 < ant1:
        raise ValueError ('second antenna is below first: %s' % ant2)
    if pol < 1 or pol > 12:
        raise ValueError ('illegal polarization code %s' % pol)

    fps = _pol_to_fpol[pol]
    ap1 = (ant1 << 3) + ((fps >> 4) & 0x07)
    ap2 = (ant2 << 3) + (fps & 0x07)
    return ap1, ap2