Skip to content
Snippets Groups Projects

Fix: LPD DARK Reading of saved constants

Merged Mikhail Karnevskiy requested to merge fix/file_reading into master
1 unresolved thread
1 file
+ 23
17
Compare changes
  • Side-by-side
  • Inline
@@ -14,7 +14,7 @@
"outputs": [],
"source": [
"cluster_profile = \"noDB\" # The ipcluster profile to use\n",
"out_folder = \"/gpfs/exfel/data/scratch/karnem/LPD/\" # path to output to, required"
"out_folder = \"/gpfs/exfel/data/scratch/karnem/test/LPD_dark_004/\" # path to output to, required"
]
},
{
@@ -30,6 +30,7 @@
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"from iCalibrationDB import Detectors\n",
"import glob\n",
"import h5py\n",
"from IPython.display import display, Markdown, Latex\n",
@@ -52,25 +53,30 @@
"metadata": {},
"outputs": [],
"source": [
"# Load constants from local files\n",
"files = glob.glob('{}/*h5'.format(out_folder))\n",
"# TODO: After changes in the Cal DB interface read files from cal repositofy\n",
"\n",
"# Load constants from local files\n",
"data = OrderedDict()\n",
"mod_names = []\n",
"# Loop over files\n",
"for filename in files:\n",
" with h5py.File(filename, 'r') as f:\n",
" # Loop over modules\n",
" for mKey in f.keys():\n",
" if mKey not in data:\n",
" mod_names.append(mKey)\n",
" data[mKey] = OrderedDict()\n",
" # Loop over constants\n",
" for cKey in f.get(mKey):\n",
" if cKey not in data[mKey]:\n",
" #print(\"/\".join((mKey, cKey, '0', 'data')))\n",
" data[mKey][cKey] = f.get(\n",
" \"/\".join((mKey, cKey, '0', 'data'))).value\n"
"# Loop over modules\n",
"for i in range(16):\n",
" qm = \"Q{}M{}\".format(i//4 + 1, i % 4 + 1)\n",
" # loop over constants\n",
" for const in ['Offset', 'Noise', 'BadPixelsDark']:\n",
" det = getattr(Detectors.LPD1M1, qm, None)\n",
" if det is None:\n",
" continue\n",
" det_name = det.device_name\n",
"\n",
" fpath = '{}/const_{}_{}.h5'.format(out_folder, const, det_name)\n",
Please register or sign in to reply
" if not os.path.isfile(fpath):\n",
" continue\n",
" with h5py.File(fpath, 'r') as f:\n",
" if qm not in data:\n",
" mod_names.append(qm)\n",
" data[qm] = OrderedDict()\n",
"\n",
" data[qm][const] = f[\"data\"][()]"
]
},
{
Loading