Example #1
0
def calc_geom(sn, field):
    """Calculate the location of bins for a given target S/N and field. """
    binsfile = "voronoi_sn{0}_w4500_5500.fits".format(sn, w1, w2)
    binimg = pf.getdata(binsfile)
    ydim, xdim = binimg.shape
    intens = "collapsed_w4500_5500.fits".format(w1, w2)
    extent = calc_extent(intens)
    extent = offset_extent(extent, field)
    x = np.linspace(extent[0], extent[1], xdim)
    y = np.linspace(extent[2], extent[3], ydim)
    xx, yy = np.meshgrid(x, y)
    binimg = np.ma.array(binimg, mask=~np.isfinite(binimg))
    bins = np.arange(binimg.min(), binimg.max()+1)
    xcen = np.zeros_like(bins)
    ycen = np.zeros_like(xcen)
    bins = bins.astype(int)
    for i, bin in enumerate(bins):
        idx = np.where(binimg == bin)
        xcen[i] = np.mean(xx[idx])
        ycen[i] = np.mean(yy[idx])
    radius = np.sqrt(xcen**2 + ycen**2)
    pa = np.rad2deg(np.arctan2(xcen, ycen))
    # Converting to strings
    xcen = ["{0:.5f}".format(x) for x in xcen]
    ycen = ["{0:.5f}".format(x) for x in ycen]
    radius = ["{0:.5f}".format(x) for x in radius]
    pa = ["{0:.5f}".format(x) for x in pa]
    specs = np.array(["{0}_bin{1}".format(field, x) for x in bins])
    return np.column_stack((specs, xcen, ycen, radius, pa))
Example #2
0
def calc_radius(sn, w1, w2, field):
    """Calculate the radius of the binning for a given target S/N. """
    binsfile = "voronoi_sn{0}_w{1}_{2}.fits".format(sn, w1, w2)
    binimg = pf.getdata(binsfile)
    ydim, xdim = binimg.shape
    intens = "collapsed_w{0}_{1}.fits".format(w1, w2)
    extent = calc_extent(intens)
    extent = offset_extent(extent, field)
    xtmp = np.linspace(extent[0], extent[1], xdim)
    ytmp = np.linspace(extent[2], extent[3], ydim)
    xx, yy = np.meshgrid(xtmp, ytmp)
    binimg = np.ma.array(binimg, mask=~np.isfinite(binimg))
    bins = np.arange(binimg.min(), binimg.max()+1)
    radius = np.zeros_like(bins)
    for i, bin in enumerate(bins):
        idx = np.where(binimg == bin)
        xcen = np.mean(xx[idx])
        ycen = np.mean(yy[idx])
        radius[i] = np.sqrt(xcen**2 + ycen**2)
    return radius
Example #3
0
 k06SII_agn = lambda x: 0.72 / (x - 0.32) + 1.3
 k06SII_liner = lambda x: 1.89 * x + 0.76
 fig = plt.figure(figsize=(8,8))
 plt.subplots_adjust(left=0.08, right=0.97, bottom=0.065, top=0.975,
                     wspace=0.25)
 for sn, field in zip(targetSN, fields):
     os.chdir(os.path.join(data_dir, "combined_{0}".format(field)))
     ######################################################################
     # Load images and prepare images
     binsfile = "voronoi_sn{0}_w{1}_{2}.fits".format(sn, w1, 5500)
     binimg = pf.getdata(binsfile)
     ydim, xdim = binimg.shape
     intens = "collapsed_w{0}_{1}.fits".format(w1, 5500)
     flux = pf.getdata(intens)
     extent = calc_extent(intens)
     extent = offset_extent(extent, field)
     xtmp = np.linspace(extent[0], extent[1], xdim)
     ytmp = np.linspace(extent[2], extent[3], ydim)
     xx, yy = np.meshgrid(xtmp, ytmp)
     binimg = np.ma.array(binimg, mask=~np.isfinite(binimg))
     bins = np.arange(binimg.min(), binimg.max() + 1)
     r = np.zeros_like(bins)
     for i, bin in enumerate(bins):
         idx = np.where(binimg == bin)
         xcen = np.mean(xx[idx])
         ycen = np.mean(yy[idx])
         r[i] = np.sqrt(xcen ** 2 + ycen ** 2)
     ######################################################################
     # Data: HB, [OIII], HA, [NII], [SII] lines
     filename = "ppxf_emission_sn{2}_w{0}_{1}.txt".format(w1, w2, sn)
     data = np.loadtxt(filename, usecols=(6,10,12,16,20,22))