In [1]:
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')
bhp_e
I learned that we can't go from bhp
in time space to energy space because of the nonuniform binning, so I built a method to generate bhm_e
on an event by event bases (methods > build_bhm_with_energy.ipynb
), then plot as bhp_e
(methods > build_plot_bhp_e.ipynb
), and now I'm going to do some slices.
P. Schuster
University of Michigan
June 28 2018
In [1]:
import matplotlib.pyplot as plt
import matplotlib.colors
import numpy as np
import os
import scipy.io as sio
import sys
import time
import inspect
import pandas as pd
from tqdm import *
# Plot entire array
np.set_printoptions(threshold=np.nan)
In [2]:
%load_ext autoreload
%autoreload 2
In [3]:
sys.path.append('../scripts/')
import bicorr as bicorr
import bicorr_plot as bicorr_plot
import bicorr_e as bicorr_e
import bicorr_math as bicorr_math
Steps in the process:
bhm_e
bhp_e
bhp_e
plot
In [4]:
bhm_e, e_bin_edges, note = bicorr_e.load_bhm_e('../analysis/Cf072115_to_Cf072215b/datap')
In [5]:
print(bhm_e.shape)
print(e_bin_edges.shape)
print(note)
In [6]:
det_df = bicorr.load_det_df()
In [7]:
dict_pair_to_index, dict_index_to_pair, dict_pair_to_angle = bicorr.build_dict_det_pair(det_df)
In [8]:
num_fissions = 2194651200.00
In [11]:
num_fissions = 2194651200.00
bhp_e, norm_factor = bicorr_e.build_bhp_e(bhm_e,e_bin_edges,num_fissions=num_fissions,print_flag=True)
In [12]:
bicorr_plot.bhp_e_plot(bhp_e, e_bin_edges, zoom_range=[0,6], title = "normalized bhp_e", show_flag = True)
In [13]:
e_slices = list(np.arange(0.5,6,.5))
print(e_slices)
In [14]:
bicorr_plot.bhp_e_plot(bhp_e, e_bin_edges, zoom_range=[0,6], title='Plot of bhp_e', show_flag=False, clear_flag=False)
for e in e_slices:
plt.axvline(e,c='w')
plt.show()
In [15]:
bhp_e_slice, slice_e_range = bicorr_e.slice_bhp_e(bhp_e, e_bin_edges, 2, 2.45, True)
In [16]:
bhp_e_slices,slice_e_ranges = bicorr_e.slices_bhp_e(bhp_e,e_bin_edges,e_slices,0.224)
In [17]:
len(e_bin_edges)
Out[17]:
In [18]:
bhp_e_slices.shape
Out[18]:
In [19]:
slice_e_ranges
Out[19]:
In [20]:
bicorr_plot.plot_bhp_e_slice(bhp_e_slice,e_bin_edges,slice_e_range,
show_flag=True)
In [21]:
bicorr_plot.plot_bhp_e_slices(bhp_e_slices,e_bin_edges,slice_e_ranges)
Out[21]:
In [22]:
bicorr_plot.plot_bhp_e_slices(bhp_e_slices,e_bin_edges,slice_e_ranges,
show_flag = False)
plt.xlim([0,6])
plt.ylim([0,0.01])
plt.show()
Need to work in absolute counts, not normalized counts.
In [23]:
bhp_e, norm_factor = bicorr_e.build_bhp_e(bhm_e,e_bin_edges,print_flag=True)
In [24]:
bhp_e_slices,slice_e_ranges = bicorr_e.slices_bhp_e(bhp_e,e_bin_edges,e_slices,0.224)
print(slice_e_ranges)
In [25]:
E_min = 0.75; E_max = 4;
Eave, Eave_err, Ej = bicorr_e.calc_Eave_slices(bhp_e_slices,e_slices,e_bin_edges,E_min,E_max)
Plot it.
In [36]:
bicorr_plot.plot_Eave_vs_Ej(Eave, Eave_err, Ej)
Over what range was this taken?
In [37]:
bicorr_plot.plot_bhp_e_slices(bhp_e_slices,e_bin_edges,slice_e_ranges,
E_min = E_min, E_max = E_max,
show_flag = False)
plt.xlim([0,6])
plt.ylim([0,0.01])
plt.show()
In [9]:
# Set up data
In [10]:
angle_bin_edges = np.arange(8,190,10)
angle_bin_centers = bicorr_math.calc_centers(angle_bin_edges)
angle_indices = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17]
In [11]:
e_slices = list(np.arange(0.5,6,.5))
E_min = 0.75; E_max = 4;
In [12]:
# Allocate arrays
In [13]:
bhp_e = np.zeros((len(angle_bin_centers),len(e_bin_edges)-1,len(e_bin_edges)-1))
norm_factor = np.zeros(len(angle_bin_centers))
bhp_e_slices = np.zeros((len(angle_bin_centers),len(e_slices),len(e_bin_edges)-1))
Eave = np.zeros((len(angle_bin_centers),len(e_slices)))
Eave_err = np.zeros((len(angle_bin_centers),len(e_slices)))
In [30]:
# Do the calculations
for i in angle_indices: #range(len(angle_bin_centers)):
angle_min = angle_bin_edges[i]
angle_max = angle_bin_edges[i+1]
pair_is = bicorr.generate_pair_is(det_df, angle_min, angle_max)
bhp_e[i,:,:], norm_factor[i] = bicorr_e.build_bhp_e(bhm_e,e_bin_edges,pair_is=pair_is,num_fissions = num_fissions,print_flag=True)
bhp_e_slices[i,:,:],slice_e_ranges = bicorr_e.slices_bhp_e(bhp_e[i,:,:],e_bin_edges,e_slices,0.224)
Eave[i,:], Eave_err[i,:], _ = bicorr_e.calc_Eave_slices(bhp_e_slices[i,:,:],e_slices,e_bin_edges,E_min,E_max,norm_factor=norm_factor[i])
In [31]:
vmin = np.min(bhp_e[np.nonzero(bhp_e)])
vmax = np.max(bhp_e)
In [32]:
Eave_min = np.min(Eave[np.nonzero(Eave)])
Eave_max = np.max(Eave)
In [36]:
# Make the plots
filenames_bhp_e = []
filenames_Eave = []
for i in angle_indices: #range(len(angle_bin_centers)):
angle_min = angle_bin_edges[i]
angle_max = angle_bin_edges[i+1]
title = '{} to {} degrees'.format(angle_min, angle_max)
filename_bhp_e = 'bhp_e_{}_{}_deg'.format(angle_min,angle_max); filenames_bhp_e.append(filename_bhp_e);
bicorr_plot.bhp_e_plot(bhp_e[i,:,:], e_bin_edges, zoom_range = [0,6],
vmin=vmin, vmax=vmax,
title=title, show_flag = True,
save_flag = True, save_filename = filename_bhp_e)
#bicorr_plot.plot_bhp_e_slices(bhp_e_slices[i,:,:],e_bin_edges,slice_e_ranges,
# E_min = E_min, E_max = E_max, title=title,
# save_filename = 'bhp_e_slices_{}_{}_degrees'.format(angle_min,angle_max))
filename_Eave = 'Eave_{}_{}_degrees'.format(angle_min,angle_max); filenames_Eave.append(filename_Eave);
bicorr_plot.plot_Eave_vs_Ej(Eave[i,:], Eave_err[i,:], e_slices, title=title,
y_range = [Eave_min,Eave_max],
save_flag = True, save_filename = filename_Eave)
Save data to file
In [38]:
np.savez('datap/slices_analysis',
angle_bin_edges = angle_bin_edges,
angle_bin_centers = angle_bin_centers,
angle_indices = angle_indices,
e_slices = e_slices,
E_min = E_min, E_max = E_max,
bhp_e = bhp_e, norm_factor=norm_factor,
bhp_e_slices = bhp_e_slices,
Eave=Eave, Eave_err = Eave_err
)
In [39]:
import imageio
In [42]:
images_bhp_e = []
for filename in filenames_bhp_e:
images_bhp_e.append(imageio.imread(os.path.join('fig',filename + '.png')))
imageio.mimsave('fig/animate_bhp_e.gif',images_bhp_e, fps=1)
In [45]:
images_Eave = []
for filename in filenames_Eave:
images_Eave.append(imageio.imread(os.path.join('fig',filename + '.png')))
imageio.mimsave('fig/animate_Eave.gif',images_Eave, fps=1)