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

Function map_data2D_hxn

pyxrf/model/load_data_from_db.py:720–1021  ·  view source on GitHub ↗

Save the data from databroker to hdf file. .. note:: Requires the databroker package from NSLS2 Parameters ---------- run_id_uid : int ID or UID of a run fpath: str path to save hdf file create_each_det: bool, optional Do not create data for eac

(
    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,
    skip_scan_types=None,
)

Source from the content-addressed store, hash-verified

718
719
720def map_data2D_hxn(
721 run_id_uid,
722 fpath,
723 create_each_det=False,
724 fname_add_version=False,
725 completed_scans_only=False,
726 successful_scans_only=False,
727 file_overwrite_existing=False,
728 output_to_file=True,
729 skip_scan_types=None,
730):
731 """
732 Save the data from databroker to hdf file.
733
734 .. note:: Requires the databroker package from NSLS2
735
736 Parameters
737 ----------
738 run_id_uid : int
739 ID or UID of a run
740 fpath: str
741 path to save hdf file
742 create_each_det: bool, optional
743 Do not create data for each detector is data size is too large,
744 if set as false. This will slow down the speed of creating hdf file
745 with large data size.
746 fname_add_version : bool
747 True: if file already exists, then file version is added to the file name
748 so that it becomes unique in the current directory. The version is
749 added to <fname>.h5 in the form <fname>_(1).h5, <fname>_(2).h5, etc.
750 False: then conversion fails.
751 completed_scans_only : bool
752 True: process only completed scans (for which ``stop`` document exists in
753 the database). Failed scan for which ``stop`` document exists are considered
754 completed even if not the whole image was scanned. If incomplete scan is
755 encountered: an exception is thrown.
756 False: the feature is disabled, incomplete scan will be processed.
757 file_overwrite_existing : bool, keyword parameter
758 This option should be used if the existing file should be deleted and replaced
759 with the new file with the same name. This option should be used with caution,
760 since the existing file may contain processed data, which will be permanently deleted.
761 True: overwrite existing files if needed. Note, that if ``fname_add_version`` is ``True``,
762 then new versions of the existing file will always be created.
763 False: do not overwrite existing files. If the file already exists, then the exception
764 is raised.
765 output_to_file : bool, optional
766 save data to hdf5 file if True
767 """
768 hdr = db[run_id_uid]
769 runid = hdr.start["scan_id"] # Replace with the true value (runid may be relative, such as -2)
770
771 logger.info(f"Loading scan #{runid}")
772 if completed_scans_only and not _is_scan_complete(hdr):
773 raise Exception("Scan is incomplete. Only completed scans are currently processed.")
774 if successful_scans_only and not _is_scan_successful(hdr):
775 raise Exception(
776 "Scan is not successfully completed. Only successfully completed scans are currently processed."
777 )

Callers 1

fetch_data_from_dbFunction · 0.85

Calls 7

_is_scan_completeFunction · 0.85
_is_scan_successfulFunction · 0.85
map_data2DFunction · 0.85
save_data_to_hdf5Function · 0.85
keysMethod · 0.80

Tested by

no test coverage detected