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
6a66dc74
Commit
6a66dc74
authored
2 years ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
use jf metadata instead of pnccd for testing
parent
851bc400
No related branches found
No related tags found
2 merge requests
!828
[PNCCD][CORRECT] Record fragment file and remove pre correction notebook
,
!776
[PNCCD][CORRECT] Using calcat interface
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cal_tools/tools.py
+1
-0
1 addition, 0 deletions
src/cal_tools/tools.py
tests/test_cal_tools.py
+110
-32
110 additions, 32 deletions
tests/test_cal_tools.py
with
111 additions
and
32 deletions
src/cal_tools/tools.py
+
1
−
0
View file @
6a66dc74
...
...
@@ -991,6 +991,7 @@ def write_constants_fragment(
metadata
[
"
retrieved-constants
"
][
karabo_da
]
=
mod_metadata
CalibrationMetadata
(
out_folder
).
add_fragment
(
metadata
)
def
write_compressed_frames
(
arr
:
np
.
ndarray
,
ofile
:
h5py
.
File
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_cal_tools.py
+
110
−
32
View file @
6a66dc74
...
...
@@ -488,51 +488,129 @@ def test_recursive_update():
assert
tgt
==
{
"
a
"
:
{
"
b
"
:
1
},
"
c
"
:
2
,
"
e
"
:
4
}
def
test_write_constants_fragment
(
tmp_path
):
pnccd_metadata
=
{
"
PNCCD01
"
:{
"
OffsetCCD
"
:
{
'
cc_id
'
:
8540
,
'
cc_name
'
:
'
pnCCD-Type_OffsetCCD_CCD Def9/wVu81XPSIX
'
,
'
condition_id
'
:
2478
,
'
ccv_id
'
:
51443
,
'
ccv_name
'
:
'
20200820_184154_sIdx=0
'
,
'
path
'
:
Path
(
'
xfel/cal/pnccd-type/pnccd_m205_m206/cal.1597948913.0951352.h5
'
),
# noqa
'
dataset
'
:
'
/PnCCD_M205_M206/OffsetCCD/0
'
,
'
begin_validity_at
'
:
'
2020-08-20T20:34:28.000+02:00
'
,
'
end_validity_at
'
:
None
,
'
raw_data_location
'
:
'
Proposal: p900166, Run: 338
'
,
'
start_idx
'
:
0
,
'
end_idx
'
:
0
,
'
physical_name
'
:
'
pnCCD_M205_M206
'
,
def
test_write_constants_fragment
(
tmp_path
:
Path
):
"""
Test `write_constants_fragment` with jungfrau.
This metadata is from constants used to correct FXE_XAD_JF1M
detector from proposal 900226, run 106.
tmp_path:
tmp_path (pathlib.Path): Temporary directory for file tests.
https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html
"""
jf_metadata
=
{
"
JNGFR01
"
:
{
"
Offset10Hz
"
:
{
"
cc_id
"
:
7064
,
"
cc_name
"
:
"
jungfrau-Type_Offset10Hz_Jungfrau DefiFE6iJX
"
,
"
condition_id
"
:
2060
,
"
ccv_id
"
:
41876
,
"
ccv_name
"
:
"
20200304_152733_sIdx=0
"
,
"
path
"
:
Path
(
"
xfel/cal/jungfrau-type/jungfrau_m233/cal.1583335651.8084984.h5
"
),
"
dataset
"
:
"
/Jungfrau_M233/Offset10Hz/0
"
,
"
begin_validity_at
"
:
"
2020-03-04T15:16:34.000+01:00
"
,
"
end_validity_at
"
:
None
,
"
raw_data_location
"
:
"
proposal:p900121 runs:136 137 138
"
,
"
start_idx
"
:
0
,
"
end_idx
"
:
0
,
"
physical_name
"
:
"
Jungfrau_M233
"
},
"
BadPixelsDark10Hz
"
:
{
"
cc_id
"
:
7066
,
"
cc_name
"
:
"
jungfrau-Type_BadPixelsDark10Hz_Jungfrau DefiFE6iJX
"
,
"
condition_id
"
:
2060
,
"
ccv_id
"
:
41878
,
"
ccv_name
"
:
"
20200304_152740_sIdx=0
"
,
"
path
"
:
Path
(
"
xfel/cal/jungfrau-type/jungfrau_m233/cal.1583335658.6813955.h5
"
),
"
dataset
"
:
"
/Jungfrau_M233/BadPixelsDark10Hz/0
"
,
"
begin_validity_at
"
:
"
2020-03-04T15:16:34.000+01:00
"
,
"
end_validity_at
"
:
None
,
"
raw_data_location
"
:
"
proposal:p900121 runs:136 137 138
"
,
"
start_idx
"
:
0
,
"
end_idx
"
:
0
,
"
physical_name
"
:
"
Jungfrau_M233
"
}
},
},
}
"
JNGFR02
"
:
{
"
Offset10Hz
"
:
{
"
cc_id
"
:
7067
,
"
cc_name
"
:
"
jungfrau-Type_Offset10Hz_Jungfrau DefzgIVHz1
"
,
"
condition_id
"
:
2061
,
"
ccv_id
"
:
41889
,
"
ccv_name
"
:
"
20200304_154434_sIdx=0
"
,
"
path
"
:
Path
(
"
xfel/cal/jungfrau-type/jungfrau_m125/cal.1583336672.760199.h5
"
),
"
dataset
"
:
"
/Jungfrau_M125/Offset10Hz/0
"
,
"
begin_validity_at
"
:
"
2020-03-04T15:16:34.000+01:00
"
,
"
end_validity_at
"
:
None
,
"
raw_data_location
"
:
"
proposal:p900121 runs:136 137 138
"
,
"
start_idx
"
:
0
,
"
end_idx
"
:
0
,
"
physical_name
"
:
"
Jungfrau_M125
"
,
},
"
BadPixelsDark10Hz
"
:
{
"
cc_id
"
:
7069
,
"
cc_name
"
:
"
jungfrau-Type_BadPixelsDark10Hz_Jungfrau DefzgIVHz1
"
,
"
condition_id
"
:
2061
,
"
ccv_id
"
:
41893
,
"
ccv_name
"
:
"
20200304_154441_sIdx=0
"
,
"
path
"
:
Path
(
"
xfel/cal/jungfrau-type/jungfrau_m125/cal.1583336679.5835564.h5
"
),
"
dataset
"
:
"
/Jungfrau_M125/BadPixelsDark10Hz/0
"
,
"
begin_validity_at
"
:
"
2020-03-04T15:16:34.000+01:00
"
,
"
end_validity_at
"
:
None
,
"
raw_data_location
"
:
"
proposal:p900121 runs:136 137 138
"
,
"
start_idx
"
:
0
,
"
end_idx
"
:
0
,
"
physical_name
"
:
"
Jungfrau_M125
"
,
}
}
}
write_constants_fragment
(
tmp_path
,
pnccd
_metadata
,
jf
_metadata
,
Path
(
"
/gpfs/exfel/d/cal/caldb_store
"
)
)
fragments
=
list
(
tmp_path
.
glob
(
"
metadata_frag*yml
"
))
assert
len
(
fragments
)
==
1
# Open YAML file
with
open
(
fragments
[
0
],
'
r
'
)
as
file
:
with
open
(
fragments
[
0
],
"
r
"
)
as
file
:
# Load YAML content into dictionary
yaml_dict
=
yaml
.
safe_load
(
file
)
assert
yaml_dict
==
{
"
retrieved-constants
"
:
{
"
PNCCD
01
"
:
{
"
retrieved-constants
"
:{
"
JNGFR
01
"
:
{
"
constants
"
:
{
"
OffsetCCD
"
:
{
"
path
"
:
"
/gpfs/exfel/d/cal/caldb_store/xfel/cal/pnccd-type/pnccd_m205_m206/cal.1597948913.0951352.h5
"
,
# noqa
"
dataset
"
:
"
/PnCCD_M205_M206/OffsetCCD/0
"
,
"
creation-time
"
:
"
2020-08-20T20:34:28.000+02:00
"
,
"
ccv_id
"
:
51443
,
},
"
BadPixelsDark10Hz
"
:
{
"
ccv_id
"
:
41878
,
"
creation-time
"
:
"
2020-03-04T15:16:34.000+01:00
"
,
"
dataset
"
:
"
/Jungfrau_M233/BadPixelsDark10Hz/0
"
,
"
path
"
:
"
/gpfs/exfel/d/cal/caldb_store/xfel/cal/jungfrau-type/jungfrau_m233/cal.1583335658.6813955.h5
"
,
# noqa
},
"
physical-name
"
:
"
pnCCD_M205_M206
"
,
}
}
"
Offset10Hz
"
:
{
"
ccv_id
"
:
41876
,
"
creation-time
"
:
"
2020-03-04T15:16:34.000+01:00
"
,
"
dataset
"
:
"
/Jungfrau_M233/Offset10Hz/0
"
,
"
path
"
:
"
/gpfs/exfel/d/cal/caldb_store/xfel/cal/jungfrau-type/jungfrau_m233/cal.1583335651.8084984.h5
"
,
# noqa
},
},
"
physical-name
"
:
"
Jungfrau_M233
"
,
},
"
JNGFR02
"
:
{
"
constants
"
:
{
"
BadPixelsDark10Hz
"
:
{
"
ccv_id
"
:
41893
,
"
creation-time
"
:
"
2020-03-04T15:16:34.000+01:00
"
,
"
dataset
"
:
"
/Jungfrau_M125/BadPixelsDark10Hz/0
"
,
"
path
"
:
"
/gpfs/exfel/d/cal/caldb_store/xfel/cal/jungfrau-type/jungfrau_m125/cal.1583336679.5835564.h5
"
,
# noqa
},
"
Offset10Hz
"
:
{
"
ccv_id
"
:
41889
,
"
creation-time
"
:
"
2020-03-04T15:16:34.000+01:00
"
,
"
dataset
"
:
"
/Jungfrau_M125/Offset10Hz/0
"
,
"
path
"
:
"
/gpfs/exfel/d/cal/caldb_store/xfel/cal/jungfrau-type/jungfrau_m125/cal.1583336672.760199.h5
"
,
# noqa
},
},
"
physical-name
"
:
"
Jungfrau_M125
"
,
},
}
}
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