コード例 #1
0
ファイル: hist.py プロジェクト: timleslie/gattini
def main():
    results_dir = "../results/hist"

    lines = open("hist_results.txt", "r").readlines()
    #print len(lines)

    for filename, line in zip((darkfiles("sbc") + darkfiles("sky")),
                              lines)[1:2]:
        x0, theta, k = map(float, line.split(","))
        print x0, theta, k

        base, _ = os.path.splitext(filename)
        outname = base + ".hist.png"
        _, outname = os.path.split(outname)
        outname = os.path.join(results_dir, outname)
        print filename, outname

        data = N.asarray(getdata(filename))
        #print "min =", min(data.flat)

        #subplot(211)
        #imshow(scipy.stats.zs(data) < 5, cmap=cm.gray)

        #subplot(212)
        data = data.flatten()
        data = data[abs(scipy.stats.zs(data)) < 6]

        x0 = min(data.flat)
        mu = data.astype(float).mean()
        sd = data.astype(float).std()
        p = (mu - x0) / data.size

        #x0 = mu - 2*(mu - x0)
        print(x0, data.max())
        ns = N.arange(x0, data.max())
        #print "mu =", mu, mu - x0, std(data.flatten())**2
        #print "a"
        header = dict(getheader(filename).items())
        #print "b", len(data.flat), data.max() - data.min(), histogram(data.flat)
        hist(data.flat, data.max() - data.min(), normed=1)
        #print "c"
        # plot(ns, [float(P(n - x0, mu - x0)) for n in ns], linewidth=2, c='r')
        # plot(ns, [float(Nm(n, mu, sd)) for n in ns], linewidth=2, c='y')
        # plot(ns, [float(G(n, 6.0, x0, sd*0.7)) for n in ns], linewidth=2, c='g')
        # plot(ns, [float(G(n, k, 0, theta)) for n in ns], linewidth=2, c='g')

        #gdat, gdat0, gdat1 = ests(data, (x0,theta,k))
        [gdat] = ests(data, (x0, theta, k))
        print N.max(gdat), N.argmax(gdat)
        plot(gdat, linewidth=2, c='y')
        #plot(ns, gdat0, linewidth=2, c='r')
        #plot(ns, gdat1, linewidth=2, c='y')

        title("Time: %1.3fs, Temp: %1.1fC (%1.0fC) (%1.0f += %1.1f)" %
              (header['EXPTIME'], header['CCD-TEMP'], header['SET-TEMP'],
               mean(data.flatten().astype(float)),
               std(data.flatten().astype(float))))
        #savefig(outname)
        show()
        clf()
コード例 #2
0
ファイル: hist.py プロジェクト: california43/gattini
def main():    
    results_dir = "../results/hist"


    lines = open("hist_results.txt", "r").readlines()
    #print len(lines)
    
    for filename, line in zip((darkfiles("sbc") + darkfiles("sky")), lines)[1:2]:
        x0, theta, k = map(float, line.split(","))
        print x0, theta, k
        
        base, _ = os.path.splitext(filename)
        outname = base + ".hist.png"
        _, outname = os.path.split(outname)
        outname = os.path.join(results_dir, outname)
        print filename, outname
        
        data = N.asarray(getdata(filename))
        #print "min =", min(data.flat)
    
        #subplot(211)
        #imshow(scipy.stats.zs(data) < 5, cmap=cm.gray)
    
        #subplot(212)
        data = data.flatten()
        data = data[abs(scipy.stats.zs(data)) < 6]
        
        x0 = min(data.flat)
        mu = data.astype(float).mean()
        sd = data.astype(float).std()
        p = (mu - x0)/data.size
        
        #x0 = mu - 2*(mu - x0)
        print (x0, data.max())
        ns = N.arange(x0, data.max())
        #print "mu =", mu, mu - x0, std(data.flatten())**2
        #print "a"
        header = dict(getheader(filename).items())
        #print "b", len(data.flat), data.max() - data.min(), histogram(data.flat)
        hist(data.flat, data.max() - data.min(), normed=1)
        #print "c"
        # plot(ns, [float(P(n - x0, mu - x0)) for n in ns], linewidth=2, c='r')
        # plot(ns, [float(Nm(n, mu, sd)) for n in ns], linewidth=2, c='y')
        # plot(ns, [float(G(n, 6.0, x0, sd*0.7)) for n in ns], linewidth=2, c='g')
        # plot(ns, [float(G(n, k, 0, theta)) for n in ns], linewidth=2, c='g')

        #gdat, gdat0, gdat1 = ests(data, (x0,theta,k))
        [gdat] = ests(data, (x0,theta,k))
        print N.max(gdat), N.argmax(gdat)
        plot(gdat, linewidth=2, c='y')
        #plot(ns, gdat0, linewidth=2, c='r')
        #plot(ns, gdat1, linewidth=2, c='y')

        title("Time: %1.3fs, Temp: %1.1fC (%1.0fC) (%1.0f += %1.1f)" %
              (header['EXPTIME'], header['CCD-TEMP'], header['SET-TEMP'],
               mean(data.flatten().astype(float)), std(data.flatten().astype(float)) ))
        #savefig(outname)
        show()
        clf()
コード例 #3
0
ファイル: dark.py プロジェクト: timleslie/gattini
def group_darks(cam, key1, key2):
    """
    Group the dark frames into a nested dictionary of Images,
    keyed by key1, then key2.
    """
    filenames = darkfiles(cam)
    images = valid_images(filenames)
    groups = groupby(images, key1)
    for key in groups:
        groups[key] = groupby(groups[key], key2)
    return groups
コード例 #4
0
ファイル: dark.py プロジェクト: california43/gattini
def group_darks(cam, key1, key2):
    """
    Group the dark frames into a nested dictionary of Images,
    keyed by key1, then key2.
    """
    filenames = darkfiles(cam)
    images = valid_images(filenames)
    groups = groupby(images, key1)
    for key in groups:
        groups[key] = groupby(groups[key], key2)
    return groups
コード例 #5
0
ファイル: examples.py プロジェクト: california43/gattini
def image_sort_example():
    """
    Sort a bunch of images based on different keys
    """
    files = darkfiles("sbc")
    images = valid_images(files)

    image = Image(files[0])
    print image.MIN
    print image.BSCALE

    sortby(images, "MAX")
    print [image.MAX for image in images]
コード例 #6
0
ファイル: examples.py プロジェクト: timleslie/gattini
def image_sort_example():
    """
    Sort a bunch of images based on different keys
    """
    files = darkfiles("sbc")
    images = valid_images(files)

    image = Image(files[0])
    print image.MIN
    print image.BSCALE

    sortby(images, "MAX")
    print[image.MAX for image in images]

    sortby(images, "MEAN")
    print[image.MEAN for image in images]