In [10]:
%pylab inline
plt.rcParams['image.cmap'] = 'viridis'

import h5py,os,sys
from flash_tools import *
root_dir = os.path.abspath(".") + "/../"
sys.path.append(root_dir)
import params

import seaborn as sns
sns.set_style("white")


Populating the interactive namespace from numpy and matplotlib

In [11]:
runs = {}
types = ["sample", "holography", "cluster"]
params_fn = "%s/params.csv" % (root_dir)
for t in types:
    runs[t] = params.run_numbers(params_fn, t)

In [15]:
# hit rates
hit_rates = {}
mul_rates = {}
for t in types:
    hit_rates[t] = []
    mul_rates[t] = []
    for run_nr in runs[t]:
        #print "Run: %i" % run_nr
        if not file_exists(run_nr=run_nr, sub_folder="hummingbird",ol=1):
            print "WARNING: File does not exist - skipping this run."
            hr = 0
            mr = 0
            
        else:
            hr = calc_hitrate(run_nr=run_nr)
            mr = calc_mulrate(run_nr=run_nr)
        hit_rates[t].append(0 if hr is None else hr)
        mul_rates[t].append(0 if mr is None else mr)
        if hr > 0.8:
            print run_nr
    hit_rates[t] = asarray(hit_rates[t])
    mul_rates[t] = asarray(mul_rates[t])

In [ ]:
fig, (ax1, ax2) = subplots(2, 1, sharex=True, figsize=(12, 8))
for t,c in zip(types, ["red", "blue", "green"]):
    ax1.semilogy(runs[t], 100*hit_rates[t], "+", ms=15, color=c)
    ax2.semilogy(runs[t], 100*mul_rates[t], "+", ms=15, color=c)
ax1.legend(types)
ax1.set_xlim(None, 350)
ax1.set_ylim(0, 100)
ax2.set_ylim(0, None)
ax1.set_ylabel("Total hit rate [%]")
ax2.set_ylabel("Multiple hit rate [%]")
ax2.set_xlabel("Run number")
#savefig("rates.png", dpi=350)

In [66]:
d_root = "multiples"
os.system("mkdir %s" % d_root)
for t in types:
    d = "%s/%s" % (d_root, t)
    os.system("mkdir %s" % d)
    for r in runs[t]:
        print "run %i" % r
        mulscores = read_mulscores(run_nr=r, ol=5)
        if mulscores is None:
            continue
        ind = mulscores.argsort()[::-1]
        for k,i in enumerate(ind):
            print (k+1),len(ind)
            I = read_intensities(run_nr=r, i=i, ol=5)
            P = read_patterson(run_nr=r, i=i, ol=5)
            #M = read_patterson_mask(run_nr=r, i=i)
            imsave("%s/r%04i_%04i_intensitites.png" % (d,r,k), I, vmin=50, vmax=500, cmap='plasma')
            imsave("%s/r%04i_%04i_patterson.png" % (d,r,k), P, vmin=0, vmax=10, cmap='gnuplot')
            #imsave("%s/r%04i_%04i_patterson_mask.png" % (d,run_nr,k), M, cmap='viridis')


run 118
1 24
2 24
3 24
4 24
5 24
6 24
7 24
8 24
9 24
10 24
11 24
12 24
13 24
14 24
15 24
16 24
17 24
18 24
19 24
20 24
21 24
22 24
23 24
24 24
run 129
1 17
2 17
3 17
4 17
5 17
6 17
7 17
8 17
9 17
10 17
11 17
12 17
13 17
14 17
15 17
16 17
17 17
run 130
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
9 10
10 10
run 121
run 122
1 4
2 4
3 4
4 4
run 123
1 19
2 19
3 19
4 19
5 19
6 19
7 19
8 19
9 19
10 19
11 19
12 19
13 19
14 19
15 19
16 19
17 19
18 19
19 19
run 115
1 35
2 35
3 35
4 35
5 35
6 35
7 35
8 35
9 35
10 35
11 35
12 35
13 35
14 35
15 35
16 35
17 35
18 35
19 35
20 35
21 35
22 35
23 35
24 35
25 35
26 35
27 35
28 35
29 35
30 35
31 35
32 35
33 35
34 35
35 35
run 117
1 9
2 9
3 9
4 9
5 9
6 9
7 9
8 9
9 9
run 119
1 8
2 8
3 8
4 8
5 8
6 8
7 8
8 8
run 128
1 17
2 17
3 17
4 17
5 17
6 17
7 17
8 17
9 17
10 17
11 17
12 17
13 17
14 17
15 17
16 17
17 17
run 131

In [ ]:


In [ ]: