Beispiel #1
0
                                outfn.replace(".fits", ".pdf")),
                    dpi=200,
                    bbox_inches='tight')

                for line in m3m:
                    line.set_visible(False)

                trans = ax.get_transform('world')
                #m7m = ax.contour((xpoints_7mm-maser_center_7mm).to(u.arcsec),
                #                 u.Quantity(masers_7mm['VLSR'], u.m/u.s),
                #                 levels=[5,10,50],
                #                 transform=trans)
                m7m = adaptive_param_plot(
                    (xpoints_7mm - maser_center_7mm).to(u.arcsec).value,
                    u.Quantity(masers_7mm['VLSR'], u.m / u.s).value,
                    axis=ax,
                    bins=100,
                    marker=',',
                    marker_color='r',
                    transform=trans)

                fig.savefig(
                    paths.fpath('pv/{0}/vlba_7mm_maseroverlay_'.format(name) +
                                outfn.replace(".fits", ".pdf")),
                    dpi=200,
                    bbox_inches='tight')

errtbl2 = {key[1]: (key[2], key[3], value) for key, value in errtbl.items()}
with open('error_estimate_table_pvs.json', 'w') as fh:
    json.dump(errtbl2, fh)
from mpl_plot_templates import adaptive_param_plot
import numpy as np
import pylab as pl

pl.clf()

adaptive_param_plot(np.random.randn(1000)+np.linspace(0,5,1000),np.random.randn(1000)+np.linspace(0,5,1000), fill=True, alpha=0.5, threshold=10)

pl.savefig('param_plot_example.png')
F.add_colorbar()

pl.figure(ii + 3)
pl.clf()
ax = pl.gca()
pl.plot([000, 4e4], [000, 4e4], "k--")
h77te_med = np.median(h77te.value[np.isfinite(h77te.value)])
h112te_med = np.median(h112te.value[np.isfinite(h112te.value)])
h77te_mean = np.mean(h77te.value[np.isfinite(h77te.value)])
h112te_mean = np.mean(h112te.value[np.isfinite(h112te.value)])
mpl_plot_templates.adaptive_param_plot(
    h77te.value,
    h112te.value,
    bins=50,
    ncontours=10,
    threshold=5,
    fill=True,
    alpha=0.5,
    cmap=pl.mpl.cm.spectral,
    axis=ax,
)
ax.plot(h77te_med, h112te_med, "kx", markersize=15, markeredgewidth=3)
ax.plot(h77te_mean, h112te_mean, "k+", markersize=15, markeredgewidth=3)
ax.set_xlabel(r"$T_e(\mathrm{H}77\alpha)$")
ax.set_ylabel(r"$T_e(\mathrm{H}112\alpha)$")
ax.axis([0, 2e4, 0, 2e4])
pl.savefig(fpath("electron_temperature_77vs111.pdf"))


keys = [r"$S_{5 GHz}$", r"$S_{15 GHz}$", r"H112$\alpha$", r"H77$\alpha$"]
Beispiel #4
0
    print('fbound: %.2f+%.2f-%.2f' %
          (np.around(fbound_median, 2), np.around(
              fbound_errmax, 2), np.around(fbound_errmin, 2)))

    fcce_median = np.nanmedian(fcce)
    fcce_errmin = fcce_median - np.nanpercentile(fcce, 16.)
    fcce_errmax = np.nanpercentile(fcce, 84.) - fcce_median

    print('fcce: %.2f+%.2f-%.2f' % (np.around(
        fcce_median, 2), np.around(fcce_errmax, 2), np.around(fcce_errmin, 2)))

    tbl = Table(data=[sigma_arr, surfg_arr, fbound],
                names=['sigma', 'surfg', 'fbound'])

    tbl.write("cfe_local_table.txt", format='ascii.csv')

if __name__ == "__main__":

    from mpl_plot_templates import adaptive_param_plot
    import pylab as pl
    pl.clf()

    bins = np.array([np.logspace(1.5, 4, 15), np.logspace(0.5, 2, 15)])
    rslt = adaptive_param_plot(
        (surfg_arr * u.kg / u.m**2).to(u.M_sun / u.pc**2).value,
        fbound,
        marker='none',
        bins=bins,
        percentilelevels=[0.05, 0.32],
    )
Beispiel #5
0
    'blue': ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0))
}
cdictblue = {
    'red': ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0)),
    'green': ((0.0, 0.0, 0.0), (1.0, 0.0, 0.0)),
    'blue': ((0.0, 1.0, 1.0), (1.0, 1.0, 1.0))
}
cm_red = LinearSegmentedColormap('red', cdict1)
cm_blue = LinearSegmentedColormap('blue', cdictblue)

#ax3.plot((surfg_arr*u.kg/u.m**2).to(u.M_sun/u.pc**2).value, cfes, 'k.', alpha=0.25, zorder=-5)
rslt = adaptive_param_plot(
    (surfg_arr * u.kg / u.m**2).to(u.M_sun / u.pc**2).value,
    global_fbound,
    marker='none',
    #levels=[1-0.95,1-0.68])
    #colors=['b']*15,
    cmap=cm_red,
    bins=bins,
    percentilelevels=[0.05, 0.32],
)
rslt2 = adaptive_param_plot(
    (surfg_arr * u.kg / u.m**2).to(u.M_sun / u.pc**2).value,
    local_fbound,
    marker='none',
    #levels=[1-0.95,1-0.68])
    #colors=['r']*15,
    cmap=cm_blue,
    linestyles='dotted',
    bins=bins,
    percentilelevels=[0.05, 0.32],
)
noise11 = h2co11_my[:50,:,:].std(axis=0)

sn11 = h2co11_my/noise11

mask = (sn11 > 2)

brick_mask = fits.getdata(datapath+'brick_mask11.fits').astype('bool')
mask_nan = np.ones(mask.shape,dtype='float')
mask_nan[np.logical_not(mask)] = np.nan


fig = pl.figure(0)
fig.clf()
ax = pl.gca()
pl.plot([0,0.7],[0,0.7],'k--',linewidth=3,alpha=0.5,zorder=0)
pl.plot([0,0.7],[0,0.7*1.65],'g--',linewidth=3,alpha=0.5,zorder=0)
adaptive_param_plot(h2co11_law[mask], h2co11_my[mask], bins=30, threshold=100,
                    marker='.', alpha=0.5, zorder=5,
                    markersize=2)
pl.plot((h2co11_law*mask_nan)[:,brick_mask],
        (h2co11_my*mask_nan)[:,brick_mask], marker='.', alpha=0.5, color='r',
        markersize=2, linestyle='none')
ax.set_xlabel(r"$\tau_{1-1}$ Law")
ax.set_ylabel(r"$\tau_{1-1}$ Ours")
ax.set_xlim(0,h2co11_law[mask].max())
ax.set_ylim(0,h2co11_my[mask].max())
pl.show()

pl.savefig(figpath+'claw_tau_vs_mytau.pdf',bbox_inches='tight')
from mpl_plot_templates import adaptive_param_plot
import numpy as np
import pylab as pl

pl.clf()

adaptive_param_plot(np.random.randn(1000) + np.linspace(0, 5, 1000),
                    np.random.randn(1000) + np.linspace(0, 5, 1000),
                    fill=True,
                    alpha=0.5,
                    threshold=10)

pl.savefig('param_plot_example.png')
import pylab as pl
import matplotlib

msx = fits.open('MSX_E_W51_mosaic_bgmatch.fits')
mips = fits.open('W51_mips1.fits')
msxd = msx[0].data
mipsd = mips[0].data

ok = np.isfinite(msxd) & np.isfinite(mipsd)

msxOK = msxd > 500
fitOK = msxOK * (mipsd<1400)*(mipsd>250)

pl.figure(1)
pl.clf()
mpl_plot_templates.adaptive_param_plot(mipsd.flat, msxd.flat, marker=',',
                                       bins=50, threshold=10)
mpl_plot_templates.adaptive_param_plot(mipsd[fitOK], msxd[fitOK], marker=',',
                                       bins=50, threshold=10, color='r')

pv = np.polyfit(mipsd[fitOK],msxd[fitOK],1)
print pv
x = np.linspace(0,2000)
pl.plot(x, np.polyval(pv, x), linewidth=3, alpha=0.5)

mixed = msxd
replace = msxd > 1000
replace = ((mipsd > 1500) & (msxd > 1000)) | (True - np.isfinite(mipsd))
mixed[True-replace] = mipsd[True-replace]*pv[0] + pv[1]

pl.figure(2)
pl.clf()
           'CO_12CO21_supersampledh2cogrid.fits',
           'CO_12CO32_supersampledh2cogrid.fits',
           'CO_13CO10_supersampledh2cogrid.fits',
           'CO_13CO21_supersampledh2cogrid.fits',
           'CO_13CO32_supersampledh2cogrid.fits',
           'CO_13CO32_supersampledh2cogrid_smoothy.fits',
           'CO_C18O32_supersampledh2cogrid.fits',
           ]

twelveco10 = fits.getdata(datapath_w51+cofiles[0])
comask = twelveco10 > 5

vranges = [(40,50),(50,60),(60,65),(65,75)]

for cf in cofiles:
    codata = fits.getdata(datapath_w51+cf)
    for vr in vranges:
        slc = slice(vel_to_x(vr[0]*u.km/u.s),vel_to_x(vr[1]*u.km/u.s))
        cdat = codata[slc,:,:]
        hdat = h2co11[slc,:,:]
        cmsk = comask[slc,:,:]
        hmsk = mask[slc,:,:]
        pl.figure(1)
        pl.clf()
        adaptive_param_plot(cdat[cmsk], hdat[cmsk], bins=50, threshold=25,
                            marker='.', alpha=0.5, color='b')
        adaptive_param_plot(cdat[hmsk], hdat[hmsk], bins=50, threshold=25,
                            marker='.', alpha=0.5, color='r', cmap=pl.cm.bone)

        pl.savefig(figurepath+"co_vs_h2co_v{0}to{1}_".format(vr[0],vr[1])+cf.replace(".fits",".pdf"))
Beispiel #10
0
epoch1matched_fft = image_registration.fft_tools.shift2d(epoch1reproj*scalefactor, -xshift, -yshift)
epoch1matched = image_registration.fft_tools.shift2d(epoch1reproj*scalefactor, dx_gf, dy_gf)

diff =  epoch3[0].data - epoch1matched
diffhdu = fits.PrimaryHDU(data=diff, header=epoch3header)
diffhdu.writeto(paths.dpath("Cband_Epoch3-Epoch1.fits"), clobber=True, output_verify='fix')

smooth_beam = beam1.deconvolve(beam3)
kernel = smooth_beam.major
pixscale = (wcs3.pixel_scale_matrix.diagonal()**2).sum()**0.5 * u.deg
smoothed3 = convolution.convolve_fft(epoch3[0].data,
                                     convolution.Gaussian2DKernel(kernel/pixscale))

diffsm =  smoothed3 - epoch1matched
diffsmhdu = fits.PrimaryHDU(data=diffsm, header=epoch3header)
diffsmhdu.writeto(paths.dpath("Cband_Epoch3sm-Epoch1.fits"), clobber=True, output_verify='fix')

diff3sm =  epoch3[0].data - smoothed3
diff3smhdu = fits.PrimaryHDU(data=diff3sm, header=epoch3header)
diff3smhdu.writeto(paths.dpath("Cband_Epoch3sm-Epoch3.fits"), clobber=True, output_verify='fix')

import pylab as pl
import mpl_plot_templates
pl.figure(1).clf()
mpl_plot_templates.adaptive_param_plot(smoothed3.ravel(), epoch1matched.ravel())
pl.plot([0,0.012], [0,0.012], 'k--', alpha=0.3)
pl.figure(2).clf()
mpl_plot_templates.adaptive_param_plot(smoothed3.ravel(), epoch1matched_fft.ravel())
pl.plot([0,0.012], [0,0.012], 'k--', alpha=0.3)