Ignore:
Timestamp:
04/25/12 14:48:08 (12 years ago)
Author:
neise
Message:
is writing pulse heights to npz
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/sandbox/dneise/gain/gain.py

    r13444 r13447  
    1 #!/usr/bin/python -tti
     1#!/usr/bin/python -tt
    22#
    33#
    44
    55from pyfact   import RawData
    6 from drs_spikes import DRSSpikes       
     6from drs_spikes import DRSSpikes
    77from fir_filter import CFD
    88from fir_filter import SlidingAverage
    99
    10 from plotters import Plotter
    11 
    1210import sys
    13 import cPickle
    14 import matplotlib.pyplot as plt
    1511import numpy as np
    1612
    17 data_filename = 'data/20111017_009.fits.gz'
     13data_filename = 'data/20111017_010.fits.gz'
    1814calib_filename = 'data/20111017_006.drs.fits.gz'
    19 out_filename = 'test.pkl'
    2015
    2116run = RawData(data_filename, calib_filename, return_dict = True, do_calibration=True)
     
    3025sws = search_window_size
    3126
    32 plt.ion()
    33 fig = plt.figure()
    34 fig.hold(True)
     27#plt.ion()
     28#fig = plt.figure()
     29#fig.hold(True)
    3530
    3631# we try to determine the:
     
    4742
    4843PEAKS_MAX = 10
    49 N_INFO = 3 # Position, Height of unfiltered peak, Height of Filtered peak
     44
    5045
    5146# TODO: this operation might under certain circumstances need way to much mem.
     
    5550#       The user will then find a certain nuber of ndarray in the output npz file.
    5651#       But this should not be a major problem.
    57 peaks = np.ones( ( N_INFO, run.nevents, run.npix, PEAKS_MAX), dtype=np.float32)
    58 
     52result_peak_positions         = np.ones( (run.nevents, run.npix,  PEAKS_MAX), dtype=np.int16) * -1
     53result_peak_unfiltered_height = np.ones( (run.nevents, run.npix,  PEAKS_MAX), dtype=np.float32) * -np.inf
     54result_peak_smoothed_height   = np.ones( (run.nevents, run.npix,  PEAKS_MAX), dtype=np.float32) * -np.inf
    5955
    6056
    6157for event in run:
    6258    event_id = event['event_id'].value - 1
    63     print 'event_id', event_id
     59   
    6460   
    6561    data = event['acal_data']
     
    7773    for dat, fil, orig in zip(data, filtered, data_orig):
    7874        pixel_id += 1
    79         print 'pixel id:', pixel_id
    80         plt.cla()
     75        print event_id, pixel_id
     76#        plt.cla()
    8177        prod = fil[:-1] * fil[1:]
    8278        cand = np.where( prod <= 0)[0]
     
    119115                max_smoothed[i]  = dat[max_pos[i]]
    120116                max_orig[i]      = orig[max_pos[i]-filter_delay]
     117       
     118        result_peak_positions[event_id,pixel_id, :len(max_pos)]         = max_pos
     119        result_peak_unfiltered_height[event_id,pixel_id, :len(max_pos)] =max_orig
     120        result_peak_smoothed_height[event_id,pixel_id, :len(max_pos)]   = max_smoothed
    121121
    122         plt.plot(max_pos, max_smoothed, 'ro')
    123         plt.plot(max_pos, max_orig, 'bo')
    124         plt.plot(np.arange(len(dat)), dat, 'k:')
     122#        plt.plot(max_pos, max_smoothed, 'ro')
     123#        plt.plot(max_pos, max_orig, 'bo')
     124#        plt.plot(np.arange(len(dat)), dat, 'k:')
    125125       
    126         ret = raw_input('pixel-loop?')
    127         if ret == 'q':
    128             break
    129     ret = raw_input('event-loop?')
    130     if ret == 'q':
    131         break
    132        
     126#        ret = raw_input('pixel-loop?')
     127#        if ret == 'q':
     128#            break
     129#    ret = raw_input('event-loop?')
     130#    if ret == 'q':
     131#        break
    133132
     133np.savez('20111017_010-006.npz',
     134    result_peak_positions = result_peak_positions,
     135    result_peak_unfiltered_height = result_peak_unfiltered_height,
     136    result_peak_smoothed_height = result_peak_smoothed_height )
    134137
    135138#output = open(out_filename, 'wb')
Note: See TracChangeset for help on using the changeset viewer.