Projet

Général

Profil

SUTrA features » Historique » Version 1

Damien Gratadour, 28/10/2013 08:30

1 1 Damien Gratadour
h1. SUTrA features
2
3
The YoGA_Ao library contains routines to simulate the whole process of image formation through the atmosphere, a telescope and an adaptive optics (AO) system. Following the [[YoGA Philosophy|http://github.com/yorick-yoga/yorick-yoga/wiki/YoGA-philosophy]] YoGA_Ao is designed around a double-sided API: a Yorick API (called hereafter high-level routines) and CUDA-C API accessible to the interpreter through Yorick wrappers (called hereafter advanced routines).
4
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
8
[List of features](#List) 
9
10
+ [Simulation geometry](#Geom)
11
12
+ [Turbulence generation](#Turbu)
13
14
+ [Wavefront Sensing](#WFS)
15
16
+ [Image formation](#Image)
17
18
[List of routines](#Routines)
19
20
+ [High-level routines](#High)
21
22
+ [Advanced routines](#Advanced) 
23
24
<a name="wiki-List"></a>
25
##List of features
26
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:
27
28
* Kolmogorov-type turbulence generation over an arbitrary number of layers with arbitrary properties.
29
30
* Shack-Hartmann wavefront sensing including Laser Guide Stars (LGS)
31
32
* Short and long exposure imaging under the turbulence
33
34
<a name="wiki-Geom"></a>
35
###Simulation geometry
36
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. 
37
38
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. 
39
40
To cope for these various requirements we can define 3 different pupils: 
41
42
* the large pupil (called ipupil) defined on the largest support (4kx4k in our previous example) more than half of which being 0
43
44
* the small pupil (spupil) defined only on the pupil size (2kx2k in our previous example) most of it being 1
45
46
* 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.
47
48
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.
49
50
[[http://github.com/dgratadour/yoga_ao/raw/master/pictures/pupil.png]]
51
52
All these pupils are contained in arrays accessible as internal keywords of the following geom structure available from the Yorick API :
53
```c
54
struct geom_struct
55
{
56
   long  ssize;       // linear size of full image (in pixels)
57
   float zenithangle; // observations zenith angle (in deg)
58
   // internal keywords
59
   long  pupdiam;     // linear size of total pupil (in pixels)
60
   float cent;        // central point of the simulation
61
   pointer _ipupil;   // total pupil (include full guard band)
62
   pointer _mpupil;   // medium pupil (part of the guard band)
63
   pointer _spupil;   // small pupil (without guard band)
64
   ...
65
};
66
```
67
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
```c
71
struct tel_struct
72
{
73
    float diam;        // telescope diameter (in meters)
74
    float cobs;        // central obstruction ratio
75
};
76
```
77
```c
78
struct loop_struct
79
{
80
    long  niter;      // number of iterations
81
    float ittime;     // iteration time (in sec)
82
};
83
```
84
85
There is one high-level routines to init the geometry with only one parameter: the pupil diameter in pixels.
86
```c
87
func geom_init(pupdiam)
88
    /* DOCUMENT geom_init
89
      geom_init,pupdiam
90
      inits simulation geometry, depending on pupdiam
91
      the linear number of pixels in the pupil
92
    */
93
```
94
95
<a name="wiki-Turbu"></a> 
96
###Turbulence generation
97
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°).
98
99
```c
100
struct atmos_struct
101
{
102
    long    nscreens;    // number of turbulent layers
103
    float   r0;          // global r0 @ 0.5µm
104
    float   pupixsize;   // pupil piwel size (in meters)
105
    pointer dim_screens; // linear size of phase screens
106
    pointer alt;         // altitudes of each layer
107
    pointer winddir;     // wind directions of each layer
108
    pointer windspeed;   // wind speeds of each layer
109
    pointer frac;        // fraction of r0 for each layer
110
    pointer deltax;      // x translation speed (in pix / iteration) for each layer
111
    pointer deltay;      // y translation speed (in pix / iteration) for each layer
112
};
113
```
114
115
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.
116
117
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.
118
119
The overall turbulence generation is done on the GPU and rely on a C++ class:
120
```c++
121
class yoga_tscreen
122
```
123
124
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:
125
126
```c++
127
class yoga_atmos
128
```
129
130
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. 
131
132
The corresponding Yorick opaque object is:
133
```c
134
    static y_userobj_t yAtmos
135
```
136
137
and there are several Yorick wrappers to manipulate this object:
138
139
```c
140
extern yoga_atmos;
141
    /* DOCUMENT yoga_atmos
142
       obj = yoga_atmos(nscreens,r0,size,size2,alt,wspeed,wdir,deltax,deltay,pupil[,ndevice])
143
       creates an yAtmos object on the gpu
144
    */
145
```
146
147
```c
148
extern init_tscreen;
149
    /* DOCUMENT init_tscreen
150
       init_tscreen,yoga_atmos_obj,altitude,a,b,istencilx,istencily,seed
151
       loads on the gpu in an yAtmos object and for a given screen data needed for extrude
152
    */
153
```
154
155
```c
156
extern get_tscreen;
157
    /* DOCUMENT get_tscreen
158
       screen = get_tscreen(yoga_atmos_obj,altitude)
159
       returns the screen in an yAtmos object and for a given altitude
160
    */
161
```
162
163
```c
164
extern get_tscreen_update;
165
    /* DOCUMENT get_tscreen_update
166
       vect = get_tscreen_update(yoga_atmos_obj,altitude)
167
       returns only the update vector in an yAtmos object and for a given altitude
168
    */
169
```
170
171
```c
172
extern extrude_tscreen;
173
    /* DOCUMENT extrude_tscreen
174
       extrude_tscreen,yoga_atmos_obj,altitude[,dir]
175
       executes one col / row screen extrusion for a given altitude in an yAtmos object 
176
    */
177
```
178
179
Additionally there is a high-level routine to initialize the whole structure on the GPU from Yorick:
180
181
```c
182
func atmos_init(void)
183
    /* DOCUMENT atmos_init
184
       atmos_init
185
       inits a yAtmos object on the gpu
186
       no input parameters
187
       requires 2 externals + 2 optional : y_atmos and y_geom + y_target and y_wfs
188
       y_atmos  : a y_struct for the atmosphere
189
       y_geom   : a y_struct for the geometry of the simulation
190
       y_target : a y_struct for the targets
191
       y_wfs    : a y_struct for the sensors
192
       creates 1 external :
193
       g_atmos : a yAtmos object on the gpu
194
    */
195
```
196
197
<a name="wiki-WFS"></a>
198
###Wavefront sensing
199
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]]. 
200
201
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.
202
203
The wavefront sensor model description is stored in the following Yorick structure.
204
```
205
struct wfs_struct
206
{
207
  long  nxsub;          // linear number of subaps
208
  long  npix;           // number of pixels per subap
209
  float pixsize;        // pixel size (in arcsec) for a subap
210
  float lambda;         // observation wavelength (in µm) for a subap
211
  float optthroughput;  // wfs global throughput
212
  float fracsub;        // minimal illumination fraction for valid subaps
213
  
214
  //target kwrd
215
  float xpos;      // guide star x position on sky (in arcsec) 
216
  float ypos;      // guide star x position on sky (in arcsec) 
217
  float gsalt;     // altitude of guide star (in m) 0 if ngs 
218
  float gsmag;     // magnitude of guide star
219
  float zerop;     // detector zero point
220
  
221
  // lgs only
222
  float lgsreturnperwatt;  // return per watt factor (high season : 10 ph/cm2/s/W)
223
  float laserpower;        // laser power in W
224
  float lltx;              // x position (in meters) of llt
225
  float llty;              // y position (in meters) of llt
226
  string proftype;         // type of sodium profile "gauss", "exp", etc ...
227
  float beamsize;          // laser beam fwhm on-sky (in arcsec)
228
...
229
};
230
```
231
232
<a name="wiki-Image">
233
###Image formation
234
```
235
struct target_struct
236
{
237
  long    ntargets;  // number of targets
238
  pointer lambda;    // observation wavelength for each target
239
  pointer xpos;      // x positions on sky (in arcsec) for each target
240
  pointer ypos;      // y positions on sky (in arcsec) for each target
241
  pointer mag;       // magnitude for each target
242
};
243
```
244
245
<a name="wiki-Routines">
246
##List of routines
247
248
<a name="wiki-High">
249
##High-level routines
250
251
<a name="wiki-Advanced">
252
##Advanced routines
253
* __**extern _GetMaxGflopsDeviceId**__ get the ID of the best CUDA-capable device on your system