Projet

Général

Profil

SUTrA features » Historique » Version 5

Damien Gratadour, 11/11/2013 10:55

1 2 Damien Gratadour
h1. SuTrA features
2 1 Damien Gratadour
3 2 Damien Gratadour
The SuTrA library contains routines to simulate the whole process of image formation through the atmosphere, a telescope and an adaptive optics (AO) system.
4 1 Damien Gratadour
5
6 3 Damien Gratadour
[[SuTrA_features#List-of-features|List of features]] 
7 1 Damien Gratadour
8 4 Damien Gratadour
* [[SuTrA_features#Simulation-geometry|Simulation geometry]]
9 1 Damien Gratadour
10 4 Damien Gratadour
* [[SuTrA_features#Turbulence-generation|Turbulence generation]]
11 1 Damien Gratadour
12 4 Damien Gratadour
* [[SuTrA_features#Wavefront-Sensing|Wavefront sensing]]
13 1 Damien Gratadour
14 4 Damien Gratadour
* [[SuTrA_features#Image-formation|Image formation]]
15 1 Damien Gratadour
16 4 Damien Gratadour
[[SuTrA_features#List-of-routines|List of routines]]
17 1 Damien Gratadour
18 4 Damien Gratadour
* [[SuTrA_features#High-level-routines|High-level-routines]]
19 1 Damien Gratadour
20 4 Damien Gratadour
* [[SuTrA_features#Advanced-routines|Advanced routines]] 
21 1 Damien Gratadour
22 4 Damien Gratadour
23
h2. List of features
24
25 1 Damien Gratadour
Each API comes with a set of structures concentrating the configuration parameters for the simulation as well as various data used for computation and diagnostics. For the Yorick API, the list of structures can be found in the file yoga_ao_ystruct.i. Concerning the CUDA-C API, please refer to the file yoga_ao.cpp. Available features include:
26
27
* Kolmogorov-type turbulence generation over an arbitrary number of layers with arbitrary properties.
28
29
* Shack-Hartmann wavefront sensing including Laser Guide Stars (LGS)
30
31
* Short and long exposure imaging under the turbulence
32
33 4 Damien Gratadour
h3. Simulation geometry
34
35 1 Damien Gratadour
The main parameter that drives most of the choices for the simulation geometry is the Fried parameter r0. Typically, for an adequate sampling, the equivalent size of the pixels we use to simulate the turbulent phase screens should be less than half r0. To ensure a good sampling, in YoGA_Ao, r0 is simulated on about 6 pixels. This ratio defines the size of the "quantum" pixels and thus the size of the phase screens to simulate (as compared to the telescope size). From this screen size, the full images size is defined,taking into account the sampling required for imaging. 
36
37
As an example, in the case of an ELT, the linear size of the phase screen support (and thus of the pupil) is of the order of 1.5k to 2k pixels. This means that the linear size of the image will be at least 4k (for a minimum Shannon sampling). This is a very large number which will imply heavy computations. 
38
39
To cope for these various requirements we can define 3 different pupils: 
40
41
* the large pupil (called ipupil) defined on the largest support (4kx4k in our previous example) more than half of which being 0
42
43
* the small pupil (spupil) defined only on the pupil size (2kx2k in our previous example) most of it being 1
44
45
* the medium pupil (mpupil) defined on a slightly larger support: typically 4 additional pixels as a guard band on each size. This guard band is useful for manipulations on phase screens like raytracing. This is also the actual size of the ground layer phase screen.
46
47
The image below helps to understand the various pupil sizes. White is the pupil, green is the support of spupil, blue the support of mpupil et black the support of ipupil.
48
49
[[http://github.com/dgratadour/yoga_ao/raw/master/pictures/pupil.png]]
50
51
All these pupils are contained in arrays accessible as internal keywords of the following geom structure available from the Yorick API :
52 4 Damien Gratadour
<pre>
53 1 Damien Gratadour
struct geom_struct
54
{
55
   long  ssize;       // linear size of full image (in pixels)
56
   float zenithangle; // observations zenith angle (in deg)
57
   // internal keywords
58
   long  pupdiam;     // linear size of total pupil (in pixels)
59
   float cent;        // central point of the simulation
60
   pointer _ipupil;   // total pupil (include full guard band)
61
   pointer _mpupil;   // medium pupil (part of the guard band)
62
   pointer _spupil;   // small pupil (without guard band)
63
   ...
64
};
65 4 Damien Gratadour
</pre>
66
67 1 Damien Gratadour
some keywords have not been reported. Please check yoga_ao_ystruct.i for more details.
68
69
In this structure pupdiam (the diameter in pixels of the pupil is considered as an internal keyword). Two other structures contain the rest of the configuration parameters :
70 4 Damien Gratadour
<pre>
71 1 Damien Gratadour
struct tel_struct
72
{
73
    float diam;        // telescope diameter (in meters)
74
    float cobs;        // central obstruction ratio
75
};
76 4 Damien Gratadour
</pre>
77 5 Damien Gratadour
78 4 Damien Gratadour
<pre>
79 1 Damien Gratadour
struct loop_struct
80
{
81
    long  niter;      // number of iterations
82
    float ittime;     // iteration time (in sec)
83
};
84 4 Damien Gratadour
</pre>
85 1 Damien Gratadour
86
There is one high-level routines to init the geometry with only one parameter: the pupil diameter in pixels.
87 5 Damien Gratadour
88 4 Damien Gratadour
<pre>
89 1 Damien Gratadour
func geom_init(pupdiam)
90
    /* DOCUMENT geom_init
91
      geom_init,pupdiam
92
      inits simulation geometry, depending on pupdiam
93
      the linear number of pixels in the pupil
94
    */
95 4 Damien Gratadour
</pre>
96 1 Damien Gratadour
97 4 Damien Gratadour
h3. Turbulence generation
98 5 Damien Gratadour
99 1 Damien Gratadour
The turbulence generation is done through the process of extruding infinite ribbons of Kolmogorov turbulence (see [[Model Description]]). An arbitrary number of turbulent layers can be defined at various altitude and various fraction of r0, wind speed and directions (in the range 0°-90°).
100
101 4 Damien Gratadour
<pre>
102 1 Damien Gratadour
struct atmos_struct
103
{
104
    long    nscreens;    // number of turbulent layers
105
    float   r0;          // global r0 @ 0.5µm
106
    float   pupixsize;   // pupil piwel size (in meters)
107
    pointer dim_screens; // linear size of phase screens
108
    pointer alt;         // altitudes of each layer
109
    pointer winddir;     // wind directions of each layer
110
    pointer windspeed;   // wind speeds of each layer
111
    pointer frac;        // fraction of r0 for each layer
112
    pointer deltax;      // x translation speed (in pix / iteration) for each layer
113
    pointer deltay;      // y translation speed (in pix / iteration) for each layer
114
};
115 4 Damien Gratadour
</pre>
116 1 Damien Gratadour
117
The phase screens size is computed in agreement with the system components. The positions of the various targets (imaging targets or wavefront sensing guide stars) in the simulation define the required field of view and thus the size of the altitude phase screens.
118
119
To create a dynamic turbulence, the phase screens are extruded in columns and rows. The number of rows and columns extruded per iteration is computed using the specified wind speed and direction. Because extrusion is an integer operation (can't extrude a portion of a column), additional interpolation is required to provide an accurate model (with non integer phase shifts). In YoGA_Ao, a combination of integer extrusion and linear interpolation (in between four pixels) is used for each layer. The phase is integrated along specified directions across the multiple layers with the positions of light rays being re-evaluated for each iteration and screen ribbons being extruded when appropriate. This explains the need for a guard band around the ground layer phase screen as light rays can partly cross the pupil pixels depending on the iteration number.
120
121
The overall turbulence generation is done on the GPU and rely on a C++ class:
122 5 Damien Gratadour
123 4 Damien Gratadour
<pre>
124 1 Damien Gratadour
class yoga_tscreen
125
</pre>
126
127
This object contains all the elements to generate an infinite length phase screen including the extrusion method. All the screens for a given atmospheric configuration are centralized in another class:
128
129 5 Damien Gratadour
<pre>
130 1 Damien Gratadour
class yoga_atmos
131 4 Damien Gratadour
</pre>
132 1 Damien Gratadour
133
In this object phase screens can be added dynamically thanks to the use of a map of __yoga_tscreen__ This has many advantages the first of which being the indexation: screens are indexed by altitude (*float*) and the use of iterators greatly simplifies the code. 
134
135
The corresponding Yorick opaque object is:
136 4 Damien Gratadour
<pre>
137 1 Damien Gratadour
    static y_userobj_t yAtmos
138 4 Damien Gratadour
</pre>
139 1 Damien Gratadour
140
and there are several Yorick wrappers to manipulate this object:
141
142 4 Damien Gratadour
<pre>
143 1 Damien Gratadour
extern yoga_atmos;
144
    /* DOCUMENT yoga_atmos
145
       obj = yoga_atmos(nscreens,r0,size,size2,alt,wspeed,wdir,deltax,deltay,pupil[,ndevice])
146
       creates an yAtmos object on the gpu
147
    */
148 4 Damien Gratadour
</pre>
149 1 Damien Gratadour
150 4 Damien Gratadour
<pre>
151 1 Damien Gratadour
extern init_tscreen;
152
    /* DOCUMENT init_tscreen
153
       init_tscreen,yoga_atmos_obj,altitude,a,b,istencilx,istencily,seed
154
       loads on the gpu in an yAtmos object and for a given screen data needed for extrude
155
    */
156 4 Damien Gratadour
</pre>
157 1 Damien Gratadour
158 4 Damien Gratadour
<pre>
159 1 Damien Gratadour
extern get_tscreen;
160
    /* DOCUMENT get_tscreen
161
       screen = get_tscreen(yoga_atmos_obj,altitude)
162
       returns the screen in an yAtmos object and for a given altitude
163
    */
164 4 Damien Gratadour
</pre>
165 1 Damien Gratadour
166 4 Damien Gratadour
<pre>
167 1 Damien Gratadour
extern get_tscreen_update;
168
    /* DOCUMENT get_tscreen_update
169
       vect = get_tscreen_update(yoga_atmos_obj,altitude)
170
       returns only the update vector in an yAtmos object and for a given altitude
171 4 Damien Gratadour
</pre>
172 1 Damien Gratadour
173 4 Damien Gratadour
<pre>
174 1 Damien Gratadour
extern extrude_tscreen;
175
    /* DOCUMENT extrude_tscreen
176
       extrude_tscreen,yoga_atmos_obj,altitude[,dir]
177
       executes one col / row screen extrusion for a given altitude in an yAtmos object 
178
    */
179 4 Damien Gratadour
</pre>
180 1 Damien Gratadour
181
Additionally there is a high-level routine to initialize the whole structure on the GPU from Yorick:
182
183 4 Damien Gratadour
<pre>
184 1 Damien Gratadour
func atmos_init(void)
185
    /* DOCUMENT atmos_init
186
       atmos_init
187
       inits a yAtmos object on the gpu
188
       no input parameters
189
       requires 2 externals + 2 optional : y_atmos and y_geom + y_target and y_wfs
190
       y_atmos  : a y_struct for the atmosphere
191
       y_geom   : a y_struct for the geometry of the simulation
192
       y_target : a y_struct for the targets
193
       y_wfs    : a y_struct for the sensors
194
       creates 1 external :
195
       g_atmos : a yAtmos object on the gpu
196
    */
197 4 Damien Gratadour
</pre>
198 1 Damien Gratadour
199 4 Damien Gratadour
h3. Wavefront sensing
200
201 1 Damien Gratadour
Wavefront sensing is done in two steps: first compute the Shack-Hartmann sub-images including diffraction effect and noise and then from these images, compute the centroids. The overall model is described here [[Model Description]]. 
202
203
The pixel size requested by the user for the sub-apertures images are approximated following a rather robust approach to cope for any kind of dimensioning. We used an empirical coefficient to set the simulated subaps field of view (FoV) to 6 times the ratio of the observing wavelength over r_0 at this wavelength. This provides sufficient FoV to include most of the turbulent speckles. The same empirical coefficient is used to define de number of phase points per subaps as 6 times the ratio of the subaps diameter over r_0. This ensures a proper sampling of r_0. From this number of phase points we compute the size of the support in the Fourier domain. The "quantum pixel size" is then deduced from the ratio of the wavelength over r_0 over the size of the Fourier support. Then the pixel size actually simulated is obtained using the product of an integer number by this quantum pixel size as close as possible to the requested pixel size.
204
205
The wavefront sensor model description is stored in the following Yorick structure.
206 4 Damien Gratadour
<pre>
207 1 Damien Gratadour
struct wfs_struct
208
{
209
  long  nxsub;          // linear number of subaps
210
  long  npix;           // number of pixels per subap
211
  float pixsize;        // pixel size (in arcsec) for a subap
212
  float lambda;         // observation wavelength (in µm) for a subap
213
  float optthroughput;  // wfs global throughput
214
  float fracsub;        // minimal illumination fraction for valid subaps
215
  
216
  //target kwrd
217
  float xpos;      // guide star x position on sky (in arcsec) 
218
  float ypos;      // guide star x position on sky (in arcsec) 
219
  float gsalt;     // altitude of guide star (in m) 0 if ngs 
220
  float gsmag;     // magnitude of guide star
221
  float zerop;     // detector zero point
222
  
223
  // lgs only
224
  float lgsreturnperwatt;  // return per watt factor (high season : 10 ph/cm2/s/W)
225
  float laserpower;        // laser power in W
226
  float lltx;              // x position (in meters) of llt
227
  float llty;              // y position (in meters) of llt
228
  string proftype;         // type of sodium profile "gauss", "exp", etc ...
229
  float beamsize;          // laser beam fwhm on-sky (in arcsec)
230
...
231
};
232 4 Damien Gratadour
</pre>
233 1 Damien Gratadour
234 4 Damien Gratadour
h3. Image formation
235
236
<pre>
237 1 Damien Gratadour
struct target_struct
238
{
239
  long    ntargets;  // number of targets
240
  pointer lambda;    // observation wavelength for each target
241
  pointer xpos;      // x positions on sky (in arcsec) for each target
242
  pointer ypos;      // y positions on sky (in arcsec) for each target
243
  pointer mag;       // magnitude for each target
244
};
245 4 Damien Gratadour
</pre>
246 1 Damien Gratadour
247 4 Damien Gratadour
h2. List of routines
248 1 Damien Gratadour
249 4 Damien Gratadour
h3. High-level routines
250 1 Damien Gratadour
251 4 Damien Gratadour
h3. Advanced routines
252
253 1 Damien Gratadour
* __**extern _GetMaxGflopsDeviceId**__ get the ID of the best CUDA-capable device on your system