Set select parameter that defines time, spw, and pol solutions to apply.
        time defines the time to find solutions near in mjd.
        freqs defines frequencies to select bandpass solution
        blarr is array of size 2xnbl that gives pairs of antennas in each baseline (a la tpipe.blarr).
        radec (radian tuple) and dist (deg) define optional location of source for filtering solutions.
        spwind is list of indices to be used (e.g., [0,2,4,10])
        pols is from d['pols'] (e.g., ['RR']). single or dual parallel allowed.
        calname not used. here for uniformity with telcal_sol.

def set_selection(self, time, freqs, blarr, calname='', radec=(), dist=1, spwind=[], pols=['XX','YY']):
        """ Set select parameter that defines time, spw, and pol solutions to apply.
        time defines the time to find solutions near in mjd.
        freqs defines frequencies to select bandpass solution
        blarr is array of size 2xnbl that gives pairs of antennas in each baseline (a la tpipe.blarr).
        radec (radian tuple) and dist (deg) define optional location of source for filtering solutions.
        spwind is list of indices to be used (e.g., [0,2,4,10])
        pols is from d['pols'] (e.g., ['RR']). single or dual parallel allowed.
        calname not used. here for uniformity with telcal_sol.
        """

        self.spwind = spwind
        if calname:
            self.logger.warn('calname option not used for casa_sol. Applied based on radec.')

        # define pol index
        if 'X' in ''.join(pols) or 'Y' in ''.join(pols):
            polord = ['XX', 'YY']
        elif 'R' in ''.join(pols) or 'L' in ''.join(pols):
            polord = ['RR', 'LL']
        self.polind = [polord.index(pol) for pol in pols]

        self.ant1ind = [n.where(ant1 == n.unique(blarr))[0][0] for (ant1,ant2) in blarr]
        self.ant2ind = [n.where(ant2 == n.unique(blarr))[0][0] for (ant1,ant2) in blarr]

        # select by smallest time distance for source within some angular region of target
        if radec:
            ra, dec = radec
            calra = n.array(self.radec)[:,0]
            caldec = n.array(self.radec)[:,1]
            fields = n.where( (n.abs(calra - ra) < n.radians(dist)) & (n.abs(caldec - dec) < n.radians(dist)) )[0]
            if len(fields) == 0:
                self.logger.warn('Warning: no close calibrator found. Removing radec restriction.')
                fields = n.unique(self.uniquefield)
        else:
            fields = n.unique(self.uniquefield)

        sel = []
        for field in fields:
            sel += list(n.where(field == self.uniquefield)[0])
        mjddist = n.abs(time - self.uniquemjd[sel])
        closestgain = n.where(mjddist == mjddist.min())[0][0]

        self.logger.info('Using gain solution for field %d at MJD %.5f, separated by %d min ' % (self.uniquefield[n.where(self.uniquemjd == self.uniquemjd[sel][closestgain])], self.uniquemjd[closestgain], mjddist[closestgain]*24*60))
        self.gain = self.gain.take(self.spwind, axis=2).take(self.polind, axis=3)[closestgain]

        if hasattr(self, 'bandpass'):
            bins = [n.where(n.min(n.abs(self.bpfreq-selfreq)) == n.abs(self.bpfreq-selfreq))[0][0] for selfreq in freqs]
            self.bandpass = self.bandpass.take(bins, axis=1).take(self.polind, axis=2)
            self.freqs = freqs
            self.logger.debug('Using bandpass at BP bins (1000 bins per spw): %s', str(bins))