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

Function map_data2D_xfm

pyxrf/model/load_data_from_db.py:3298–3420  ·  view source on GitHub ↗

Transfer the data from databroker into a correct format following the shape of 2D scan. This function is used at XFM beamline for step scan. Save the new data dictionary to hdf file if needed. .. note:: It is recommended to read data from databroker into memory directly, in

(
    run_id_uid,
    fpath,
    create_each_det=False,
    fname_add_version=False,
    completed_scans_only=False,
    successful_scans_only=False,
    file_overwrite_existing=False,
    output_to_file=True,
)

Source from the content-addressed store, hash-verified

3296
3297
3298def map_data2D_xfm(
3299 run_id_uid,
3300 fpath,
3301 create_each_det=False,
3302 fname_add_version=False,
3303 completed_scans_only=False,
3304 successful_scans_only=False,
3305 file_overwrite_existing=False,
3306 output_to_file=True,
3307):
3308 """
3309 Transfer the data from databroker into a correct format following the
3310 shape of 2D scan.
3311 This function is used at XFM beamline for step scan.
3312 Save the new data dictionary to hdf file if needed.
3313
3314 .. note:: It is recommended to read data from databroker into memory
3315 directly, instead of saving to files. This is ongoing work.
3316
3317 Parameters
3318 ----------
3319 run_id_uid : int
3320 ID or UID of a run
3321 fpath: str
3322 path to save hdf file
3323 create_each_det: bool, optional
3324 Do not create data for each detector is data size is too large,
3325 if set as false. This will slow down the speed of creating hdf file
3326 with large data size.
3327 fname_add_version : bool
3328 True: if file already exists, then file version is added to the file name
3329 so that it becomes unique in the current directory. The version is
3330 added to <fname>.h5 in the form <fname>_(1).h5, <fname>_(2).h5, etc.
3331 False: then conversion fails.
3332 completed_scans_only : bool
3333 True: process only completed scans (for which ``stop`` document exists in
3334 the database). Failed scan for which ``stop`` document exists are considered
3335 completed even if not the whole image was scanned. If incomplete scan is
3336 encountered: an exception is thrown.
3337 False: the feature is disabled, incomplete scan will be processed.
3338 file_overwrite_existing : bool, keyword parameter
3339 This option should be used if the existing file should be deleted and replaced
3340 with the new file with the same name. This option should be used with caution,
3341 since the existing file may contain processed data, which will be permanently deleted.
3342 True: overwrite existing files if needed. Note, that if ``fname_add_version`` is ``True``,
3343 then new versions of the existing file will always be created.
3344 False: do not overwrite existing files. If the file already exists, then the exception
3345 is raised.
3346 output_to_file : bool, optional
3347 save data to hdf5 file if True
3348
3349 Returns
3350 -------
3351 dict of data in 2D format matching x,y scanning positions
3352 """
3353 hdr = db[run_id_uid]
3354 runid = hdr.start["scan_id"] # Replace with the true value (runid may be relative, such as -2)
3355

Callers 1

fetch_data_from_dbFunction · 0.85

Calls 5

_is_scan_completeFunction · 0.85
_is_scan_successfulFunction · 0.85
map_data2DFunction · 0.85
save_data_to_hdf5Function · 0.85

Tested by

no test coverage detected