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 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))
32 config
= Hkl
.geometry_factory_get_config_from_type(
33 Hkl
.GeometryType
.KAPPA6C
)
34 geometry
= Hkl
.Geometry
.factory_newv(config
, [math
.radians(50.)])
35 values_w
= [0., 30., 0., 0., 0., 60.]
36 geometry
.set_axes_values_unit(values_w
)
37 axes_names
= [axis
.parameter
.name
for axis
in geometry
.axes()]
38 print config
.name
, "diffractometer has", geometry
.len,\
42 sample
= Hkl
.Sample
.new("toto", Hkl
.SampleType
.MONOCRYSTAL
)
43 sample
.set_lattice(1.54, 1.54, 1.54,
48 # compute all the pseudo axes managed by all engines
49 engines
= Hkl
.EngineList
.factory(config
)
50 engines
.init(geometry
, detector
, sample
)
53 # get the hkl engine and do a computation
54 hkl
= engines
.get_by_name("hkl")
55 values
= hkl
.get_values_unit()
56 print "read : ", values
58 # set the hkl engine and get the results
62 hkl
.set_values_unit(values
)
63 print hkl
.get_values_unit()
65 print("idx".center(15)),
66 for name
in axes_names
:
67 print("{}".format(name
.center(15))),
70 for i
, item
in enumerate(engines
.geometries
.items()):
71 read
= item
.geometry
.get_axes_values_unit()
72 print("{}".format(repr(i
).center(15))),
74 print("{}".format(repr(value
)[:15].center(15))),
76 except GLib
.GError
, err
: