code: def aap_to_bp (ant1, ant2, pol):
      
  
      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
docs: Create a basepol from antenna numbers and a CASA polarization code.