#sp.error[:] = sp.stats((218.5e9,218.65e9))['std']
            sp.specname = name
            # Error is already computed above; this is an old hack
            #sp.error[:] = sp.stats((218e9,218.1e9))['std']
            spectra[name] = sp
            sp.unit = "$T_{A}$ [K]"
        else:
            sp = spectra[name]

        velo = pars[name]['velo'][0]

        sp.plotter.figure = pl.figure(1)
        # extend y limits to make space for annotations
        sp.plotter(errstyle='fill', ypeakscale=1.5)
        #linesel = (lfreq > sp.xarr.as_unit('GHz').min()) & (lfreq < sp.xarr.as_unit('GHz').max())
        frequencies_shifted = [f*(1-velo/ckms) for f in all_lines.values()]
        names, freqs = zip(*[(lines_tex[name],freq)
                             for name,freq in zip(all_lines.keys(),
                                                  frequencies_shifted)
                             if freq > sp.xarr.as_unit('GHz').min()+0.05
                             and freq < sp.xarr.as_unit('GHz').max()-0.05])
        try:
            sp.plotter.line_ids(names, freqs, xval_units='GHz', linewidth=0.5,
                                auto_yloc_fraction=0.85)
        except RuntimeError as ex:
            print ex

        spname = sp.specname.replace(" ","_")
        sp.plotter.savefig(fpath("{0}_{1}.png".format(spname, lh)), bbox_inches='tight', dpi=300)
        sp.plotter.savefig(fpath("{0}_{1}.pdf".format(spname, lh)), bbox_inches='tight', rasterized=True)
            sp.unit = "$T_{A}$ [K]"
        else:
            sp = spectra[name]

        velo = pars[name]['velo'][0]

        sp.plotter.figure = pl.figure(1)
        # extend y limits to make space for annotations
        sp.plotter(errstyle='fill', ypeakscale=1.5)
        #linesel = (lfreq > sp.xarr.as_unit('GHz').min()) & (lfreq < sp.xarr.as_unit('GHz').max())
        frequencies_shifted = [
            f * (1 - velo / ckms) for f in all_lines.values()
        ]
        names, freqs = zip(
            *[(lines_tex[name], freq)
              for name, freq in zip(all_lines.keys(), frequencies_shifted)
              if freq > sp.xarr.as_unit('GHz').min() +
              0.05 and freq < sp.xarr.as_unit('GHz').max() - 0.05])
        try:
            sp.plotter.line_ids(names,
                                freqs,
                                xval_units='GHz',
                                linewidth=0.5,
                                auto_yloc_fraction=0.85)
        except RuntimeError as ex:
            print ex

        spname = sp.specname.replace(" ", "_")
        sp.plotter.savefig(fpath("{0}_{1}.png".format(spname, lh)),
                           bbox_inches='tight',
                           dpi=300)
            #sp.error[:] = sp.stats((218e9,218.1e9))['std']
            spectra[name] = sp
            #sp.unit = "$T_{A}$ [K]"
            sp.unit = "$T_{MB}$ (K)"
        else:
            sp = spectra[name]

        velo = pars[name]['velo'][0]

        sp.plotter.figure = pl.figure(1)
        # extend y limits to make space for annotations
        sp.plotter(errstyle='fill', ypeakscale=1.5)
        #linesel = (lfreq > sp.xarr.as_unit('GHz').min()) & (lfreq < sp.xarr.as_unit('GHz').max())
        frequencies_shifted = [f*(1-velo/ckms) for f in all_lines.values()]
        names, freqs = zip(*[(lines_tex[name],freq)
                             for name,freq in zip(all_lines.keys(),
                                                  frequencies_shifted)
                             if freq > sp.xarr.as_unit('GHz').min()+0.05
                             and freq < sp.xarr.as_unit('GHz').max()-0.05])
        try:
            sp.plotter.line_ids(names, freqs, xval_units='GHz', linewidth=0.5,
                                auto_yloc_fraction=0.85)
        except RuntimeError as ex:
            print ex

        spname = sp.specname.replace(" ","_")
        sp.plotter.savefig(fpath("{0}_{1}.png".format(spname, lh)), bbox_inches='tight', dpi=300)
        sp.plotter.savefig(fpath("{0}_{1}.pdf".format(spname, lh)), bbox_inches='tight', rasterized=True)

        cubes,spectra = velo_overlays(scube, all_lines.keys())
            #sp.error[:] = sp.stats((218e9,218.1e9))['std']
            spectra[name] = sp
            #sp.unit = "$T_{A}$ [K]"
            sp.unit = "$T_{MB}$ (K)"
        else:
            sp = spectra[name]

        velo = pars[name]['velo'][0]

        sp.plotter.figure = pl.figure(1)
        # extend y limits to make space for annotations
        sp.plotter(errstyle='fill', ypeakscale=1.5)
        #linesel = (lfreq > sp.xarr.as_unit('GHz').min()) & (lfreq < sp.xarr.as_unit('GHz').max())
        frequencies_shifted = [f*(1-velo/ckms) for f in all_lines.values()]
        names, freqs = zip(*[(lines_tex[name],freq)
                             for name,freq in zip(all_lines.keys(),
                                                  frequencies_shifted)
                             if freq > sp.xarr.as_unit('GHz').min()+0.05
                             and freq < sp.xarr.as_unit('GHz').max()-0.05])
        try:
            sp.plotter.line_ids(names, freqs, xval_units='GHz', linewidth=0.5,
                                auto_yloc_fraction=0.85)
        except RuntimeError as ex:
            print ex

        spname = sp.specname.replace(" ","_")
        sp.plotter.savefig(fpath("{0}_{1}.png".format(spname, lh)), bbox_inches='tight', dpi=300)
        sp.plotter.savefig(fpath("{0}_{1}.pdf".format(spname, lh)), bbox_inches='tight', rasterized=True)

        cubes,spectra = velo_overlays(scube, all_lines.keys())