Skip to content
Snippets Groups Projects
xgm.py 47.8 KiB
Newer Older
            channel: Fast ADC channel
            intstart: trace index of integration start
            intstop: trace index of integration stop
            bkgstart: trace index of background start
            bkgstop: trace index of background stop
            period: Number of samples separation between two pulses. Needed
                if bunch pattern info is not available. If None, checks the 
                pulse pattern and determine the period assuming a resolution
                of 9.23 ns per sample which leads to 24 samples between
                two bunches @ 4.5 MHz. 
            npulses: number of pulses. If None, takes the maximum number of
                pulses according to the bunch patter (field 'npulses_sase3')
            dim: name of the xr dataset dimension along the peaks
            
    '''
    peaks = fastAdcPeaks(data, channel=channel, intstart=intstart, intstop=intstop,
                         bkgstart=bkgstart, bkgstop=bkgstop, period=period,
                         npulses=npulses)
    
    key = 'FastADC{}peaks'.format(channel) 
    if key in data:
        s = data.drop(key)
    else:
        s = data
    peaks = peaks.rename(key).rename({'peakId':dim})
    subset = xr.merge([s, peaks], join='inner')
    for k in data.attrs.keys():
        subset.attrs[k] = data.attrs[k]