Ora spostiamo tutto in un modulo (file con estensione .py) e riscriviamo da 0

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from insulab_testbeam_functions import dataframe_from_run


datadir='axial_example'
nrun = 300097

df = dataframe_from_run(datadir,300097)

Analisi

head e tail

In [2]:
df.head(2)
Out[2]:
tele0 tele1 tele2 tele3 bc0 bc1 clu0 clu1 clu2 clu3 ... time6 time7 gonio0 gonio1 gonio2 gonio3 gonio4 step event_n event_time
0 0.71793 0.30609 0.60781 0.46317 3.8587 2.8515 2.0 2.0 2.0 2.0 ... 245.0 119.0 548.2254 -11000.653 25.199999 0.0 0.0 19.0 4.0 98983.0
1 1.20000 0.75151 1.03250 1.08000 4.2592 3.5468 1.0 2.0 2.0 1.0 ... 384.0 384.0 548.2254 -11000.653 25.199999 0.0 0.0 19.0 4.0 98985.0

2 rows × 50 columns

In [3]:
df.tail(3)
Out[3]:
tele0 tele1 tele2 tele3 bc0 bc1 clu0 clu1 clu2 clu3 ... time6 time7 gonio0 gonio1 gonio2 gonio3 gonio4 step event_n event_time
300926 1.4500 0.10588 1.49290 0.2450 4.8158 2.6398 1.0 2.0 2.0 1.0 ... 511.0 481.0 1449.7229 -11000.653 25.199999 0.0 0.0 91.0 22.0 500401.0
300927 0.9650 1.40930 0.80500 1.7100 2.6948 9.3790 1.0 3.0 1.0 1.0 ... 403.0 75.0 1449.7229 -11000.653 25.199999 0.0 0.0 91.0 22.0 500404.0
300928 1.1326 0.97113 0.95152 1.3066 4.3633 3.7817 2.0 2.0 2.0 2.0 ... 410.0 240.0 1449.7229 -11000.653 25.199999 0.0 0.0 91.0 22.0 500407.0

3 rows × 50 columns

bema profile

In [4]:
# histograms
for i in range(4):
    plt.subplot(221+i)
    plt.hist(df['tele%i'%i],100)

Angolo in ingresso (divergenza), angolo in uscita

In [10]:
df['angX'] = (df['tele2'] - df['tele0'])/55.3
df['angY'] = (df['tele3'] - df['tele1'])/55.3
for n,dato in enumerate(['angX','angY']):
    plt.subplot(221+n)
    plt.hist(df[dato],100)
In [11]:
df['exitX'] = (df['bc0'] - df['tele2'])/102
df['exitY'] = (df['bc1'] - df['tele3'])/102

for n,dato in enumerate(['bc0','bc1']):
    plt.subplot(221+n)
    plt.hist(df[dato],100)
In [12]:
df['deflX'] = df['exitX'] - df['angX']
df['deflY'] = df['exitY'] - df['angY']

for n,dato in enumerate(['deflX','deflY']):
    plt.subplot(221+n)
    plt.hist(df[dato],100)
In [13]:
plt.hist2d(df['deflX'],df['angX']*102 + df['tele2'],100)
plt.show()
In [14]:
# for accessing logscale
import matplotlib.colors as colors
plt.figure(figsize=(20,8))
for i in range(8):
    plt.subplot(241+i)
    plt.hist2d(df['time%d'%i],df['ph%d'%i],[500,100], norm=colors.LogNorm())

plt.show()