Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
dataAnalysis
geomtools
Commits
bab254a0
Commit
bab254a0
authored
4 weeks ago
by
Egor Sobolev
Browse files
Options
Downloads
Patches
Plain Diff
Add snr parameter to sfx hot-pixels mask
parent
7e8c4b1f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
SNR parameter for sfx mask maker
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/geomtools/sfx/optimiser.py
+3
-1
3 additions, 1 deletion
src/geomtools/sfx/optimiser.py
src/geomtools/sfx/report.ipynb
+3
-3
3 additions, 3 deletions
src/geomtools/sfx/report.ipynb
with
6 additions
and
4 deletions
src/geomtools/sfx/optimiser.py
+
3
−
1
View file @
bab254a0
...
@@ -21,6 +21,8 @@ def refine():
...
@@ -21,6 +21,8 @@ def refine():
help
=
"
Collection of rigid groups to pose
"
)
help
=
"
Collection of rigid groups to pose
"
)
parser
.
add_argument
(
'
-m
'
,
'
--min-counts
'
,
type
=
int
,
default
=
50
,
parser
.
add_argument
(
'
-m
'
,
'
--min-counts
'
,
type
=
int
,
default
=
50
,
help
=
"
Minimum counts per group
"
)
help
=
"
Minimum counts per group
"
)
parser
.
add_argument
(
'
--snr
'
,
type
=
float
,
default
=
4
,
help
=
"
SNR for bad pixels threshold
"
)
parser
.
add_argument
(
'
-o
'
,
'
--output
'
,
type
=
pathlib
.
Path
,
parser
.
add_argument
(
'
-o
'
,
'
--output
'
,
type
=
pathlib
.
Path
,
default
=
pathlib
.
Path
(
"
refined.geom
"
),
default
=
pathlib
.
Path
(
"
refined.geom
"
),
help
=
"
File to store refined geometry
"
)
help
=
"
File to store refined geometry
"
)
...
@@ -69,7 +71,7 @@ def refine():
...
@@ -69,7 +71,7 @@ def refine():
panels_new
,
transform
,
clen
=
refine_geometry
(
panels_new
,
transform
,
clen
=
refine_geometry
(
ma
,
panels
,
layout
,
1.0
,
args
.
min_counts
,
args
.
connected
)
ma
,
panels
,
layout
,
1.0
,
args
.
min_counts
,
args
.
connected
)
px
=
badpixels_mask
(
pe
,
panels
)
px
=
badpixels_mask
(
pe
,
panels
,
snr
=
args
.
snr
)
badpx
=
pixels_to_image
(
shape
,
px
)
badpx
=
pixels_to_image
(
shape
,
px
)
geom_fn
=
args
.
output
geom_fn
=
args
.
output
...
...
This diff is collapsed.
Click to expand it.
src/geomtools/sfx/report.ipynb
+
3
−
3
View file @
bab254a0
...
@@ -205,7 +205,7 @@
...
@@ -205,7 +205,7 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"px = badpixels_mask(pe, panels)\n",
"px = badpixels_mask(pe, panels
, snr=4
)\n",
"shape = get_detector_shape(panels)\n",
"shape = get_detector_shape(panels)\n",
"msk = pixels_to_image(shape, px, 'msk')\n",
"msk = pixels_to_image(shape, px, 'msk')\n",
"fig, ax = plot_data_on_detector(msk, panels, colorbar=False, cmap=plt.cm.copper)"
"fig, ax = plot_data_on_detector(msk, panels, colorbar=False, cmap=plt.cm.copper)"
...
@@ -284,7 +284,7 @@
...
@@ -284,7 +284,7 @@
"metadata": {
"metadata": {
"celltoolbar": "Raw Cell Format",
"celltoolbar": "Raw Cell Format",
"kernelspec": {
"kernelspec": {
"display_name": "Python 3
.9
",
"display_name": "Python 3
(ipykernel)
",
"language": "python",
"language": "python",
"name": "python3"
"name": "python3"
},
},
...
@@ -298,7 +298,7 @@
...
@@ -298,7 +298,7 @@
"name": "python",
"name": "python",
"nbconvert_exporter": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"pygments_lexer": "ipython3",
"version": "3.
9.16
"
"version": "3.
11.7
"
},
},
"title": "Detector geometry optimisation report"
"title": "Detector geometry optimisation report"
},
},
...
...
%% Cell type:code id:3852d9ec-1143-4846-9f48-11751729d547 tags:parameters
%% Cell type:code id:3852d9ec-1143-4846-9f48-11751729d547 tags:parameters
```
python
```
python
xwiz_dir
=
""
xwiz_dir
=
""
stream_file
=
""
stream_file
=
""
summary_file
=
""
summary_file
=
""
prefix
=
""
prefix
=
""
output_dir
=
""
output_dir
=
""
geometry_file
=
""
geometry_file
=
""
connected_groups
=
""
connected_groups
=
""
```
```
%% Cell type:code id:19d522a3-26f5-4ac6-a4af-ee2139deafa2 tags:
%% Cell type:code id:19d522a3-26f5-4ac6-a4af-ee2139deafa2 tags:
```
python
```
python
import
os
import
os
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
import
pandas
as
pd
import
pandas
as
pd
from
cfelpyutils.geometry
import
load_crystfel_geometry
from
cfelpyutils.geometry
import
load_crystfel_geometry
from
geomtools
import
(
from
geomtools
import
(
read_crystfel_streamfile
,
extract_geometry
,
parse_xwiz_summary
,
read_crystfel_streamfile
,
extract_geometry
,
parse_xwiz_summary
,
read_crystfel_geom
,
plot_center_shift
,
plot_cell_parameters
,
read_crystfel_geom
,
plot_center_shift
,
plot_cell_parameters
,
plot_peakogram
,
plot_powder
,
get_peak_position
,
rmsd_per_group
,
plot_peakogram
,
plot_powder
,
get_peak_position
,
rmsd_per_group
,
avg_pixel_displacement
,
plot_geoptimiser_errormap
,
avg_pixel_displacement
,
plot_geoptimiser_errormap
,
plot_data_on_detector
,
pixels_to_image
,
badpixels_mask
,
plot_data_on_detector
,
pixels_to_image
,
badpixels_mask
,
get_detector_shape
get_detector_shape
)
)
```
```
%% Cell type:code id:776ff0aa tags:
%% Cell type:code id:776ff0aa tags:
```
python
```
python
xwiz_conf
,
summary
=
parse_xwiz_summary
(
summary_file
)
xwiz_conf
,
summary
=
parse_xwiz_summary
(
summary_file
)
propno
=
int
(
xwiz_conf
[
'
data
'
][
'
proposal
'
])
propno
=
int
(
xwiz_conf
[
'
data
'
][
'
proposal
'
])
runs
=
eval
(
xwiz_conf
[
'
data
'
][
'
runs
'
])
runs
=
eval
(
xwiz_conf
[
'
data
'
][
'
runs
'
])
panels
,
beam
,
mask
=
read_crystfel_geom
(
geometry_file
,
indexes
=
{
'
modno
'
:
1
})
panels
,
beam
,
mask
=
read_crystfel_geom
(
geometry_file
,
indexes
=
{
'
modno
'
:
1
})
panel_columns
=
panels
.
columns
.
tolist
()
+
[
'
panel
'
]
panel_columns
=
panels
.
columns
.
tolist
()
+
[
'
panel
'
]
if
connected_groups
not
in
panel_columns
:
if
connected_groups
not
in
panel_columns
:
raise
ValueError
(
raise
ValueError
(
f
"
Connected groups
'
{
connected_groups
}
'
are not defined
"
)
f
"
Connected groups
'
{
connected_groups
}
'
are not defined
"
)
photon_energy
=
beam
[
'
photon_energy
'
]
photon_energy
=
beam
[
'
photon_energy
'
]
clen
=
panels
.
clen
.
unique
()
clen
=
panels
.
clen
.
unique
()
if
len
(
clen
)
==
1
:
if
len
(
clen
)
==
1
:
clen
=
clen
[
0
]
clen
=
clen
[
0
]
fr
,
pe
,
la
,
re
,
ma
=
read_crystfel_streamfile
(
fr
,
pe
,
la
,
re
,
ma
=
read_crystfel_streamfile
(
stream_file
,
panels
,
connected_groups
,
disp
=
False
)
stream_file
,
panels
,
connected_groups
,
disp
=
False
)
```
```
%% Cell type:markdown id:046f728b tags:
%% Cell type:markdown id:046f728b tags:
# EXtra-xwiz summary
# EXtra-xwiz summary
%% Cell type:code id:7c2a58aa tags:
%% Cell type:code id:7c2a58aa tags:
```
python
```
python
print
(
f
"
Proposal:
{
propno
}
"
)
print
(
f
"
Proposal:
{
propno
}
"
)
print
(
f
"
Runs:
{
runs
}
"
)
print
(
f
"
Runs:
{
runs
}
"
)
print
()
print
()
print
(
f
"
Photon energy:
{
photon_energy
}
eV
"
)
print
(
f
"
Photon energy:
{
photon_energy
}
eV
"
)
print
(
f
"
Distance to sample:
{
clen
}
m
"
)
print
(
f
"
Distance to sample:
{
clen
}
m
"
)
print
()
print
()
print
(
summary
)
print
(
summary
)
print
()
print
()
print
(
"
From Crystfel stream file
"
)
print
(
"
From Crystfel stream file
"
)
print
(
f
"
read:
{
len
(
fr
)
:
9
d
}
chunks,
{
len
(
la
)
:
9
d
}
crystalls
"
)
print
(
f
"
read:
{
len
(
fr
)
:
9
d
}
chunks,
{
len
(
la
)
:
9
d
}
crystalls
"
)
```
```
%% Cell type:markdown id:3978ac22 tags:
%% Cell type:markdown id:3978ac22 tags:
# Cell parameters
# Cell parameters
%% Cell type:code id:2050288b-6bbd-4e5a-9854-04cde094ff6b tags:
%% Cell type:code id:2050288b-6bbd-4e5a-9854-04cde094ff6b tags:
```
python
```
python
fig
,
axs
=
plot_cell_parameters
(
la
)
fig
,
axs
=
plot_cell_parameters
(
la
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id:59980ed1 tags:
%% Cell type:markdown id:59980ed1 tags:
# Center shift
# Center shift
%% Cell type:code id:c4265f40-f0c4-4ad6-bfbd-21796fb1354c tags:
%% Cell type:code id:c4265f40-f0c4-4ad6-bfbd-21796fb1354c tags:
```
python
```
python
fig
,
ax
=
plot_center_shift
(
la
)
fig
,
ax
=
plot_center_shift
(
la
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id:d772ce42 tags:
%% Cell type:markdown id:d772ce42 tags:
# Peakogram
# Peakogram
%% Cell type:code id:5ce7abee-fd09-48d3-85ef-cacc7b3a3468 tags:
%% Cell type:code id:5ce7abee-fd09-48d3-85ef-cacc7b3a3468 tags:
```
python
```
python
fig
,
ax
=
plot_peakogram
(
re
)
fig
,
ax
=
plot_peakogram
(
re
)
plt
.
show
()
plt
.
show
()
```
```
%% Cell type:markdown id:7f05317e tags:
%% Cell type:markdown id:7f05317e tags:
# Pseudo-powder diffraction
# Pseudo-powder diffraction
%% Cell type:code id:3cdf4100 tags:
%% Cell type:code id:3cdf4100 tags:
```
python
```
python
peak_pos
=
pe
[[
'
intensity
'
]].
join
(
get_peak_position
(
pe
,
panels
))
peak_pos
=
pe
[[
'
intensity
'
]].
join
(
get_peak_position
(
pe
,
panels
))
fig
,
ax
=
plot_powder
(
peak_pos
,
counts
=
False
)
fig
,
ax
=
plot_powder
(
peak_pos
,
counts
=
False
)
```
```
%% Cell type:markdown id:c407096a tags:
%% Cell type:markdown id:c407096a tags:
# Peak distribution
# Peak distribution
%% Cell type:code id:aa673412 tags:
%% Cell type:code id:aa673412 tags:
```
python
```
python
fig
,
ax
=
plot_powder
(
peak_pos
,
counts
=
True
)
fig
,
ax
=
plot_powder
(
peak_pos
,
counts
=
True
)
```
```
%% Cell type:markdown id:c5fb7a10-6ec2-4fc1-93bd-931440c7d0de tags:
%% Cell type:markdown id:c5fb7a10-6ec2-4fc1-93bd-931440c7d0de tags:
# Bad pixels
# Bad pixels
%% Cell type:code id:e5a90585-47e1-4445-a038-e6bed28ec13d tags:
%% Cell type:code id:e5a90585-47e1-4445-a038-e6bed28ec13d tags:
```
python
```
python
px
=
badpixels_mask
(
pe
,
panels
)
px
=
badpixels_mask
(
pe
,
panels
,
snr
=
4
)
shape
=
get_detector_shape
(
panels
)
shape
=
get_detector_shape
(
panels
)
msk
=
pixels_to_image
(
shape
,
px
,
'
msk
'
)
msk
=
pixels_to_image
(
shape
,
px
,
'
msk
'
)
fig
,
ax
=
plot_data_on_detector
(
msk
,
panels
,
colorbar
=
False
,
cmap
=
plt
.
cm
.
copper
)
fig
,
ax
=
plot_data_on_detector
(
msk
,
panels
,
colorbar
=
False
,
cmap
=
plt
.
cm
.
copper
)
```
```
%% Cell type:markdown id:d13224ba-344a-460d-8a18-ae011e3839e4 tags:
%% Cell type:markdown id:d13224ba-344a-460d-8a18-ae011e3839e4 tags:
# Peak distribution (masked)
# Peak distribution (masked)
%% Cell type:code id:aa6706da-0470-4dc1-a88b-428fd209eb89 tags:
%% Cell type:code id:aa6706da-0470-4dc1-a88b-428fd209eb89 tags:
```
python
```
python
flag
=
~
(
flag
=
~
(
pe
[[
'
panel
'
,
'
fs
'
,
'
ss
'
,
'
intensity
'
]]
pe
[[
'
panel
'
,
'
fs
'
,
'
ss
'
,
'
intensity
'
]]
.
astype
({
'
fs
'
:
int
,
'
ss
'
:
int
})
.
astype
({
'
fs
'
:
int
,
'
ss
'
:
int
})
.
join
(
px
.
set_index
([
'
panel
'
,
'
fs
'
,
'
ss
'
]),
on
=
[
'
panel
'
,
'
fs
'
,
'
ss
'
]).
msk
.
join
(
px
.
set_index
([
'
panel
'
,
'
fs
'
,
'
ss
'
]),
on
=
[
'
panel
'
,
'
fs
'
,
'
ss
'
]).
msk
)
)
peak_pos
=
pe
[
flag
][[
'
intensity
'
]].
join
(
get_peak_position
(
pe
,
panels
))
peak_pos
=
pe
[
flag
][[
'
intensity
'
]].
join
(
get_peak_position
(
pe
,
panels
))
fig
,
ax
=
plot_powder
(
peak_pos
,
counts
=
True
)
fig
,
ax
=
plot_powder
(
peak_pos
,
counts
=
True
)
```
```
%% Cell type:markdown id:81b065a7 tags:
%% Cell type:markdown id:81b065a7 tags:
# Geoptimiser error map
# Geoptimiser error map
%% Cell type:code id:0d829343 tags:
%% Cell type:code id:0d829343 tags:
```
python
```
python
pxdispl
=
avg_pixel_displacement
(
ma
,
panels
)
pxdispl
=
avg_pixel_displacement
(
ma
,
panels
)
fig
,
ax
=
plot_geoptimiser_errormap
(
pxdispl
,
panels
)
fig
,
ax
=
plot_geoptimiser_errormap
(
pxdispl
,
panels
)
```
```
%% Cell type:markdown id:5cbe54a5 tags:
%% Cell type:markdown id:5cbe54a5 tags:
\n
ewpage
\n
ewpage
%% Cell type:code id:d4041551 tags:
%% Cell type:code id:d4041551 tags:
```
python
```
python
rmsd_detector
=
np
.
sqrt
((
pxdispl
.
r_avg
*
pxdispl
.
r_avg
).
mean
())
rmsd_detector
=
np
.
sqrt
((
pxdispl
.
r_avg
*
pxdispl
.
r_avg
).
mean
())
print
(
f
"
Detector-wide error: RMSD =
{
rmsd_detector
:
.
4
f
}
pixels.
"
)
print
(
f
"
Detector-wide error: RMSD =
{
rmsd_detector
:
.
4
f
}
pixels.
"
)
rmsd
=
rmsd_per_group
(
pxdispl
,
panels
,
connected_groups
)
rmsd
=
rmsd_per_group
(
pxdispl
,
panels
,
connected_groups
)
rmsd
=
rmsd
.
sort_index
(
key
=
np
.
vectorize
(
lambda
x
:
int
(
x
[
1
:])))
rmsd
=
rmsd
.
sort_index
(
key
=
np
.
vectorize
(
lambda
x
:
int
(
x
[
1
:])))
print
(
"
Error per module:
"
)
print
(
"
Error per module:
"
)
display
(
rmsd
)
display
(
rmsd
)
```
```
...
...
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