In [1]:
import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np
import glob
In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np
import glob
for f in glob.iglob("./data/data*.h5"): # generator, search immediate subdirectories
#print ' ', f
#break
#with h5py.File('./data/data01_*.h5','r') as hf:
with h5py.File(f,'r') as hf:
#print('List of arrays in this file: \n', hf.keys())
'''
print 'NORMAL'
print ' XINC:', np.array(hf.get('XINC')), ' YINC:', np.array(hf.get('YINC')),
print ' FRAMES:', np.array(hf.get('FRAMES')), ' TRIG:', np.array(hf.get('TRIG')),
print ' XORIGIN:', np.array(hf.get('XORIGIN'))
print ' YORIGIN:', np.array(hf.get('YORIGIN'))
print ' TIME: ', np.array(hf.get('TIME'))
print 'RAW'
print ' XINC:', np.array(hf.get('XINCR')), ' YINC:', np.array(hf.get('YINCR')),
print ' FRAMES:', np.array(hf.get('FRAMES')), ' TRIG:', np.array(hf.get('TRIGR')),
print ' XORIGIN:', np.array(hf.get('XORIGINR'))
print ' YORIGIN:', np.array(hf.get('YORIGINR'))
print ' TIME: ', np.array(hf.get('TIME'))
'''
frames = np.array(hf.get('FRAMES'))
for n in range(1,frames+1):
data = hf.get(str(n))
np_data = 1.0 * np.array(data)
#print 'np_data:', max(np_data)
np_data = np_data - 128 - np.array(hf.get('YORIGIN'))
np_data = np.array(hf.get('YINC')) * np_data * 1000 # to mV
#np_data -= 5
np_time = range(0,1400)
np_time *= np.array(hf.get('XINC'))
np_time *= 1e6 # to microseconds
np_time -= 10 # trigger time offset
np_time += 1.0e6*np.array(hf.get('XORIGIN'))
np_time *= 1.0e-3 # milliseconds are more fun
plt.figure(figsize=(18,5))
plt.plot(np_time, np_data)
plt.title(f)
plt.xlabel('Time [us]')
plt.ylabel('Amplitude [V]')
# Process the raw data
rawdata = hf.get(str(n)+'R')
np_rawdata = 1.0 * np.array(rawdata)
np_rawdata = np_rawdata - 128 - np.array(hf.get('YORIGINR'))
np_rawdata = np.array(hf.get('YINCR')) * np_rawdata # to Volts
np_rawtime = range(0,len(np_rawdata))
np_rawtime *= np.array(hf.get('XINCR'))
np_rawtime *= 1e6 # to microseconds
np_rawtime -= 10 # trigger time offset
np_rawtime += 1.0e6*np.array(hf.get('XORIGINR'))
np_rawtime *= 1.0e-3 # milliseconds are more fun
#plt.figure(figsize=(18,5))
#plt.plot(np_rawtime,np_rawdata)
plt.xlabel('Time [us]')
plt.ylabel('Amplitude [mV]')
In [12]:
%matplotlib inline
import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np
plt.rcParams['figure.figsize'] = [18, 5]
for f in glob.iglob("./data/data12_*.h5"): # generator, search immediate subdirectories
print ' ', f
break
#with h5py.File('./data/data01_*.h5','r') as hf:
with h5py.File(f,'r') as hf:
#print('List of arrays in this file: \n', hf.keys())
print 'NORMAL'
print ' XINC:', np.array(hf.get('XINC')), ' YINC:', np.array(hf.get('YINC')),
print ' FRAMES:', np.array(hf.get('FRAMES')), ' TRIG:', np.array(hf.get('TRIG')),
print ' XORIGIN:', np.array(hf.get('XORIGIN'))
print ' YORIGIN:', np.array(hf.get('YORIGIN'))
print ' TIME: ', np.array(hf.get('TIME'))
print 'RAW'
print ' XINC:', np.array(hf.get('XINCR')), ' YINC:', np.array(hf.get('YINCR')),
print ' FRAMES:', np.array(hf.get('FRAMES')), ' TRIG:', np.array(hf.get('TRIGR')),
print ' XORIGIN:', np.array(hf.get('XORIGINR'))
print ' YORIGIN:', np.array(hf.get('YORIGINR'))
print ' TIME: ', np.array(hf.get('TIME'))
frames = np.array(hf.get('FRAMES'))
for n in range(1,frames+1):
data = hf.get(str(n))
np_data = 1.0 * np.array(data)
#print 'np_data:', max(np_data)
np_data = np_data - 128 - np.array(hf.get('YORIGIN'))
np_data = np.array(hf.get('YINC')) * np_data # to Volts
np_data -= 5
np_time = range(0,1400)
np_time *= np.array(hf.get('XINC'))
np_time *= 1e6 # to microseconds
np_time -= 10 # trigger time offset
np_time += 1.0e6*np.array(hf.get('XORIGIN'))
np_time *= 1.0e-3 # milliseconds are more fun
#plt.plot(np_time, np_data)
# Process the raw data
rawdata = hf.get(str(n)+'R')
np_rawdata = 1.0 * np.array(rawdata)
np_rawdata = np_rawdata - 128 - np.array(hf.get('YORIGINR'))
np_rawdata = np.array(hf.get('YINCR')) * np_rawdata # to Volts
np_rawtime = range(0,len(np_rawdata))
np_rawtime *= np.array(hf.get('XINCR'))
np_rawtime *= 1e6 # to microseconds
np_rawtime -= 10 # trigger time offset
np_rawtime += 1.0e6*np.array(hf.get('XORIGINR'))
np_rawtime *= 1.0e-3 # milliseconds are more fun
plt.plot(np_rawtime,np_rawdata)
plt.xlabel('Time [us]')
plt.ylabel('Amplitude [V]')
Out[12]:
In [241]:
%matplotlib inline
import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np
import glob
import matplotlib
plt.figure(figsize=(20,10))
x = []
y = []
z = []
all_frames = 0
xinc = 0
yinc = 0
def ProcessData():
global all_frames
global xinc
global yinc
#print('List of arrays in this file: \n', hf.keys())
xinc = np.array(hf.get('XINC'))
yinc = np.array(hf.get('YINC'))
yorigin = np.array(hf.get('YORIGIN'))
xorigin = np.array(hf.get('XORIGIN'))
trig = np.array(hf.get('TRIG'))
capturing = np.array(hf.get('CAPTURING'))
frames = np.array(hf.get('FRAMES'))
all_frames = all_frames + frames
print 'XINC:', xinc, ' YINC:', yinc, ' FRAMES:', frames, ' XORIGIN:', xorigin, ' YORIGIN:', yorigin, ' TRIG:', trig
print 'CAPTURING:', capturing
for n in range(1,frames+1):
data = hf.get(str(n))
#np_data = np.array(data)
np_data = np.array(data)
#np_data += *np.array(hf.get('YORIGIN'))
#np_data = np.array(hf.get('YINC'))*np_data
#plt.plot(np_data)
#print np_data
maximum = 0
minimum = 255
suma = 0
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
if (maximum < 256):
#if (maximum < 254):
x.append(maximum)
#x.append(maximum-np_data[2])
#x.append(maximum-np_data[30])
#y.append(suma/maximum)
y.append(suma)
z.append(minimum)
for f in glob.iglob("./compare/data*.h5"): # generator, search immediate subdirectories
print ' ', f
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
for f in glob.iglob("./compare/**/data*.h5"): # generator, search immediate subdirectories
print ' ', f
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
plt.figure(figsize=(20,10))
ble = plt.hist2d(y, x, bins=(200,128), norm=matplotlib.colors.LogNorm(), cmap=plt.cm.jet)
#ble = plt.hist2d(y, x, bins=(500,200), cmap=plt.cm.jet)
plt.xlabel('Integral of Pulse [square of the step of A/D converter]')
plt.ylabel('Amplitude of Pulse [step of A/D converter]')
#cb = plt.colorbar()
#cb.set_label('Count')
#plt.plot([0,10000],[100,100],ls='-',c='r',marker='o')
#plt.plot([0,100000],[100,1000],c='r',lw=3,zorder=99)
#plt.xlim(60000,160000)
#plt.ylim(50,150)
plt.show()
In [6]:
np.std(x)
Out[6]:
In [242]:
%matplotlib inline
import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np
import glob
import matplotlib
plt.figure(figsize=(20,10))
x = []
y = []
z = []
all_frames = 0
xinc = 0
yinc = 0
def ProcessData():
global all_frames
global xinc
global yinc
#print('List of arrays in this file: \n', hf.keys())
xinc = np.array(hf.get('XINC'))
yinc = np.array(hf.get('YINC'))
yorigin = np.array(hf.get('YORIGIN'))
xorigin = np.array(hf.get('XORIGIN'))
trig = np.array(hf.get('TRIG'))
capturing = np.array(hf.get('CAPTURING'))
frames = np.array(hf.get('FRAMES'))
all_frames = all_frames + frames
#print 'XINC:', xinc, ' YINC:', yinc, ' FRAMES:', frames, ' XORIGIN:', xorigin, ' YORIGIN:', yorigin, ' TRIG:', trig
#print 'CAPTURING:', capturing
for n in range(1,frames+1):
data = hf.get(str(n))
#np_data = np.array(data)
np_data = np.array(data)
#np_data += *np.array(hf.get('YORIGIN'))
#np_data = np.array(hf.get('YINC'))*np_data
#plt.plot(np_data)
#print np_data
maximum = 0
minimum = 255
suma = 0
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
if (maximum < 256):
#if (maximum < 254):
x.append(maximum)
#y.append(suma/maximum)
y.append(suma)
z.append((maximum))
for f in glob.iglob("./data/data*.h5"): # generator, search immediate subdirectories
print ' ', f,
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
for f in glob.iglob("./data/**/xdata*.h5"): # generator, search immediate subdirectories
print ' ', f,
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
plt.figure(figsize=(20,10))
ble = plt.hist2d(y, x, bins=(500,129), norm=matplotlib.colors.LogNorm(), cmap=plt.cm.jet)
#ble = plt.hist2d(y, x, bins=(500,200), cmap=plt.cm.jet)
plt.xlabel('Integral of Pulse [square of the step of A/D converter]')
plt.ylabel('Amplitude of Pulse [step of A/D converter]')
#cb = plt.colorbar()
#cb.set_label('Count')
#plt.plot([0,10000],[100,100],ls='-',c='r',marker='o')
#plt.plot([0,100000],[100,1000],c='r',lw=3,zorder=99)
#plt.xlim(60000,160000)
#plt.ylim(50,150)
plt.show()
In [161]:
matplotlib.rcParams.update({'font.size': 15})
plt.figure(figsize=(20,10))
plt.tight_layout()
ble = plt.hist2d(y, x, bins=(500,203), range= [[25000, 60000], [48,250]], norm=matplotlib.colors.LogNorm(), cmap=plt.cm.jet)
plt.xlabel('Integral of Pulse [steps of ADC multiple by sample time]')
plt.ylabel('Amplitude of Pulse [steps of ADC]')
#plt.xlabel('Plocha pulzu [krok pulzu krat vzorkovaci cas]')
#plt.ylabel('Amplituda pulzu [kroky ADC]')
plt.title('PCRD, V_bias 3 V, step of ADC = ' + str(yinc) + ' [V], step of time = ' + str(xinc) + ' [s], frames = '+ str(all_frames))
cb = plt.colorbar()
cb.set_label('Counts')
In [136]:
matplotlib.rcParams.update({'font.size': 15})
plt.figure(figsize=(20,10))
ble = plt.hist(y, bins=250)
plt.yscale('log')
#plt.xscale('log')
#plt.ylim(0,200)
#plt.xlim(1000,140000)
plt.xlabel('Integral')
plt.ylabel('Counts')
plt.title('Surface')
Out[136]:
In [243]:
matplotlib.rcParams.update({'font.size': 18})
plt.figure(figsize=(15,8))
ble = plt.hist(x, bins=256-40-1, range=(40,256), histtype='step' )
plt.yscale('log')
#plt.xscale('log')
#plt.ylim(0,200)
plt.xlim(40,256)
plt.xlabel('Ch.')
plt.ylabel('Counts')
plt.title('Amplitude')
Out[243]:
In [79]:
matplotlib.rcParams.update({'font.size': 15})
x = []
y = []
z = []
all_frames = 0
xinc = 0
yinc = 0
def ProcessData():
global all_frames
global xinc
global yinc
#print('List of arrays in this file: \n', hf.keys())
xinc = np.array(hf.get('XINC'))
yinc = np.array(hf.get('YINC'))
yorigin = np.array(hf.get('YORIGIN'))
frames = np.array(hf.get('FRAMES'))
all_frames = all_frames + frames
print 'XINC:', xinc, ' YINC:', yinc, ' FRAMES:', frames, ' YORIGIN:', yorigin
for n in range(1,frames+1):
data = hf.get(str(n))
#np_data = np.array(data)
np_data = np.array(data)
#np_data += *np.array(hf.get('YORIGIN'))
#np_data = np.array(hf.get('YINC'))*np_data
#plt.plot(np_data)
#print np_data
maximum = 0
minimum = 255
suma = 0
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
x.append(maximum)
#y.append(suma/maximum)
y.append(suma)
z.append((maximum))
def Cut(maxmax,minmin,colour):
for f in glob.iglob("./data/**/data*.h5"): # generator, search immediate subdirectories
try:
with h5py.File(f,'r') as hf:
frames = np.array(hf.get('FRAMES'))
for n in range(1,frames+1):
data = hf.get(str(n))
np_data = 1.0 * np.array(data)
maximum = 0
minimum = 255
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
if (maximum <= maxmax) and (maximum >= minmin):
plt.plot(np_data, c=colour)
except:
pass
for f in glob.iglob("./data/**/data*.h5"): # generator, search immediate subdirectories
print f,
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
plt.figure(1,figsize=(20,10))
matplotlib.rc('axes',edgecolor='black')
#ble = plt.hist2d(y, x, bins=(500,128), norm=matplotlib.colors.LogNorm(), cmap=plt.cm.jet)
ble = plt.hist2d(y, x, bins=(500,128), cmap=plt.cm.jet)
#plt.xlim(60000,125000)
#plt.ylim(50,225)
plt.title('CANDY')
plt.xlabel('Integral of Pulse [square of step of A/D converter]')
plt.ylabel('Amplitude of Pulse [step of A/D converter]')
cb = plt.colorbar()
maxmax1 = 100
maxmax2 = 100
maxmax3 = 100
maxmax4 = 46
maxmax5 = 35
width = 1
minmin1 = maxmax1-width
plt.plot([0,150000],[maxmax1,maxmax1],c='r',lw=1,zorder=99)
plt.plot([0,150000],[minmin1,minmin1],c='r',lw=1,zorder=99)
minmin2 = maxmax2-width
plt.plot([0,150000],[maxmax2,maxmax2],c='g',lw=1,zorder=99)
plt.plot([0,150000],[minmin2,minmin2],c='g',lw=1,zorder=99)
minmin3 = maxmax3-width
plt.plot([0,150000],[maxmax3,maxmax3],c='purple',lw=1,zorder=99)
plt.plot([0,150000],[minmin3,minmin3],c='purple',lw=1,zorder=99)
minmin4 = maxmax4-width
plt.plot([0,150000],[maxmax4,maxmax4],c='orange',lw=1,zorder=99)
plt.plot([0,150000],[minmin4,minmin4],c='orange',lw=1,zorder=99)
minmin5 = maxmax5-width
plt.plot([0,150000],[maxmax5,maxmax5],c='grey',lw=1,zorder=99)
plt.plot([0,150000],[minmin5,minmin5],c='grey',lw=1,zorder=99)
plt.figure(2,figsize=(7,7))
#matplotlib.rc('axes',edgecolor='r')
Cut(maxmax1,minmin1,'r')
Cut(maxmax2,minmin2,'g')
Cut(maxmax3,minmin3,'purple')
Cut(maxmax4,minmin4,'orange')
Cut(maxmax5,minmin5,'grey')
plt.xlabel('Sample Number ['+ str(xinc*1e9)+' ns per sample]')
plt.ylabel('Amplitude [step of A/D converter, '+ str(yinc*1e3) + ' mV per step]')
plt.show()
In [31]:
matplotlib.rcParams.update({'font.size': 15})
x = []
y = []
z = []
all_frames = 0
xinc = 0
yinc = 0
def ProcessData():
global all_frames
global xinc
global yinc
#print('List of arrays in this file: \n', hf.keys())
xinc = np.array(hf.get('XINC'))
yinc = np.array(hf.get('YINC'))
yorigin = np.array(hf.get('YORIGIN'))
frames = np.array(hf.get('FRAMES'))
all_frames = all_frames + frames
print 'XINC:', xinc, ' YINC:', yinc, ' FRAMES:', frames, ' YORIGIN:', yorigin
for n in range(1,frames+1):
data = hf.get(str(n))
#np_data = np.array(data)
np_data = np.array(data)
#np_data += *np.array(hf.get('YORIGIN'))
#np_data = np.array(hf.get('YINC'))*np_data
#plt.plot(np_data)
#print np_data
maximum = 0
minimum = 255
suma = 0
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
x.append(maximum)
#y.append(suma/maximum)
y.append(suma)
z.append((maximum))
def Cut(maxmax,minmin,colour):
for f in glob.iglob("./data/**/data*.h5"): # generator, search immediate subdirectories
try:
with h5py.File(f,'r') as hf:
frames = np.array(hf.get('FRAMES'))
for n in range(1,frames+1):
data = hf.get(str(n))
np_data = 1.0 * np.array(data)
maximum = 0
minimum = 255
suma = 0
colour = 'black'
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
if (maximum <= maxmax) and (maximum >= minmin):
if (suma>0) and (suma<73000):
colour = 'red'
if (suma>73000) and (suma<82000):
colour = 'green'
if (suma>82000) and (suma<100000):
colour = 'purple'
if (suma>100000) and (suma<150000):
colour = 'orange'
plt.plot(np_data, c=colour)
except:
pass
for f in glob.iglob("./data/**/data*.h5"): # generator, search immediate subdirectories
print f,
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
plt.figure(1,figsize=(20,10))
matplotlib.rc('axes',edgecolor='black')
plt.xlim(42000,175000)
plt.ylim(35,130)
ble = plt.hist2d(y, x, bins=(500,128), norm=matplotlib.colors.LogNorm(), cmap=plt.cm.jet)
plt.title('CANDY x CERF')
plt.xlabel('Integral of Pulse [square of step of A/D converter]')
plt.ylabel('Amplitude of Pulse [step of A/D converter]')
cb = plt.colorbar()
maxmax1 = 190
maxmax2 = 167
maxmax3 = 123
maxmax4 = 105
maxmax5 = 60
width = 4
minmin1 = maxmax1-width
#plt.plot([0,175000],[maxmax1,maxmax1],c='r',lw=1,zorder=99)
#plt.plot([0,175000],[minmin1,minmin1],c='r',lw=1,zorder=99)
minmin2 = maxmax2-width
#plt.plot([0,175000],[maxmax2,maxmax2],c='g',lw=1,zorder=99)
#plt.plot([0,175000],[minmin2,minmin2],c='g',lw=1,zorder=99)
minmin3 = maxmax3-width
plt.plot([0,175000],[maxmax3,maxmax3],c='purple',lw=1,zorder=99)
plt.plot([0,175000],[minmin3,minmin3],c='purple',lw=1,zorder=99)
minmin4 = maxmax4-width
#plt.plot([0,175000],[maxmax4,maxmax4],c='orange',lw=1,zorder=99)
#plt.plot([0,175000],[minmin4,minmin4],c='orange',lw=1,zorder=99)
minmin5 = maxmax5-width
#plt.plot([0,175000],[maxmax5,maxmax5],c='grey',lw=1,zorder=99)
#plt.plot([0,175000],[minmin5,minmin5],c='grey',lw=1,zorder=99)
plt.figure(2,figsize=(7,7))
#matplotlib.rc('axes',edgecolor='r')
#Cut(maxmax1,minmin1,'r')
#Cut(maxmax2,minmin2,'g')
Cut(maxmax3,minmin3,'purple')
#Cut(maxmax4,minmin4,'orange')
#Cut(maxmax5,minmin5,'grey')
plt.xlabel('Sample Number ['+ str(xinc*1e9)+' ns per sample]')
plt.ylabel('Amplitude [step of A/D converter, '+ str(yinc*1e3) + ' mV per step]')
plt.show()
In [32]:
matplotlib.rcParams.update({'font.size': 15})
x = []
y = []
z = []
all_frames = 0
xinc = 0
yinc = 0
def ProcessData():
global all_frames
global xinc
global yinc
#print('List of arrays in this file: \n', hf.keys())
xinc = np.array(hf.get('XINC'))
yinc = np.array(hf.get('YINC'))
yorigin = np.array(hf.get('YORIGIN'))
frames = np.array(hf.get('FRAMES'))
all_frames = all_frames + frames
print 'XINC:', xinc, ' YINC:', yinc, ' FRAMES:', frames, ' YORIGIN:', yorigin
for n in range(1,frames+1):
data = hf.get(str(n))
#np_data = np.array(data)
np_data = np.array(data)
#np_data += *np.array(hf.get('YORIGIN'))
#np_data = np.array(hf.get('YINC'))*np_data
#plt.plot(np_data)
#print np_data
maximum = 0
minimum = 255
suma = 0
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
x.append(maximum)
#y.append(suma/maximum)
y.append(suma)
z.append((maximum))
def Cut(maxmax,minmin,colour):
for f in glob.iglob("./data/**/data*.h5"): # generator, search immediate subdirectories
try:
with h5py.File(f,'r') as hf:
frames = np.array(hf.get('FRAMES'))
for n in range(1,frames+1):
data = hf.get(str(n))
np_data = 1.0 * np.array(data)
maximum = 0
minimum = 255
suma = 0
colour = 'black'
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
if (maximum <= maxmax) and (maximum >= minmin):
if (suma>0) and (suma<73000):
colour = 'purple'
if (suma>73000) and (suma<82000):
print suma, "."
colour = 'red'
if (suma>82000) and (suma<100000):
print suma
colour = 'green'
if (suma>100000) and (suma<150000):
colour = 'orange'
plt.plot(np_data, c=colour)
except:
pass
def VCut(maxmax,minmin,colour):
for f in glob.iglob("./data/**/data*.h5"): # generator, search immediate subdirectories
try:
with h5py.File(f,'r') as hf:
frames = np.array(hf.get('FRAMES'))
for n in range(1,frames+1):
data = hf.get(str(n))
np_data = 1.0 * np.array(data)
maximum = 0
minimum = 255
suma = 0
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
if (suma<=maxmax) and (suma>=minmin):
#print maximum
colour = 'green'
if (maximum>70):
colour = 'red'
plt.plot(np_data, c=colour)
except:
pass
for f in glob.iglob("./data/**/data*.h5"): # generator, search immediate subdirectories
print f,
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
plt.figure(1,figsize=(20,10))
matplotlib.rc('axes',edgecolor='black')
plt.xlim(42000,175000)
plt.ylim(35,130)
ble = plt.hist2d(y, x, bins=(500,128), norm=matplotlib.colors.LogNorm(), cmap=plt.cm.jet)
plt.title('Protons X Photons')
plt.xlabel('Integral of Pulse [square of step of A/D converter]')
plt.ylabel('Amplitude of Pulse [step of A/D converter]')
cb = plt.colorbar()
maxmax1 = 81000
maxmax2 = 167
maxmax3 = 80
maxmax4 = 105
maxmax5 = 60
width = 1
minmin1 = maxmax1-1000
plt.plot([maxmax1,maxmax1],[0,250],c='r',lw=1,zorder=99)
plt.plot([minmin1,minmin1],[0,250],c='r',lw=1,zorder=99)
minmin2 = maxmax2-width
#plt.plot([0,175000],[maxmax2,maxmax2],c='g',lw=1,zorder=99)
#plt.plot([0,175000],[minmin2,minmin2],c='g',lw=1,zorder=99)
minmin3 = maxmax3-width
plt.plot([0,175000],[maxmax3,maxmax3],c='purple',lw=1,zorder=99)
plt.plot([0,175000],[minmin3,minmin3],c='purple',lw=1,zorder=99)
minmin4 = maxmax4-width
#plt.plot([0,175000],[maxmax4,maxmax4],c='orange',lw=1,zorder=99)
#plt.plot([0,175000],[minmin4,minmin4],c='orange',lw=1,zorder=99)
minmin5 = maxmax5-width
#plt.plot([0,175000],[maxmax5,maxmax5],c='grey',lw=1,zorder=99)
#plt.plot([0,175000],[minmin5,minmin5],c='grey',lw=1,zorder=99)
plt.figure(2,figsize=(7,7))
#matplotlib.rc('axes',edgecolor='r')
#Cut(maxmax1,minmin1,'r')
#Cut(maxmax2,minmin2,'g')
Cut(maxmax3,minmin3,'purple')
#Cut(maxmax4,minmin4,'orange')
#Cut(maxmax5,minmin5,'grey')
plt.xlabel('Sample Number ['+ str(xinc*1e9)+' ns per sample]')
plt.ylabel('Amplitude [step of A/D converter, '+ str(yinc*1e3) + ' mV per step]')
plt.figure(3,figsize=(7,7))
#matplotlib.rc('axes',edgecolor='r')
#Cut(maxmax1,minmin1,'r')
#Cut(maxmax2,minmin2,'g')
VCut(maxmax1,minmin1,'purple')
#Cut(maxmax4,minmin4,'orange')
#Cut(maxmax5,minmin5,'grey')
plt.xlabel('Sample Number ['+ str(xinc*1e9)+' ns per sample]')
plt.ylabel('Amplitude [step of A/D converter, '+ str(yinc*1e3) + ' mV per step]')
plt.show()
In [33]:
%matplotlib inline
import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np
import glob
import matplotlib
plt.figure(figsize=(20,10))
x = []
y = []
z = []
all_frames = 0
xinc = 0
yinc = 0
def ProcessData():
global all_frames
global xinc
global yinc
#print('List of arrays in this file: \n', hf.keys())
xinc = np.array(hf.get('XINC'))
yinc = np.array(hf.get('YINC'))
yorigin = np.array(hf.get('YORIGIN'))
frames = np.array(hf.get('FRAMES'))
all_frames = all_frames + frames
print 'XINC:', xinc, ' YINC:', yinc, ' FRAMES:', frames, ' YORIGIN:', yorigin
for n in range(1,frames+1):
data = hf.get(str(n))
#np_data = np.array(data)
np_data = np.array(data)
#np_data += *np.array(hf.get('YORIGIN'))
#np_data = np.array(hf.get('YINC'))*np_data
#plt.plot(np_data)
#print np_data
maximum = 0
minimum = 255
suma = 0
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
if (maximum < 151):
x.append(maximum)
#y.append(suma/maximum)
y.append(suma)
z.append((maximum))
for f in glob.iglob("./data/data*.h5"): # generator, search immediate subdirectories
print f,
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
for f in glob.iglob("./data/**/data*.h5"): # generator, search immediate subdirectories
print f,
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
plt.figure(figsize=(20,10))
ble = plt.hist2d(y, x, bins=(500,150), norm=matplotlib.colors.LogNorm(), cmap=plt.cm.jet)
#ble = plt.hist2d(y, x, bins=(500,200), cmap=plt.cm.jet)
plt.xlabel('Integral of Pulse [square of the step of A/D converter]')
plt.ylabel('Amplitude of Pulse [step of A/D converter]')
#cb = plt.colorbar()
#cb.set_label('Count')
#plt.plot([0,10000],[100,100],ls='-',c='r',marker='o')
#plt.plot([0,100000],[100,1000],c='r',lw=3,zorder=99)
#plt.xlim(60000,160000)
#plt.ylim(50,150)
plt.show()
In [34]:
%matplotlib inline
import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np
import glob
import matplotlib
plt.figure(figsize=(20,10))
x = []
y = []
z = []
all_frames = 0
xinc = 0
yinc = 0
def ProcessData():
global all_frames
global xinc
global yinc
#print('List of arrays in this file: \n', hf.keys())
xinc = np.array(hf.get('XINC'))
yinc = np.array(hf.get('YINC'))
yorigin = np.array(hf.get('YORIGIN'))
xorigin = np.array(hf.get('XORIGIN'))
trig = np.array(hf.get('TRIG'))
capturing = np.array(hf.get('CAPTURING'))
frames = np.array(hf.get('FRAMES'))
all_frames = all_frames + frames
print 'XINC:', xinc, ' YINC:', yinc, ' FRAMES:', frames, ' XORIGIN:', xorigin, ' YORIGIN:', yorigin, ' TRIG:', trig
print 'CAPTURING:', capturing
for n in range(1,frames+1):
data = hf.get(str(n))
#np_data = np.array(data)
np_data = np.array(data)
#np_data += *np.array(hf.get('YORIGIN'))
#np_data = np.array(hf.get('YINC'))*np_data
#plt.plot(np_data)
#print np_data
maximum = 0
minimum = 255
suma = 0
for i in range(1400):
if np_data[i] > maximum:
maximum = np_data[i]
if np_data[i] < minimum:
minimum = np_data[i]
suma = suma + np_data[i]
if (maximum < 256):
#if (maximum < 254):
x.append(maximum)
#y.append(suma/maximum)
y.append(suma)
z.append((maximum))
for f in glob.iglob("./dataB/data*.h5"): # generator, search immediate subdirectories
print ' ', f
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
for f in glob.iglob("./dataB/**/data*.h5"): # generator, search immediate subdirectories
print ' ', f
try:
with h5py.File(f,'r') as hf:
ProcessData()
except:
pass
plt.figure(figsize=(20,10))
ble = plt.hist2d(y, x, bins=(500,129), norm=matplotlib.colors.LogNorm(), cmap=plt.cm.jet)
#ble = plt.hist2d(y, x, bins=(500,200), cmap=plt.cm.jet)
plt.xlabel('Integral of Pulse [square of the step of A/D converter]')
plt.ylabel('Amplitude of Pulse [step of A/D converter]')
#cb = plt.colorbar()
#cb.set_label('Count')
#plt.plot([0,10000],[100,100],ls='-',c='r',marker='o')
#plt.plot([0,100000],[100,1000],c='r',lw=3,zorder=99)
#plt.xlim(60000,160000)
#plt.ylim(50,150)
plt.show()
In [ ]: