Projet

Général

Profil

YoGA Ao features » Historique » Version 3

Florian Ferreira, 08/01/2015 14:59

1 2 Damien Gratadour
h1. YoGA AO features
2 1 Damien Gratadour
3 2 Damien Gratadour
The YoGA_AO extension 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
There are two ways to use YoGA_Ao, either through the GUI or through the command line possibly using predefined scripts. The following description is valid for both ways but is probably more relevant to command line users. The main difference between the GUI and the command line interface is the way the simulation parameters are imported. In the latter case, the simulation parameters are centralized into a parameter file (.par). Examples of .par files are given in the data/par directory and can be used as templates. The high-level API contains a dedicated routine to read the parameters from this file and import them in the simulation environment.
6
7
[[YoGA Ao features#List-of-features|List of features]]
8
9
* [[YoGA Ao features#Simulation-geometry|Simulation geometry]]
10
* [[YoGA Ao features#Turbulence-generation|Turbulence generation]]
11
* [[YoGA Ao features#Wavefront-Sensing|Wavefront Sensing]]
12
* [[YoGA Ao features#Image-formation|Image formation]]
13 3 Florian Ferreira
* [[YoGA Ao features#Modal-optimization|Modal optimization]]
14 1 Damien Gratadour
15
[[YoGA Ao features#List-of-routines|List of routines]]
16
17
* [[YoGA Ao features#High-level-routines|High-level routines]]
18
* [[YoGA Ao features#Advanced-routines|Advanced routines]]
19
20
h2. List of features
21
22
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:
23
24
* Kolmogorov-type turbulence generation over an arbitrary number of layers with arbitrary properties.
25
* Shack-Hartmann wavefront sensing including Laser Guide Stars (LGS)
26
* Short and long exposure imaging under the turbulence
27
28
h3. Simulation geometry
29
30
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.
31
32
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.
33
34
To cope for these various requirements we can define 3 different pupils: 
35
36
* the large pupil (called ipupil) defined on the largest support (4kx4k in our previous example) more than half of which being 0
37
38
* the small pupil (spupil) defined only on the pupil size (2kx2k in our previous example) most of it being 1
39
40
* 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.
41
42
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.
43
44
!https://dev-lesia.obspm.fr/projets/attachments/download/570/pupil.png!
45
46
All these pupils are contained in arrays accessible as internal keywords of the following geom structure available from the Yorick API : 
47
48
<pre>
49
<code class="c">
50
struct geom_struct
51
{
52
   long  ssize;       // linear size of full image (in pixels)
53
   float zenithangle; // observations zenith angle (in deg)
54
   // internal keywords
55
   long  pupdiam;     // linear size of total pupil (in pixels)
56
   float cent;        // central point of the simulation
57
   pointer _ipupil;   // total pupil (include full guard band)
58
   pointer _mpupil;   // medium pupil (part of the guard band)
59
   pointer _spupil;   // small pupil (without guard band)
60
   ...
61
};
62
63
</code>
64
</pre>
65
66
some keywords have not been reported. Please check yoga_ao_ystruct.i for more details.
67
68
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 : 
69
70
<pre>
71
<code class="c">
72
struct tel_struct
73
{
74
    float diam;        // telescope diameter (in meters)
75
    float cobs;        // central obstruction ratio
76
};
77
</code>
78
</pre>
79
80
<pre>
81
<code class="c">
82
struct loop_struct
83
{
84
    long  niter;      // number of iterations
85
    float ittime;     // iteration time (in sec)
86
};
87
</code>
88
</pre>
89
90
There is one high-level routines to init the geometry with only one parameter: the pupil diameter in pixels. 
91
92
<pre>
93
<code class="c">
94
func geom_init(pupdiam)
95
    /* DOCUMENT geom_init
96
      geom_init,pupdiam
97
      inits simulation geometry, depending on pupdiam
98
      the linear number of pixels in the pupil
99
    */
100
101
</code>
102
</pre>
103
104
105
106
107
108
h3. Turbulence generation
109
110
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°).
111
112
<pre>
113
<code class="c">
114
struct atmos_struct
115
{
116
    long    nscreens;    // number of turbulent layers
117
    float   r0;          // global r0 @ 0.5µm
118
    float   pupixsize;   // pupil piwel size (in meters)
119
    pointer dim_screens; // linear size of phase screens
120
    pointer alt;         // altitudes of each layer
121
    pointer winddir;     // wind directions of each layer
122
    pointer windspeed;   // wind speeds of each layer
123
    pointer frac;        // fraction of r0 for each layer
124
    pointer deltax;      // x translation speed (in pix / iteration) for each layer
125
    pointer deltay;      // y translation speed (in pix / iteration) for each layer
126
};
127
128
129
</code>
130
</pre>
131
132
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.
133
134
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.
135
136
The overall turbulence generation is done on the GPU and rely on a C++ class:
137
138
139
<pre>
140
<code class="c">
141
class yoga_tscreen
142
</code>
143
</pre>
144
145
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:
146
147
148
149
<pre>
150
<code class="c">
151
class yoga_atmos
152
153
</code>
154
</pre>
155
156
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.
157
158
The corresponding Yorick opaque object is: 
159
160
<pre>
161
<code class="c">
162
 static y_userobj_t yAtmos
163
</code>
164
</pre>
165
166
and there are several Yorick wrappers to manipulate this object:
167
168
<pre>
169
<code class="c">
170
extern yoga_atmos;
171
    /* DOCUMENT yoga_atmos
172
       obj = yoga_atmos(nscreens,r0,size,size2,alt,wspeed,wdir,deltax,deltay,pupil[,ndevice])
173
       creates an yAtmos object on the gpu
174
    */
175
</code>
176
</pre>
177
178
179
<pre>
180
<code class="c">
181
extern init_tscreen;
182
    /* DOCUMENT init_tscreen
183
       init_tscreen,yoga_atmos_obj,altitude,a,b,istencilx,istencily,seed
184
       loads on the gpu in an yAtmos object and for a given screen data needed for extrude
185
    */
186
</code>
187
</pre>
188
189
190
<pre>
191
<code class="c">
192
extern get_tscreen;
193
    /* DOCUMENT get_tscreen
194
       screen = get_tscreen(yoga_atmos_obj,altitude)
195
       returns the screen in an yAtmos object and for a given altitude
196
    */
197
</code>
198
</pre>
199
200
<pre>
201
<code class="c">
202
extern get_tscreen_update;
203
    /* DOCUMENT get_tscreen_update
204
       vect = get_tscreen_update(yoga_atmos_obj,altitude)
205
       returns only the update vector in an yAtmos object and for a given altitude
206
    */
207
</code>
208
</pre>
209
210
<pre>
211
<code class="c">
212
extern extrude_tscreen;
213
    /* DOCUMENT extrude_tscreen
214
       extrude_tscreen,yoga_atmos_obj,altitude[,dir]
215
       executes one col / row screen extrusion for a given altitude in an yAtmos object 
216
    */
217
</code>
218
</pre>
219
220
221
Additionally there is a high-level routine to initialize the whole structure on the GPU from Yorick:
222
223
<pre>
224
<code class="c">
225
func atmos_init(void)
226
    /* DOCUMENT atmos_init
227
       atmos_init
228
       inits a yAtmos object on the gpu
229
       no input parameters
230
       requires 2 externals + 2 optional : y_atmos and y_geom + y_target and y_wfs
231
       y_atmos  : a y_struct for the atmosphere
232
       y_geom   : a y_struct for the geometry of the simulation
233
       y_target : a y_struct for the targets
234
       y_wfs    : a y_struct for the sensors
235
       creates 1 external :
236
       g_atmos : a yAtmos object on the gpu
237
    */
238
239
</code>
240
</pre>
241
242
243
244
245
h3. Wavefront Sensing
246
247
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]].
248
249
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.
250
251
The wavefront sensor model description is stored in the following Yorick structure. 
252
253
<pre>
254
<code class="c">
255
struct wfs_struct
256
{
257
  long  nxsub;          // linear number of subaps
258
  long  npix;           // number of pixels per subap
259
  float pixsize;        // pixel size (in arcsec) for a subap
260
  float lambda;         // observation wavelength (in µm) for a subap
261
  float optthroughput;  // wfs global throughput
262
  float fracsub;        // minimal illumination fraction for valid subaps
263
  
264
  //target kwrd
265
  float xpos;      // guide star x position on sky (in arcsec) 
266
  float ypos;      // guide star x position on sky (in arcsec) 
267
  float gsalt;     // altitude of guide star (in m) 0 if ngs 
268
  float gsmag;     // magnitude of guide star
269
  float zerop;     // detector zero point
270
  
271
  // lgs only
272
  float lgsreturnperwatt;  // return per watt factor (high season : 10 ph/cm2/s/W)
273
  float laserpower;        // laser power in W
274
  float lltx;              // x position (in meters) of llt
275
  float llty;              // y position (in meters) of llt
276
  string proftype;         // type of sodium profile "gauss", "exp", etc ...
277
  float beamsize;          // laser beam fwhm on-sky (in arcsec)
278
...
279
};
280
281
</code>
282
</pre>
283
284
285
286
h3. Image formation
287
288
<pre>
289
<code class="c">
290
struct target_struct
291
{
292
  long    ntargets;  // number of targets
293
  pointer lambda;    // observation wavelength for each target
294
  pointer xpos;      // x positions on sky (in arcsec) for each target
295
  pointer ypos;      // y positions on sky (in arcsec) for each target
296
  pointer mag;       // magnitude for each target
297
};
298
</code>
299
</pre>
300
301
302 3 Florian Ferreira
h3. Modal optimization
303 1 Damien Gratadour
304 3 Florian Ferreira
Modal optimization is available for Least Square controller. This features computes modal gains to apply to the command matrix from a modal base of the DM and a set of open-loop slopes (_Modal Control Optimization_, E.Gendron & P.Léna, Astron. Atrophies. 291,337-347 (1994)). 
305
In COMPASS, a matrix M2V (Modes to Volts) is computed from a Karhunen-Loeve basis of the DM (computed during the simulation) and open-loop slopes are recorded before the beginning of the simulation and used to compute a S2M (Slopes to Modes) matrix. Then, we are able to find optimal gains G to apply to each modes for improving performances in noisy AO system. Finally, the command matrix is computed as: M2V*G*S2M
306
To use this feature, you need to specify some new specific parameters in the input parameters file : 
307 1 Damien Gratadour
308 3 Florian Ferreira
<pre>
309
<code class="c">
310
311
struct controller_struct
312
{
313
  [..]
314
  int     modopti;  // Flag for modal optimization
315
  int     nrec;     // Number of sample of open loop slopes for modal optimization computation
316
  int     nmodes;   // Number of modes for M2V matrix (modal optimization)
317
  float     gmin;     // Minimum gain for modal optimization
318
  float     gmax;     // Maximum gain for modal optimization
319
  int     ngain;    // Number of tested gains
320
};
321
</code>
322
</pre>
323
324
You have to set modopti=1 to activate the feature. Then, you can specify the other parameters: if not, default values will be used.
325
Be careful with the nmodes parameter: maximum value is the number of actuators, but you may have to ignored some of them in order to make the matrix IMAT*S2M inversion possible.
326
Finally, note that modal gain are recomputed (i.e.. refreshed) each nrec iterations.
327
328
An example of parameter file which run a modal optimization simulation is available in data/par/1wfs8x8_1layer_rtc_modopti_dm.par
329 1 Damien Gratadour
330
h2. List of routines
331
332
h3. High-level routines
333
334
h3. Advanced routines
335
336
337
<pre>
338
<code class="c">
339
extern _GetMaxGflopsDeviceId  //get the ID of the best CUDA-capable device on your system
340
</code>
341
</pre>