Index: /fact/tools/pyscripts/sandbox/dneise/gain/gain.py
===================================================================
--- /fact/tools/pyscripts/sandbox/dneise/gain/gain.py	(revision 13442)
+++ /fact/tools/pyscripts/sandbox/dneise/gain/gain.py	(revision 13443)
@@ -34,8 +34,33 @@
 fig.hold(True)
 
+# we try to determine the:
+#   * Position
+#   * and Height (in two versions: filtered, and unfiltered data)
+# of dark count peaks in:
+#  a) all events
+#  b) all pixel
+#
+# we limit ourselfs to 10 peaks per pixel max!
+# and 1000 events max!
+#
+# So in order to store this stuff, we prepare an n-dim-array
+
+PEAKS_MAX = 10
+N_INFO = 3 # Position, Height of unfiltered peak, Height of Filtered peak
+
+# TODO: this operation might under certain circumstances need way to much mem.
+#       I would like to solve this, using try except, and in case of a 'MemoryError'
+#       reduce the number of events. 
+#       So I will process the events, in e.g. chunks of 1000 and save the results
+#       The user will then find a certain nuber of ndarray in the output npz file.
+#       But this should not be a major problem.
+peaks = np.ones( ( N_INFO, run.nevents, run.npix, PEAKS_MAX), dtype=np.float32)
+
 
 
 for event in run:
-    print event['event_id'].value
+    event_id = event['event_id'].value - 1
+    print 'event_id', event_id
+    
     data = event['acal_data']
     data = despike(data)
@@ -45,7 +70,10 @@
     filtered = smooth(filtered)
 
+    
+
+
     # this is a loop over all pixel of this event
-    
-    for dat, fil, orig in zip(data, filtered, data_orig):
+    for pixel_id, dat, fil, orig in enumerate(zip(data, filtered, data_orig)):
+        print 'pixel id:', pixel_id
         plt.cla()
         prod = fil[:-1] * fil[1:]
@@ -94,5 +122,11 @@
         plt.plot(np.arange(len(dat)), dat, 'k:')
         
-        raw_input('bla')
+        ret = raw_input('pixel-loop?')
+        if ret == 'q':
+            break
+    ret = raw_input('event-loop?')
+    if ret == 'q':
+        break
+        
 
 
