continue
    print mp.axis_number(ypos[yd], xpos[xd]), xpos[xd], ypos[yd]
    ax = mp.grid[mp.axis_number(ypos[yd], xpos[xd])]
    # ax.plot(data[xd][rrlmask],data[yd][rrlmask],'.')
    mpl_plot_templates.adaptive_param_plot(
        data[xd][rrlmask].to(u.Jy).value,
        data[yd][rrlmask].to(u.Jy).value,
        bins=30,
        threshold=5,
        fill=False,
        alpha=0.8,
        axis=ax,
        cmap=pl.mpl.cm.spectral,
    )
    axlims = ax.axis()
    factor = fit_a_line.total_least_squares(data[xd][rrlmask], data[yd][rrlmask], intercept=False)
    ax.plot(np.linspace(0, 20), factor * np.linspace(0, 20), "k--", linewidth=2, alpha=0.5, label="$y=%0.2fx$" % factor)
    ax.axis(axlims)  # reset plot limits

    ax.legend(loc="best", fontsize=16)

    # tweaks to prevent tick overlaps
    if xpos[xd] > 0:
        ax.set_yticklabels([])
        ax.set_ylabel("")
    else:
        ax.set_ylabel(yd)
    ax.set_xlabel(xd)
    if ypos[yd] > 0:
        ax.set_yticks(ax.get_yticks()[:-1])
        # if ypos[yd] == 2:
示例#2
0
            v = np.array([x.value/1000. for x in leaf_vrms[leaf]])
            pl.plot(r, v, linestyle='-', marker=markers.next(), alpha=0.5, color=color)

trunkslopes = {}
xvals = {}

# filter based on minimum radius in arcsec
min_rad_as = 15
for trunk in trunk_leaves:
    if trunk_leaves[trunk][0] in leaf_stats:
        # size-linewidth -> sigma=0.72 R^0.5
        x = [(j.value*as_to_pc)**0.5 for leaf in trunk_leaves[trunk] for j in leaf_radii[leaf] if j.value > min_rad_as]
        y = [j.value/1000. for leaf in trunk_leaves[trunk] for j,r in zip(leaf_vrms[leaf],leaf_radii[leaf]) if r.value > min_rad_as]
        if len(x) <= 3:
            continue
        fitpars = fit_a_line.total_least_squares(np.array(x),np.array(y))
        trunkslopes[trunk] = fitpars
        xvals[trunk] = x

pl.figure(4)
pl.clf()
pl.xlabel("R$^{1/2}$ (pc at D=7.5 kpc)")
pl.ylabel(r'$\sigma_v$ (km s$^{-1}$')
pl.title(r'$\sigma_v = C R^{1/2}$, $C>1.4$ or $C<0.35$')
pl.plot(np.linspace(0,5)**0.5,0.72*np.linspace(0,5)**0.5,'k--',linewidth=2,alpha=0.5)
pl.figure(5)
pl.clf()
pl.xlabel("R$^{1/2}$ (pc at D=7.5 kpc)")
pl.ylabel(r'$\sigma_v$ (km s$^{-1}$')
pl.title(r'$\sigma_v = C R^{1/2}$, $C\sim0.7$')
pl.plot(np.linspace(0,5)**0.5,0.72*np.linspace(0,5)**0.5,'k--',linewidth=2,alpha=0.5)
示例#3
0
# filter based on minimum radius in arcsec
min_rad_as = 15
for trunk in trunk_leaves:
    if trunk_leaves[trunk][0] in leaf_stats:
        # size-linewidth -> sigma=0.72 R^0.5
        x = [(j.value * as_to_pc)**0.5 for leaf in trunk_leaves[trunk]
             for j in leaf_radii[leaf] if j.value > min_rad_as]
        y = [
            j.value / 1000. for leaf in trunk_leaves[trunk]
            for j, r in zip(leaf_vrms[leaf], leaf_radii[leaf])
            if r.value > min_rad_as
        ]
        if len(x) <= 3:
            continue
        fitpars = fit_a_line.total_least_squares(np.array(x), np.array(y))
        trunkslopes[trunk] = fitpars
        xvals[trunk] = x

pl.figure(4)
pl.clf()
pl.xlabel("R$^{1/2}$ (pc at D=7.5 kpc)")
pl.ylabel(r'$\sigma_v$ (km s$^{-1}$')
pl.title(r'$\sigma_v = C R^{1/2}$, $C>1.4$ or $C<0.35$')
pl.plot(np.linspace(0, 5)**0.5,
        0.72 * np.linspace(0, 5)**0.5,
        'k--',
        linewidth=2,
        alpha=0.5)
pl.figure(5)
pl.clf()
cont11 = fits.getdata(cont11filename)
cont22 = fits.getdata(cont22filename)

rrlerr6cm = 0.0415
rrlerr2cm = 0.0065
rrl6cmmask = rrl6cm > rrlerr6cm * 2
rrl2cmmask = rrl2cm > rrlerr2cm * 2

offset2cm, offset6cm = 0,0

rrldata,contdata,rrlmask = (rrl2cm,cont22,rrl2cmmask)
rrlmask *= (contdata > 0.1)
nok = np.count_nonzero(rrlmask)
factor2cm,offset2cm = fit_a_line.total_least_squares(rrldata[rrlmask],
                                                     contdata[rrlmask],
                                                     data1err=np.ones(nok)*rrlerr2cm,
                                                     data2err=np.ones(nok)*0.05,
                                                     print_results=True,
                                                     intercept=True)
print "2cm: ",offset2cm,factor2cm
artificial_cont_2cm = rrldata * factor2cm + offset2cm


rrldata,contdata,rrlmask = (rrl6cm,cont11,rrl6cmmask)
rrlmask *= (contdata > 0.1)
nok = np.count_nonzero(rrlmask)
factor6cm, offset6cm = fit_a_line.total_least_squares(rrldata[rrlmask],
                                                      contdata[rrlmask],
                                                      data1err=np.ones(nok)*rrlerr6cm,
                                                      data2err=np.ones(nok)*0.05,
                                                      print_results=True,
                                                      intercept=True)