Source code for tesfdmtools.methods.positivepulse

#!/usr/bin/env python3
#

import numpy

[docs]def positivepulse(hdfrecs,thresh): ''' See if pulse is positive or negative Args: * `hdfrecs` = list of event records * `thresh` = threshold for pulse Returns: * **True** if pulse is positive, **False** if pulse is negative ''' if thresh is None: # if no threshold, use 5*noise in first 10 samples rr=hdfrecs[1][:,0] thresh=numpy.ptp(rr[:10])*5.0 for record in hdfrecs: if numpy.ptp(record[:,0]) > thresh: bb=numpy.average(record[:10,0]) rmin=numpy.min(record[:,0]) rmax=numpy.max(record[:,0]) tt=max([thresh,((rmax-rmin)*0.25)]) if rmin < (bb-tt): return False if rmax > (bb+tt): print("Data records have positive pulses") return True return False