Skip to content
Snippets Groups Projects
Commit f276de19 authored by Egor Sobolev's avatar Egor Sobolev
Browse files

Fix connected group paramter in report notebook

parent 157fe57d
No related branches found
No related tags found
No related merge requests found
%% 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 = "" 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,
) )
``` ```
%% 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 = read_crystfel_geom(geometry_file, indexes={'modno': 1}) panels, beam = 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):9d} chunks, {len(la):9d} crystalls") print(f"read: {len(fr):9d} chunks, {len(la):9d} 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: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:
\newpage \newpage
%% 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:.4f} pixels.") print(f"Detector-wide error: RMSD = {rmsd_detector:.4f} pixels.")
rmsd = rmsd_per_group(pxdispl, panels, "modules") 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)
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment