[hkl] fix the test suite due to binoculars new projection signature.
[hkl.git] / binoculars / hkl-binoculars.h
blob3e3f7e66c537ff709270cb84792da558547e0675
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__
25 #include "hkl.h"
26 #include "stdint.h"
28 G_BEGIN_DECLS
30 /****************/
31 /* 2D detectors */
32 /****************/
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,
57 const char *fname);
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,
65 const char *fname);
67 HKLAPI extern void hkl_binoculars_detector_2d_sixs_calibration(HklBinocularsDetectorEnum n,
68 double *arr,
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,
74 size_t *n_pixels);
76 /***********/
77 /* Limits */
78 /***********/
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);
87 /********/
88 /* Axis */
89 /********/
91 typedef struct _HklBinocularsAxis HklBinocularsAxis;
93 HKLAPI extern double *hkl_binoculars_axis_array(const HklBinocularsAxis *self);
95 /*********/
96 /* Space */
97 /*********/
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,
111 size_t n_axes);
113 HKLAPI extern void hkl_binoculars_space_free(HklBinocularsSpace *self);
115 /********/
116 /* Cube */
117 /********/
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,
144 const char *config,
145 const HklBinocularsCube *self);
147 HKLAPI extern void hkl_binoculars_cube_fprintf(FILE *f, const HklBinocularsCube *self);
149 /***************/
150 /* Projections */
151 /***************/
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))" */
161 /* angles */
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, \
167 size_t n_pixels, \
168 double weight, \
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, \
176 size_t n_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);
183 /* qcustom */
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 /* Add new your subprojection in the same order than the haskell order here */
204 HKL_BINOCULARS_QCUSTOM_NUM_SUBPROJECTIONS,
205 } HklBinocularsQCustomSubProjectionEnum;
207 #define HKL_BINOCULARS_SPACE_QCUSTOM_DECL(image_t) \
208 void hkl_binoculars_space_qcustom_ ## image_t (HklBinocularsSpace *space, \
209 const HklGeometry *geometry, \
210 const image_t *image, \
211 size_t n_pixels, \
212 double weight, \
213 const double *pixels_coordinates, \
214 size_t pixels_coordinates_ndim, \
215 const size_t *pixels_coordinates_dims, \
216 const double *resolutions, \
217 size_t n_resolutions, \
218 const uint8_t *masked, \
219 HklBinocularsSurfaceOrientationEnum surf, \
220 const HklBinocularsAxisLimits **limits, \
221 size_t n_limits, \
222 double timestamp, \
223 const HklBinocularsQCustomSubProjectionEnum subprojection, \
224 double uqx, \
225 double uqy, \
226 double uqz, \
227 const char *sample_axis, \
228 int do_polarisation_correction \
232 HKLAPI extern HKL_BINOCULARS_SPACE_QCUSTOM_DECL(int32_t);
233 HKLAPI extern HKL_BINOCULARS_SPACE_QCUSTOM_DECL(uint16_t);
234 HKLAPI extern HKL_BINOCULARS_SPACE_QCUSTOM_DECL(uint32_t);
236 /* hkl */
238 #define HKL_BINOCULARS_SPACE_HKL_DECL(image_t) \
239 void hkl_binoculars_space_hkl_ ## image_t (HklBinocularsSpace *space, \
240 const HklGeometry *geometry, \
241 const HklSample *sample, \
242 const image_t *image, \
243 size_t n_pixels, \
244 double weight, \
245 const double *pixels_coordinates, \
246 size_t pixels_coordinates_ndim, \
247 const size_t *pixels_coordinates_dims, \
248 const double *resolutions, \
249 size_t n_resolutions, \
250 const uint8_t *masked, \
251 const HklBinocularsAxisLimits **limits, \
252 size_t n_limits, \
253 int do_polarisation_correction \
256 HKLAPI extern HKL_BINOCULARS_SPACE_HKL_DECL(int32_t);
257 HKLAPI extern HKL_BINOCULARS_SPACE_HKL_DECL(uint16_t);
258 HKLAPI extern HKL_BINOCULARS_SPACE_HKL_DECL(uint32_t);
260 /* test */
262 #define HKL_BINOCULARS_SPACE_TEST_DECL(image_t) \
263 void hkl_binoculars_space_test_ ## image_t (HklBinocularsSpace *space, \
264 const HklGeometry *geometry, \
265 const HklSample *sample, \
266 const image_t *image, \
267 size_t n_pixels, \
268 double weight, \
269 const double *pixels_coordinates, \
270 size_t pixels_coordinates_ndim, \
271 const size_t *pixels_coordinates_dims, \
272 const double *resolutions, \
273 size_t n_resolutions, \
274 const uint8_t *masked, \
275 const HklBinocularsAxisLimits **limits, \
276 size_t n_limits, \
277 int do_polarisation_correction \
281 HKLAPI extern HKL_BINOCULARS_SPACE_TEST_DECL(int32_t);
282 HKLAPI extern HKL_BINOCULARS_SPACE_TEST_DECL(uint16_t);
283 HKLAPI extern HKL_BINOCULARS_SPACE_TEST_DECL(uint32_t);
286 G_END_DECLS
288 #endif