In [1]:
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')
In [62]:
import numpy as np
import scipy.io as sio
import os
import sys
import matplotlib.pyplot as plt
import matplotlib.colors
from matplotlib.pyplot import cm
import inspect
import seaborn as sns
sns.set(style='ticks')
In [7]:
# Load the bicorr.py functions I have already developed
sys.path.append('../scripts')
import bicorr as bicorr
import bicorr_plot as bicorr_plot
import bicorr_math as bicorr_math
In [8]:
%load_ext autoreload
%autoreload 2
In [9]:
os.listdir('../meas_info/')
Out[9]:
In [10]:
det_df = bicorr.load_det_df('../meas_info/det_df_pairs_angles.csv',plot_flag=True)
In [11]:
chList, fcList, detList, num_dets, num_det_pairs = bicorr.build_ch_lists(print_flag=True)
In [12]:
os.listdir('../analysis/Cf072115_to_Cf072215b/')
Out[12]:
In [25]:
bhp_nn_gif_data = np.load('../analysis/Cf072115_to_Cf072215b/bhp_nn_gif.npz')
print(bhp_nn_gif_data.files)
In [26]:
norm_factor = bhp_nn_gif_data['norm_factor']
bhp_nn_pos = bhp_nn_gif_data['bhp_nn_pos']
bhp_nn_neg = bhp_nn_gif_data['bhp_nn_neg']
bhp_nn_diff = bhp_nn_gif_data['bhp_nn_diff']
th_bin_edges= bhp_nn_gif_data['th_bin_edges']
th_bin_centers = (th_bin_edges[:-1]+th_bin_edges[1:])/2
dt_bin_edges= bhp_nn_gif_data['dt_bin_edges']
dt_bin_edges_neg= bhp_nn_gif_data['dt_bin_edges_neg']
In [27]:
bhp_nn_diff.shape
Out[27]:
Sum along first axis to make distribution across all angles. Multiply by norm_factor so we're working with counts (instead of normalized).
In [28]:
for i in range(len(norm_factor)):
bhp_nn_diff[i,:,:] = norm_factor[i] * bhp_nn_diff[i,:,:]
bhp = np.sum(bhp_nn_diff,axis=0)
bhp.shape
Out[28]:
In [30]:
bicorr.bhp_plot(bhp,dt_bin_edges,show_flag = True,vmin=1)
Coarsen time binning.
In [31]:
bhp, dt_bin_edges = bicorr.coarsen_bhp(bhp, dt_bin_edges, 8, normalized = True, print_flag = True)
In [32]:
bicorr.bhp_plot(bhp,dt_bin_edges,show_flag = True, vmin=1)
In [42]:
dt_bin_centers = bicorr.calc_centers(dt_bin_edges)
In [27]:
i = 25
print(dt_bin_edges[i])
print(dt_bin_edges[i+1])
print(dt_bin_centers[i])
In [28]:
t = 51
i = np.digitize(t,dt_bin_edges)-1
In [29]:
print(dt_bin_edges[i])
print(dt_bin_edges[i+1])
print(dt_bin_centers[i])
In [30]:
plt.figure(figsize=(4,4))
plt.plot(dt_bin_centers,bhp[i,:],'.-k',linewidth=.5)
plt.xlabel('$\Delta t_2$')
plt.ylabel('Normalized counts')
plt.title('Slice at $\Delta t_1$ = {}'.format(dt_bin_centers[i]))
plt.tight_layout()
plt.show()
In [31]:
plt.figure(figsize=(4,4))
plt.plot(dt_bin_centers,bhp[i,:],'.-k',linewidth=.5)
plt.xlabel('$\Delta t_2$')
plt.ylabel('Normalized counts')
plt.title('$\Delta t_1$ = {}'.format(dt_bin_centers[i]))
plt.tight_layout()
plt.show()
This works, but I need to work with the full dataset and coarsen the timing.
The way I am plotting the distribution above, I am holding $\Delta t_1$ constant and looking at $\Delta t_2$. This means that I am looking at the distribution of detctor 2 with detector 1 held constant.
This introduces some bias, or more precisely, removes a biased set of channels from the distribution.
Since detctor pairs are organizes such that det1ch < det2ch
, I am looking at the distribution of neutron times for the higher detector channels.
In [32]:
bicorr.plot_det_df(det_df, which='index')
In order to include all data, I need to take the sum of all detectors pairs in both directions. Try it out.
In [33]:
plt.figure(figsize=(4,4))
plt.plot(dt_bin_centers,bhp[i,:]+bhp[:,i],'.-',linewidth=.5)
plt.xlabel('$\Delta t_2$')
plt.ylabel('Normalized counts')
plt.title('$\Delta t_1$ = {}'.format(dt_bin_centers[i]))
plt.tight_layout()
plt.show()
In [88]:
t_slices = [30,40,50,60,70,80,90]
In [90]:
bicorr.bhp_plot(bhp,dt_bin_edges,title='bhp',clear=False,vmin=1)
for t in t_slices:
plt.axvline(t,c='w')
plt.show()
In [91]:
bhp_slices = np.zeros((len(t_slices),len(dt_bin_centers)))
In [93]:
plt.figure(figsize=(4,3))
for t in t_slices:
i = t_slices.index(t) # Works as long as t_slices is unique
bhp_slices[i,:] = bhp[i,:]+bhp[:,i]
plt.plot(dt_bin_centers,bhp_slices[i,:],'.-',linewidth=.5)
plt.xlabel('Time (ns)')
plt.ylabel('Counts / (fission-ns2-pair)')
plt.legend([str(t) for t in t_slices])
plt.title('Non-normalized bhp slices')
sns.despine(right=False)
plt.show()
In [94]:
plt.figure(figsize=(4,3))
for t in t_slices:
i = t_slices.index(t) # Works as long as t_slices is unique
bhp_slices[i,:] = bhp[i,:]+bhp[:,i]
plt.plot(dt_bin_centers,bhp_slices[i,:]/np.sum(bhp_slices[i,:]),'.-',linewidth=.5)
plt.xlabel('Time (ns)')
plt.ylabel('Counts / (fission-ns2-pair)')
plt.legend([str(t) for t in t_slices])
plt.title('Normalized bhp slices by integral')
sns.despine(right=False)
plt.show()
In [95]:
plt.figure(figsize=(4,3))
for t in t_slices:
i = t_slices.index(t) # Works as long as t_slices is unique
bhp_slices[i,:] = bhp[i,:]+bhp[:,i]
plt.plot(dt_bin_centers,bhp_slices[i,:]/np.max(bhp_slices[i,:]),'.-',linewidth=.5)
plt.xlabel('Time (ns)')
plt.ylabel('Counts / (fission-ns2-pair)')
plt.legend([str(t) for t in t_slices])
plt.title('Normalized bhp slices by height')
sns.despine(right=False)
plt.show()
In [33]:
help(bicorr.slice_bhp)
In [96]:
bhp_slice, slice_dt_range = bicorr.slice_bhp(bhp,dt_bin_edges,50.0,53.0,True)
In [97]:
t_slices
print(t_slices)
In [98]:
bhp_slices, slice_dt_ranges = bicorr.slices_bhp(bhp,dt_bin_edges,t_slices)
In [169]:
help(bicorr.plot_bhp_slice)
In [167]:
bicorr_plot.plot_bhp_slice(bhp_slice, dt_bin_edges, slice_range = slice_dt_range, show_flag = True, normalized='max', title='Normalized by max')
bicorr_plot.plot_bhp_slice(bhp_slice, dt_bin_edges, slice_range = slice_dt_range, show_flag = True, normalized='int', title='Normalized by integral')
In [173]:
bicorr_plot.plot_bhp_slices(bhp_slices,dt_bin_edges,slice_dt_ranges);
In [131]:
energy_bin_edges = np.asarray(np.insert([bicorr.convert_time_to_energy(t) for t in dt_bin_edges[1:]],0,10000))
How do time and energy relate?
In [132]:
plt.figure(figsize=(4,3))
plt.plot(dt_bin_edges,energy_bin_edges,'.-k',linewidth=.5)
plt.yscale('log')
plt.xlabel('time (ns)')
plt.ylabel('enregy (MeV)')
sns.despine(right=False)
plt.title('Relationship between time and energy')
plt.show()
The problem here is that the distance to each detector is slightly different so the conversion is different for each detector.
I did some analysis to show that the conversion introduces an error large enough that we need to go back to the bicorr
script and make bhm_e
on an event-by-event basis.
Investigate this in methods > time_energy_bin_edges
. Create bhm_e
in methods > build_bhm_with_energy.ipynb
.
In [ ]: