MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / assemble_data_SRX_stepscan

Function assemble_data_SRX_stepscan

pyxrf/model/load_data_from_db.py:3562–3686  ·  view source on GitHub ↗

Convert stepscan data from SRX beamline obtained from databroker into the for accepted by ``write_db_to_hdf_base`` function. This function can handle stopped/aborted scans. Parameters ---------- data : pandas.core.frame.DataFrame data from data broker datashape

(
    data,
    datashape,
    det_list=("xspress3_ch1", "xspress3_ch2", "xspress3_ch3"),
    pos_list=("zpssx[um]", "zpssy[um]"),
    scaler_list=("sclr1_ch3", "sclr1_ch4"),
    fname_add_version=False,
    create_each_det=True,
    fly_type=None,
    subscan_dims=None,
    base_val=None,
)

Source from the content-addressed store, hash-verified

3560
3561
3562def assemble_data_SRX_stepscan(
3563 data,
3564 datashape,
3565 det_list=("xspress3_ch1", "xspress3_ch2", "xspress3_ch3"),
3566 pos_list=("zpssx[um]", "zpssy[um]"),
3567 scaler_list=("sclr1_ch3", "sclr1_ch4"),
3568 fname_add_version=False,
3569 create_each_det=True,
3570 fly_type=None,
3571 subscan_dims=None,
3572 base_val=None,
3573):
3574 """
3575 Convert stepscan data from SRX beamline obtained from databroker into the for accepted
3576 by ``write_db_to_hdf_base`` function.
3577 This function can handle stopped/aborted scans.
3578
3579 Parameters
3580 ----------
3581 data : pandas.core.frame.DataFrame
3582 data from data broker
3583 datashape : tuple or list
3584 shape of two D image
3585 det_list : list, tuple, optional
3586 list of detector channels
3587 pos_list : list, tuple, optional
3588 list of pos pv
3589 scaler_list : list, tuple, optional
3590 list of scaler pv
3591 fname_add_version : bool
3592 True: if file already exists, then file version is added to the file name
3593 so that it becomes unique in the current directory. The version is
3594 added to <fname>.h5 in the form <fname>_(1).h5, <fname>_(2).h5, etc.
3595 False: the exception is thrown if the file exists.
3596 create_each_det: bool
3597 True: output dataset contains data for individual detectors, False: output
3598 dataset contains only sum of all detectors.
3599 """
3600
3601 data_assembled = {}
3602
3603 sum_data = None
3604 new_v_shape = datashape[0] # to be updated if scan is not completed
3605 spectrum_len = 4096 # standard
3606
3607 for n, c_name in enumerate(det_list):
3608 if c_name in data:
3609 detname = "det" + str(n + 1)
3610 channel_data = data[c_name]
3611
3612 # new veritcal shape is defined to ignore zeros points caused by stopped/aborted scans
3613 new_v_shape = len(channel_data) // datashape[1]
3614
3615 new_data = np.vstack(channel_data)
3616 new_data = new_data.astype(np.float32, copy=False) # Change representation to np.float32
3617 new_data = new_data[: new_v_shape * datashape[1], :]
3618
3619 new_data = new_data.reshape([new_v_shape, datashape[1], len(channel_data[1])])

Callers 1

map_data2D_srx_oldFunction · 0.85

Calls 2

flip_dataFunction · 0.85
get_name_value_from_dbFunction · 0.85

Tested by

no test coverage detected