expmon documentation¶
Module HexUtils
a set of generic methods for hexanode project¶
Usage
import expmon.HexUtils as hu
hu.print_kwargs(d)
d = hu.dict_from_str_srcchs(s)
- See:
- References:
Created on 2017-12-08 by Mikhail Dubrovin
Module HexCalib
a set of generic methods for hexanode project¶
Created on 2017-12-08 by Mikhail Dubrovin
-
HexCalib.
h1d
(hlst, bins=None, amp_range=None, weights=None, color=None, show_stat=True, log=False, figsize=(6, 5), axwin=(0.15, 0.12, 0.78, 0.8), title='Title', xlabel='x', ylabel='y', titwin=None, fnm='hist.png')[source]¶ Wrapper for hist1d, move, and save methods, using common store parameters
Class HexDataIO
a set of methods to access psana data of hexanode detector¶
HexDataIO - a set of methods to access data, resembling hexanode/src/LMF_IO.cpp
Usage
Create object and access methods
--------------------------------
from expmon.HexDataIO import HexDataIO
o = HexDataIO(srcchs={'AmoETOF.0:Acqiris.0':(6,7,8,9,10,11),'AmoITOF.0:Acqiris.0':(0,)}, numchs=7, numhits=16)
o.open_input_dataset('exp=xpptut15:run=390')
# OR:
o.open_input_h5file(ofname='./test.h5')
# OR:
ds = psana.MPIDataSource('exp=xpptut15:run=390')
o.use_psana_dataset(ds, pbits=1022)
status = o.read_next_event() # gets next event from dataset, returns True if event is available
nhits = o.get_number_of_hits_array() # number of hits per channel, shape=(NUM_CHANNELS,)
tdc_ns = o.get_tdc_data_array() # array of hit time [ns], shape=(NUM_CHANNELS, NUM_HITS)
tdc_ind = o.get_tdc_index_array() # array of hit index, shape=(NUM_CHANNELS, NUM_HITS)
wf = o.get_wf(channel=1) # per channel array of intensities
wt = o.get_wt(channel=1) # per channel array of times [s]
nch = o.get_number_of_channels() # returns a number of channels
t_ns = o.tdc_resolution() # returns TDC bin width in ns
t_sec = o.start_time_sec() # returns (loatr) run start time
t_sec = o.stop_time_sec() # returns (float) run start time
tstamp = o.start_time() # returns (str) time stamp like '2017-10-23T17:00:00'
tstamp = o.stop_time() # returns (str) time stamp like '2017-10-23T17:00:00'
o.open_output_h5file(ofname='./test.h5')
o.close_output_h5file()
o.close_input_h5file()
o.add_event_to_h5file()
o.print_tdc_data()
o.print_times()
Created on 2017-10-23 by Mikhail Dubrovin
Class HexDataIOExt
- extension of HexDataIO for data processing with “3-line example”¶
Usage
# Example 1 - dataset created outside object
#-------------------------------------------
from expmon.HexDataIOExt import HexDataIOExt # Line 0 - import
# dictionary of input parameters
kwargs = {'command' : 1,
'srcchs' : {'AmoETOF.0:Acqiris.0':(6,7,8,9,10,11),'AmoITOF.0:Acqiris.0':(0,)},
'numchs' : 7,
'numhits' : 16,
'dsname' : 'exp=xpptut15:run=390:smd',
'evskip' : 0,
'events' : 500,
'verbose' : False,
'cfd_base' : 0. ,
'cfd_thr' : -0.04,
'cfd_cfr' : 0.9 ,
'cfd_deadtime' : 5.0 ,
'cfd_leadingedge' : True,
'cfd_ioffsetbeg' : 0 ,
'cfd_ioffsetend' : 1000,
}
ds = psana.MPIDataSource(kwargs['dsname'])
o = HexDataIOExt(ds, **kwargs) # Line 1 - initialization
for evt in ds.events() :
if o.skip_event(evt) : continue # Line 2 - loop control method passes evt to the object
if o.event_number() > o.EVENTS : break
#x, y, t = o.hits_xyt() # Line 3 - get arrays x, y, t of hits' coordinates and time
o.print_hits() # prints x, y, time for all hits in the event
o.print_summary() # print total number of events, processing time, frequency, etc
# Example 2 - dataset created inside object
#------------------------------------------
from expmon.HexDataIOExt import HexDataIOExt # Line 0 - import
# dictionary of input (non-default) parameters
kwargs = {'srcchs' : {'AmoETOF.0:Acqiris.0':(6,7,8,9,10,11),'AmoITOF.0:Acqiris.0':(0,)},
'numchs' : 7,
'numhits': 16,
'dsname' : 'exp=xpptut15:run=390:smd',
}
o = HexDataIOExt(**kwargs) # Line 1 - initialization, dataset is defined inside the object
while o.read_next_event() : # Line 2 - event loop
o.print_sparsed_event_info() # print sparsed event number and time consumption
if o.skip_event() : continue # event loop control, skip events with zero hits
if o.break_event_loop() : break # event loop control, break ate teh end or when smth went wrong
o.print_hits() # prints x, y, time, method for found in event hits
x, y, t = o.hits_xyt() # Line 3 - get arrays x, y, t of hits' coordinates and time
#-------------
# Make object
#-------------
o = HexDataIOExt(ds=None, **kwargs)
# Event loop control methods
#---------------------------
status = o.read_next_event()
stat = o.break_event_loop(
stat = o.skip_event()
stat = o.skip_event(evt) # pass evt for external dataset
# Methods per event
#-------------------
o.print_sparsed_event_info()
o.print_summary()
o.print_hits()
o.calib_command2() # for calibration with command 2
o.calib_command3() # for calibration with command 3
# Access sorted data info, hit coordinates, times, hit finding method
#--------------------------------------------------------------------
x, y, t = o.hits_xyt()
x = o.hits_x()
y = o.hits_y()
t = o.hits_t()
m = o.hits_method()
Created on 2017-12-14 by Mikhail Dubrovin.
Module HexDataPreProc
- hexanode LCLS data processing using MPI and creating “small data” hdf5 file¶
Created on 2017-12-08 by Mikhail Dubrovin