diff --git a/pyCHX/Create_Report.py b/pyCHX/Create_Report.py index 9c3a968..7d5cefd 100644 --- a/pyCHX/Create_Report.py +++ b/pyCHX/Create_Report.py @@ -1948,10 +1948,10 @@ def export_xpcs_results_to_h5(filename, export_dir, export_dict): fout = export_dir + filename dicts = ["md", "qval_dict", "qval_dict_v", "qval_dict_p"] dict_nest = ["taus_uids", "g2_uids"] + dataframe_keys = ["g2_fit_paras", "g2b_fit_paras", "spec_km_pds", "spec_pds", "qr_1d_pds"] hf = _open_xpcs_h5(fout) try: - flag = False for key in list(export_dict.keys()): # print( key ) if key in dicts: # =='md' or key == 'qval_dict': @@ -1963,19 +1963,18 @@ def export_xpcs_results_to_h5(filename, export_dir, export_dict): except Exception: print("Can't export the key: %s in this dataset." % key) - elif key in ["g2_fit_paras", "g2b_fit_paras", "spec_km_pds", "spec_pds", "qr_1d_pds"]: - try: - _write_xpcs_dataframe(export_dict[key], fout, key) - except Exception: - flag = True + elif key in dataframe_keys: + # pandas opens the HDF5 file itself, so write these entries + # after the h5py handle has been closed. + continue else: _write_xpcs_array(hf, key, export_dict[key]) finally: _close_xpcs_h5(hf) - if flag: - for key in list(export_dict.keys()): - if key in ["g2_fit_paras", "g2b_fit_paras", "spec_km_pds", "spec_pds", "qr_1d_pds"]: - _write_xpcs_dataframe(export_dict[key], fout, key) + + for key in dataframe_keys: + if key in export_dict: + _write_xpcs_dataframe(export_dict[key], fout, key) print("The xpcs analysis results are exported to %s with filename as %s" % (export_dir, filename)) diff --git a/pyCHX/chx_generic_functions.py b/pyCHX/chx_generic_functions.py index 2400f43..affdbd2 100644 --- a/pyCHX/chx_generic_functions.py +++ b/pyCHX/chx_generic_functions.py @@ -1144,7 +1144,7 @@ def copy_data(old_path, new_path="/tmp/"): Copy Eiger file containing master and data files to a new path old_path: the full path of the Eiger master file new_path: the new path - + Updated default new_path to "/tmp/" """ import glob import shutil @@ -1163,6 +1163,7 @@ def delete_data(old_path, new_path="/tmp/"): Delete copied Eiger file containing master and data in a new path old_path: the full path of the Eiger master file new_path: the new path + Updated default new_path to "/tmp/" """ import glob diff --git a/pyproject.toml b/pyproject.toml index bbb7e37..3925e38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ dependencies = [ "scikit-beam>=0.0.27,<0.1", "scikit-image>=0.20,<1", "scipy>=1.9,<2", + "tables>=3.9", "tifffile>=2022.8", "threadpoolctl>=3.1", "tqdm>=4.64",