File: cxrayutilities.c

package info (click to toggle)
xrayutilities 1.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 12,452 kB
  • sloc: python: 29,264; ansic: 4,232; makefile: 23
file content (528 lines) | stat: -rw-r--r-- 24,453 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
/*
 * This file is part of xrayutilities.
 *
 * xrayutilities is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
 * Copyright (C) 2013 Eugen Wintersberger <eugen.wintersberger@desy.de>
 *
*/
#include <Python.h>

#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#define PY_ARRAY_UNIQUE_SYMBOL XU_UNIQUE_SYMBOL
#include <numpy/arrayobject.h>


/* functions from block_average.c */
extern PyObject* block_average1d(PyObject *self, PyObject *args);
extern PyObject* block_average2d(PyObject *self, PyObject *args);
extern PyObject* block_average_PSD(PyObject *self, PyObject *args);
extern PyObject* block_average_CCD(PyObject *self, PyObject *args);

/* functions from gridder1d.c */
extern PyObject* pygridder1d(PyObject *self, PyObject *args);
extern PyObject* pyfuzzygridder1d(PyObject *self, PyObject *args);

/* functions from gridder2d.c */
extern PyObject* pygridder2d(PyObject *self, PyObject *args);
extern PyObject* pyfuzzygridder2d(PyObject *self, PyObject *args);

/* function from gridder3d.c */
extern PyObject* pygridder3d(PyObject *self, PyObject *args);
extern PyObject* pyfuzzygridder3d(PyObject *self, PyObject *args);

/* functions from qconversion.c */
extern PyObject* py_ang2q_conversion(PyObject *self, PyObject *args);
extern PyObject* py_ang2q_conversion_linear(PyObject *self, PyObject *args);
extern PyObject* py_ang2q_conversion_area(PyObject *self, PyObject *args);
extern PyObject* ang2q_conversion_area_pixel(PyObject *self, PyObject *args);
extern PyObject* ang2q_conversion_area_pixel2(PyObject *self, PyObject *args);

extern PyObject* ang2q_detpos(PyObject *self, PyObject *args);
extern PyObject* ang2q_detpos_linear(PyObject *self, PyObject *args);
extern PyObject* ang2q_detpos_area(PyObject *self, PyObject *args);

/* functions from file_io.c */
extern PyObject* cbfread(PyObject *self, PyObject *args);

/* functions from hklcond.c */
extern PyObject* testhklcond(PyObject *self, PyObject *args);

static PyMethodDef XRU_Methods[] = {
    {"block_average1d", (PyCFunction)block_average1d, METH_VARARGS,
     "block average for one-dimensional numpy double array\n\n"
     "Parameters \n"
     "----------\n"
     " input:        input array of datatype double \n"
     " Nav:          number of items to average \n\n"
     "Returns\n"
     "-------\n"
     " block_av:   block averaged output array\n"
     "             size = ceil(N / Nav) \n"
    },
    {"block_average2d", block_average2d, METH_VARARGS,
     "2D block average for one CCD frame\n\n"
     "Parameters\n"
     "----------\n"
     " ccd:     input array/CCD frame\n"
     "          size = (Nch2, Nch1) \n"
     "          Nch1 is the fast varying index\n"
     " Nav1, 2:  number of channels to average in each dimension\n"
     "          in total a block of Nav1 x Nav2 is averaged\n"
     "\n"
     "Returns\n"
     "-------\n"
     " block_av:     block averaged output array\n"
     "               size = (ceil(Nch2 / Nav2) , ceil(Nch1 / Nav1))\n"
    },
    {"block_average_PSD", block_average_PSD, METH_VARARGS,
     "1D block average for a bunch of PSD spectra in a 2D array\n"
     "\n"
     "Parameters\n"
     "----------\n"
     " psd:         input array of PSD values\n"
     "              size = (Nspec, Nch) (in)\n"
     " Nav:         number of channels to average\n"
     "\n"
     "Returns\n"
     "-------\n"
     " block_av:    block averaged output array\n"
     "              size = (Nspec , ceil(Nch/Nav)) (out)\n"
    },
    {"block_average_CCD", block_average_CCD, METH_VARARGS,
     "2D block average for a series of CCD frames\n\n"
     "Parameters\n"
     "----------\n"
     " ccd:     input array/CCD frames\n"
     "          size = (Nframes, Nch2, Nch1) \n"
     "          Nch1 is the fast varying index\n"
     " Nav1, 2:  number of channels to average in each dimension\n"
     "          in total a block of Nav1 x Nav2 is averaged\n"
     "\n"
     "Returns\n"
     "-------\n"
     " block_av:     block averaged output array\n"
     "               size = (Nframes, ceil(Nch2 / Nav2) , ceil(Nch1 / Nav1))\n"
    },
    {"gridder1d", pygridder1d, METH_VARARGS,
     "Function performs 1D gridding on 1D input data. \n\n"
     "Parameters\n"
     "----------\n"
     "  x ...... input x-values (1D numpy array - float64)\n"
     "  data ... input data (1D numpy array - float64)\n"
     "  nx ..... number of grid points in x-direction\n"
     "  xmin ... minimum x-value of the grid\n"
     "  xmax ... maximum x-value of the grid\n"
     "  out .... output data\n"
     "  norm ... normalization array\n"
     "  flags .. flags to specify behavior\n"
    },
    {"fuzzygridder1d", pyfuzzygridder1d, METH_VARARGS,
     "Function performs fuzzy 1D gridding on 1D input data. \n\n"
     "Parameters\n"
     "----------\n"
     "  x ...... input x-values (1D numpy array - float64)\n"
     "  data ... input data (1D numpy array - float64)\n"
     "  nx ..... number of grid points in x-direction\n"
     "  xmin ... minimum x-value of the grid\n"
     "  xmax ... maximum x-value of the grid\n"
     "  out .... output data\n"
     "  norm ... normalization array\n"
     "  fuzzywidth .. fuzzy-size of the input data\n"
     "  flags .. flags to specify behavior\n"
    },
    {"gridder2d", pygridder2d, METH_VARARGS,
     "Function performs 2D gridding on 1D input data. \n\n"
     "Parameters\n"
     "----------\n"
     "  x ...... input x-values (1D numpy array - float64)\n"
     "  y ...... input y-values (1D numpy array - float64)\n"
     "  data ... input data (1D numpy array - float64)\n"
     "  nx ..... number of grid points in x-direction\n"
     "  ny ..... number of grid points in y-direction\n"
     "  xmin ... minimum x-value of the grid\n"
     "  xmax ... maximum x-value of the grid\n"
     "  ymin ... minimum y-value of the grid\n"
     "  ymax ... minimum y-value of the grid\n"
     "  out .... output data\n"
     "  norm ... normalization array\n"
     "  flags .. flags to specify behavior\n"
    },
    {"fuzzygridder2d", pyfuzzygridder2d, METH_VARARGS,
     "Function performs 2D fuzzy gridding on 1D input data. \n\n"
     "Parameters\n"
     "----------\n"
     "  x ...... input x-values (1D numpy array - float64)\n"
     "  y ...... input y-values (1D numpy array - float64)\n"
     "  data ... input data (1D numpy array - float64)\n"
     "  nx ..... number of grid points in x-direction\n"
     "  ny ..... number of grid points in y-direction\n"
     "  xmin ... minimum x-value of the grid\n"
     "  xmax ... maximum x-value of the grid\n"
     "  ymin ... minimum y-value of the grid\n"
     "  ymax ... minimum y-value of the grid\n"
     "  out .... output data\n"
     "  norm ... normalization array\n"
     "  wx ..... fuzzy width of data points in x-direction\n"
     "  wy ..... fuzzy width of data points in y-direction\n"
     "  flags .. flags to specify behavior\n"
    },
    {"gridder3d", pygridder3d, METH_VARARGS,
     "Function performs 2D gridding on 1D input data. \n\n"
     "Parameters\n"
     "----------\n"
     "  x ...... input x-values (1D numpy array - float64)\n"
     "  y ...... input y-values (1D numpy array - float64)\n"
     "  z ...... input z-values (1D numpy array - float64)\n"
     "  data ... input data (1D numpy array - float64)\n"
     "  nx ..... number of grid points in x-direction\n"
     "  ny ..... number of grid points in y-direction\n"
     "  nz ..... number of grid points in z-direction\n"
     "  xmin ... minimum x-value of the grid\n"
     "  xmax ... maximum x-value of the grid\n"
     "  ymin ... minimum y-value of the grid\n"
     "  ymax ... maximum y-value of the grid\n"
     "  zmin ... minimum z-value of the grid\n"
     "  zmax ... maximum z-value of the grid\n"
     "  out .... output data\n"
     "  norm ... normalization array\n"
     "  flags .. flags to specify behavior\n"
    },
    {"fuzzygridder3d", pyfuzzygridder3d, METH_VARARGS,
     "Function performs 3D fuzzy gridding on 1D input data. \n\n"
     "Parameters\n"
     "----------\n"
     "  x ...... input x-values (1D numpy array - float64)\n"
     "  y ...... input y-values (1D numpy array - float64)\n"
     "  z ...... input z-values (1D numpy array - float64)\n"
     "  data ... input data (1D numpy array - float64)\n"
     "  nx ..... number of grid points in x-direction\n"
     "  ny ..... number of grid points in y-direction\n"
     "  nz ..... number of grid points in z-direction\n"
     "  xmin ... minimum x-value of the grid\n"
     "  xmax ... maximum x-value of the grid\n"
     "  ymin ... minimum y-value of the grid\n"
     "  ymax ... maximum y-value of the grid\n"
     "  zmin ... minimum z-value of the grid\n"
     "  zmax ... maximum z-value of the grid\n"
     "  out .... output data\n"
     "  norm ... normalization array\n"
     "  wx ..... fuzzy width of data points in x-direction\n"
     "  wy ..... fuzzy width of data points in y-direction\n"
     "  wz ..... fuzzy width of data points in z-direction\n"
     "  flags .. flags to specify behavior\n"
    },
    {"ang2q_conversion", py_ang2q_conversion, METH_VARARGS,
     "conversion of Npoints of goniometer positions to reciprocal space\n"
     "for a setup with point detector\n"
     "\n"
     "Parameters\n"
     "----------\n"
     "  sampleAngles .... angular positions of the sample goniometer\n"
     "                    (Npoints, Ns)\n"
     "  detectorAngles .. angular positions of the detector goniometer\n"
     "                    (Npoints, Nd)\n"
     "  ri .............. direction of primary beam (length irrelevant)\n"
     "                    (angles zero)\n"
     "  sampleAxis ...... string with sample axis directions\n"
     "  detectorAxis .... string with detector axis directions\n"
     "  kappadir ........ rotation axis of a possible kappa circle\n"
     "  UB .............. orientation matrix and reciprocal space conversion\n"
     "                    of investigated crystal (3, 3)\n"
     "  sampledis ....... sample displacement vector in relative units of\n"
     "                    the detector distance\n"
     "  lambda .......... wavelength of the used x-rays (Angstreom)\n"
     "  nthreads ........ number of threads to use in parallel section of\n"
     "                    the code\n"
     "  flags ........... integer flags to select sub-function\n"
     "\n"
     "Returns\n"
     "-------\n"
     " qpos .......... momentum transfer (Npoints, 3)\n"
    },
    {"ang2q_conversion_linear", py_ang2q_conversion_linear, METH_VARARGS,
     "conversion of Npoints of goniometer positions to reciprocal space\n"
     "for a linear detector with a given pixel size mounted along one of\n"
     "the coordinate axis\n"
     "\n"
     "Parameters\n"
     "----------\n"
     " sampleAngles .... angular positions of the goniometer (Npoints, Ns)\n"
     " detectorAngles .. angular positions of the detector goniometer\n"
     "                   (Npoints, Nd)\n"
     " rcch ............ direction + distance of center channel (angles\n"
     "                   zero)\n"
     " sampleAxis ...... string with sample axis directions\n"
     " detectorAxis .... string with detector axis directions\n"
     " kappadir ........ rotation axis of a possible kappa circle\n"
     " cch ............. center channel of the detector\n"
     " dpixel .......... width of one pixel, same unit as distance rcch\n"
     " roi ............. region of interest of the detector\n"
     " dir ............. direction of the detector, e.g.: 'x+'\n"
     " tilt ............ tilt of the detector direction from dir\n"
     " UB .............. orientation matrix and reciprocal space conversion\n"
     "                   of investigated crystal (9)\n"
     " sampledis ....... sample displacement vector in same unit as the\n"
     "                   detector distance\n"
     " lambda .......... wavelength of the used x-rays in angstrom\n"
     " nthreads ........ number of threads to use in parallel section of the\n"
     "                   code\n"
     " flags ........... integer flags to select sub-function\n"
     "\n"
     "Returns\n"
     "-------\n"
     " qpos ............ momentum transfer (Npoints * Nch, 3)\n"
     " \n"
    },
    {"ang2q_conversion_area", py_ang2q_conversion_area, METH_VARARGS,
     "conversion of Npoints of goniometer positions to reciprocal space\n"
     "for an area detector with a given pixel size mounted along one of\n"
     "the coordinate axis\n"
     "\n"
     "Parameters\n"
     "----------\n"
     "  sampleAngles .... angular positions of the sample goniometer\n"
     "                    (Npoints, Ns)\n"
     "  detectorAngles .. angular positions of the detector goniometer\n"
     "                    (Npoints, Nd)\n"
     "  rcch ............ direction + distance of center pixel (angles zero)\n"
     "  sampleAxis ...... string with sample axis directions\n"
     "  detectorAxis .... string with detector axis directions\n"
     "  kappadir ...... rotation axis of a possible kappa circle\n"
     "  cch1 ............ center channel of the detector\n"
     "  cch2 ............ center channel of the detector\n"
     "  dpixel1 ......... width of one pixel in first direction, same unit\n"
     "                    as distance rcch\n"
     "  dpixel2 ......... width of one pixel in second direction, same unit\n"
     "                    as distance rcch\n"
     "  roi ............. region of interest for the area detector\n"
     "                    [dir1min, dir1max, dir2min, dir2max]\n"
     "  dir1 ............ first direction of the detector, e.g.: 'x+'\n"
     "  dir2 ............ second direction of the detector, e.g.: 'z+'\n"
     "  tiltazimuth ..... azimuth of the tilt\n"
     "  tilt ............ tilt of the detector plane (rotation around axis\n"
     "                    normal to the direction given by the tiltazimuth\n"
     "  UB .............. orientation matrix and reciprocal space conversion\n"
     "                    of investigated crystal (3, 3)\n"
     "  sampledis ....... sample displacement vector in same unit as the\n"
     "                    detector distance\n"
     "  lambda .......... wavelength of the used x-rays \n"
     "  nthreads ........ number of threads to use in parallel section of\n"
     "                    the code\n"
     "  flags ........... integer flags to select sub-function\n"
     "\n"
     "Returns\n"
     "-------\n"
     " qpos ............ momentum transfer (Npoints * Npix1 * Npix2, 3)\n"
     "\n"
    },
    {"ang2q_conversion_area_pixel", ang2q_conversion_area_pixel, METH_VARARGS,
     "conversion of Npoints of detector positions to Q\n"
     "for an area detector with a given pixel size mounted along one of\n"
     "the coordinate axis. This function only calculates the q-position for\n"
     "the pairs of pixel numbers (n1, n2) given in the input and should\n"
     "therefore be used only for detector calibration purposes.\n"
     "\n"
     "Parameters\n"
     "----------\n"
     " detectorAngles .. angular positions of the detector goniometer\n"
     "                   (Npoints, Nd)\n"
     " n1 .............. detector pixel numbers dim1 (Npoints)\n"
     " n2 .............. detector pixel numbers dim2 (Npoints)\n"
     " rcch ............ direction + distance of center pixel (angles zero)\n"
     " detectorAxis .... string with detector axis directions\n"
     " cch1 ............ center channel of the detector\n"
     " cch2 ............ center channel of the detector\n"
     " dpixel1 ......... width of one pixel in first direction, same unit as\n"
     "                   distance rcch\n"
     " dpixel2 ......... width of one pixel in second direction, same unit\n"
     "                   as distance rcch\n"
     " dir1 ............ first direction of the detector, e.g.: 'x+'\n"
     " dir2 ............ second direction of the detector, e.g.: 'z+'\n"
     " tiltazimuth ..... azimuth of the tilt\n"
     " tilt ............ tilt of the detector plane (rotation around axis\n"
     "                   normal to the direction given by the tiltazimuth\n"
     " lambda .......... wavelength of the used x-rays\n"
     " nthreads ........ number of threads to use in parallel section of the\n"
     "                   code\n"
     "\n"
     "Returns\n"
     "-------\n"
     " qpos ............ momentum transfer (Npoints, 3)\n"
    },
    {"ang2q_conversion_area_pixel2",
     ang2q_conversion_area_pixel2, METH_VARARGS,
     "conversion of Npoints of detector positions to Q.\n"
     "for an area detector with a given pixel size mounted along one of\n"
     "the coordinate axis. This function only calculates the q-position for\n"
     "the pairs of pixel numbers (n1, n2) given in the input and should\n"
     "therefore be used only for detector calibration purposes.\n"
     "\n"
     "This variant of this function also takes a sample orientation matrix\n"
     "as well as the sample goniometer as input to allow for a simultaneous\n"
     "fit of reference samples orientation\n"
     "\n"
     "Parameters\n"
     "----------\n"
     " sampleAngles .... angular positions of the sample goniometer\n"
     "                   (Npoints, Ns)\n"
     " detectorAngles .. angular positions of the detector goniometer\n"
     "                   (Npoints, Nd)\n"
     " n1 .............. detector pixel numbers dim1 (Npoints)\n"
     " n2 .............. detector pixel numbers dim2 (Npoints)\n"
     " rcch ............ direction + distance of center pixel (angles zero)\n"
     " sampleAxis ...... string with sample axis directions\n"
     " detectorAxis .... string with detector axis directions\n"
     " cch1 ............ center channel of the detector\n"
     " cch2 ............ center channel of the detector\n"
     " dpixel1 ......... width of one pixel in first direction, same unit as\n"
     "                   distance rcch\n"
     " dpixel2 ......... width of one pixel in second direction, same unit\n"
     "                   as distance rcch \n"
     " dir1 ............ first direction of the detector, e.g.: 'x+'\n"
     " dir2 ............ second direction of the detector, e.g.: 'z+'\n"
     " tiltazimuth ..... azimuth of the tilt\n"
     " tilt ............ tilt of the detector plane (rotation around axis\n"
     "                   normal to the direction given by the tiltazimuth\n"
     " UB .............. orientation matrix and reciprocal space conversion\n"
     "                   of investigated crystal (3, 3)\n"
     " lambda .......... wavelength of the used x-rays\n"
     " nthreads ........ number of threads to use in parallel section of the\n"
     "                   code\n"
     "\n"
     "Returns\n"
     "-------\n"
     " qpos ............ momentum transfer (Npoints, 3)\n"
    },
    {"ang2q_detpos", ang2q_detpos, METH_VARARGS,
     "conversion of Npoints of detector arm angles to real space position\n"
     "for a setup with point detector\n"
     "\n"
     "Parameters\n"
     "----------\n"
     "  detectorAngles .. angular positions of the detector goniometer\n"
     "                    (Npoints, Nd)\n"
     "  ri .............. direction and distance of detector at zero angles\n"
     "  detectorAxis .... string with detector axis directions\n"
     "  nthreads ........ number of threads to use in parallel section of\n"
     "                    the code\n"
     "\n"
     "Returns\n"
     "-------\n"
     " dpos .......... real space detector position (Npoints, 3)\n"
    },
    {"ang2q_detpos_linear", ang2q_detpos_linear, METH_VARARGS,
     "conversion of Npoints of detector arm angles to real space\n"
     "position for a linear detector\n"
     "\n"
     "Parameters\n"
     "----------\n"
     " detectorAngles .. angular positions of the detector goniometer\n"
     "                   (Npoints, Nd)\n"
     " rcch ............ direction + distance of center channel\n"
     "                   (angles zero)\n"
     " detectorAxis .... string with detector axis directions\n"
     " cch ............. center channel of the detector\n"
     " dpixel .......... width of one pixel, same unit as distance rcch\n"
     " roi ............. region of interest of the detector\n"
     " dir ............. direction of the detector, e.g.: 'x+'\n"
     " tilt ............ tilt of the detector direction from dir\n"
     " nthreads ........ number of threads to use in parallel section of\n"
     "                   the code\n"
     "\n"
     "Returns\n"
     "-------\n"
     " dpos ............ real space detector position (Npoints * Nch, 3)\n"
     " \n"
    },
    {"ang2q_detpos_area", ang2q_detpos_area, METH_VARARGS,
     "conversion of Npoints of detector arm angles to reciprocal space\n"
     "position for an area detector with a given pixel size\n"
     "\n"
     "Parameters\n"
     "----------\n"
     "  detectorAngles .. angular positions of the detector goniometer\n"
     "                    (Npoints, Nd)\n"
     "  rcch ............ direction + distance of center pixel (angles zero)\n"
     "  detectorAxis .... string with detector axis directions\n"
     "  cch1 ............ center channel of the detector\n"
     "  cch2 ............ center channel of the detector\n"
     "  dpixel1 ......... width of one pixel in first direction, same unit\n"
     "                    as distance rcch\n"
     "  dpixel2 ......... width of one pixel in second direction, same unit\n"
     "                    as distance rcch\n"
     "  roi ............. region of interest for the area detector\n"
     "                    [dir1min, dir1max, dir2min, dir2max]\n"
     "  dir1 ............ first direction of the detector, e.g.: 'x+'\n"
     "  dir2 ............ second direction of the detector, e.g.: 'z+'\n"
     "  tiltazimuth ..... azimuth of the tilt\n"
     "  tilt ............ tilt of the detector plane (rotation around axis\n"
     "                    normal to the direction given by the tiltazimuth\n"
     "  nthreads ........ number of threads to use in parallel section of\n"
     "                    the code\n"
     "\n"
     "Returns\n"
     "-------\n"
     " dpos ............ real space detector position\n"
     "                   (Npoints * Npix1 * Npix2, 3)\n"
     "\n"
    },
    {"cbfread", cbfread, METH_VARARGS,
     "parser for cbf data arrays from Pilatus detector images\n\n"
     " Parameters\n"
     " ----------\n"
     "  data:   data stream (character array)\n"
     "  nx, ny: number of entries of the two dimensional image\n\n"
     " Returns\n"
     " -------\n"
     "  the parsed data values as float ndarray\n"
    },
    {"testhklcond", testhklcond, METH_VARARGS,
     "test if a Bragg peak is allowed according to reflection conditions\n\n"
     " Parameters\n"
     " ----------\n"
     "  hkl :           Miller indices of the peak to test (integer array)\n"
     "  condgeneral :   General reflection conditions (list of tuples)\n"
     "  condwp :        Reflection conditions for Wyckoff positions\n"
     "                  (list of list of tuples)\n\n"
     " Returns\n"
     " -------\n"
     " bool : True if peak is allowed, False otherwise\n"
    },
    {NULL, NULL, 0, NULL}        /* Sentinel */
};

static struct PyModuleDef moduledef = {
    PyModuleDef_HEAD_INIT,
    "cxrayutilities",  /* m_name */
    "Python C extension including performance critical parts\n"
    "of xrayutilities (gridder, qconversion, block-averageing)\n",  /* m_doc */
    -1,                /* m_size */
    XRU_Methods,       /* m_methods */
    NULL,              /* m_reload */
    NULL,              /* m_traverse */
    NULL,              /* m_clear */
    NULL,              /* m_free */
};

PyMODINIT_FUNC PyInit_cxrayutilities(void)
{
    PyObject *m;
    m = PyModule_Create(&moduledef);

    import_array();

    return m;
}