diff --git a/cal_tools/cal_tools/tools.py b/cal_tools/cal_tools/tools.py index 5f1170d52d52f63d55ed8a535f24e52d435c1e55..d2d480d3116b1abdad828b9778ccb455586d36f3 100644 --- a/cal_tools/cal_tools/tools.py +++ b/cal_tools/cal_tools/tools.py @@ -264,13 +264,15 @@ def get_dir_creation_date(directory: str, run: int, ntries = 100 while ntries > 0: try: - dates = [] - for f in directory.glob('*.h5'): - with h5py.File(f, 'r') as fin: - cdate = fin['METADATA/creationDate'][0].decode() - cdate = datetime.datetime.strptime(cdate, "%Y%m%dT%H%M%SZ") - dates.append(cdate) - return min(dates) + rfiles = list(directory.glob('*.h5')) + rfiles.sort(key=path.getmtime) + # get creation time for oldest file, + # as creation time between run files + # should be different only within few seconds + with h5py.File(rfiles[0], 'r') as fin: + cdate = fin['METADATA/creationDate'][0].decode() + cdate = datetime.datetime.strptime(cdate, "%Y%m%dT%H%M%SZ") + return cdate except (IOError, ValueError): ntries -= 1 except KeyError: # The files are here, but it's an older dataset diff --git a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb index e19a03b99b81b8394b893ed27e44288fabe9e932..ff59e54189eaec5d49481e77698b83dcaca5495f 100644 --- a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb +++ b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb @@ -293,9 +293,6 @@ " if acq_rate == 0.:\n", " acq_rate = get_acq_rate((f, karabo_id, idx))\n", "\n", - " print(f\"Set memory cells to {max_cells}\")\n", - " print(f\"Set acquistion rate cells to {acq_rate} MHz\")\n", - "\n", " # avoid creating retireving constant, if requested.\n", " if not nodb_with_dark: \n", " const_dict = assemble_constant_dict(corr_bools, pc_bools, max_cells, bias_voltage,\n", @@ -311,7 +308,7 @@ " co, mdata = \\\n", " get_from_db(dev, getattr(Constants.AGIPD, cname)(),\n", " condition, getattr(np, cval[0])(cval[1]),\n", - " cal_db_interface, creation_time, meta_only=True)\n", + " cal_db_interface, creation_time, meta_only=True, verbosity=0)\n", " mdata_const = mdata.calibration_constant_version\n", " # saving metadata in a dict\n", " mdata_dict[cname] = dict()\n",