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

Function retrieve_data_from_hdf_suitcase

pyxrf/model/fileio.py:1753–1796  ·  view source on GitHub ↗

Retrieve data from suitcase part in hdf file. Data name is defined in config file.

(fpath)

Source from the content-addressed store, hash-verified

1751
1752
1753def retrieve_data_from_hdf_suitcase(fpath):
1754 """
1755 Retrieve data from suitcase part in hdf file.
1756 Data name is defined in config file.
1757 """
1758 data_dict = {}
1759 with h5py.File(fpath, "r+") as f:
1760 other_data_list = [v for v in f.keys() if v != "xrfmap"]
1761 if len(other_data_list) > 0:
1762 f_hdr = f[other_data_list[0]].attrs["start"]
1763 if not isinstance(f_hdr, str):
1764 f_hdr = f_hdr.decode("utf-8")
1765 start_doc = ast.literal_eval(f_hdr)
1766 other_data = f[other_data_list[0] + "/primary/data"]
1767
1768 if start_doc["beamline_id"] == "HXN":
1769 current_dir = os.path.dirname(os.path.realpath(__file__))
1770 config_file = "hxn_pv_config.json"
1771 config_path = sep_v.join(current_dir.split(sep_v)[:-2] + ["configs", config_file])
1772 with open(config_path, "r") as json_data:
1773 config_data = json.load(json_data)
1774 extra_list = config_data["other_list"]
1775 fly_type = start_doc.get("fly_type", None)
1776 subscan_dims = start_doc.get("subscan_dims", None)
1777
1778 if "dimensions" in start_doc:
1779 datashape = start_doc["dimensions"]
1780 elif "shape" in start_doc:
1781 datashape = start_doc["shape"]
1782 else:
1783 logger.error("No dimension/shape is defined in hdr.start.")
1784
1785 datashape = [datashape[1], datashape[0]] # vertical first, then horizontal
1786 for k in extra_list:
1787 # k = k.encode('utf-8')
1788 if k not in other_data.keys():
1789 continue
1790 _v = np.array(other_data[k])
1791 v = _v.reshape(datashape)
1792 if fly_type in ("pyramid",):
1793 # flip position the same as data flip on det counts
1794 v = flip_data(v, subscan_dims=subscan_dims)
1795 data_dict[k] = v
1796 return data_dict
1797
1798
1799def read_MAPS(working_directory, file_name, channel_num=1):

Callers 1

read_hdf_APSFunction · 0.85

Calls 2

flip_dataFunction · 0.90
keysMethod · 0.80

Tested by

no test coverage detected