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 @@
@@ -14,7 +14,7 @@
"outputs": [],
"outputs": [],
"source": [
"source": [
"cluster_profile = \"noDB\" # The ipcluster profile to use\n",
"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 @@
@@ -30,6 +30,7 @@
"import warnings\n",
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"\n",
 
"from iCalibrationDB import Detectors\n",
"import glob\n",
"import glob\n",
"import h5py\n",
"import h5py\n",
"from IPython.display import display, Markdown, Latex\n",
"from IPython.display import display, Markdown, Latex\n",
@@ -52,25 +53,30 @@
@@ -52,25 +53,30 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"# Load constants from local files\n",
"# TODO: After changes in the Cal DB interface read files from cal repositofy\n",
"files = glob.glob('{}/*h5'.format(out_folder))\n",
"\n",
"\n",
 
"# Load constants from local files\n",
"data = OrderedDict()\n",
"data = OrderedDict()\n",
"mod_names = []\n",
"mod_names = []\n",
"# Loop over files\n",
"# Loop over modules\n",
"for filename in files:\n",
"for i in range(16):\n",
" with h5py.File(filename, 'r') as f:\n",
" qm = \"Q{}M{}\".format(i//4 + 1, i % 4 + 1)\n",
" # Loop over modules\n",
" # loop over constants\n",
" for mKey in f.keys():\n",
" for const in ['Offset', 'Noise', 'BadPixelsDark']:\n",
" if mKey not in data:\n",
" det = getattr(Detectors.LPD1M1, qm, None)\n",
" mod_names.append(mKey)\n",
" if det is None:\n",
" data[mKey] = OrderedDict()\n",
" continue\n",
" # Loop over constants\n",
" det_name = det.device_name\n",
" for cKey in f.get(mKey):\n",
"\n",
" if cKey not in data[mKey]:\n",
" fpath = '{}/const_{}_{}.h5'.format(out_folder, const, det_name)\n",
Please register or sign in to reply
" #print(\"/\".join((mKey, cKey, '0', 'data')))\n",
" if not os.path.isfile(fpath):\n",
" data[mKey][cKey] = f.get(\n",
" continue\n",
" \"/\".join((mKey, cKey, '0', 'data'))).value\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