@@ -0,0 +1,2038 @@
+from astrometry.util.fits import *%0Afrom glob import glob%0Aimport os%0Aimport matplotlib%0Amatplotlib.use('Agg')%0Aimport pylab as plt%0Aimport numpy as np%0Afrom astrometry.util.plotutils import *%0A%0Afn = 'dr2-depth.fits'%0Aif os.path.exists(fn):%0A    T = fits_table(fn)%0A    dlo = T.depthlo.copy()%0A    dd = dlo%5B2%5D - dlo%5B1%5D%0A    dlo%5B0%5D = dlo%5B1%5D - dd%0A%0A    ps = PlotSequence('depth')%0A    %0A    for band in 'grz':%0A        plt.clf()%0A        plt.bar(dlo, T.get('counts_ptsrc_%25s' %25 band), width=dd)%0A        plt.xlabel('Depth: %25s band' %25 band)%0A        plt.ylabel('Number of pixels')%0A        plt.title('DECaLS DR2 Depth: Point Sources, %25s' %25 band)%0A        ps.savefig()%0A%0A        plt.clf()%0A        plt.bar(dlo, T.get('counts_gal_%25s' %25 band), width=dd)%0A        plt.xlabel('Depth: %25s band' %25 band)%0A        plt.ylabel('Number of pixels')%0A        plt.title('DECaLS DR2 Depth: Canonical Galaxy, %25s' %25 band)%0A        ps.savefig()%0A%0A    import sys%0A    sys.exit(0)%0A        %0A        %0Aif __name__ == '__main__':%0A    fns = glob('dr2p/coadd/*/*/*-depth.fits')%0A    fns.sort()%0A    print len(fns), 'depth files'%0A%0A    fn = fns.pop(0)%0A    print 'Reading', fn%0A    T = fits_table(fn)%0A    # Create / upgrade the count columns to int64.%0A    for band in 'grz':%0A        for pro in %5B'ptsrc', 'gal'%5D:%0A            col = 'counts_%25s_%25s' %25 (pro, band)%0A            if not col in T.columns():%0A                v = np.array(len(T), np.int64)%0A            else:%0A                v = T.get(col).astype(np.int64)%0A            T.set(col, v)%0A                %0A    for ifn,fn in enumerate(fns):%0A        print 'Reading', ifn, 'of', len(fns), ':', fn%0A        t = fits_table(fn)%0A        assert(np.all(t.depthlo == T.depthlo))%0A        assert(np.all(t.depthhi == T.depthhi))%0A        cols = t.get_columns()%0A        for band in 'grz':%0A            col = 'counts_ptsrc_%25s' %25 band%0A            if not col in cols:%0A                continue%0A            C = T.get(col)%0A            C += t.get(col)%0A            col = 'counts_gal_%25s' %25 band%0A            C = T.get(col)%0A            C += t.get(col)%0A%0A    T.writeto('dr2-depth.fits')%0A

add script to gather up whole survey depth histograms