for ifnum in samplers:
        for sampler,feednum in zip(samplers[ifnum],feeds[ifnum]):

            savefile = AGBT14A_110_2_path+"AGBT14A_110_02_{0}_fd{1}_if{2}_sr{3}-{4}".format(sampler,feednum,ifnum,ref1,ref2)

            # determine_best_off_Ku reveals that there is no need to interpolate the offs;
            # even with a standard median there is no obvious signal
            # (even at the 1% level, no signal!  This is surprising.)
            if sampler in ('A9','A13','C25','C29'):
                off_template,off_template_in = make_off_template.make_off(filename, scanrange=scanrange,
                        #exclude_velo=[-10,70], interp_vrange=[-150,250],
                        interp_polyorder=10, sampler=sampler, return_uninterp=True,
                        feednum=feednum,
                        percentile=50,
                        sourcename=sourcename,
                        savefile=savefile,
                        clobber=True,
                        #debug=True,
                        linefreq=28.9748e9, # needed to get velo right...
                        extension=1, exclude_spectral_ends=10)
            # there is some RFI or weird ringing (recvr related?) from 70-80 km/s, about
            # This section of the data should be flagged out, actually
            # (note that this section was never used: if the MEDIAN shows this, it
            # should be treated as "real off")
            #elif sampler in ('C25','C29'):
            #    off_template,off_template_in = make_off_template.make_off(filename, scanrange=scanrange,
            #            #exclude_velo=[-10,70], interp_vrange=[-150,250],
            #            interp_polyorder=10, sampler=sampler, return_uninterp=True, 
            #            feednum=feednum,
            #            percentile=50,
    for sampler in ['A10', 'A13', 'A14', 'A9', 'B17', 'B18', 'B21', 'B22', 'C25', 'C26',
                    'C29', 'C30', 'D33', 'D34', 'D37', 'D38']:

        ref1,ref2 = refscans = scanrange

        savefile = AGBT12B_221_path+'AGBT12B_221_01_{0}_sr{1}-{2}'.format(sampler,ref1,ref2)

        if sampler in ('A9','A13'):
            off_template,off_template_in = make_off_template.make_off(filepyfits,
                                                                      scanrange=scanrange,
                                                                      obsmode=obsmode,
                                                                      #exclude_velo=[-58,103,158,193],
                                                                      #exclude_velo=[-127,-96,-78,38,62,96,158,193],
                                                                      exclude_velo=[-59,-42,-33,-25,-12,8,62,96,158,193],
                                                                      interp_vrange=[-300,300],
                                                                      interp_polyorder=10,
                                                                      sampler=sampler,
                                                                      return_uninterp=True,
                                                                      percentile=99,
                                                                      savefile=savefile,
                                                                      debug=True,
                                                                      clobber=True,
                                                                      exclude_spectral_ends=10)
                    # previously used median with no exclusion; I think this is much better.
                    # 95% preserves the overall shape very well, but does a far superior job of excluding
                    # lines
                    # -127 to -58 clearly shows some structure at the 50 and 95 level, but maybe not 99
        elif sampler in ('C25','C29'): # h2 13CO
            off_template = make_off_template.make_off(filename,
                                                      scanrange=scanrange,
                                                      obsmode=obsmode,