COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
shesha.init.atmos_init Namespace Reference

Initialization of a Atmos object. More...

Functions

def atmos_init (carmaWrap_context context, conf.Param_atmos p_atmos, conf.Param_tel p_tel, conf.Param_geom p_geom, ittime=None, p_wfss=None, p_targets=None, dataBase={}, use_DB=False)
 Initializes an Atmos object. More...
 

Detailed Description

Initialization of a Atmos object.

Author
COMPASS Team https://github.com/ANR-COMPASS
Version
5.0.0
Date
2020/05/18

This file is part of COMPASS https://anr-compass.github.io/compass/

Copyright (C) 2011-2019 COMPASS Team https://github.com/ANR-COMPASS All rights reserved. Distributed under GNU - LGPL

COMPASS is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

COMPASS: End-to-end AO simulation tool using GPU acceleration The COMPASS platform was designed to meet the need of high-performance for the simulation of AO systems.

The final product includes a software package for simulating all the critical subcomponents of AO, particularly in the context of the ELT and a real-time core based on several control approaches, with performances consistent with its integration into an instrument. Taking advantage of the specific hardware architecture of the GPU, the COMPASS tool allows to achieve adequate execution speeds to conduct large simulation campaigns called to the ELT.

The COMPASS platform can be used to carry a wide variety of simulations to both testspecific components of AO of the E-ELT (such as wavefront analysis device with a pyramid or elongated Laser star), and various systems configurations such as multi-conjugate AO.

COMPASS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with COMPASS. If not, see https://www.gnu.org/licenses/lgpl-3.0.txt.

Function Documentation

◆ atmos_init()

def shesha.init.atmos_init.atmos_init ( carmaWrap_context  context,
conf.Param_atmos  p_atmos,
conf.Param_tel  p_tel,
conf.Param_geom  p_geom,
  ittime = None,
  p_wfss = None,
  p_targets = None,
  dataBase = {},
  use_DB = False 
)

Initializes an Atmos object.

:parameters: context (carmaWrap_context): GPU device context p_atmos (Param_atmos): Atmosphere parameters p_tel (Param_tel): Telescope parameters p_geom (Param_geom): Geometry parameters ittime (float): (optional) exposition time [s] p_wfss (list of Param_wfs): (optional) WFS parameters p_targets (list of Param_target): (optional) target parameters dataBase (dict): (optional) dictionary for data base use_DB (bool): (optional) flag for using the dataBase system :return: atm (Atmos): Atmos object

Definition at line 63 of file atmos_init.py.

63  :return:
64  atm : (Atmos): Atmos object
65  """
66  if not p_geom.is_init:
67  raise RuntimeError("Cannot init atmosphere with uninitialized p_geom.")
68 
69  # Deleted carmaWrap_context : get the singleton
70 
71  if p_atmos.r0 is None:
72  p_atmos.r0 = 0.
73 
74  if ittime is None:
75  ittime = 1.
76  # Adjust layers alt using zenith angle
77  p_atmos.alt = p_atmos.alt / np.cos(p_geom.zenithangle * CONST.DEG2RAD)
78  # Pixel size in meters
79  p_atmos.pupixsize = p_tel.diam / p_geom.pupdiam
80 
81  # Off-axis wavefront sensors and targets
82  # Note : p_wfss is a list of single-WFS configs
83  # but p_target groups several targets
84  # hence different xpos, ypos syntaxes
85  norms = [0.]
86  if p_wfss is not None:
87  norms += [(w.xpos**2 + w.ypos**2)**0.5 for w in p_wfss]
88  if p_targets is not None:
89  norms += [(p_target.xpos**2 + p_target.ypos**2)**0.5 for p_target in p_targets]
90 
91  max_size = max(norms)
92 
93  # Meta-pupil diameter for all layers depending on altitude
94  patch_diam = (p_geom._n + 2 * (max_size * CONST.ARCSEC2RAD * p_atmos.alt) /
95  p_atmos.pupixsize + 4).astype(np.int64)
96  p_atmos.dim_screens = (patch_diam + patch_diam % 2)
97 
98  # Phase screen speeds
99  lin_delta = p_geom.pupdiam / p_tel.diam * p_atmos.windspeed * \
100  np.cos(CONST.DEG2RAD * p_geom.zenithangle) * ittime
101  p_atmos._deltax = lin_delta * np.sin(CONST.DEG2RAD * p_atmos.winddir + np.pi)
102  p_atmos._deltay = lin_delta * np.cos(CONST.DEG2RAD * p_atmos.winddir + np.pi)
103 
104  # Fraction normalization
105  p_atmos.frac /= np.sum(p_atmos.frac)
106 
107  if p_atmos.L0 is None:
108  # Set almost infinite L0
109  p_atmos.L0 = np.ones(p_atmos.nscreens, dtype=np.float32) * 1e5
110  L0_pix = p_atmos.L0 * p_geom.pupdiam / p_tel.diam
111 
112  if p_atmos.seeds is None:
113  p_atmos.seeds = np.arange(p_atmos.nscreens, dtype=np.int64) + 1234
114 
115  r0_layers = p_atmos.r0 / (p_atmos.frac**(3. / 5.) * p_atmos.pupixsize)
116  stencil_size = itK.stencil_size_array(p_atmos.dim_screens)
117 
118  atm = Atmos(context, p_atmos.nscreens, p_atmos.r0, r0_layers, p_atmos.dim_screens,
119  stencil_size, p_atmos.alt, p_atmos.windspeed, p_atmos.winddir,
120  p_atmos._deltax, p_atmos._deltay, context.active_device)
121 
122  print("Creating turbulent layers :")
123  for i in tqdm(range(p_atmos.nscreens)):
124  if "A" in dataBase:
125  A, B, istx, isty = h5u.load_AB_from_dataBase(dataBase, i)
126  else:
127  A, B, istx, isty = itK.AB(p_atmos.dim_screens[i], L0_pix[i],
128  p_atmos._deltax[i], p_atmos._deltay[i], 0)
129  if use_DB:
130  h5u.save_AB_in_database(i, A, B, istx, isty)
131 
132  atm.init_screen(i, A, B, istx, isty, p_atmos.seeds[i])
133 
134  return atm