HDF_Eventutils : Algorithms used for X-ray event processing¶
-
tesfdmtools.methods.HDF_Eventutils.
crosscplt
(ax, hdf, channel, freq, c1, c2, xlabel='c1', ylabel='c2', center=None, ytilt=None)[source]¶ plot correlation between two parameters and the fitted linear correlation relation
- Args:
ax = a plotting instance for the plot output
hdf = HDF5 input file object
channel = channel number being processed
freq = frequency number (pixel) being processed
c1 = array of first parameter
c2 = array of second parameter
- Kwargs:
xlabel = label for x-axis [default: ‘c1’]
ylabel = label for y-axis [default: ‘c12’]
center = fitted center of distribution [default: None]
ytilt = fitted linear slope between parameters [default: ‘None’]
- Returns:
none
-
tesfdmtools.methods.HDF_Eventutils.
dellist
(delist, nrecs)[source]¶ make logical array specifying which event records to use from HDF file
- Args:
delist = full file name which hold the records which decribe which events to ignore
nrecs = size of array to make
- Returns:
evuse = logical array with True values for events to use
-
tesfdmtools.methods.HDF_Eventutils.
eventlist_out
(wfile, freq, recordno, optfit, baseline, peaks, hdffilename, channel=None, rtimes=None, ftimes=None, evttim=None, eefit=None, surf=None)[source]¶ write eventlist to file
- Args:
wfile = write eventlist or not
freq = frequency number in file
recordno = list of record numbers
optfit = list of optimal filtering results for each event
baseline = list of baseline levels for each event
peaks = list of pulse peak values for each event
hdffilename = full filename (including path) of processed HDF file
- Kwargs:
channel = channel number used
rtimes = pulses rise times
ftimes = pulses fall times
evttim = time of the events
eefit = list of (calibrated) energies for the events
surf = list of pulse surfaces for each event
-
tesfdmtools.methods.HDF_Eventutils.
eventpars
(hdf, channel=None, freq=None, threshold=2000, bsec=0.05, nrecs=None, rotation=0.0, bpt=False, delist=None, flip=False)[source]¶ get basic event record parameters for further event selection. Only the I-signal is considered
- Args:
hdf = HDF5 input file object
- Kwargs:
channel = channel number to process. If Nont, take first channel [default: None]
freq = frequency (pixel) number to process. If None, take first frequency [default: None]
threshold = consider only records which have a max-min larger than threshold [default: None]
bsec = part of record (start and end) from which baselines are derived. (This part of the record should not contain a pulse or partial pulse) [default: 0.05]
nrecs = number of records to process. If None, process all records. [default: None]
rotation = if not zero, rotate events with this amount [default: 0.0]
bpt = if True, select pretrigger section of event only for baseline [default: False]
flip = flip record data
- Returns:
channel = channel number which was processed
freq = frequency (pixel number) which was processed
blines1 = background levels at start of record
blines2 = background levels at end of record
positions = position of pulse minimum (pulse runs negative)
peaks = value of pulse minimum (value at maximum pulse signal)
surf = surface of pulse minus background. Bacground is linear fit between blines1 and blines2
ptp = maximum signal difference within record (max - min)
evttim = event times (time of event peak value in seconds)
rsize = length of record (number of samples in record)
-
tesfdmtools.methods.HDF_Eventutils.
fitspectrum
(pltdata, iplt, hdf, channel, freq, spectrum, bins, debug=False, afitrange=[5.86, 5.92])[source]¶ fit the Holzer alpha and beta Mn54 lines to the spectrum
- Args:
pltdata = dictionary for the fit results
iplt = number of the plot to process
hdf = HDF5 input file object
channel = channel number being processed
freq = frequency number (pixel) being processed
spectrum = spectrum of the pulse fit parameters
bins = centers of the spectrum bins
- Kwargs:
debug = if True, plot debug information [default: False]
afitrange = range (keV) for spectrum fit [default: 5.860,5.920]
- Results:
pltdata[iplot] = spectrum fit results
- Returns:
fwhm = fitted resolution inFWHM
fitpars = additional fitted parameters
-
tesfdmtools.methods.HDF_Eventutils.
getphase
(hdf, channel, freq, indx, nevents=100, debug=False)[source]¶ Get average phase of first ‘nevents’ events
- Args:
hdf = HDF5 input file object
channel = channel number being processed
freq = frequency number (pixel) being processed
indx = index of selected events, to be processed
- Kwargs:
nevents = number of events to process [default: 100]
debug = if True, show some events [default: False]
- Returns:
phase = average phase correction for events
-
tesfdmtools.methods.HDF_Eventutils.
getrisetime
(xax, pulse, debug=False, plotfit=None)[source]¶ compute rise time for pulse, based on linear fit of log values
- Args:
xax = X-axis of pulse expressed in sample #
pulse = pulse shape, with background subtracted
- Kwargs:
debug = if True, plot each pulse and fit [default: False]
plotfit = plotinstance for log plot of fitted pulse [default: None]
- Returns:
rtime = rise time of pulse in sample units
ftime = fall time of pulse in sample units
-
tesfdmtools.methods.HDF_Eventutils.
limdist
(cc, ext=0.5, bins=2500)[source]¶ compute range of main data distribution in array of values
- Args:
cc = array of values
- Kwargs:
bins = number of bins to use for histogram
ext = range extension [default: 0.5]
- Returns:
xmin = minimum of range
xmax = maximum of range
-
tesfdmtools.methods.HDF_Eventutils.
makeplot
(pdf, ps=False)[source]¶ finish plot
- Args:
pdf = plot output file
- Kwargs:
ps = if False, also put output on screen [default: False]
-
tesfdmtools.methods.HDF_Eventutils.
makespectrum
(pulsefits, sbins=5000, debug=False, efrac=0.05)[source]¶ make spectrum of fitted optimal filtering scale factors, and determine proper range (leave out the outliers)
- Args:
pulsefits = array of pulse fit paramters (scale factors)
- Kwargs:
sbins = number of bins for spectrum [default: 5000]
debug = if True, plot/print debug output [default: False]
efrac = fraction of the events at low and hig end defined as outliers [default: 0.05]
- Returns:
spectrum = spectrum of the pulsefits
bins = centers of the spectral bins
-
tesfdmtools.methods.HDF_Eventutils.
noisefile
(hdf, channel, freq, nfile=None)[source]¶ See if there is an associated noise file, or a noise file is given. If so , open file and retrieve ptp info
- Args:
hdf = HDF5 input xray file
channel = channel number to use
freq = frequency number to use
- Kwargs:
nfile = noise file to use, or True to ask for noise file [default: None]
- Returns:
nhdf = HDF5 file object for noise data
ptp = max-min signal fluctuations for the records
-
tesfdmtools.methods.HDF_Eventutils.
noisespec
(hdf, channel, freq, ptp, fraction=0.1, debug=False, absolute=False, prlen=None, flip=False)[source]¶ Retrieve noise spectra. Use given fraction of I-signal records with least max-min signal fluctuations.
- Args:
hdf = HDF5 input file object
channel = channel number to use
freq = frequency (pixel) number to use
ptp = max-min signal fluctuations for the records
- Kwargs:
fraction = fraction of least signal fluctuations to use [default: 0.1]
debug = if True, print/plot debug info [default: False]
prlen = length of record to take [default: None]
flip = flip record data
- Returns:
noisspec = average noise spectrum
fax = frequency axis for noise spectrum
-
tesfdmtools.methods.HDF_Eventutils.
noisplot
(pltax, spectrum, nspectrum, fax, title)[source]¶ plot noise spectrum
- Args:
pltax = plot instance for plotting
spectrum = spectrum data
fax = frequency axis
title = title of plot
-
tesfdmtools.methods.HDF_Eventutils.
optfilter
(hdf, channel, freq, indx, base1, base2, noisspec, debug=False, freqcutoff=None, rotate=False, risetime=False, bsec=0.05, absolute=False, prlen=None, apulsepos=None, flip=False, showpspec=None, **kwargs)[source]¶ perform optimal filtering fit of individual pulses
- Args:
hdf = HDF5 input file object
channel = channel number being processed
freq = frequency number (pixel) being processed
indx = index of selected events, to be processed
base1 = baseline level at start of record
base2 = baseline level at end of record
noisspec = noise spectrum
- Kwargs:
debug = if True, plot various fit parameters [default: False]
freqcutoff = cutoff frequency (Hz) for optimal filtering [default: None]
rotate = rotation angle (radians) for I/Q pulse record
risetime = it True, compute rise time of pulses [default: None]
bsec = section of record to take for background (only used for ‘rotate’ or ‘absolute’) [default: 0.05]
absolute = use sqrt(I^2+Q^2) signal [default: False]
prlen = length of record to process (None = entire record) [default: None]
apulsepos = average position of pulse maximum; used for limited prlen. [default: None]
flip = flip record data
showpspec = interactive plot of a given set of pulse spectra
- Returns:
ifit = fitted pulse heigth parameters
rtimes = computed rise times of fitted pulses
ftimes = computed fall times of fitted pulses
avpulse = average pulse profile with baseline subtracted
avbline = average baseline for the average pulse prfile
-
tesfdmtools.methods.HDF_Eventutils.
plotepar
(hdf, channel, freq, bline, positions, peaks, surf, show=None, pdf=None, indx=None, ectpar=None)[source]¶ Plot basic event record parameters
- Args:
hdf = HDF5 input file object
channel = channel number
freq = frequency (pixel) number
bline = baseline level
positions = pulse positions
peaks = pulse minima (pulse peaks)
surf = pulse surface
- Kwargs:
- show = plot mode [default: None] :
‘X’ : both show on screen and print to pdf file
‘screen’ : show on screen only
‘pdf’ : print to pdf file
None : do not plot
pdf = pdf object for plotting [default: None]
indx = indexnumbers of records used
ectpar = electric crosstalk parameters (tuple):
ectpar[0] = actual list of selected records
ectpar[1] = actual list of parameters for the indexed records
ectpar[2] = actual threshold applied for the electric crosstalk
- Returns:
none
-
tesfdmtools.methods.HDF_Eventutils.
plotptimes
(rtimes, ftimes, nfit, avpulse, ptitle, pdf, ps=False, outtxt=False, erange=[None, None], avbline=None)[source]¶ Make plot of pulse times (rise and fall) and correlations with energy + average pulse profile Also write ASCII data of average pulse profile when outtxt=True
- Args:
rtimes = pulse rise times for the events
ftimes = pulse fall times for the events
nfit = optimum filter fits for the events (scales with energy)
avpulse = the average pulse profile
ptitle = title of the plot page
pdf = pdf plot instance
- Kwargs:
ps = if False, also show plot interactively [default: False]
outtxt = if True, write ASCII data of average pulse profile [default: False]
erange = range of the nfit parameter to plot in the energy/(rise/fall)time correlation [default: None,None]
avbline = average baseline level for the average pulse. To be included in the ASCII pulse profile [default: None]
-
tesfdmtools.methods.HDF_Eventutils.
selectdtim
(indx, evttim, etprev=[None, None], etnext=[None, None])[source]¶ Select events based on the delta times to the previous and next events
- Args:
indx = index of valid events
evttim = time tages of the events
- Kwargs:
etprev = selection window of delta time to the previous event [min,max]
etnext = selection window of delta time to the next event [min,max]
-
tesfdmtools.methods.HDF_Eventutils.
selectevs
(hdf, channel, freq, bline, positions, peaks, surf, rclen, show=None, debug=False, nopos=False, pdf=None, nopulse=False, bsec=0.05)[source]¶ select the proper events to process from the basic event record parameters
- Args:
hdf = HDF5 file which is being used
channel = channel number whch was processed
freq = frequency (pixel) number which was processed
bline = baseline levels of the records
positions = pulse positions for the records
peaks = record minima (pulse peak values)
surf = pulse surfaces
rclen = record length (number of samples in record)
nopulse = do not select on pulse intensity when set True
- Kwargs:
- show = plot mode [default: None]:
‘X’ : both show on screen and print to pdf file
‘screen’ : show on screen only
‘pdf’ : print to pdf file
None : do not plot
debug = if True, print/plot some debug info [default: False]
nopos = if True, do not select pulses on pulse position [default: False]
bsec = section of record (baseline section) where pulse should not occur when nopos
pdf = pdf object for plotting [default: None]
- Returns:
sindx = list of selected record numbers to use for further processing
-
tesfdmtools.methods.HDF_Eventutils.
selecthist
(data, tlevel=0.01, debug=False, label='')[source]¶ compute data range which selects the main body of the data, leaving out data values where data become sparse
- Args:
data = array of input values
- Kwargs:
tlevel = select only data where data density is above this level [default: 0.01]
debug = if True, plot debug info [default: False]
label = plot label for debug plot [default: “”]
- Returns:
lowb = low range value
higb = high rang evalue
-
tesfdmtools.methods.HDF_Eventutils.
showcorr
(c1, c2, xlabel='X', ylabel='Y', title='', center=None, ytilt=None)[source]¶ plot correlation between two parameters and the fitted linear correlation relation
- Args:
c1 = array of first parameter
c2 = array of second parameter
- Kwargs:
xlabel = label for x-axis [default: ‘X’]
ylabel = label for y-axis [default: ‘Y’]
title = title for plot [default: ‘’]
center = fitted center of distribution [default: None]
ytilt = fitted linear slope between parameters [default: None]
- Returns:
none
-
tesfdmtools.methods.HDF_Eventutils.
subsel
(indx, par, prange=[None, None])[source]¶ select a subset within the given parameter range
- Args:
indx = index of the parameters to be considered
par = list of parameter values
prange = selection range of the parameters
- Returns:
sindx = new index selecting only the relevant items
-
tesfdmtools.methods.HDF_Eventutils.
timplt
(ax, hdf, channel, freq, c1, c2, frange=None, xlabel='c1', ylabel='c2')[source]¶ time evolution plot of pulse fit parameter
- Args:
ax = a plotting instance for the plot output
hdf = HDF5 input file object
channel = channel number being processed
freq = frequency number (pixel) being processed
c1 = array of time parameter (event record number)
c2 = array of pulse fits
- Kwargs:
frange = range of fits parameter values to plot [default: None]
xlabel = label for x-axis [default: ‘c1’]
ylabel = label for y-axis [default: ‘c2’]
- Returns:
none