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

Initialization of a Target object. More...

Functions

def target_init (carmaWrap_context ctxt, Telescope telescope, list p_targets, conf.Param_atmos p_atmos, conf.Param_tel p_tel, conf.Param_geom p_geom, dm=None, brahma=False)
 Create a cython target from parametres structures. More...
 

Detailed Description

Initialization of a Target 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

◆ target_init()

def shesha.init.target_init.target_init ( carmaWrap_context  ctxt,
Telescope  telescope,
list  p_targets,
conf.Param_atmos  p_atmos,
conf.Param_tel  p_tel,
conf.Param_geom  p_geom,
  dm = None,
  brahma = False 
)

Create a cython target from parametres structures.

:parameters: ctxt (carmaWrap_context) : telescope (Telescope): Telescope object p_targets (lis of Param_target) : target_settings p_atmos (Param_atmos) : atmos settings p_tel (Param_tel) : telescope settings p_geom (Param_geom) : geom settings dm (Param_dm) : (optional) dm settings brahma (bool): (optional) brahma flag :return: tar (Target): Target object

Definition at line 61 of file target_init.py.

61  :return:
62  tar: (Target): Target object
63  """
64  type_target = "atmos"
65 
66  if (p_targets is not None):
67  for p_target in p_targets:
68  if (p_target.dms_seen is None and dm is not None):
69  p_target.dms_seen = np.arange(len(dm))
70 
71  sizes = np.ones(len(p_targets), dtype=np.int64) * p_geom.pupdiam
72 
73  ceiled_pupil = np.ceil(p_geom._spupil)
74 
75  ceiled_pupil[np.where(ceiled_pupil > 1)] = 1
76 
77  if (p_target.apod == 1):
78  Npts = 0
79  # TODO apodizer, Npts=nb element of apodizer>0
80  ceiled_apodizer = np.ceil(p_geom._apodizer * p_geom._spupil)
81  ceiled_apodizer[np.where(ceiled_apodizer > 1)] = 1
82  Npts = np.sum(ceiled_apodizer)
83  else:
84  Npts = np.sum(ceiled_pupil)
85 
86  xpos = np.array([p_target.xpos for p_target in p_targets], dtype=np.float32)
87  ypos = np.array([p_target.ypos for p_target in p_targets], dtype=np.float32)
88  Lambda = np.array([p_target.Lambda for p_target in p_targets], dtype=np.float32)
89  mag = np.array([p_target.mag for p_target in p_targets], dtype=np.float32)
90  zerop = p_targets[0].zerop
91 
92  if (brahma):
93  target = Target_brahma(ctxt, "target_brahma", telescope, 0, len(p_targets), xpos,
94  ypos, Lambda, mag, zerop, sizes, Npts, ctxt.active_device)
95  else:
96  target = Target(ctxt, telescope, len(p_targets), xpos, ypos, Lambda, mag, zerop,
97  sizes, Npts, ctxt.active_device)
98 
99  # cc=i
100  for i in range(len(p_targets)):
101  p_target = p_targets[i]
102  if (p_atmos.nscreens > 0):
103  for j in range(p_atmos.nscreens):
104  xoff = p_target.xpos * CONST.ARCSEC2RAD * \
105  p_atmos.alt[j] / p_atmos.pupixsize
106  yoff = p_target.ypos * CONST.ARCSEC2RAD * \
107  p_atmos.alt[j] / p_atmos.pupixsize
108  xoff += float((p_atmos.dim_screens[j] - p_geom._n) / 2)
109  yoff += float((p_atmos.dim_screens[j] - p_geom._n) / 2)
110  pupdiff = (p_geom._n - p_geom.pupdiam) / 2
111  xoff += pupdiff
112  yoff += pupdiff
113  target.d_targets[i].add_layer(type_target, j, xoff, yoff)
114 
115  # if (y_dm != []) {
116  if (dm is not None):
117  # j=ddd
118  # for (ddd=1;ddd<=numberof(*y_target(cc).dms_seen);ddd++) {
119  for j in range(p_target.dms_seen.size):
120  # k=dd
121  # dd = (*y_target(cc).dms_seen)(ddd)
122  k = p_target.dms_seen[j]
123  dims = dm[k]._n2 - dm[k]._n1 + 1
124  dim = p_geom._mpupil[2].size
125  dim_dm = max(dim, dims)
126  xoff = p_target.xpos * CONST.ARCSEC2RAD * \
127  dm[k].alt / p_tel.diam * p_geom.pupdiam
128  yoff = p_target.ypos * CONST.ARCSEC2RAD * \
129  dm[k].alt / p_tel.diam * p_geom.pupdiam
130 
131  xoff += float((dim_dm - p_geom._n) / 2)
132  yoff += float((dim_dm - p_geom._n) / 2)
133 
134  pupdiff = (p_geom._n - p_geom.pupdiam) / 2
135  xoff += pupdiff
136  yoff += pupdiff
137 
138  # if (dm[k].type == scons.DmType.KL):
139  # xoff -= 2
140  # yoff -= 2
141  target.d_targets[i].add_layer(dm[k].type, k, xoff, yoff)
142 
143  target.d_targets[i].init_strehlmeter()
144 
145  return target