def fit_and_save(regname, fignum=1, pfignum=2): pc = do_1comp_region(regname, **regions[regname]) pc.mapplot.figure = pl.figure(fignum) pc.plotter.figure = pl.figure(pfignum) pc.mapplot(estimator=3, cmap=cm) plane = pc.mapplot.plane plane[plane == 0.0] = np.nan temmap = piecewise_rtotem.pwtem(plane.flat).reshape(plane.shape) hdu = fits.PrimaryHDU(data=temmap, header=pc.mapplot.header) hdu.writeto(hpath("{0}_pyspeckit_tmap.fits".format(regname)), clobber=True) pc.mapplot.figure.clf() FF = aplpy.FITSFigure(hdu, figure=pc.mapplot.figure, convention='calabretta') FF.set_tick_labels_format('d.dd', 'd.dd') FF.show_colorscale(cmap=cm, vmin=15, vmax=200, interpolation='nearest') FF.add_colorbar() FF.save(fpath("{0}_pyspeckit_tmap.pdf".format(regname)), dpi=150) #pl.savefig(fpath("{0}_pyspeckit_tmap.pdf".format(regname))) return pc
def fit_and_save(regname, fignum=1, pfignum=2): pc = do_1comp_region(regname, **regions[regname]) pc.mapplot.figure = pl.figure(fignum) pc.plotter.figure = pl.figure(pfignum) pc.mapplot(estimator=3, cmap=cm) plane = pc.mapplot.plane plane[plane == 0.0] = np.nan temmap = piecewise_rtotem.pwtem(plane.flat).reshape(plane.shape) hdu = fits.PrimaryHDU(data=temmap, header=pc.mapplot.header) hdu.writeto(hpath("{0}_pyspeckit_tmap.fits".format(regname)), clobber=True) pc.mapplot.figure.clf() FF = aplpy.FITSFigure(hdu, figure=pc.mapplot.figure, convention='calabretta') FF.set_tick_labels_format('d.dd','d.dd') FF.show_colorscale(cmap=cm, vmin=15, vmax=200, interpolation='nearest') FF.add_colorbar() FF.save(fpath("{0}_pyspeckit_tmap.pdf".format(regname)), dpi=150) #pl.savefig(fpath("{0}_pyspeckit_tmap.pdf".format(regname))) return pc
def multiscale_fit(pcube, centerx, centery, offset_scale=0.3, savedir=None, savepre=None, exclude=(236,323, 539,654, 972,1049, 1180,1238), radii=(2,3,4,5,6,7,8,9), guesses=[0.84,37.9,6.5,0.5,0.8,1.0]): pcube.plotter.figure = pl.figure(1) pcube.plotter.axis = pl.figure(1).gca() pcube.specfit.Registry.add_fitter('h2co_simple', simple_fitter2, 6, multisingle='multi') sp = pcube.get_spectrum(centerx, centery) sp.plotter.figure = pl.figure(1) sp.plotter.axis = pl.figure(1).gca() fitspec(sp, exclude, guesses) sp.specfit.plotresiduals(axis=pcube.plotter.axis, yoffset=-sp.specfit.parinfo[0].value*offset_scale, clear=False, color='#444444', label=False) sp.plotter.axis.set_ylim(-5*sp.specfit.residuals.std() -sp.specfit.parinfo[0].value*offset_scale, pcube.plotter.axis.get_ylim()[1]) sp.plotter.savefig(paths.fpath('{0}/{1}_r0.pdf'.format(savedir, savepre))) r1b = [] er1b = [] sigb = [] esigb = [] r1 = [sp.specfit.parinfo[3].value] er1 = [sp.specfit.parinfo[3].error] sig = [sp.specfit.parinfo[2].value] esig = [sp.specfit.parinfo[2].error] cen = [sp.specfit.parinfo[1].value] ecen = [sp.specfit.parinfo[1].error] mergefig = pl.figure(0) mergefig.clf() splast = sp for ii,radius in enumerate(radii): sp = pcube.get_apspec([centerx, centery, radius], wunit='pixel') sp.plotter(figure=pl.figure(1)) fitspec(sp, exclude, guesses) sp.specfit.plotresiduals(axis=pcube.plotter.axis, yoffset=-sp.specfit.parinfo[0].value*offset_scale, clear=False, color='#444444', label=False) sp.plotter.axis.set_ylim(-5*sp.specfit.residuals.std() -sp.specfit.parinfo[0].value*offset_scale, sp.plotter.axis.get_ylim()[1]) sp.plotter.savefig(paths.fpath('{0}/{1}_r{2}.pdf'.format(savedir, savepre, radius))) r1.append(sp.specfit.parinfo[3].value) er1.append(sp.specfit.parinfo[3].error) sig.append(sp.specfit.parinfo[2].value) esig.append(sp.specfit.parinfo[2].error) cen.append(sp.specfit.parinfo[1].value) ecen.append(sp.specfit.parinfo[1].error) spannulus = sp - splast spannulus.plotter.figure = sp.plotter.figure spannulus.plotter.axis = sp.plotter.axis fitspec(spannulus, exclude, guesses=sp.specfit.parinfo.values) spannulus.specfit.plotresiduals(axis=pcube.plotter.axis, yoffset=-spannulus.specfit.parinfo[0].value*offset_scale, clear=False, color='#444444', label=False) spannulus.plotter.axis.set_ylim(-5*spannulus.specfit.residuals.std() -spannulus.specfit.parinfo[0].value*offset_scale, spannulus.plotter.axis.get_ylim()[1]) spannulus.plotter.savefig(paths.fpath('{0}/{1}_r{2}_annulus.pdf'.format(savedir, savepre, radius))) r1b.append(spannulus.specfit.parinfo[3].value) er1b.append(spannulus.specfit.parinfo[3].error) sigb.append(spannulus.specfit.parinfo[2].value) esigb.append(spannulus.specfit.parinfo[2].error) splast = sp.copy() sp.smooth(4) sp.plotter(figure=mergefig, clear=False, axis=mergefig.gca(), color=pl.cm.spectral(ii/float(len(radii))), label="{0:0.1f}".format(radius*7.2)) sp.plotter.axis.relim() sp.plotter.axis.autoscale() pl.figure(mergefig.number) pl.legend(loc='upper right', fontsize=16) mergefig.savefig(paths.fpath('{0}/{1}_mergefig.pdf'.format(savedir, savepre))) pl.figure(2) pl.clf() ax1 = pl.subplot(2,1,1) ax1.errorbar(np.arange(1,10)*7.2, r1, yerr=er1, linestyle='none', marker='s', color='k') ax1.set_xlim(0.5*7.2,9.5*7.2) #ax1.set_xlabel("Aperture Radius (arcseconds)") ax1.set_ylabel("Ratio $3_{2,1}-2_{2,0} / 3_{0,3} - 2_{0,2}$") ax1.xaxis.set_ticklabels([]) # Remove the bottom label (overlap) tl = ax1.yaxis.get_ticklabels() tl[0].set_visible(False) ax1b = ax1.twinx() # set the y limits to pwtem(the ratio limits) ylim = ax1.get_ylim() # pwtem can't go above 0.6; returns NaN above that if ylim[1] > 0.599999: ylim = (ylim[0], 0.599999) ax1.set_ylim(*ylim) ax1b.set_ylim(*pwtem(ylim)) ax1b.xaxis.set_ticklabels([]) ax1b.set_ylabel('Temperature (K)') ax2 = pl.subplot(2,1,2) pl.subplots_adjust(hspace=0) ax2.errorbar(np.arange(1,10)*7.2, sig, yerr=esig, linestyle='none', marker='s', color='k') ax2.set_xlim(0.5*7.2,9.5*7.2) ax2.set_xlabel("Aperture Radius (arcseconds)") ax2.set_ylabel("$\sigma$ (km s$^{-1}$)") # Steve suggested adding a Mach number label, but this isn't possible: # it would require a 3rd graph, since M ~ sigma/sqrt(T) # ax2b = ax2.twinx() # # set the y limits to the sigma limits # ylim = ax2.get_ylim() # ax2b.set_ylim() # ax2b.xaxis.set_ticklabels([]) # ax2b.set_ylabel('Temperature (K)') pl.savefig(paths.fpath('{0}/{1}_ratio_vs_scale.pdf'.format(savedir, savepre))) ax1.errorbar(np.arange(2,10)*7.2, r1b, yerr=er1b, linestyle='none', marker='s', color='b', zorder=-1, alpha=0.5) ax2.errorbar(np.arange(2,10)*7.2, sigb, yerr=esigb, linestyle='none', marker='s', color='b', zorder=-1, alpha=0.5) pl.savefig(paths.fpath('{0}/{1}_ratio_vs_scale_annuli.pdf'.format(savedir, savepre))) return r1,er1,sig,esig,cen,ecen,r1b,er1b,sigb,esigb
F.add_label(1.60, -0.22, "$v=[{0}, {1}]$ km s$^{{-1}}$".format( vrange[0], vrange[1]), color='w', size=14, zorder=20, horizontalalignment='left') F.save( os.path.join( figurepath, 'big_maps', "big_H2CO_321220_to_303202{0}_bl_{1}to{2}_slabratio.pdf". format(smooth, int(vrange[0]), int(vrange[1])))) tproj = np.copy(proj) tproj[np.isfinite(proj)] = pwtem(proj[np.isfinite(proj)].value) hdu = fits.PrimaryHDU(tproj, projhi.hdu.header) fig.clf() F = aplpy.FITSFigure(hdu, convention='calabretta', figure=fig) #cm = copy.copy(pl.cm.rainbow) cm = copy.copy(pl.cm.RdYlBu_r) cm.set_bad('#888888') #cm.set_bad((0.5,0.5,0.5,0.5)) F.show_colorscale(cmap=cm, vmin=15, vmax=200) F.set_tick_labels_format('d.dd', 'd.dd') peaksn = sn.spectral_slab(*(vrange * u.km / u.s)).max(axis=0) peaksn[(peaksn < 0) | np.isnan(peaksn)] = 0 color = (0.5, ) * 3 # should be same as background #888 nlevs = 50 F.show_contour(peaksn.hdu,
# fashion!) #pv = pvextractor.extract_pv_slice(cube, P, respect_nan=False) pv = pvextractor.extract_pv_slice(cube, P, respect_nan=True) if not os.path.isdir(os.path.dirname(pvfilename)): os.mkdir(os.path.dirname(pvfilename)) print("writing {0}".format(pvfilename)) pv.writeto(pvfilename) bad_cols = np.isnan(np.nanmax(pv.data, axis=0)) nandata = np.isnan(pv.data) pv.data[nandata & ~bad_cols] = 0 ok = ~nandata & ~bad_cols if 'TemperatureFromRatio' in molecule: pv.data[ok] = pwtem(pv.data[ok]) fig1 = pl.figure(1, figsize=figsize) fig1.clf() ax = fig1.gca() mywcs = WCS(pv.header) xext, = mywcs.sub([1]).wcs_pix2world((0,pv.shape[1]), 0) print("xext: ",xext) yext, = mywcs.sub([2]).wcs_pix2world((0,pv.shape[0]), 0) yext /= 1e3 dy = yext[1]-yext[0] dx = xext[1]-xext[0] #F = aplpy.FITSFigure(pv, figure=fig1) #actual_aspect = pv.shape[0]/float(pv.shape[1]) if 'Temperature' in molecule: #F.show_colorscale(cmap=cmap, aspect=0.5/actual_aspect, vmin=vmin, vmax=vmax)
# need to respect it and then manually flag (in a rather unreliable # fashion!) #pv = pvextractor.extract_pv_slice(cube, P, respect_nan=False) pv = pvextractor.extract_pv_slice(cube, P, respect_nan=True) if not os.path.isdir(os.path.dirname(pvfilename)): os.mkdir(os.path.dirname(pvfilename)) pv.writeto(pvfilename) bad_cols = np.isnan(np.nanmax(pv.data, axis=0)) nandata = np.isnan(pv.data) pv.data[nandata & ~bad_cols] = 0 ok = ~nandata & ~bad_cols if 'TemperatureFromRatio' in molecule: pv.data[ok] = pwtem(pv.data[ok]) fig1 = pl.figure(1, figsize=figsize) fig1.clf() ax = fig1.gca() mywcs = WCS(pv.header) xext, = mywcs.sub([1]).wcs_pix2world((0,pv.shape[1]), 0) print "xext: ",xext yext, = mywcs.sub([2]).wcs_pix2world((0,pv.shape[0]), 0) yext /= 1e3 dy = yext[1]-yext[0] dx = xext[1]-xext[0] #F = aplpy.FITSFigure(pv, figure=fig1) #actual_aspect = pv.shape[0]/float(pv.shape[1]) if 'Temperature' in molecule: #F.show_colorscale(cmap=cmap, aspect=0.5/actual_aspect, vmin=vmin, vmax=vmax)
import numpy as np from paths import hpath, apath from spectral_cube import SpectralCube, BooleanArrayMask from ratio_cubes import (ratio303321, eratio303321, noise_flat, mask, ratioOK, ratio303321sm, ratioOKsm, masksm) from masked_cubes import (cube303m,cube321m,cube303msm,cube321msm, cube303,cube321,cube303sm,cube321sm, sncube, sncubesm) from piecewise_rtotem import pwtem tcubedata = np.empty(cube303m.shape) tcubedata[~mask] = np.nan tcubedata[mask] = pwtem(ratio303321[ratioOK]) tcube = SpectralCube(data=tcubedata, wcs=cube303m.wcs, mask=cube303m.mask, meta={'unit':'K'}, header=cube303m.header, ) assert tcube.header['CUNIT3'] == 'km s-1' tcube_direct = tcube # smoothed version tcubedatasm = np.empty(cube303msm.shape) tcubedatasm[~masksm] = np.nan tcubedatasm[masksm] = pwtem(ratio303321sm[ratioOKsm]) tcubesm = SpectralCube(data=tcubedatasm, wcs=cube303msm.wcs, mask=cube303msm.mask, meta={'unit':'K'}, header=cube303msm.header,) assert tcubesm.header['CUNIT3'] == 'km s-1'
from piecewise_rtotem import pwtem from temperature_cubes import tcubesm_direct, tcube_direct tcube_direct.write(hpath('TemperatureCube_PiecewiseFromRatio.fits'), overwrite=True) tcubesm_direct.write(hpath('TemperatureCube_smooth_PiecewiseFromRatio.fits'), overwrite=True) # Do the integrated version for smooth in ('', '_smooth'): top = hpath('APEX_H2CO_321_220{0}_bl_mask_integ.fits'.format(smooth)) bot = hpath('APEX_H2CO_303_202{0}_bl_mask_integ.fits'.format(smooth)) ff = fits.open(top) rr = ff[0].data / fits.getdata(bot) tem = pwtem(rr.ravel()) ff[0].data = tem.reshape(rr.shape) ff.writeto(hpath( 'IntegratedRatioPiecewiseTemperature{0}_303to321.fits'.format(smooth)), clobber=True) # Try the same thing but on the dendrogrammed data. Basically, this is # dendro_temperature but *much* faster for sm, cubeA, cubeB, objects in zip( ( "", "_smooth", ), ( cube303,
from dendrograms import dend, dendsm from piecewise_rtotem import pwtem from temperature_cubes import tcubesm_direct, tcube_direct tcube_direct.write(hpath('TemperatureCube_PiecewiseFromRatio.fits'), overwrite=True) tcubesm_direct.write(hpath('TemperatureCube_smooth_PiecewiseFromRatio.fits'), overwrite=True) # Do the integrated version for smooth in ('', '_smooth'): top = hpath('APEX_H2CO_321_220{0}_bl_mask_integ.fits'.format(smooth)) bot = hpath('APEX_H2CO_303_202{0}_bl_mask_integ.fits'.format(smooth)) ff = fits.open(top) rr = ff[0].data/fits.getdata(bot) tem = pwtem(rr.ravel()) ff[0].data = tem.reshape(rr.shape) ff.writeto(hpath('IntegratedRatioPiecewiseTemperature{0}_303to321.fits'.format(smooth)), clobber=True) # Try the same thing but on the dendrogrammed data. Basically, this is # dendro_temperature but *much* faster for sm,cubeA,cubeB,objects in zip(("","_smooth",), (cube303,cube303sm,), (cube321,cube321sm,), (dend,dendsm,),): # reset data tcubedata = np.empty(cubeA.shape) tcubedata[:] = np.nan
#F.recenter(**small_recen) #F.save(os.path.join(figurepath, ratio.replace(".fits",".pdf"))) F.recenter(**big_recen) F.add_label(1.60, -0.22, "$v=[{0}, {1}]$ km s$^{{-1}}$".format(vrange[0],vrange[1]), color='w', size=14, zorder=20, horizontalalignment='left') F.save(os.path.join(figurepath, 'big_maps', "big_H2CO_321220_to_303202{0}_bl_{1}to{2}_slabratio.pdf" .format(smooth,int(vrange[0]),int(vrange[1])) ) ) tproj = np.copy(proj) tproj[np.isfinite(proj)] = pwtem(proj[np.isfinite(proj)].value) hdu = fits.PrimaryHDU(tproj, projhi.hdu.header) fig.clf() F = aplpy.FITSFigure(hdu, convention='calabretta', figure=fig) #cm = copy.copy(pl.cm.rainbow) cm = copy.copy(pl.cm.RdYlBu_r) cm.set_bad('#888888') #cm.set_bad((0.5,0.5,0.5,0.5)) F.show_colorscale(cmap=cm,vmin=15,vmax=200) F.set_tick_labels_format('d.dd','d.dd') peaksn = sn.spectral_slab(*(vrange*u.km/u.s)).max(axis=0) peaksn[(peaksn<0) | np.isnan(peaksn)] = 0 color = (0.5,)*3 # should be same as background #888
import numpy as np from paths import hpath, apath from spectral_cube import SpectralCube, BooleanArrayMask from ratio_cubes import (ratio303321, eratio303321, noise_flat, mask, ratioOK, ratio303321sm, ratioOKsm, masksm) from masked_cubes import (cube303m, cube321m, cube303msm, cube321msm, cube303, cube321, cube303sm, cube321sm, sncube, sncubesm) from piecewise_rtotem import pwtem tcubedata = np.empty(cube303m.shape) tcubedata[~mask] = np.nan tcubedata[mask] = pwtem(ratio303321[ratioOK]) tcube = SpectralCube( data=tcubedata, wcs=cube303m.wcs, mask=cube303m.mask, meta={'unit': 'K'}, header=cube303m.header, ) assert tcube.header['CUNIT3'] == 'km s-1' tcube_direct = tcube # smoothed version tcubedatasm = np.empty(cube303msm.shape) tcubedatasm[~masksm] = np.nan tcubedatasm[masksm] = pwtem(ratio303321sm[ratioOKsm]) tcubesm = SpectralCube( data=tcubedatasm, wcs=cube303msm.wcs,
def multiscale_fit(pcube, centerx, centery, offset_scale=0.3, savedir=None, savepre=None, exclude=(236, 323, 539, 654, 972, 1049, 1180, 1238), radii=(2, 3, 4, 5, 6, 7, 8, 9), guesses=[0.84, 37.9, 6.5, 0.5, 0.8, 1.0]): pcube.plotter.figure = pl.figure(1) pcube.plotter.axis = pl.figure(1).gca() pcube.specfit.Registry.add_fitter('h2co_simple', simple_fitter2, 6, multisingle='multi') sp = pcube.get_spectrum(centerx, centery) sp.plotter.figure = pl.figure(1) sp.plotter.axis = pl.figure(1).gca() fitspec(sp, exclude, guesses) sp.specfit.plotresiduals(axis=pcube.plotter.axis, yoffset=-sp.specfit.parinfo[0].value * offset_scale, clear=False, color='#444444', label=False) sp.plotter.axis.set_ylim( -5 * sp.specfit.residuals.std() - sp.specfit.parinfo[0].value * offset_scale, pcube.plotter.axis.get_ylim()[1]) sp.plotter.savefig(paths.fpath('{0}/{1}_r0.pdf'.format(savedir, savepre))) r1b = [] er1b = [] sigb = [] esigb = [] r1 = [sp.specfit.parinfo[3].value] er1 = [sp.specfit.parinfo[3].error] sig = [sp.specfit.parinfo[2].value] esig = [sp.specfit.parinfo[2].error] cen = [sp.specfit.parinfo[1].value] ecen = [sp.specfit.parinfo[1].error] mergefig = pl.figure(0) mergefig.clf() splast = sp for ii, radius in enumerate(radii): sp = pcube.get_apspec([centerx, centery, radius], wunit='pixel') sp.plotter(figure=pl.figure(1)) fitspec(sp, exclude, guesses) sp.specfit.plotresiduals(axis=pcube.plotter.axis, yoffset=-sp.specfit.parinfo[0].value * offset_scale, clear=False, color='#444444', label=False) sp.plotter.axis.set_ylim( -5 * sp.specfit.residuals.std() - sp.specfit.parinfo[0].value * offset_scale, sp.plotter.axis.get_ylim()[1]) sp.plotter.savefig( paths.fpath('{0}/{1}_r{2}.pdf'.format(savedir, savepre, radius))) r1.append(sp.specfit.parinfo[3].value) er1.append(sp.specfit.parinfo[3].error) sig.append(sp.specfit.parinfo[2].value) esig.append(sp.specfit.parinfo[2].error) cen.append(sp.specfit.parinfo[1].value) ecen.append(sp.specfit.parinfo[1].error) spannulus = sp - splast spannulus.plotter.figure = sp.plotter.figure spannulus.plotter.axis = sp.plotter.axis fitspec(spannulus, exclude, guesses=sp.specfit.parinfo.values) spannulus.specfit.plotresiduals( axis=pcube.plotter.axis, yoffset=-spannulus.specfit.parinfo[0].value * offset_scale, clear=False, color='#444444', label=False) spannulus.plotter.axis.set_ylim( -5 * spannulus.specfit.residuals.std() - spannulus.specfit.parinfo[0].value * offset_scale, spannulus.plotter.axis.get_ylim()[1]) spannulus.plotter.savefig( paths.fpath('{0}/{1}_r{2}_annulus.pdf'.format( savedir, savepre, radius))) r1b.append(spannulus.specfit.parinfo[3].value) er1b.append(spannulus.specfit.parinfo[3].error) sigb.append(spannulus.specfit.parinfo[2].value) esigb.append(spannulus.specfit.parinfo[2].error) splast = sp.copy() sp.smooth(4) sp.plotter(figure=mergefig, clear=False, axis=mergefig.gca(), color=pl.cm.spectral(ii / float(len(radii))), label="{0:0.1f}".format(radius * 7.2)) sp.plotter.axis.relim() sp.plotter.axis.autoscale() pl.figure(mergefig.number) pl.legend(loc='upper right', fontsize=16) mergefig.savefig( paths.fpath('{0}/{1}_mergefig.pdf'.format(savedir, savepre))) pl.figure(2) pl.clf() ax1 = pl.subplot(2, 1, 1) ax1.errorbar(np.arange(1, 10) * 7.2, r1, yerr=er1, linestyle='none', marker='s', color='k') ax1.set_xlim(0.5 * 7.2, 9.5 * 7.2) #ax1.set_xlabel("Aperture Radius (arcseconds)") ax1.set_ylabel("Ratio $3_{2,1}-2_{2,0} / 3_{0,3} - 2_{0,2}$") ax1.xaxis.set_ticklabels([]) # Remove the bottom label (overlap) tl = ax1.yaxis.get_ticklabels() tl[0].set_visible(False) ax1b = ax1.twinx() # set the y limits to pwtem(the ratio limits) ylim = ax1.get_ylim() # pwtem can't go above 0.6; returns NaN above that if ylim[1] > 0.599999: ylim = (ylim[0], 0.599999) ax1.set_ylim(*ylim) ax1b.set_ylim(*pwtem(ylim)) ax1b.xaxis.set_ticklabels([]) ax1b.set_ylabel('Temperature (K)') ax2 = pl.subplot(2, 1, 2) pl.subplots_adjust(hspace=0) ax2.errorbar(np.arange(1, 10) * 7.2, sig, yerr=esig, linestyle='none', marker='s', color='k') ax2.set_xlim(0.5 * 7.2, 9.5 * 7.2) ax2.set_xlabel("Aperture Radius (arcseconds)") ax2.set_ylabel("$\sigma$ (km s$^{-1}$)") # Steve suggested adding a Mach number label, but this isn't possible: # it would require a 3rd graph, since M ~ sigma/sqrt(T) # ax2b = ax2.twinx() # # set the y limits to the sigma limits # ylim = ax2.get_ylim() # ax2b.set_ylim() # ax2b.xaxis.set_ticklabels([]) # ax2b.set_ylabel('Temperature (K)') pl.savefig( paths.fpath('{0}/{1}_ratio_vs_scale.pdf'.format(savedir, savepre))) ax1.errorbar(np.arange(2, 10) * 7.2, r1b, yerr=er1b, linestyle='none', marker='s', color='b', zorder=-1, alpha=0.5) ax2.errorbar(np.arange(2, 10) * 7.2, sigb, yerr=esigb, linestyle='none', marker='s', color='b', zorder=-1, alpha=0.5) pl.savefig( paths.fpath('{0}/{1}_ratio_vs_scale_annuli.pdf'.format( savedir, savepre))) return r1, er1, sig, esig, cen, ecen, r1b, er1b, sigb, esigb