<jupyter_start><jupyter_text>Integrated Spectrum and Peaks generated from Etchverry Roof Data* This program uses bokeh, and outputs an HTML file containing the plot when it's done running<jupyter_code>from bokeh.plotting import *
import pandas as pd
import numpy as np
from bokeh.layouts import row

df = pd.read_csv('etch_roof_d3s.csv') # The name of the file can be changed depending on the user's needs

arr = df.as_matrix(columns=df.columns[6:]) # Contains all counts per channel

conv = df.as_matrix(columns=df.columns[5:6]).ravel() # Contains list of calibration constants
# arr contains all the counts per channel, but it doesn't include which channel the counts belong to
# In order to account for that, we must create a new array called channels, which is quite simply a list of all the channel numbers

i = 0
channels = []

while i <=1023:
    channels.append(i)
    i= i+1

######################################################################################################################
# This code aims to sort counts into bins based on the energy of their channel, and in order to do this, we must create an 
# array containing all the bin edges

m = 200
bins = []
while m<=2600:
    bins.append(m)
    m =m+5

######################################################################################################################

buckets = [0] * 1300 # This is the empty array that all our counts will eventually be sorted into
# This cell multiplies the list of channels by each element in the list of calibration factors and sums the results into the previously created energy bins

k = 0

while k < len(conv):

    if k%100 == 0:
        print k

    kev = [i * conv[k] for i in channels]

    indexes = np.digitize(kev, bins).flatten()

    i = 0
    while i < len(indexes):
          buckets[indexes[i]-1] = buckets[indexes[i]-1] + arr[k][i]
          i = i+1

    k = k+1

# Bismuth 214 has a peak at around 620 kev

bismuthA = buckets[70:100]

# -----------------------------------------------------------------------------------------------------------------------
# Potassium 40 has a peak at around 1400 kev

potassiumA = buckets[230:270]

# -----------------------------------------------------------------------------------------------------------------------
# Bismuth 214 has a peak at around 2400 kev

thoriumA = buckets[423:450]
p = figure(y_axis_type="log",title="Entire Spectrum")
p.circle(bins,buckets)

p1 = figure(y_axis_type="log",title="Bismuth Peak")
p1.circle(bins[70:97],bismuthA,color = 'blue')

p2 = figure(y_axis_type="log",title="Potassium Peak")
p2.circle(bins[230:270],potassiumA,color = 'red')

# -----------------------------------------------------------------------------------------------------------------------
# Used to calibrate the thorium peak
# In this code, it is not important

#point = [(bins[423],thoriumA[0]),(bins[450],thoriumA[len(thoriumA)-1])]
#m = ((math.log(18475)-math.log(19395))/(2450-2315))
#c = 10.7061162898
#A = math.exp(c)

#xarino = np.arange(2315,2450) 
#y = (A*np.exp((m*xarino)))

#print np.trapz(y,x=xarino)

# -----------------------------------------------------------------------------------------------------------------------


p3 = figure(y_axis_type="log",title="Thallium Peak")
p3.circle(bins[423:450],thoriumA, color = 'green')

show(row(p,p1,p2,p3))<jupyter_output>/Users/albertqiang/anaconda2/lib/python2.7/site-packages/bokeh/models/sources.py:110: BokehUserWarning: ColumnDataSource's columns must be of the same length. Current lengths: ('x', 481), ('y', 1300)
  "Current lengths: %s" % ", ".join(sorted(str((k, len(v))) for k, v in data.items())), BokehUserWarning))
/Users/albertqiang/anaconda2/lib/python2.7/site-packages/bokeh/models/sources.py:110: BokehUserWarning: ColumnDataSource's columns must be of the same length. Current lengths: ('x', 27), ('y', 30)
  "Current lengths: %s" % ", ".join(sorted(str((k, len(v))) for k, v in data.items())), BokehUserWarning))
{'fraction_non_alphanumeric': 0.285426629750818, 'fraction_numerical': 0.04102693178957966, 'mean_word_length': 2.689879294336119, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '130231', 'license': 'MIT', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1164, 'n_words': 367, 'path': 'D3S_analysis/Peaks and Spectrum (Etchverry).ipynb', 'repo_name': 'kevinlmao/dosenet-analysis', 'size': '3973'}