COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
sutra_centroider.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 // This file is part of COMPASS <https://anr-compass.github.io/compass/>
3 //
4 // Copyright (C) 2011-2023 COMPASS Team <https://github.com/ANR-COMPASS>
5 // All rights reserved.
6 
7 // -----------------------------------------------------------------------------
8 
16 
17 
18 #ifndef _SUTRA_CENTROIDER_H_
19 #define _SUTRA_CENTROIDER_H_
20 
21 #include <sutra_acquisim.h>
22 #include <sutra_wfs.h>
23 #include <string>
24 
25 enum class SlopeOrder {
26  untied = 0, // x,x,x,y,y,y
27  interlaced = 1 // x,y,x,y,x,y
28 };
29 
30 inline SlopeOrder slope_order(std::size_t value) {
31  return static_cast<SlopeOrder>(value);
32 }
33 template <class Tin, class Tout>
35 public:
36  int device;
38  int nvalid;
39  int nslopes;
40  int npix;
41  int nxsub;
42  bool filter_TT;
43 
44  float offset;
45  float scale;
46 
48 
50 
53  CarmaObj<Tout> *d_centroids_ref; // ref centroids
62 
67 
68 protected:
70  float offset, float scale, bool filter_TT, int device);
71 
72 private:
73  template <typename Q = Tout>
74  typename std::enable_if<std::is_same<Q, float>::value, int>::type
75  apply_TT_filter_impl(Tout *centroids, std::true_type);
76  int apply_TT_filter_impl(Tout *centroids, std::false_type);
77 
78 public:
79  virtual ~SutraCentroider();
80  int set_scale(float scale);
81  int set_offset(float offset);
82  int set_dark(float *dark, int n);
83  int set_flat(float *flat, int n);
84  int set_lutPix(int *lutPix, int n);
85  int init_calib(int n, int m);
86  int init_roi(int N);
87  int set_centroids_ref(float *centroids_ref);
89  int calibrate_img_validPix(cudaStream_t stream);
90  int calibrate_img() { return calibrate_img(0); };
91  int calibrate_img(cudaStream_t stream);
92  int load_validpos(int *ivalid, int *jvalid, int N);
93  int set_npix(int npix);
94  int set_nxsub(int nxsub);
95  int load_img(Tin *img, int n);
96  int load_img(Tin *img, int n, int location);
97  int load_img(Tin *img, int m, int n, int location);
99  int init_img_raw(int m, int n);
101  bool is_type(string typec) { return (typec.compare(get_type()) == 0); }
103  int apply_TT_filter(Tout *centroids);
104 
105  virtual string get_type() = 0;
106 
107  virtual int get_cog(float *img, float *intensities, Tout *centroids,
108  int nvalid, int npix, int ntot,
109  cudaStream_t stream = 0) = 0;
110  virtual int get_cog(float *intensities, Tout *slopes, bool noise) = 0;
111  virtual int get_cog() = 0;
112 };
113 
114 template <class Tin>
115 int calibration_validPix_sh(int npix, int size, int blocks, Tin *img_raw,
116  float *img_cal, float *dark, float *flat,
117  int *lutPix, int *validx, int *validy,
118  CarmaDevice *device, cudaStream_t stream);
119 
120 template <class Tin>
121 int calibration_validPix_pyr(Tin *img_raw, float *img_cal, float *dark,
122  float *flat, int *lutPix, int *validx, int *validy,
123  int nvalid, int img_sizex, CarmaDevice *device,
124  cudaStream_t stream = 0);
125 
126 template <class Tin>
127 int calibration(Tin *img_raw, float *img_cal, float *dark, float *flat,
128  int *lutPix, int N, CarmaDevice *device,
129  cudaStream_t stream = 0);
130 
131 template <typename T>
132 int convert_centro(T *d_odata, T *d_idata, float offset, float scale, int N,
133  CarmaDevice *device);
134 int fill_validMask(int size, int npix, int blocks, int *d_validMask,
135  int *validx, int *validy, CarmaDevice *device);
136 
137 #endif // _SUTRA_CENTROIDER_H_
this class provides the context in which CarmaObj are created
Definition: carma_context.h:79
this class provides the centroider features to COMPASS
CarmaObj< float > * d_ref_Tilt
CarmaObj< float > * d_flat
int load_img(Tin *img, int n, int location)
CarmaObj< float > * d_ref_Tip
int set_scale(float scale)
int calibrate_img_validPix(cudaStream_t stream)
virtual int get_cog()=0
SlopeOrder slope_order
virtual int get_cog(float *img, float *intensities, Tout *centroids, int nvalid, int npix, int ntot, cudaStream_t stream=0)=0
CarmaObj< float > * d_TT_slopes
int set_nxsub(int nxsub)
int set_lutPix(int *lutPix, int n)
CarmaObj< int > * d_validx
CarmaContext * current_context
virtual int get_cog(float *intensities, Tout *slopes, bool noise)=0
CarmaObj< float > * d_centro_filtered
int set_offset(float offset)
CarmaObj< float > * d_intensities
int init_img_raw(int m, int n)
CarmaObj< Tin > * d_img_raw
int set_npix(int npix)
int calibrate_img_validPix()
virtual string get_type()=0
CarmaObj< float > * d_dark
CarmaObj< int > * d_validy
virtual ~SutraCentroider()
int load_validpos(int *ivalid, int *jvalid, int N)
CarmaObj< int > * d_validMask
int load_img(CarmaObj< Tin > *img)
bool is_type(string typec)
CarmaObj< Tout > * d_bincube
CarmaObj< int > * d_lutPix
CarmaObj< float > * d_img
int set_centroids_ref(float *centroids_ref)
int calibrate_img(cudaStream_t stream)
SutraCentroider(CarmaContext *context, SutraWfs *wfs, long nvalid, float offset, float scale, bool filter_TT, int device)
int init_calib(int n, int m)
int set_flat(float *flat, int n)
int load_img(Tin *img, int m, int n, int location)
int set_dark(float *dark, int n)
CarmaObj< Tout > * d_centroids_ref
int load_img(Tin *img, int n)
int init_roi(int N)
int apply_TT_filter(Tout *centroids)
this class provides the wfs features to COMPASS
Definition: sutra_wfs.h:35
SlopeOrder
int calibration_validPix_pyr(Tin *img_raw, float *img_cal, float *dark, float *flat, int *lutPix, int *validx, int *validy, int nvalid, int img_sizex, CarmaDevice *device, cudaStream_t stream=0)
int convert_centro(T *d_odata, T *d_idata, float offset, float scale, int N, CarmaDevice *device)
int fill_validMask(int size, int npix, int blocks, int *d_validMask, int *validx, int *validy, CarmaDevice *device)
SlopeOrder slope_order(std::size_t value)
int calibration(Tin *img_raw, float *img_cal, float *dark, float *flat, int *lutPix, int N, CarmaDevice *device, cudaStream_t stream=0)
int calibration_validPix_sh(int npix, int size, int blocks, Tin *img_raw, float *img_cal, float *dark, float *flat, int *lutPix, int *validx, int *validy, CarmaDevice *device, cudaStream_t stream)