2 # -*- coding: utf-8 -*-
4 This file is part of the hkl library.
6 The hkl library is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 The hkl library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
19 Copyright (C) 2003-2012, 2019 Synchrotron SOLEIL
20 L'Orme des Merisiers Saint-Aubin
21 BP 48 91192 GIF-sur-YVETTE CEDEX
22 Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
26 from gi
.repository
import GLib
27 from gi
.repository
import Hkl
29 detector
= Hkl
.Detector
.factory_new(Hkl
.DetectorType(0))
31 factory
= Hkl
.factories()['K6C']
32 geometry
= factory
.create_new_geometry()
33 values_w
= [0., 30., 0., 0., 0., 60.]
34 geometry
.axis_values_set(values_w
, Hkl
.UnitEnum
.USER
)
35 axis_names
= geometry
.axis_names_get()
36 print(geometry
.name_get(), "diffractometer has", len(axis_names
),\
37 "axes : ", axis_names
)
40 sample
= Hkl
.Sample
.new("toto")
41 lattice
= Hkl
.Lattice
.new(1.54, 1.54, 1.54,
45 sample
.lattice_set(lattice
)
47 # compute all the pseudo axes managed by all engines
48 engines
= factory
.create_new_engine_list()
49 engines
.init(geometry
, detector
, sample
)
52 # get the hkl engine and do a computation
53 hkl
= engines
.engine_get_by_name("hkl")
54 values
= hkl
.pseudo_axis_values_get(Hkl
.UnitEnum
.USER
)
55 print("read : ", values
)
57 # set the hkl engine and get the results
61 solutions
= hkl
.pseudo_axis_values_set(values
,
63 print(hkl
.pseudo_axis_values_get(Hkl
.UnitEnum
.USER
))
65 print("idx".center(15)),
66 for name
in axis_names
:
67 print("{}".format(name
.center(15))),
70 for i
, item
in enumerate(solutions
.items()):
71 read
= item
.geometry_get().axis_values_get(Hkl
.UnitEnum
.USER
)
72 print("{}".format(repr(i
).center(15))),
74 print("{}".format(repr(value
)[:15].center(15))),
76 except GLib
.GError
as err
: