def edr_dr2_vs_dr3(): #plotrange = ((240.9, 242.1), (4.8, 5.9)) plotrange = ((240, 245), (4.5, 12.0)) #fns = glob('dr2-tractor/241/tractor-*p05*.fits') fns = glob('dr2-tractor/24[01234]/tractor-*.fits') fns.sort() TT2,TT3 = [],[] for fn in fns: fn3 = fn.replace('dr2-tractor', 'dr3-tractor') if not os.path.exists(fn3): print('Does not exist:', fn3) continue cols = 'ra dec brick_primary brickname decam_anymask'.split() T2 = fits_table(fn, columns=cols) T3 = fits_table(fn3, columns=cols) print('Reading', fn, '->', len(T2), 'DR2,', len(T3), 'DR3') TT2.append(T2) TT3.append(T3) T2 = merge_tables(TT2, columns='fillzero') T3 = merge_tables(TT3, columns='fillzero') del TT2, TT3 plt.clf() plothist(T2.ra, T2.dec, nbins=200, range=plotrange) plt.title('DR2') ps.savefig() plt.clf() plothist(T3.ra, T3.dec, nbins=200, range=plotrange) plt.title('DR3') ps.savefig() plt.clf() I = np.flatnonzero(T2.brick_primary) print('DR2:', len(I), 'brick_primary') H2,xe,ye = plothist(T2.ra[I], T2.dec[I], nbins=200, range=plotrange) mx = H2.max() plt.title('DR2 brick_primary') ps.savefig() plt.clf() I = np.flatnonzero(T3.brick_primary) print('DR3:', len(I), 'brick_primary') H3,xe,ye = plothist(T3.ra[I], T3.dec[I], nbins=200, imshowargs=dict(vmax=mx), range=plotrange) plt.title('DR3 brick_primary') ps.savefig() plt.clf() plt.imshow((H3 - H2).T, interpolation='nearest', origin='lower', cmap='hot', extent=(min(xe), max(xe), min(ye), max(ye)), aspect='auto') plt.colorbar() plt.title('DR3 - DR2 brick_primary') ps.savefig() for name,bit in CP_DQ_BITS.items(): plt.clf() anymask = reduce(np.bitwise_or, (T3.decam_anymask[:,1], T3.decam_anymask[:,2], T3.decam_anymask[:,4])) I = np.flatnonzero((anymask & bit) > 0) #plt.subplot(1,2,1) plothist(T3.ra[I], T3.dec[I], nbins=200, imshowargs=dict(vmax=mx), doclf=False, range=plotrange) plt.title('DR3, %s any' % name) #plt.suptitle('DR3') ps.savefig()
def edr_dr2_vs_dr3(): #plotrange = ((240.9, 242.1), (4.8, 5.9)) plotrange = ((240, 245), (4.5, 12.0)) #fns = glob('dr2-tractor/241/tractor-*p05*.fits') fns = glob('dr2-tractor/24[01234]/tractor-*.fits') fns.sort() TT2, TT3 = [], [] for fn in fns: fn3 = fn.replace('dr2-tractor', 'dr3-tractor') if not os.path.exists(fn3): print('Does not exist:', fn3) continue cols = 'ra dec brick_primary brickname decam_anymask'.split() T2 = fits_table(fn, columns=cols) T3 = fits_table(fn3, columns=cols) print('Reading', fn, '->', len(T2), 'DR2,', len(T3), 'DR3') TT2.append(T2) TT3.append(T3) T2 = merge_tables(TT2, columns='fillzero') T3 = merge_tables(TT3, columns='fillzero') del TT2, TT3 plt.clf() plothist(T2.ra, T2.dec, nbins=200, range=plotrange) plt.title('DR2') ps.savefig() plt.clf() plothist(T3.ra, T3.dec, nbins=200, range=plotrange) plt.title('DR3') ps.savefig() plt.clf() I = np.flatnonzero(T2.brick_primary) print('DR2:', len(I), 'brick_primary') H2, xe, ye = plothist(T2.ra[I], T2.dec[I], nbins=200, range=plotrange) mx = H2.max() plt.title('DR2 brick_primary') ps.savefig() plt.clf() I = np.flatnonzero(T3.brick_primary) print('DR3:', len(I), 'brick_primary') H3, xe, ye = plothist(T3.ra[I], T3.dec[I], nbins=200, imshowargs=dict(vmax=mx), range=plotrange) plt.title('DR3 brick_primary') ps.savefig() plt.clf() plt.imshow((H3 - H2).T, interpolation='nearest', origin='lower', cmap='hot', extent=(min(xe), max(xe), min(ye), max(ye)), aspect='auto') plt.colorbar() plt.title('DR3 - DR2 brick_primary') ps.savefig() for name, bit in CP_DQ_BITS.items(): plt.clf() anymask = reduce(np.bitwise_or, (T3.decam_anymask[:, 1], T3.decam_anymask[:, 2], T3.decam_anymask[:, 4])) I = np.flatnonzero((anymask & bit) > 0) #plt.subplot(1,2,1) plothist(T3.ra[I], T3.dec[I], nbins=200, imshowargs=dict(vmax=mx), doclf=False, range=plotrange) plt.title('DR3, %s any' % name) #plt.suptitle('DR3') ps.savefig()