Plots of oscilloscope records


In [1]:
import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np
import glob

Read waveforms from the file


In [240]:
%matplotlib inline 

import matplotlib.pyplot as plt
import sys
import os
import time
import h5py
import numpy as np

for f in glob.iglob("./data/data10_*-CHAN1.h5"): # generator, search immediate subdirectories 
    print '  ', f
    break

#with h5py.File('./data/data11.h5','r') as hf:
with h5py.File(f,'r') as hf:
    #print('List of arrays in this file: \n', hf.keys())
    print 'XINC:', np.array(hf.get('XINC')), '   YINC:', np.array(hf.get('YINC')), '   FRAMES:', np.array(hf.get('FRAMES')), '   TRIG:', np.array(hf.get('TRIG')), '   YORIGIN:', np.array(hf.get('YORIGIN'))
    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_time = range(0,1400)
        np_time *= np.array(hf.get('XINC'))
        np_time *= 1e6   # to microseconds
        np_time -= 10    # trigger time offset
        
        #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 n<30:
            print n,',', minimum,',', maximum,',', suma
        
        #if (np_data[170]-minimum < 0.001):
        #    plt.plot(np_time, np_data-minimum) 
        #plt.plot(np_time, np_data-np_data[0]) 
        plt.plot(np_time, np_data) 
        
plt.xlabel('Time [us]')
plt.ylabel('Amplitude [V]')


   ./data/data10_1559318754-CHAN1.h5
XINC: 2e-10    YINC: 0.0016    FRAMES: 508    TRIG: 0.0352    YORIGIN: -99.0
1 , -0.008 , 0.17600000000000002 , 112.53600000000041
2 , -0.008 , 0.22080000000000002 , 153.20320000000012
3 , -0.008 , 0.1568 , 90.66400000000014
4 , -0.009600000000000001 , 0.13440000000000002 , 69.6448000000002
5 , -0.008 , 0.08320000000000001 , 31.849599999999725
6 , -0.0064 , 0.1024 , 49.1376000000001
7 , -0.0064 , 0.1456 , 78.78079999999963
8 , -0.008 , 0.1424 , 79.43999999999964
9 , -0.008 , 0.1072 , 51.22399999999997
10 , -0.008 , 0.1328 , 71.48479999999975
11 , -0.0112 , 0.11520000000000001 , 61.588799999999814
12 , -0.008 , 0.064 , 22.59519999999961
13 , -0.008 , 0.192 , 119.1600000000004
14 , -0.008 , 0.07680000000000001 , 29.77759999999977
15 , -0.008 , 0.0656 , 22.35199999999964
16 , -0.008 , 0.1632 , 97.11840000000024
17 , -0.009600000000000001 , 0.12000000000000001 , 59.44639999999952
18 , -0.008 , 0.0848 , 36.108800000000215
19 , -0.008 , 0.1408 , 78.19039999999991
20 , -0.0048000000000000004 , 0.1696 , 99.71359999999993
21 , -0.008 , 0.10400000000000001 , 51.651199999999996
22 , -0.008 , 0.128 , 67.21439999999986
23 , -0.0064 , 0.062400000000000004 , 22.193599999999613
24 , -0.008 , 0.1184 , 64.88800000000012
25 , -0.0112 , 0.1136 , 57.795199999999724
26 , -0.008 , 0.0864 , 37.90879999999992
27 , -0.008 , 0.168 , 102.65120000000002
28 , -0.008 , 0.064 , 19.947199999999526
29 , -0.008 , 0.1024 , 50.36160000000012
Out[240]:
Text(0,0.5,'Amplitude [V]')

Parse all data files in current directory

Read in all the data files in current directory and process them into a histogram.


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()


   ./compare/data01_1548186723-CHAN1.h5
XINC: 1e-09  YINC: 0.02  FRAMES: 18335  XORIGIN: -1.7e-07  YORIGIN: -77.0  TRIG: 0.0716
CAPTURING: 229.66
<Figure size 1440x720 with 0 Axes>

In [6]:
np.std(x)


Out[6]:
7.2204956677864809

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()


   ./data/data07_1559318603-CHAN1.h5    ./data/data03_1559318400-CHAN1.h5    ./data/data09_1559318704-CHAN1.h5    ./data/data02_1559318349-CHAN1.h5    ./data/data04_1559318451-CHAN1.h5    ./data/data08_1559318653-CHAN1.h5    ./data/data10_1559318754-CHAN1.h5    ./data/data01_1559318299-CHAN1.h5    ./data/data05_1559318502-CHAN1.h5    ./data/data06_1559318552-CHAN1.h5
<Figure size 1440x720 with 0 Axes>

Simply replot the current x, y in a nicer way


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')


Flat histogram (only X or Y)


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]:
Text(0.5,1,'Surface')

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]:
Text(0.5,1,'Amplitude')

Cut Plot


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()


./data/Na/data04_1559143613-CHAN1.h5 XINC: 1e-09  YINC: 0.0015625  FRAMES: 10090  YORIGIN: -119.0
./data/Co/data02_1559142413-CHAN1.h5 XINC: 1e-09  YINC: 0.0015625  FRAMES: 3757  YORIGIN: -119.0
./data/Co/data01_1559141460-CHAN1.h5 XINC: 1e-09  YINC: 0.0015625  FRAMES: 4844  YORIGIN: -119.0

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()


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-31-ccc0108c4e8a> in <module>()
     97 plt.xlabel('Integral of Pulse [square of step of A/D converter]')
     98 plt.ylabel('Amplitude of Pulse [step of A/D converter]')
---> 99 cb = plt.colorbar()
    100 
    101 maxmax1 = 190

/usr/lib/python2.7/dist-packages/matplotlib/pyplot.pyc in colorbar(mappable, cax, ax, **kw)
   2235         ax = gca()
   2236 
-> 2237     ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
   2238     return ret
   2239 colorbar.__doc__ = matplotlib.colorbar.colorbar_doc

/usr/lib/python2.7/dist-packages/matplotlib/figure.pyc in colorbar(self, mappable, cax, ax, use_gridspec, **kw)
   1593                 cax, kw = cbar.make_axes(ax, **kw)
   1594         cax.hold(True)
-> 1595         cb = cbar.colorbar_factory(cax, mappable, **kw)
   1596 
   1597         self.sca(current_ax)

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in colorbar_factory(cax, mappable, **kwargs)
   1328         cb = ColorbarPatch(cax, mappable, **kwargs)
   1329     else:
-> 1330         cb = Colorbar(cax, mappable, **kwargs)
   1331 
   1332     cid = mappable.callbacksSM.connect('changed', cb.on_mappable_changed)

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in __init__(self, ax, mappable, **kw)
    903                 kw['alpha'] = mappable.get_alpha()
    904 
--> 905             ColorbarBase.__init__(self, ax, **kw)
    906 
    907     def on_mappable_changed(self, mappable):

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in __init__(self, ax, cmap, norm, alpha, values, boundaries, orientation, ticklocation, extend, spacing, ticks, format, drawedges, filled, extendfrac, extendrect, label)
    321         # The rest is in a method so we can recalculate when clim changes.
    322         self.config_axis()
--> 323         self.draw_all()
    324 
    325     def _extend_lower(self):

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in draw_all(self)
    346         X, Y = self._mesh()
    347         C = self._values[:, np.newaxis]
--> 348         self._config_axes(X, Y)
    349         if self.filled:
    350             self._add_solids(X, Y, C)

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in _config_axes(self, X, Y)
    442         ax.add_artist(self.patch)
    443 
--> 444         self.update_ticks()
    445 
    446     def _set_label(self):

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in update_ticks(self)
    371         """
    372         ax = self.ax
--> 373         ticks, ticklabels, offset_string = self._ticker()
    374         if self.orientation == 'vertical':
    375             ax.yaxis.set_ticks(ticks)

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in _ticker(self)
    592         formatter.set_data_interval(*intv)
    593 
--> 594         b = np.array(locator())
    595         if isinstance(locator, ticker.LogLocator):
    596             eps = 1e-10

/usr/lib/python2.7/dist-packages/matplotlib/ticker.pyc in __call__(self)
   1536         'Return the locations of the ticks'
   1537         vmin, vmax = self.axis.get_view_interval()
-> 1538         return self.tick_values(vmin, vmax)
   1539 
   1540     def tick_values(self, vmin, vmax):

/usr/lib/python2.7/dist-packages/matplotlib/ticker.pyc in tick_values(self, vmin, vmax)
   1554             if vmin <= 0.0 or not np.isfinite(vmin):
   1555                 raise ValueError(
-> 1556                     "Data has no positive values, and therefore can not be "
   1557                     "log-scaled.")
   1558 

ValueError: Data has no positive values, and therefore can not be log-scaled.
Error in callback <function post_execute at 0x7f9fa8f44848> (for post_execute):
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/matplotlib/pyplot.pyc in post_execute()
    145             def post_execute():
    146                 if matplotlib.is_interactive():
--> 147                     draw_all()
    148 
    149             # IPython >= 2

/usr/lib/python2.7/dist-packages/matplotlib/_pylab_helpers.pyc in draw_all(cls, force)
    148         for f_mgr in cls.get_all_fig_managers():
    149             if force or f_mgr.canvas.figure.stale:
--> 150                 f_mgr.canvas.draw_idle()
    151 
    152 atexit.register(Gcf.destroy_all)

/usr/lib/python2.7/dist-packages/matplotlib/backend_bases.pyc in draw_idle(self, *args, **kwargs)
   2024         if not self._is_idle_drawing:
   2025             with self._idle_draw_cntx():
-> 2026                 self.draw(*args, **kwargs)
   2027 
   2028     def draw_cursor(self, event):

/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.pyc in draw(self)
    472 
    473         try:
--> 474             self.figure.draw(self.renderer)
    475         finally:
    476             RendererAgg.lock.release()

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/figure.pyc in draw(self, renderer)
   1157         dsu.sort(key=itemgetter(0))
   1158         for zorder, a, func, args in dsu:
-> 1159             func(*args)
   1160 
   1161         renderer.close_group('figure')

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)
   2322 
   2323         for zorder, a in dsu:
-> 2324             a.draw(renderer)
   2325 
   2326         renderer.close_group('axes')

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in draw(self, renderer, *args, **kwargs)
    387                               " correctly with this backend.")
    388 
--> 389             im = self.make_image(renderer.get_image_magnification())
    390             if im is None:
    391                 return

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in make_image(self, magnification)
    622         im, xmin, ymin, dxintv, dyintv, sx, sy = \
    623             self._get_unsampled_image(self._A, [_x1, _x2, _y1, _y2],
--> 624                                       transformed_viewLim)
    625 
    626         fc = self.axes.patch.get_facecolor()

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in _get_unsampled_image(self, A, image_extents, viewlim)
    229             else:
    230                 if self._rgbacache is None:
--> 231                     x = self.to_rgba(A, bytes=False)
    232                     # Avoid side effects: to_rgba can return its argument
    233                     # unchanged.

/usr/lib/python2.7/dist-packages/matplotlib/cm.pyc in to_rgba(self, x, alpha, bytes)
    259         # This is the normal case, mapping a scalar array:
    260         x = ma.asarray(x)
--> 261         x = self.norm(x)
    262         x = self.cmap(x, alpha=alpha, bytes=bytes)
    263         return x

/usr/lib/python2.7/dist-packages/matplotlib/colors.pyc in __call__(self, value, clip)
   1002             raise ValueError("minvalue must be less than or equal to maxvalue")
   1003         elif vmin <= 0:
-> 1004             raise ValueError("values must all be positive")
   1005         elif vmin == vmax:
   1006             result.fill(0)

ValueError: values must all be positive
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/IPython/core/formatters.pyc in __call__(self, obj)
    332                 pass
    333             else:
--> 334                 return printer(obj)
    335             # Finally look for special method names
    336             method = get_real_method(obj, self.print_method)

/usr/local/lib/python2.7/dist-packages/IPython/core/pylabtools.pyc in <lambda>(fig)
    245 
    246     if 'png' in formats:
--> 247         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    248     if 'retina' in formats or 'png2x' in formats:
    249         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

/usr/local/lib/python2.7/dist-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt, bbox_inches, **kwargs)
    129 
    130     bytes_io = BytesIO()
--> 131     fig.canvas.print_figure(bytes_io, **kw)
    132     data = bytes_io.getvalue()
    133     if fmt == 'svg':

/usr/lib/python2.7/dist-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2178                     orientation=orientation,
   2179                     dryrun=True,
-> 2180                     **kwargs)
   2181                 renderer = self.figure._cachedRenderer
   2182                 bbox_inches = self.figure.get_tightbbox(renderer)

/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
    525 
    526     def print_png(self, filename_or_obj, *args, **kwargs):
--> 527         FigureCanvasAgg.draw(self)
    528         renderer = self.get_renderer()
    529         original_dpi = renderer.dpi

/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.pyc in draw(self)
    472 
    473         try:
--> 474             self.figure.draw(self.renderer)
    475         finally:
    476             RendererAgg.lock.release()

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/figure.pyc in draw(self, renderer)
   1157         dsu.sort(key=itemgetter(0))
   1158         for zorder, a, func, args in dsu:
-> 1159             func(*args)
   1160 
   1161         renderer.close_group('figure')

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)
   2322 
   2323         for zorder, a in dsu:
-> 2324             a.draw(renderer)
   2325 
   2326         renderer.close_group('axes')

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in draw(self, renderer, *args, **kwargs)
    387                               " correctly with this backend.")
    388 
--> 389             im = self.make_image(renderer.get_image_magnification())
    390             if im is None:
    391                 return

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in make_image(self, magnification)
    622         im, xmin, ymin, dxintv, dyintv, sx, sy = \
    623             self._get_unsampled_image(self._A, [_x1, _x2, _y1, _y2],
--> 624                                       transformed_viewLim)
    625 
    626         fc = self.axes.patch.get_facecolor()

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in _get_unsampled_image(self, A, image_extents, viewlim)
    229             else:
    230                 if self._rgbacache is None:
--> 231                     x = self.to_rgba(A, bytes=False)
    232                     # Avoid side effects: to_rgba can return its argument
    233                     # unchanged.

/usr/lib/python2.7/dist-packages/matplotlib/cm.pyc in to_rgba(self, x, alpha, bytes)
    259         # This is the normal case, mapping a scalar array:
    260         x = ma.asarray(x)
--> 261         x = self.norm(x)
    262         x = self.cmap(x, alpha=alpha, bytes=bytes)
    263         return x

/usr/lib/python2.7/dist-packages/matplotlib/colors.pyc in __call__(self, value, clip)
   1002             raise ValueError("minvalue must be less than or equal to maxvalue")
   1003         elif vmin <= 0:
-> 1004             raise ValueError("values must all be positive")
   1005         elif vmin == vmax:
   1006             result.fill(0)

ValueError: values must all be positive
<matplotlib.figure.Figure at 0x7f9f9e7fbb10>

Vertical Cut


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()


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-32-61752287803a> in <module>()
    128 plt.xlabel('Integral of Pulse [square of step of A/D converter]')
    129 plt.ylabel('Amplitude of Pulse [step of A/D converter]')
--> 130 cb = plt.colorbar()
    131 
    132 maxmax1 = 81000

/usr/lib/python2.7/dist-packages/matplotlib/pyplot.pyc in colorbar(mappable, cax, ax, **kw)
   2235         ax = gca()
   2236 
-> 2237     ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
   2238     return ret
   2239 colorbar.__doc__ = matplotlib.colorbar.colorbar_doc

/usr/lib/python2.7/dist-packages/matplotlib/figure.pyc in colorbar(self, mappable, cax, ax, use_gridspec, **kw)
   1593                 cax, kw = cbar.make_axes(ax, **kw)
   1594         cax.hold(True)
-> 1595         cb = cbar.colorbar_factory(cax, mappable, **kw)
   1596 
   1597         self.sca(current_ax)

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in colorbar_factory(cax, mappable, **kwargs)
   1328         cb = ColorbarPatch(cax, mappable, **kwargs)
   1329     else:
-> 1330         cb = Colorbar(cax, mappable, **kwargs)
   1331 
   1332     cid = mappable.callbacksSM.connect('changed', cb.on_mappable_changed)

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in __init__(self, ax, mappable, **kw)
    903                 kw['alpha'] = mappable.get_alpha()
    904 
--> 905             ColorbarBase.__init__(self, ax, **kw)
    906 
    907     def on_mappable_changed(self, mappable):

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in __init__(self, ax, cmap, norm, alpha, values, boundaries, orientation, ticklocation, extend, spacing, ticks, format, drawedges, filled, extendfrac, extendrect, label)
    321         # The rest is in a method so we can recalculate when clim changes.
    322         self.config_axis()
--> 323         self.draw_all()
    324 
    325     def _extend_lower(self):

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in draw_all(self)
    346         X, Y = self._mesh()
    347         C = self._values[:, np.newaxis]
--> 348         self._config_axes(X, Y)
    349         if self.filled:
    350             self._add_solids(X, Y, C)

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in _config_axes(self, X, Y)
    442         ax.add_artist(self.patch)
    443 
--> 444         self.update_ticks()
    445 
    446     def _set_label(self):

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in update_ticks(self)
    371         """
    372         ax = self.ax
--> 373         ticks, ticklabels, offset_string = self._ticker()
    374         if self.orientation == 'vertical':
    375             ax.yaxis.set_ticks(ticks)

/usr/lib/python2.7/dist-packages/matplotlib/colorbar.pyc in _ticker(self)
    592         formatter.set_data_interval(*intv)
    593 
--> 594         b = np.array(locator())
    595         if isinstance(locator, ticker.LogLocator):
    596             eps = 1e-10

/usr/lib/python2.7/dist-packages/matplotlib/ticker.pyc in __call__(self)
   1536         'Return the locations of the ticks'
   1537         vmin, vmax = self.axis.get_view_interval()
-> 1538         return self.tick_values(vmin, vmax)
   1539 
   1540     def tick_values(self, vmin, vmax):

/usr/lib/python2.7/dist-packages/matplotlib/ticker.pyc in tick_values(self, vmin, vmax)
   1554             if vmin <= 0.0 or not np.isfinite(vmin):
   1555                 raise ValueError(
-> 1556                     "Data has no positive values, and therefore can not be "
   1557                     "log-scaled.")
   1558 

ValueError: Data has no positive values, and therefore can not be log-scaled.
Error in callback <function post_execute at 0x7f9fa8f44848> (for post_execute):
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/matplotlib/pyplot.pyc in post_execute()
    145             def post_execute():
    146                 if matplotlib.is_interactive():
--> 147                     draw_all()
    148 
    149             # IPython >= 2

/usr/lib/python2.7/dist-packages/matplotlib/_pylab_helpers.pyc in draw_all(cls, force)
    148         for f_mgr in cls.get_all_fig_managers():
    149             if force or f_mgr.canvas.figure.stale:
--> 150                 f_mgr.canvas.draw_idle()
    151 
    152 atexit.register(Gcf.destroy_all)

/usr/lib/python2.7/dist-packages/matplotlib/backend_bases.pyc in draw_idle(self, *args, **kwargs)
   2024         if not self._is_idle_drawing:
   2025             with self._idle_draw_cntx():
-> 2026                 self.draw(*args, **kwargs)
   2027 
   2028     def draw_cursor(self, event):

/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.pyc in draw(self)
    472 
    473         try:
--> 474             self.figure.draw(self.renderer)
    475         finally:
    476             RendererAgg.lock.release()

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/figure.pyc in draw(self, renderer)
   1157         dsu.sort(key=itemgetter(0))
   1158         for zorder, a, func, args in dsu:
-> 1159             func(*args)
   1160 
   1161         renderer.close_group('figure')

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)
   2322 
   2323         for zorder, a in dsu:
-> 2324             a.draw(renderer)
   2325 
   2326         renderer.close_group('axes')

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in draw(self, renderer, *args, **kwargs)
    387                               " correctly with this backend.")
    388 
--> 389             im = self.make_image(renderer.get_image_magnification())
    390             if im is None:
    391                 return

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in make_image(self, magnification)
    622         im, xmin, ymin, dxintv, dyintv, sx, sy = \
    623             self._get_unsampled_image(self._A, [_x1, _x2, _y1, _y2],
--> 624                                       transformed_viewLim)
    625 
    626         fc = self.axes.patch.get_facecolor()

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in _get_unsampled_image(self, A, image_extents, viewlim)
    229             else:
    230                 if self._rgbacache is None:
--> 231                     x = self.to_rgba(A, bytes=False)
    232                     # Avoid side effects: to_rgba can return its argument
    233                     # unchanged.

/usr/lib/python2.7/dist-packages/matplotlib/cm.pyc in to_rgba(self, x, alpha, bytes)
    259         # This is the normal case, mapping a scalar array:
    260         x = ma.asarray(x)
--> 261         x = self.norm(x)
    262         x = self.cmap(x, alpha=alpha, bytes=bytes)
    263         return x

/usr/lib/python2.7/dist-packages/matplotlib/colors.pyc in __call__(self, value, clip)
   1002             raise ValueError("minvalue must be less than or equal to maxvalue")
   1003         elif vmin <= 0:
-> 1004             raise ValueError("values must all be positive")
   1005         elif vmin == vmax:
   1006             result.fill(0)

ValueError: values must all be positive
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/IPython/core/formatters.pyc in __call__(self, obj)
    332                 pass
    333             else:
--> 334                 return printer(obj)
    335             # Finally look for special method names
    336             method = get_real_method(obj, self.print_method)

/usr/local/lib/python2.7/dist-packages/IPython/core/pylabtools.pyc in <lambda>(fig)
    245 
    246     if 'png' in formats:
--> 247         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    248     if 'retina' in formats or 'png2x' in formats:
    249         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

/usr/local/lib/python2.7/dist-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt, bbox_inches, **kwargs)
    129 
    130     bytes_io = BytesIO()
--> 131     fig.canvas.print_figure(bytes_io, **kw)
    132     data = bytes_io.getvalue()
    133     if fmt == 'svg':

/usr/lib/python2.7/dist-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2178                     orientation=orientation,
   2179                     dryrun=True,
-> 2180                     **kwargs)
   2181                 renderer = self.figure._cachedRenderer
   2182                 bbox_inches = self.figure.get_tightbbox(renderer)

/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
    525 
    526     def print_png(self, filename_or_obj, *args, **kwargs):
--> 527         FigureCanvasAgg.draw(self)
    528         renderer = self.get_renderer()
    529         original_dpi = renderer.dpi

/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.pyc in draw(self)
    472 
    473         try:
--> 474             self.figure.draw(self.renderer)
    475         finally:
    476             RendererAgg.lock.release()

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/figure.pyc in draw(self, renderer)
   1157         dsu.sort(key=itemgetter(0))
   1158         for zorder, a, func, args in dsu:
-> 1159             func(*args)
   1160 
   1161         renderer.close_group('figure')

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)
   2322 
   2323         for zorder, a in dsu:
-> 2324             a.draw(renderer)
   2325 
   2326         renderer.close_group('axes')

/usr/lib/python2.7/dist-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     59     def draw_wrapper(artist, renderer, *args, **kwargs):
     60         before(artist, renderer)
---> 61         draw(artist, renderer, *args, **kwargs)
     62         after(artist, renderer)
     63 

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in draw(self, renderer, *args, **kwargs)
    387                               " correctly with this backend.")
    388 
--> 389             im = self.make_image(renderer.get_image_magnification())
    390             if im is None:
    391                 return

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in make_image(self, magnification)
    622         im, xmin, ymin, dxintv, dyintv, sx, sy = \
    623             self._get_unsampled_image(self._A, [_x1, _x2, _y1, _y2],
--> 624                                       transformed_viewLim)
    625 
    626         fc = self.axes.patch.get_facecolor()

/usr/lib/python2.7/dist-packages/matplotlib/image.pyc in _get_unsampled_image(self, A, image_extents, viewlim)
    229             else:
    230                 if self._rgbacache is None:
--> 231                     x = self.to_rgba(A, bytes=False)
    232                     # Avoid side effects: to_rgba can return its argument
    233                     # unchanged.

/usr/lib/python2.7/dist-packages/matplotlib/cm.pyc in to_rgba(self, x, alpha, bytes)
    259         # This is the normal case, mapping a scalar array:
    260         x = ma.asarray(x)
--> 261         x = self.norm(x)
    262         x = self.cmap(x, alpha=alpha, bytes=bytes)
    263         return x

/usr/lib/python2.7/dist-packages/matplotlib/colors.pyc in __call__(self, value, clip)
   1002             raise ValueError("minvalue must be less than or equal to maxvalue")
   1003         elif vmin <= 0:
-> 1004             raise ValueError("values must all be positive")
   1005         elif vmin == vmax:
   1006             result.fill(0)

ValueError: values must all be positive
<matplotlib.figure.Figure at 0x7f9f9e7c9510>

Limited maximum histogram


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()


./data/data40_1538561816-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data22_1538560556-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data15_1538559989-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data09_1538559561-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data14_1538559914-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data10_1538559633-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data23_1538560624-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data18_1538560275-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data13_1538559846-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data37_1538561604-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data32_1538561255-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data11_1538559705-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data42_1538561956-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data31_1538561188-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data30_1538561116-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data02_1538559068-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data01_1538559000-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data28_1538560976-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data03_1538559141-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data16_1538560062-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data41_1538561888-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data46_1538562237-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data38_1538561676-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data34_1538561398-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data29_1538561048-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data33_1538561325-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data08_1538559493-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data45_1538562166-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data05_1538559281-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data07_1538559421-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data43_1538562028-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data25_1538560764-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data06_1538559353-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data27_1538560908-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data19_1538560347-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data39_1538561748-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data21_1538560484-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data20_1538560415-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data17_1538560206-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data44_1538562098-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data36_1538561537-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data12_1538559774-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data26_1538560835-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data35_1538561465-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data04_1538559209-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data24_1538560696-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
./data/data47_1538562305-CHAN1.h5 XINC: 5e-09  YINC: 0.0008  FRAMES: 508  YORIGIN: -87.0
<matplotlib.figure.Figure at 0x7f9f9fd70f10>

Histogram for oscilloscope B


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()


<matplotlib.figure.Figure at 0x7f9f9fcb58d0>

In [ ]: