COMPASS  5.4.4
End-to-end AO simulation tool using GPU acceleration
sutra_source.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 #ifndef _SUTRA_SOURCE_H_
18 #define _SUTRA_SOURCE_H_
19 
20 #include <carma.h>
21 #include <sutra_atmos.h>
22 #include <sutra_dm.h>
23 #include <sutra_lgs.h>
24 #include <sutra_source.h>
25 #include <sutra_telemetry.h>
26 #include <sutra_telescope.h>
27 #include <sutra_utils.h>
28 #include <map>
29 #include <string>
30 #include <vector>
31 
32 using std::map;
33 using std::string;
34 
35 typedef std::pair<std::string, int> type_screen;
36 
37 class SutraSource {
38  public:
41  int device;
43  float posx;
45  float posy;
47  long npts;
49  float mag;
51  float lambda;
53  float zp;
55  float scale;
57  bool lgs;
59  float G;
61  float thetaML;
63  float dx;
65  float dy;
67  string type;
70 
72  float strehl_se;
74  float strehl_le;
76  float ref_strehl;
80  float phase_var;
85 
88  // INTRO PHASE INSTRU
89  // SutraPhase *d_phase_instru;
106  map<type_screen, float> xoff;
108  map<type_screen, float> yoff;
113  const int d_smallimg_size = 3;
114 
115  public:
116  SutraSource(CarmaContext *context, float xpos, float ypos, float lambda,
117  float mag, float zerop, long size, string type,
118  CarmaObj<float> *pupil, int Npts, int device);
119  SutraSource(CarmaContext *context, float xpos, float ypos, float lambda,
120  float mag, float zerop, long size, string type, int device);
122  inline int init_source(CarmaContext *context, float xpos, float ypos,
123  float lambda, float mag, float zerop, long size,
124  string type, int device);
125  int add_layer(string type, int idx, float xoff, float yoff);
126  int remove_layer(string type, int idx);
127  // int get_phase(float *h_dest);
128  int raytrace(SutraTelescope *tel, bool rst = false);
129  int raytrace(SutraAtmos *atmos, bool async = false);
130  int raytrace(SutraDms *ydms, bool rst = false, bool do_phase_var = true,
131  bool async = false);
132  int raytrace(SutraTelescope *tel, SutraAtmos *atmos, SutraDms *ydms,
133  bool do_phase_var = true, bool async = false);
134  int raytrace(bool rst = false);
136  int comp_image(int puponly = 0, bool comp_le = true);
139  int comp_strehl(bool do_fit);
140  int reset_phase();
141 
142  private:
156  float fitmax2x1dSinc(float *d_img, int ind_max, int img_size);
157 };
158 
159 int target_raytrace(float *d_odata, float *d_idata, int nx, int ny, int Nx,
160  float xoff, float yoff, float G, float thetaML, float dx,
161  float dy, int block_size, float delta);
162 int target_raytrace_async(CarmaStreams streams, float *d_odata, float *d_idata,
163  int nx, int ny, int Nx, float xoff, float yoff,
164  int block_size);
166  float *d_odata, float *d_idata, int nx, int ny,
167  int Nx, float xoff, float yoff, int block_size);
168 int fft_goodsize(long size);
169 
170 // ATTEMPT AT ADDING PHASE_INSTRU
171 /*int
172 fill_amplipup(cuFloatComplex *amplipup, float *phase, float *phase_instru, float
173 *mask, float scale,
174  int puponly, int nx, int ny, int Nx, CarmaDevice *device);*/
175 
176 int fill_amplipup(cuFloatComplex *amplipup, float *phase, float *mask,
177  float scale, int puponly, int nx, int ny, int Nx,
178  CarmaDevice *device);
179 
180 #endif // _SUTRA_SOURCE_H_
this class provides the context in which CarmaObj are created
Definition: carma_context.h:79
this class provides the stream features to CarmaObj
Definition: carma_streams.h:24
this class provides the atmos features to COMPASS
Definition: sutra_atmos.h:25
this class provides the lgs features to COMPASS
Definition: sutra_lgs.h:28
this class provides the phase features to COMPASS
Definition: sutra_phase.h:31
this class provides the source features to COMPASS
Definition: sutra_source.h:37
int device
device #
Definition: sutra_source.h:41
int raytrace(SutraTelescope *tel, SutraAtmos *atmos, SutraDms *ydms, bool do_phase_var=true, bool async=false)
int block_size
optimum block size of device
Definition: sutra_source.h:69
float mag
brightness of target
Definition: sutra_source.h:49
int init_source(CarmaContext *context, float xpos, float ypos, float lambda, float mag, float zerop, long size, string type, int device)
CarmaObj< float > * d_ncpa_phase
ncpa phase
Definition: sutra_source.h:110
CarmaObj< int > * d_wherephase
positions of valid phase points in the pupil (target only)
Definition: sutra_source.h:104
float strehl_le
long exposure strehl
Definition: sutra_source.h:74
CarmaHostObj< float > * phase_telemetry
Definition: sutra_source.h:90
float phase_var
current phase variance in the pupil
Definition: sutra_source.h:80
float posy
y position of target on the sky
Definition: sutra_source.h:45
int reset_phase()
CarmaObj< float > * d_pupil
the pupil mask
Definition: sutra_source.h:94
int raytrace(SutraDms *ydms, bool rst=false, bool do_phase_var=true, bool async=false)
int remove_layer(string type, int idx)
int init_strehlmeter()
SutraPhase * d_phase
phase for this target
Definition: sutra_source.h:87
CarmaContext * current_context
Definition: sutra_source.h:39
float thetaML
Pupil rotation angle.
Definition: sutra_source.h:61
map< type_screen, float > yoff
y reference for raytracing
Definition: sutra_source.h:108
float zp
imaging zero point
Definition: sutra_source.h:53
SutraLGS * d_lgs
the lgs object
Definition: sutra_source.h:92
SutraSource(CarmaContext *context, float xpos, float ypos, float lambda, float mag, float zerop, long size, string type, int device)
CarmaObj< float > * d_image_le
the long exposure image for this target
Definition: sutra_source.h:98
CarmaObj< float > * d_smallimg
temporary array for accurate strehl computation
Definition: sutra_source.h:112
int raytrace_shm(SutraAtmos *atmos)
float phase_var_avg
average phase variance in the pupil
Definition: sutra_source.h:82
string type
type of source : target / wfs
Definition: sutra_source.h:67
int comp_strehl(bool do_fit)
CarmaObj< cuFloatComplex > * d_amplipup
the complex amplitude in the pupil plane
Definition: sutra_source.h:100
float G
Magnifying factor for WFS misalignment.
Definition: sutra_source.h:59
float scale
phase scale
Definition: sutra_source.h:55
int reset_strehlmeter()
float lambda
imaging lambda
Definition: sutra_source.h:51
int comp_image(int puponly=0, bool comp_le=true)
const int d_smallimg_size
Definition: sutra_source.h:113
CarmaObj< float > * d_image_se
the resulting image for this target
Definition: sutra_source.h:96
float ref_strehl
reference for strehl computation
Definition: sutra_source.h:76
float strehl_se
short exposure strehl
Definition: sutra_source.h:72
float dy
WFS misalignment.
Definition: sutra_source.h:65
int phase_var_count
counter for average phase variance in the pupil
Definition: sutra_source.h:84
int strehl_counter
counter for le strehl computation
Definition: sutra_source.h:78
float dx
WFS misalignment.
Definition: sutra_source.h:63
float posx
x position of target on the sky
Definition: sutra_source.h:43
CarmaObj< float > * d_phasepts
the valid phase points in the pupil (target only)
Definition: sutra_source.h:102
long npts
number of points in the pupil
Definition: sutra_source.h:47
int raytrace(SutraTelescope *tel, bool rst=false)
SutraSource(CarmaContext *context, float xpos, float ypos, float lambda, float mag, float zerop, long size, string type, CarmaObj< float > *pupil, int Npts, int device)
int raytrace(bool rst=false)
int raytrace(SutraAtmos *atmos, bool async=false)
map< type_screen, float > xoff
x reference for raytracing
Definition: sutra_source.h:106
bool lgs
flag for lgs
Definition: sutra_source.h:57
int add_layer(string type, int idx, float xoff, float yoff)
this class provides the telescope features to COMPASS
int fft_goodsize(long size)
int fill_amplipup(cuFloatComplex *amplipup, float *phase, float *mask, float scale, int puponly, int nx, int ny, int Nx, CarmaDevice *device)
int target_raytrace(float *d_odata, float *d_idata, int nx, int ny, int Nx, float xoff, float yoff, float G, float thetaML, float dx, float dy, int block_size, float delta)
int target_raytrace_async(CarmaStreams streams, float *d_odata, float *d_idata, int nx, int ny, int Nx, float xoff, float yoff, int block_size)
std::pair< std::string, int > type_screen
Definition: sutra_source.h:35