COMPASS  5.0.0
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-2019 COMPASS Team <https://github.com/ANR-COMPASS>
5 // All rights reserved.
6 // Distributed under GNU - LGPL
7 //
8 // COMPASS is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser
9 // General Public License as published by the Free Software Foundation, either version 3 of the License,
10 // or any later version.
11 //
12 // COMPASS: End-to-end AO simulation tool using GPU acceleration
13 // The COMPASS platform was designed to meet the need of high-performance for the simulation of AO systems.
14 //
15 // The final product includes a software package for simulating all the critical subcomponents of AO,
16 // particularly in the context of the ELT and a real-time core based on several control approaches,
17 // with performances consistent with its integration into an instrument. Taking advantage of the specific
18 // hardware architecture of the GPU, the COMPASS tool allows to achieve adequate execution speeds to
19 // conduct large simulation campaigns called to the ELT.
20 //
21 // The COMPASS platform can be used to carry a wide variety of simulations to both testspecific components
22 // of AO of the E-ELT (such as wavefront analysis device with a pyramid or elongated Laser star), and
23 // various systems configurations such as multi-conjugate AO.
24 //
25 // COMPASS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
26 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 // See the GNU Lesser General Public License for more details.
28 //
29 // You should have received a copy of the GNU Lesser General Public License along with COMPASS.
30 // If not, see <https://www.gnu.org/licenses/lgpl-3.0.txt>.
31 // -----------------------------------------------------------------------------
32 
41 
42 #ifndef _SUTRA_SOURCE_H_
43 #define _SUTRA_SOURCE_H_
44 
45 #include <carma.h>
46 #include <sutra_atmos.h>
47 #include <sutra_dm.h>
48 #include <sutra_lgs.h>
49 #include <sutra_source.h>
50 #include <sutra_telemetry.h>
51 #include <sutra_telescope.h>
52 #include <sutra_utils.h>
53 #include <map>
54 #include <string>
55 #include <vector>
56 
57 using std::map;
58 using std::string;
59 
60 typedef std::pair<std::string, int> type_screen;
61 
62 class SutraSource {
63  public:
66  int device;
68  float posx;
70  float posy;
72  long npts;
74  float mag;
76  float lambda;
78  float zp;
80  float scale;
82  bool lgs;
84  float G;
86  float thetaML;
88  float dx;
90  float dy;
92  string type;
95 
97  float strehl_se;
99  float strehl_le;
101  float ref_strehl;
105  float phase_var;
110 
113  // INTRO PHASE INSTRU
114  // SutraPhase *d_phase_instru;
131  map<type_screen, float> xoff;
133  map<type_screen, float> yoff;
138  const int d_smallimg_size = 3;
139 
140  public:
141  SutraSource(CarmaContext *context, float xpos, float ypos, float lambda,
142  float mag, float zerop, long size, string type,
143  CarmaObj<float> *pupil, int Npts, int device);
144  SutraSource(CarmaContext *context, float xpos, float ypos, float lambda,
145  float mag, float zerop, long size, string type, int device);
147  inline int init_source(CarmaContext *context, float xpos, float ypos,
148  float lambda, float mag, float zerop, long size,
149  string type, int device);
150  int add_layer(string type, int idx, float xoff, float yoff);
151  int remove_layer(string type, int idx);
152  // int get_phase(float *h_dest);
153  int raytrace(SutraTelescope *tel, bool rst = false);
154  int raytrace(SutraAtmos *atmos, bool async = false);
155  int raytrace(SutraDms *ydms, bool rst = false, bool do_phase_var = true,
156  bool async = false);
157  int raytrace(SutraTelescope *tel, SutraAtmos *atmos, SutraDms *ydms,
158  bool do_phase_var = true, bool async = false);
159  int raytrace(bool rst = false);
161  int comp_image(int puponly = 0, bool comp_le = true);
164  int comp_strehl(bool do_fit);
165  int reset_phase();
166 
167  private:
181  float fitmax2x1dSinc(float *d_img, int ind_max, int img_size);
182 };
183 
184 int target_raytrace(float *d_odata, float *d_idata, int nx, int ny, int Nx,
185  float xoff, float yoff, float G, float thetaML, float dx,
186  float dy, int block_size, float delta);
187 int target_raytrace_async(CarmaStreams streams, float *d_odata, float *d_idata,
188  int nx, int ny, int Nx, float xoff, float yoff,
189  int block_size);
191  float *d_odata, float *d_idata, int nx, int ny,
192  int Nx, float xoff, float yoff, int block_size);
193 int fft_goodsize(long size);
194 
195 // ATTEMPT AT ADDING PHASE_INSTRU
196 /*int
197 fill_amplipup(cuFloatComplex *amplipup, float *phase, float *phase_instru, float
198 *mask, float scale,
199  int puponly, int nx, int ny, int Nx, CarmaDevice *device);*/
200 
201 int fill_amplipup(cuFloatComplex *amplipup, float *phase, float *mask,
202  float scale, int puponly, int nx, int ny, int Nx,
203  CarmaDevice *device);
204 
205 #endif // _SUTRA_SOURCE_H_
SutraSource::npts
long npts
number of points in the pupil
Definition: sutra_source.h:72
SutraSource::init_source
int init_source(CarmaContext *context, float xpos, float ypos, float lambda, float mag, float zerop, long size, string type, int device)
SutraSource::raytrace
int raytrace(bool rst=false)
SutraLGS
this class provides the lgs features to COMPASS
Definition: sutra_lgs.h:53
fill_amplipup
int fill_amplipup(cuFloatComplex *amplipup, float *phase, float *mask, float scale, int puponly, int nx, int ny, int Nx, CarmaDevice *device)
SutraSource::thetaML
float thetaML
Pupil rotation angle.
Definition: sutra_source.h:86
SutraSource::d_smallimg
CarmaObj< float > * d_smallimg
temporary array for accurate strehl computation
Definition: sutra_source.h:137
CarmaDevice
Definition: carma_context.h:57
SutraSource::phase_var_count
int phase_var_count
counter for average phase variance in the pupil
Definition: sutra_source.h:109
SutraSource::raytrace
int raytrace(SutraTelescope *tel, SutraAtmos *atmos, SutraDms *ydms, bool do_phase_var=true, bool async=false)
SutraSource::comp_strehl
int comp_strehl(bool do_fit)
SutraDms
Definition: sutra_dm.h:164
SutraSource::raytrace
int raytrace(SutraTelescope *tel, bool rst=false)
SutraSource::zp
float zp
imaging zero point
Definition: sutra_source.h:78
SutraSource::scale
float scale
phase scale
Definition: sutra_source.h:80
SutraSource::add_layer
int add_layer(string type, int idx, float xoff, float yoff)
sutra_telescope.h
SutraSource::G
float G
Magnifying factor for WFS misalignment.
Definition: sutra_source.h:84
SutraSource::d_phase
SutraPhase * d_phase
phase for this target
Definition: sutra_source.h:112
SutraSource::reset_phase
int reset_phase()
SutraSource::SutraSource
SutraSource(CarmaContext *context, float xpos, float ypos, float lambda, float mag, float zerop, long size, string type, int device)
SutraAtmos
this class provides the atmos features to COMPASS
Definition: sutra_atmos.h:50
SutraSource::yoff
map< type_screen, float > yoff
y reference for raytracing
Definition: sutra_source.h:133
SutraSource::raytrace
int raytrace(SutraDms *ydms, bool rst=false, bool do_phase_var=true, bool async=false)
SutraSource::strehl_se
float strehl_se
short exposure strehl
Definition: sutra_source.h:97
SutraSource::phase_telemetry
CarmaHostObj< float > * phase_telemetry
Definition: sutra_source.h:115
sutra_lgs.h
target_raytrace
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)
fft_goodsize
int fft_goodsize(long size)
SutraSource::ref_strehl
float ref_strehl
reference for strehl computation
Definition: sutra_source.h:101
SutraSource::comp_image
int comp_image(int puponly=0, bool comp_le=true)
SutraSource::d_smallimg_size
const int d_smallimg_size
Definition: sutra_source.h:138
CarmaStreams
this class provides the stream features to CarmaObj
Definition: carma_streams.h:49
target_raytrace_async
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)
SutraSource::d_lgs
SutraLGS * d_lgs
the lgs object
Definition: sutra_source.h:117
SutraSource::phase_var
float phase_var
current phase variance in the pupil
Definition: sutra_source.h:105
SutraTelescope
this class provides the telescope features to COMPASS
Definition: sutra_telescope.h:53
SutraSource::lgs
bool lgs
flag for lgs
Definition: sutra_source.h:82
SutraSource::xoff
map< type_screen, float > xoff
x reference for raytracing
Definition: sutra_source.h:131
SutraSource::init_strehlmeter
int init_strehlmeter()
CarmaObj< float >
SutraSource::dy
float dy
WFS misalignment.
Definition: sutra_source.h:90
SutraSource::~SutraSource
~SutraSource()
SutraSource::dx
float dx
WFS misalignment.
Definition: sutra_source.h:88
SutraSource::posy
float posy
y position of target on the sky
Definition: sutra_source.h:70
sutra_atmos.h
SutraSource::raytrace_shm
int raytrace_shm(SutraAtmos *atmos)
CarmaContext
this class provides the context in which CarmaObj are created
Definition: carma_context.h:104
SutraSource::device
int device
device #
Definition: sutra_source.h:66
sutra_telemetry.h
SutraSource::SutraSource
SutraSource(CarmaContext *context, float xpos, float ypos, float lambda, float mag, float zerop, long size, string type, CarmaObj< float > *pupil, int Npts, int device)
sutra_utils.h
SutraSource::phase_var_avg
float phase_var_avg
average phase variance in the pupil
Definition: sutra_source.h:107
SutraSource::d_wherephase
CarmaObj< int > * d_wherephase
positions of valid phase points in the pupil (target only)
Definition: sutra_source.h:129
CarmaHostObj< float >
SutraSource::lambda
float lambda
imaging lambda
Definition: sutra_source.h:76
SutraSource::posx
float posx
x position of target on the sky
Definition: sutra_source.h:68
SutraSource::reset_strehlmeter
int reset_strehlmeter()
SutraSource::d_amplipup
CarmaObj< cuFloatComplex > * d_amplipup
the complex amplitude in the pupil plane
Definition: sutra_source.h:125
SutraSource::d_pupil
CarmaObj< float > * d_pupil
the pupil mask
Definition: sutra_source.h:119
SutraSource::type
string type
type of source : target / wfs
Definition: sutra_source.h:92
sutra_dm.h
SutraSource::current_context
CarmaContext * current_context
Definition: sutra_source.h:64
SutraSource::d_image_se
CarmaObj< float > * d_image_se
the resulting image for this target
Definition: sutra_source.h:121
SutraSource::mag
float mag
brightness of target
Definition: sutra_source.h:74
SutraSource::d_phasepts
CarmaObj< float > * d_phasepts
the valid phase points in the pupil (target only)
Definition: sutra_source.h:127
SutraSource::block_size
int block_size
optimum block size of device
Definition: sutra_source.h:94
SutraPhase
this class provides the phase features to COMPASS
Definition: sutra_phase.h:56
SutraSource::strehl_le
float strehl_le
long exposure strehl
Definition: sutra_source.h:99
SutraSource
this class provides the source features to COMPASS
Definition: sutra_source.h:62
type_screen
std::pair< std::string, int > type_screen
Definition: sutra_source.h:60
SutraSource::strehl_counter
int strehl_counter
counter for le strehl computation
Definition: sutra_source.h:103
SutraSource::d_image_le
CarmaObj< float > * d_image_le
the long exposure image for this target
Definition: sutra_source.h:123
sutra_source.h
SutraSource::raytrace
int raytrace(SutraAtmos *atmos, bool async=false)
SutraSource::remove_layer
int remove_layer(string type, int idx)
SutraSource::d_ncpa_phase
CarmaObj< float > * d_ncpa_phase
ncpa phase
Definition: sutra_source.h:135