def detection_plots_2(tims, bands, targetwcs, refstars, Tnew, hot, saturated_pix, ps): coimgs, _ = quick_coadds(tims, bands, targetwcs) crossa = dict(ms=10, mew=1.5) plt.clf() dimshow(get_rgb(coimgs, bands)) plt.title('Detections') ps.savefig() ax = plt.axis() if len(refstars): I, = np.nonzero([len(r) and r[0] == 'T' for r in refstars.ref_cat]) if len(I): plt.plot(refstars.ibx[I], refstars.iby[I], '+', color=(0, 1, 1), label='Tycho-2', **crossa) I, = np.nonzero([len(r) and r[0] == 'G' for r in refstars.ref_cat]) if len(I): plt.plot(refstars.ibx[I], refstars.iby[I], '+', color=(0.2, 0.2, 1), label='Gaia', **crossa) I, = np.nonzero([len(r) and r[0] == 'L' for r in refstars.ref_cat]) if len(I): plt.plot(refstars.ibx[I], refstars.iby[I], '+', color=(0.6, 0.6, 0.2), label='Large Galaxy', **crossa) plt.plot(Tnew.ibx, Tnew.iby, '+', color=(0, 1, 0), label='New SED-matched detections', **crossa) plt.axis(ax) plt.title('Detections') plt.legend(loc='upper left') ps.savefig() plt.clf() plt.subplot(1, 2, 1) dimshow(hot, vmin=0, vmax=1, cmap='hot') plt.title('hot') plt.subplot(1, 2, 2) H, W = targetwcs.shape rgb = np.zeros((H, W, 3)) for i, satpix in enumerate(saturated_pix): rgb[:, :, 2 - i] = satpix dimshow(rgb) plt.title('saturated_pix') ps.savefig()
def halo_plots_before(tims, bands, targetwcs, halostars, ps): coimgs, _ = quick_coadds(tims, bands, targetwcs) plt.clf() dimshow(get_rgb(coimgs, bands)) ax = plt.axis() plt.plot(halostars.ibx, halostars.iby, 'o', mec='r', ms=15, mfc='none') plt.axis(ax) plt.title('Before star halo subtraction') ps.savefig() return coimgs
def halo_plots_after(tims, bands, targetwcs, halostars, coimgs, ps): coimgs2, _ = quick_coadds(tims, bands, targetwcs) plt.clf() dimshow(get_rgb(coimgs2, bands)) ax = plt.axis() plt.plot(halostars.ibx, halostars.iby, 'o', mec='r', ms=15, mfc='none') plt.axis(ax) plt.title('After star halo subtraction') ps.savefig() plt.clf() dimshow(get_rgb([co - co2 for co, co2 in zip(coimgs, coimgs2)], bands)) ax = plt.axis() plt.plot(halostars.ibx, halostars.iby, 'o', mec='r', ms=15, mfc='none') plt.axis(ax) plt.title('Subtracted halos') ps.savefig() for g in halostars[:10]: plt.clf() pixscale = targetwcs.pixel_scale() pixrad = int(g.radius * 3600. / pixscale) ax = [g.ibx - pixrad, g.ibx + pixrad, g.iby - pixrad, g.iby + pixrad] ima = dict(interpolation='nearest', origin='lower') plt.subplot(2, 2, 1) plt.imshow(get_rgb(coimgs, bands), **ima) plt.plot(halostars.ibx, halostars.iby, 'o', mec='r', ms=15, mfc='none') plt.axis(ax) plt.subplot(2, 2, 2) plt.imshow(get_rgb(coimgs2, bands), **ima) plt.axis(ax) plt.subplot(2, 2, 3) plt.imshow( get_rgb([co - co2 for co, co2 in zip(coimgs, coimgs2)], bands), **ima) plt.axis(ax) ps.savefig()
def showresid(tims,mods,wcs,bands='grz'): co,_ = quick_coadds(tims, bands, wcs) comod,_ = quick_coadds(tims, bands, wcs, images=mods) plt.imshow(np.flipud(get_rgb([i-m for i,m in zip(co,comod)], bands))) plt.xticks([]); plt.yticks([]) return co,comod
def fitblobs_plots(tims, bands, targetwcs, blobslices, blobsrcs, cat, blobs, ps): coimgs, _ = quick_coadds(tims, bands, targetwcs) plt.clf() dimshow(get_rgb(coimgs, bands)) ax = plt.axis() for i, bs in enumerate(blobslices): sy, sx = bs by0, by1 = sy.start, sy.stop bx0, bx1 = sx.start, sx.stop plt.plot([bx0, bx0, bx1, bx1, bx0], [by0, by1, by1, by0, by0], 'r-') plt.text((bx0 + bx1) / 2., by0, '%i' % i, ha='center', va='bottom', color='r') plt.axis(ax) plt.title('Blobs') ps.savefig() for i, Isrcs in enumerate(blobsrcs): for isrc in Isrcs: src = cat[isrc] ra, dec = src.getPosition().ra, src.getPosition().dec _, x, y = targetwcs.radec2pixelxy(ra, dec) plt.text(x, y, 'b%i/s%i' % (i, isrc), ha='center', va='bottom', color='r') plt.axis(ax) plt.title('Blobs + Sources') ps.savefig() plt.clf() dimshow(blobs) ax = plt.axis() for i, bs in enumerate(blobslices): sy, sx = bs by0, by1 = sy.start, sy.stop bx0, bx1 = sx.start, sx.stop plt.plot([bx0, bx0, bx1, bx1, bx0], [by0, by1, by1, by0, by0], 'r-') plt.text((bx0 + bx1) / 2., by0, '%i' % i, ha='center', va='bottom', color='r') plt.axis(ax) plt.title('Blobs') ps.savefig() plt.clf() dimshow(blobs != -1) ax = plt.axis() for i, bs in enumerate(blobslices): sy, sx = bs by0, by1 = sy.start, sy.stop bx0, bx1 = sx.start, sx.stop plt.plot([bx0, bx0, bx1, bx1, bx0], [by0, by1, by1, by0, by0], 'r-') plt.text((bx0 + bx1) / 2., by0, '%i' % i, ha='center', va='bottom', color='r') plt.axis(ax) plt.title('Blobs') ps.savefig()
def detection_plots(detmaps, detivs, bands, saturated_pix, tims, targetwcs, refstars, large_galaxies, gaia_stars, ps): rgb = get_rgb(detmaps, bands) plt.clf() dimshow(rgb) plt.title('detmaps') ps.savefig() for i, satpix in enumerate(saturated_pix): rgb[:, :, 2 - i][satpix] = 1 plt.clf() dimshow(rgb) plt.title('detmaps & saturated') ps.savefig() coimgs, _ = quick_coadds(tims, bands, targetwcs, fill_holes=False) if refstars: plt.clf() dimshow(get_rgb(coimgs, bands)) ax = plt.axis() lp, lt = [], [] tycho = refstars[refstars.isbright] if len(tycho): _, ix, iy = targetwcs.radec2pixelxy(tycho.ra, tycho.dec) p = plt.plot(ix - 1, iy - 1, 'o', mew=3, ms=14, mec='r', mfc='none') lp.append(p) lt.append('Tycho-2 only') if gaia_stars: gaia = refstars[refstars.isgaia] if gaia_stars and len(gaia): _, ix, iy = targetwcs.radec2pixelxy(gaia.ra, gaia.dec) p = plt.plot(ix - 1, iy - 1, 'o', mew=3, ms=10, mec='c', mfc='none') for x, y, g in zip(ix, iy, gaia.phot_g_mean_mag): plt.text(x, y, '%.1f' % g, color='k', bbox=dict(facecolor='w', alpha=0.5)) lp.append(p) lt.append('Gaia') # star_clusters? if large_galaxies: galaxies = refstars[refstars.islargegalaxy] if large_galaxies and len(galaxies): _, ix, iy = targetwcs.radec2pixelxy(galaxies.ra, galaxies.dec) p = plt.plot(ix - 1, iy - 1, 'o', mew=3, ms=14, mec=(0, 1, 0), mfc='none') lp.append(p) lt.append('Galaxies') plt.axis(ax) plt.title('Ref sources') plt.figlegend([p[0] for p in lp], lt) ps.savefig() for band, detmap, detiv in zip(bands, detmaps, detivs): plt.clf() plt.subplot(2, 1, 1) plt.hist((detmap * np.sqrt(detiv))[detiv > 0], bins=50, range=(-5, 8), log=True) plt.title('Detection map pixel values (sigmas): band %s' % band) plt.subplot(2, 1, 2) plt.hist((detmap * np.sqrt(detiv))[detiv > 0], bins=50, range=(-5, 8)) ps.savefig()