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

Function read_MAPS

pyxrf/model/fileio.py:1799–1892  ·  view source on GitHub ↗
(working_directory, file_name, channel_num=1)

Source from the content-addressed store, hash-verified

1797
1798
1799def read_MAPS(working_directory, file_name, channel_num=1):
1800 # data_dict = OrderedDict()
1801 data_sets = OrderedDict()
1802 img_dict = OrderedDict()
1803
1804 # Empty container for metadata
1805 mdata = ScanMetadataXRF()
1806
1807 # cut off bad point on the last position of the spectrum
1808 # bad_point_cut = 0
1809
1810 fit_val = None
1811 fit_v_pyxrf = None
1812
1813 file_path = os.path.join(working_directory, file_name)
1814 print("file path is {}".format(file_path))
1815
1816 with h5py.File(file_path, "r+") as f:
1817 data = f["MAPS"]
1818 fname = file_name.split(".")[0]
1819
1820 # for 2D MAP
1821 # data_dict[fname] = data
1822
1823 # raw data
1824 exp_data = data["mca_arr"][:]
1825
1826 # data from channel summed
1827 roi_channel = data["channel_names"][()]
1828 roi_val = data["XRF_roi"][:]
1829
1830 scaler_names = data["scaler_names"][()]
1831 scaler_val = data["scalers"][:]
1832
1833 try:
1834 # data from fit
1835 fit_val = data["XRF_fits"][:]
1836 except KeyError:
1837 logger.info("No fitting from MAPS can be loaded.")
1838
1839 try:
1840 fit_data = f["xrfmap/detsum"]
1841 fit_v_pyxrf = fit_data["xrf_fit"][:]
1842 fit_n_pyxrf = fit_data["xrf_fit_name"][()]
1843 print(fit_n_pyxrf)
1844 except KeyError:
1845 logger.info("No fitting from pyxrf can be loaded.")
1846
1847 # exp_shape = exp_data.shape
1848 exp_data = exp_data.T
1849 exp_data = np.rot90(exp_data, 1)
1850 logger.info("File : {} with total counts {}".format(fname, np.sum(exp_data)))
1851 DS = DataSelection(filename=fname, raw_data=exp_data)
1852 data_sets.update({fname: DS})
1853
1854 # save roi and fit into dict
1855
1856 temp_roi = {}

Callers 2

load_data_from_hdf5Function · 0.85
fit_pixel_data_and_saveFunction · 0.85

Calls 3

ScanMetadataXRFClass · 0.85
DataSelectionClass · 0.85
updateMethod · 0.80

Tested by

no test coverage detected