Skip to content

Commit

Permalink
Merge pull request #34 from anananacr/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
anananacr authored Jun 5, 2024
2 parents feecf2d + 53ee5a5 commit e5493a8
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions bblib/models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import numpy as np
from dataclasses import dataclass, field
import math
import re
from om.algorithms.crystallography import TypePeakList, Peakfinder8PeakDetection
from om.lib.geometry import (
TypePixelMaps,
TypeDetectorLayoutInformation,
GeometryInformation,
_read_crystfel_geometry_from_text,
_parse_direction
)


Expand Down Expand Up @@ -115,21 +117,43 @@ def set_geometry_from_file(self, geometry_filename: str = None):
for x in detector_panels[panel_name]["dim_structure"]
if x == "ss" or x == "fs"
]

if frame_dim_structure[0] == "ss":
self.ss_in_rows = True
else:
self.ss_in_rows = False

## The transformation matrix here are only for visualization purposes. Small stretching factors won't have an impact on the visualization of the images (slabby data).
fs_string = [
x.split(" = ")[-1][:-1]
for x in self.geometry_txt
if (x.split(" = ")[0]).split("/")[-1] == "fs"
][0]

ss_string = [
x.split(" = ")[-1][:-1]
for x in self.geometry_txt
if (x.split(" = ")[0]).split("/")[-1] == "ss"
][0]
pattern = r"([-+]?\d*\.?\d+)(?=[xyz])"

try:
fsx, fsy, fsz = re.findall(pattern, fs_string)
except(ValueError):
fsx, fsy = re.findall(pattern, fs_string)

try:
ssx, ssy, ssz = re.findall(pattern, ss_string)
except(ValueError):
ssx, ssy = re.findall(pattern, ss_string)

## The transformation matrix here is only for visualization purposes. Small stretching factors won't have an impact on the visualization of the images (slabby data).
self.transformation_matrix = [
[
np.round(detector_panels[panel_name]["fsx"]),
np.round(detector_panels[panel_name]["fsy"]),
np.round(float(fsx)),
np.round(float(fsy)),
],
[
np.round(detector_panels[panel_name]["ssx"]),
np.round(detector_panels[panel_name]["ssy"]),
np.round(float(ssx)),
np.round(float(ssy)),
],
]

Expand Down

0 comments on commit e5493a8

Please sign in to comment.