1 /* This file is part of the hkl library.
3 * The hkl library is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * The hkl library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with the hkl library. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright (C) 2003-2023 Synchrotron SOLEIL
17 * L'Orme des Merisiers Saint-Aubin
18 * BP 48 91192 GIF-sur-YVETTE CEDEX
20 * Authors: Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr>
22 #ifndef __HKL_BINOCULARS_H__
23 #define __HKL_BINOCULARS_H__
34 typedef enum _HklBinocularsDetectorEnum
36 HKL_BINOCULARS_DETECTOR_IMXPAD_S140
= 0,
37 HKL_BINOCULARS_DETECTOR_XPAD_FLAT_CORRECTED
,
38 HKL_BINOCULARS_DETECTOR_IMXPAD_S70
,
39 HKL_BINOCULARS_DETECTOR_DECTRIS_EIGER1M
,
40 HKL_BINOCULARS_DETECTOR_UFXC
,
41 HKL_BINOCULARS_DETECTOR_MERLIN
,
42 HKL_BINOCULARS_DETECTOR_MERLIN_MEDIPIX_3RX_QUAD
,
43 /* Add new your detectors here */
44 HKL_BINOCULARS_DETECTOR_NUM_DETECTORS
,
45 } HklBinocularsDetectorEnum
;
47 HKLAPI
extern int hkl_binoculars_detector_2d_number_of_detectors(void);
49 HKLAPI
extern const char *hkl_binoculars_detector_2d_name_get(HklBinocularsDetectorEnum n
);
51 HKLAPI
extern void hkl_binoculars_detector_2d_shape_get(HklBinocularsDetectorEnum n
,
52 int *width
, int *height
);
54 HKLAPI
extern double *hkl_binoculars_detector_2d_coordinates_get(HklBinocularsDetectorEnum n
);
56 HKLAPI
extern void hkl_binoculars_detector_2d_coordinates_save(HklBinocularsDetectorEnum n
,
59 HKLAPI
extern uint8_t *hkl_binoculars_detector_2d_mask_get(HklBinocularsDetectorEnum n
);
61 HKLAPI
extern uint8_t *hkl_binoculars_detector_2d_mask_load(HklBinocularsDetectorEnum n
,
62 const char *filename
);
64 HKLAPI
extern void hkl_binoculars_detector_2d_mask_save(HklBinocularsDetectorEnum n
,
67 HKLAPI
extern void hkl_binoculars_detector_2d_sixs_calibration(HklBinocularsDetectorEnum n
,
69 int width
, int height
,
70 int ix0
, int iy0
, double sdd
,
71 double detrot
, int normalize_flag
);
73 HKLAPI
extern uint32_t *hkl_binoculars_detector_2d_fake_image_uint32(HklBinocularsDetectorEnum n
,
80 typedef struct _HklBinocularsAxisLimits HklBinocularsAxisLimits
;
82 HKLAPI
extern void hkl_binoculars_axis_limits_free(HklBinocularsAxisLimits
*self
);
84 HKLAPI
extern HklBinocularsAxisLimits
*hkl_binoculars_axis_limits_new(const ptrdiff_t *min
,
85 const ptrdiff_t *max
);
91 typedef struct _HklBinocularsAxis HklBinocularsAxis
;
93 HKLAPI
extern double *hkl_binoculars_axis_array(const HklBinocularsAxis
*self
);
99 typedef struct _HklBinocularsSpace HklBinocularsSpace
;
101 typedef enum _HklBinocularsSurfaceOrientationEnum
103 HKL_BINOCULARS_SURFACE_ORIENTATION_VERTICAL
= 0,
104 HKL_BINOCULARS_SURFACE_ORIENTATION_HORIZONTAL
,
105 /* Add new your detectors here */
106 HKL_BINOCULARS_SURFACE_ORIENTATION_NUM_ORIENTATION
,
107 } HklBinocularsSurfaceOrientationEnum
;
110 HKLAPI
extern HklBinocularsSpace
*hkl_binoculars_space_new(size_t n_indexes_0
,
113 HKLAPI
extern void hkl_binoculars_space_free(HklBinocularsSpace
*self
);
119 typedef struct _HklBinocularsCube HklBinocularsCube
;
121 HKLAPI
extern void hkl_binoculars_cube_free(HklBinocularsCube
*self
);
123 HKLAPI
extern HklBinocularsCube
*hkl_binoculars_cube_new(size_t n_spaces
,
124 const HklBinocularsSpace
*const *spaces
);
126 HKLAPI
extern HklBinocularsCube
*hkl_binoculars_cube_new_empty(void);
128 HKLAPI
extern HklBinocularsCube
*hkl_binoculars_cube_new_empty_from_cube(const HklBinocularsCube
*src
);
130 HKLAPI
extern HklBinocularsCube
*hkl_binoculars_cube_new_copy(const HklBinocularsCube
*src
);
132 HKLAPI
extern HklBinocularsCube
*hkl_binoculars_cube_new_from_space(const HklBinocularsSpace
*space
);
134 HKLAPI
extern HklBinocularsCube
*hkl_binoculars_cube_new_merge(const HklBinocularsCube
*cube1
,
135 const HklBinocularsCube
*cube2
);
137 HKLAPI
extern unsigned int hkl_binoculars_cube_cmp(const HklBinocularsCube
*self
,
138 const HklBinocularsCube
*other
);
140 HKLAPI
extern void hkl_binoculars_cube_add_space(HklBinocularsCube
*self
,
141 const HklBinocularsSpace
*space
);
143 HKLAPI
extern void hkl_binoculars_cube_save_hdf5(const char *fn
,
145 const HklBinocularsCube
*self
);
147 HKLAPI
extern void hkl_binoculars_cube_fprintf(FILE *f
, const HklBinocularsCube
*self
);
153 /* subprojection for QCustom */
154 /* q_index / tth_index ( index = numero du scan) (optional) */
155 /* q_timescan0 / tth_timescan0 (timescan0 = timestamp du 1er point du scan (constant pour 1 scan)) */
157 /* Adding the polarization correction from fit2D */
158 /* dans un premier temps faire (1 - (epsilon (0, 1, 0) . kf) ^ 2) */
159 /* pola = "0.5 * (1.0 + cos(tth)**2 - factor * cos(2.0 * (chi + axis_offset)) * (1.0 - cos(tth)**2))" */
163 #define HKL_BINOCULARS_SPACE_ANGLES_DECL(image_t) \
164 void hkl_binoculars_space_angles_ ## image_t (HklBinocularsSpace *space, \
165 const HklGeometry *geometry, \
166 const image_t *image, \
169 const double *pixels_coordinates, \
170 size_t pixels_coordinates_ndim, \
171 const size_t *pixels_coordinates_dims, \
172 const double *resolutions, \
173 size_t n_resolutions, \
174 const uint8_t *masked, \
175 const HklBinocularsAxisLimits **limits, \
177 const char *sample_axis)
179 HKLAPI
extern HKL_BINOCULARS_SPACE_ANGLES_DECL(int32_t);
180 HKLAPI
extern HKL_BINOCULARS_SPACE_ANGLES_DECL(uint16_t);
181 HKLAPI
extern HKL_BINOCULARS_SPACE_ANGLES_DECL(uint32_t);
185 typedef enum _HklBinocularsQCustomSubProjectionEnum
187 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_QX_QY_QZ
= 0,
188 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Q_TTH_TIMESTAMP
,
189 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Q_TIMESTAMP
,
190 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_QPAR_QPER_TIMESTAMP
,
191 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_QPAR_QPER
,
192 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Q_PHI_QX
,
193 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Q_PHI_QY
,
194 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Q_PHI_QZ
,
195 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Q_STEREO
,
196 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_DELTALAB_GAMMALAB_SAMPLEAXIS
,
197 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_X_Y_Z
,
198 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Y_Z_TIMESTAMP
,
199 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Q_QPAR_QPER
,
200 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_QPARS_QPER_TIMESTAMP
,
201 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_QPAR_QPER_SAMPLEAXIS
,
202 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Q_SAMPLEAXIS_TTH
,
203 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_Q_SAMPLEAXIS_TIMESTAMP
,
204 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_QX_QY_TIMESTAMP
,
205 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_QX_QZ_TIMESTAMP
,
206 HKL_BINOCULARS_QCUSTOM_SUB_PROJECTION_QY_QZ_TIMESTAMP
,
207 /* Add new your subprojection in the same order than the haskell order here */
208 HKL_BINOCULARS_QCUSTOM_NUM_SUBPROJECTIONS
,
209 } HklBinocularsQCustomSubProjectionEnum
;
211 #define HKL_BINOCULARS_SPACE_QCUSTOM_DECL(image_t) \
212 void hkl_binoculars_space_qcustom_ ## image_t (HklBinocularsSpace *space, \
213 const HklGeometry *geometry, \
214 const image_t *image, \
217 const double *pixels_coordinates, \
218 size_t pixels_coordinates_ndim, \
219 const size_t *pixels_coordinates_dims, \
220 const double *resolutions, \
221 size_t n_resolutions, \
222 const uint8_t *masked, \
223 HklBinocularsSurfaceOrientationEnum surf, \
224 const HklBinocularsAxisLimits **limits, \
227 const HklBinocularsQCustomSubProjectionEnum subprojection, \
231 const char *sample_axis, \
232 int do_polarisation_correction \
236 HKLAPI
extern HKL_BINOCULARS_SPACE_QCUSTOM_DECL(int32_t);
237 HKLAPI
extern HKL_BINOCULARS_SPACE_QCUSTOM_DECL(uint16_t);
238 HKLAPI
extern HKL_BINOCULARS_SPACE_QCUSTOM_DECL(uint32_t);
242 #define HKL_BINOCULARS_SPACE_HKL_DECL(image_t) \
243 void hkl_binoculars_space_hkl_ ## image_t (HklBinocularsSpace *space, \
244 const HklGeometry *geometry, \
245 const HklSample *sample, \
246 const image_t *image, \
249 const double *pixels_coordinates, \
250 size_t pixels_coordinates_ndim, \
251 const size_t *pixels_coordinates_dims, \
252 const double *resolutions, \
253 size_t n_resolutions, \
254 const uint8_t *masked, \
255 const HklBinocularsAxisLimits **limits, \
257 int do_polarisation_correction \
260 HKLAPI
extern HKL_BINOCULARS_SPACE_HKL_DECL(int32_t);
261 HKLAPI
extern HKL_BINOCULARS_SPACE_HKL_DECL(uint16_t);
262 HKLAPI
extern HKL_BINOCULARS_SPACE_HKL_DECL(uint32_t);
266 #define HKL_BINOCULARS_SPACE_TEST_DECL(image_t) \
267 void hkl_binoculars_space_test_ ## image_t (HklBinocularsSpace *space, \
268 const HklGeometry *geometry, \
269 const HklSample *sample, \
270 const image_t *image, \
273 const double *pixels_coordinates, \
274 size_t pixels_coordinates_ndim, \
275 const size_t *pixels_coordinates_dims, \
276 const double *resolutions, \
277 size_t n_resolutions, \
278 const uint8_t *masked, \
279 const HklBinocularsAxisLimits **limits, \
281 int do_polarisation_correction \
285 HKLAPI
extern HKL_BINOCULARS_SPACE_TEST_DECL(int32_t);
286 HKLAPI
extern HKL_BINOCULARS_SPACE_TEST_DECL(uint16_t);
287 HKLAPI
extern HKL_BINOCULARS_SPACE_TEST_DECL(uint32_t);