diff options
author | Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr> | 2016-05-02 14:46:40 +0200 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr> | 2016-05-02 14:46:40 +0200 |
commit | 524e812416eee73f6c297f01a26fcd6cbe8e4795 (patch) | |
tree | e190a35f53ef3958b3d29069624d6c3909e26e05 /binoculars | |
parent | a6c4d417e5ed28d3ec648625865ccb4a0cd8da21 (diff) |
Add the Hkl[Geometry/Detector/Sample] objects
Diffstat (limited to 'binoculars')
-rw-r--r-- | binoculars/backends/sixs.py | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/binoculars/backends/sixs.py b/binoculars/backends/sixs.py index 1a414a4..28a8d9c 100644 --- a/binoculars/backends/sixs.py +++ b/binoculars/backends/sixs.py @@ -38,6 +38,7 @@ from math import cos, sin from networkx import DiGraph, dijkstra_path from numpy.linalg import inv from pyFAI.detectors import ALL_DETECTORS +from gi.repository import Hkl from .. import backend, errors, util @@ -52,6 +53,10 @@ else: ZAXIS = "ZAXIS" SOLEIL_SIXS_MED1_2 = "SOLEIL SIXS MED1+2" +############### +# Projections # +############### + PDataFrame = namedtuple("PDataFrame", ["pixels", "k", "ub", "R", "P"]) @@ -151,6 +156,10 @@ class QparQperProjection(QxQyQzProjection): return 'Qpar', 'Qper' +################### +# Common methodes # +################### + def get_nxclass(hfile, nxclass, path="/"): """ :param hfile: the hdf5 file. @@ -215,7 +224,9 @@ def get_axes(name): Diffractometer = namedtuple('Diffractometer', ['name', # name of the hkl diffractometer 'ub', # the UB matrix - 'axes']) # the Axes namedtuple + 'axes', # the Axes namedtuple + 'geometry']) # the HklGeometry + def get_diffractometer(hfile): @@ -226,12 +237,18 @@ def get_diffractometer(hfile): ub = node.UB[:] axes = get_axes(name) - return Diffractometer(name, ub, axes) + factory = Hkl.factories()[name] + geometry = factory.create_new_geometry() + + # wavelength = get_nxclass(hfile, 'NXmonochromator').wavelength[0] + # geometry.wavelength_set(wavelength) + + return Diffractometer(name, ub, axes, geometry) Sample = namedtuple("Sample", ["a", "b", "c", "alpha", "beta", "gamma", - "ux", "uy", "uz", "graph"]) + "ux", "uy", "uz", "graph", "sample"]) def get_sample(hfile): @@ -242,14 +259,40 @@ def get_sample(hfile): graph.add_edges_from([("ux", "uy"), ("uy", "uz")]) - return Sample(1.54, 1.54, 1.54, 90, 90, 90, 0, 0, 0, graph) + # hkl sample + a = b = c = 1.54 + alpha = beta = gamma = 90 + ux = uy = uz = 0 + + sample = Hkl.Sample.new("test") + lattice = Hkl.Lattice.new(a, b, c, + math.radians(alpha), + math.radians(beta), + math.radians(gamma)) + sample.lattice_set(lattice) + parameter = sample.ux_get() + parameter.value_set(ux, Hkl.UnitEnum.USER) + sample.ux_set(parameter) -Detector = namedtuple("Detector", ["name"]) + parameter = sample.uy_get() + parameter.value_set(uy, Hkl.UnitEnum.USER) + sample.uy_set(parameter) + + parameter = sample.uz_get() + parameter.value_set(uz, Hkl.UnitEnum.USER) + sample.uz_set(parameter) + + return Sample(1.54, 1.54, 1.54, 90, 90, 90, 0, 0, 0, graph, sample) + + +Detector = namedtuple("Detector", ["name", "detector"]) def get_detector(hfile): - return Detector("imxpads140") + detector = Hkl.Detector.factory_new(Hkl.DetectorType(0)) + + return Detector("imxpads140", detector) Source = namedtuple("Source", ["wavelength"]) @@ -354,6 +397,10 @@ def normalized(a, axis=-1, order=2): return a / numpy.expand_dims(l2, axis) +################## +# Input Backends # +################## + class SIXS(backend.InputBase): # OFFICIAL API |