Ora spostiamo tutto in un modulo (file con estensione .py) e riscriviamo da 0
%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)
head e tail
df.head(2)
df.tail(3)
bema profile
# histograms
for i in range(4):
plt.subplot(221+i)
plt.hist(df['tele%i'%i],100)
Angolo in ingresso (divergenza), angolo in uscita
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)
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)
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)
plt.hist2d(df['deflX'],df['angX']*102 + df['tele2'],100)
plt.show()
# 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()