Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
dee6e4dc
Commit
dee6e4dc
authored
2 years ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
fill table correctly if no constants retrieved
parent
5ab20f02
No related branches found
No related tags found
1 merge request
!641
[AGIPD] [CORRECT] Fix / Correcting AGIPD run with no images.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notebooks/AGIPD/AGIPD_Correct_and_Verify_Summary_NBC.ipynb
+3
-1
3 additions, 1 deletion
notebooks/AGIPD/AGIPD_Correct_and_Verify_Summary_NBC.ipynb
with
3 additions
and
1 deletion
notebooks/AGIPD/AGIPD_Correct_and_Verify_Summary_NBC.ipynb
+
3
−
1
View file @
dee6e4dc
...
...
@@ -101,7 +101,9 @@
" timestamp = const_data[const]\n",
" table_data.setdefault(timestamp, []).append(f\"{seq}:{mod}\")\n",
" table = []\n",
" if len(table_data) == 1:\n",
" if len(table_data) == 0:\n",
" table.append([\"No constants retrieved\"])\n",
" elif len(table_data) == 1:\n",
" table.append([[*table_data][0], \"All modules\"])\n",
" else:\n",
" for timestamp, seqmod in table_data.items():\n",
...
...
%% Cell type:markdown id: tags:
# Summary of the AGIPD offline correction #
%% Cell type:code id: tags:
```
python
run
=
11
# runs to process, required
out_folder
=
"
/gpfs/exfel/data/scratch/ahmedk/test/AGIPD_Corr
"
# path to output to, required
karabo_id
=
"
SPB_DET_AGIPD1M-1
"
# karabo karabo_id
modules
=
[
-
1
]
karabo_da
=
[
'
-1
'
]
# a list of data aggregators names, Default [-1] for selecting all data aggregators
```
%% Cell type:code id: tags:
```
python
import
re
import
warnings
from
pathlib
import
Path
import
dateutil.parser
import
numpy
as
np
import
yaml
warnings
.
filterwarnings
(
'
ignore
'
)
import
matplotlib.pyplot
as
plt
%
matplotlib
inline
import
tabulate
from
cal_tools.tools
import
CalibrationMetadata
from
IPython.display
import
Latex
,
Markdown
,
display
```
%% Cell type:code id: tags:
```
python
out_folder
=
Path
(
out_folder
)
metadata
=
CalibrationMetadata
(
out_folder
)
const_dict
=
metadata
.
setdefault
(
"
retrieved-constants
"
,
{})
time_dict
=
const_dict
.
setdefault
(
"
time-summary
"
,
{})
# Extracting Instrument string
instrument
=
karabo_id
.
split
(
"
_
"
)[
0
]
# Evaluate detector instance for mapping
if
instrument
==
"
SPB
"
:
dinstance
=
"
AGIPD1M1
"
nmods
=
16
elif
instrument
==
"
MID
"
:
dinstance
=
"
AGIPD1M2
"
nmods
=
16
elif
instrument
==
"
HED
"
:
dinstance
=
"
AGIPD500K
"
nmods
=
8
if
karabo_da
[
0
]
==
'
-1
'
:
if
modules
[
0
]
==
-
1
:
modules
=
list
(
range
(
nmods
))
karabo_da
=
[
"
AGIPD{:02d}
"
.
format
(
i
)
for
i
in
modules
]
else
:
modules
=
[
int
(
x
[
-
2
:])
for
x
in
karabo_da
]
# This is needed only if AGIPD Correction notebook had no precorrection notebooks for retrieving constants
# gather all generated sequence yml files for time summary of retrieved constant under retrieved-constants in metadata.yml
for
fn
in
sorted
(
out_folder
.
glob
(
"
retrieved_constants_*.yml
"
)):
with
fn
.
open
(
"
r
"
)
as
fd
:
fdict
=
yaml
.
safe_load
(
fd
)
# append different sequences' time summary to the main yaml
time_dict
.
update
(
fdict
[
"
time-summary
"
])
fn
.
unlink
()
metadata
.
save
()
```
%% Cell type:code id: tags:
```
python
def
print_const_table
(
const
):
print
(
f
"
{
const
}
constants were injected on:
"
)
table_data
=
{}
for
seq
,
mod_data
in
time_dict
.
items
():
for
mod
,
const_data
in
mod_data
.
items
():
timestamp
=
const_data
[
const
]
table_data
.
setdefault
(
timestamp
,
[]).
append
(
f
"
{
seq
}
:
{
mod
}
"
)
table
=
[]
if
len
(
table_data
)
==
1
:
if
len
(
table_data
)
==
0
:
table
.
append
([
"
No constants retrieved
"
])
elif
len
(
table_data
)
==
1
:
table
.
append
([[
*
table_data
][
0
],
"
All modules
"
])
else
:
for
timestamp
,
seqmod
in
table_data
.
items
():
table
.
append
([
timestamp
,
seqmod
[
0
]])
for
further_module
in
seqmod
[
1
:]:
table
.
append
([
""
,
further_module
])
display
(
Latex
(
tabulate
.
tabulate
(
table
,
tablefmt
=
"
latex
"
,
headers
=
[
"
Timestamps
"
,
"
Modules and sequences
"
])))
for
const
in
[
'
Offset
'
,
'
SlopesPC
'
,
'
SlopesFF
'
]:
print_const_table
(
const
)
```
%% Cell type:code id: tags:
```
python
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment