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