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

On the fly modification of the WFS. More...

Functions

def comp_new_pyr_ampl (int nwfs, float ampli, list p_wfss, conf.Param_tel p_tel, int npts_force=None)
 Set the pyramid modulation amplitude. More...
 
def noise_cov (int nw, conf.Param_wfs p_wfs, conf.Param_atmos p_atmos, conf.Param_tel p_tel)
 Compute the diagonal of the noise covariance matrix for a SH WFS (arcsec^2) Photon (pi^2/2)*(1/Nphotons)*(d/r0)^2 / (2*pi*d/lambda)^2 Electronic (pi^2/3)*(wfs.noise^2/N^2photons)*wfs.npix^2*(wfs.npix*wfs.pixsize*d/lambda)^2 / (2*pi*d/lambda)^2. More...
 
def comp_new_fstop (Sensors wfs, int n, conf.Param_wfs p_wfs, float fssize, bytes fstop)
 Compute a new field stop for pyrhr WFS. More...
 

Detailed Description

On the fly modification of the WFS.

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

◆ comp_new_fstop()

def shesha.ao.wfs.comp_new_fstop ( Sensors  wfs,
int  n,
conf.Param_wfs  p_wfs,
float  fssize,
bytes  fstop 
)

Compute a new field stop for pyrhr WFS.

:parameters:

n (int) : WFS index

wfs (Param_wfs) : WFS parameters

fssize (float) : field stop size [arcsec]

fstop (string) : "square" or "round" (field stop shape)

Definition at line 149 of file wfs.py.

149  fstop : (string) : "square" or "round" (field stop shape)
150  """
151  fsradius_pixels = int(fssize / p_wfs._qpixsize / 2.)
152  if (fstop == scons.FieldStopType.ROUND):
153  p_wfs.fstop = fstop
154  focmask = util.dist(p_wfs._Nfft, xc=p_wfs._Nfft / 2. - 0.5,
155  yc=p_wfs._Nfft / 2. - 0.5) < (fsradius_pixels)
156  # fstop_area = np.pi * (p_wfs.fssize/2.)**2. #UNUSED
157  elif (p_wfs.fstop == scons.FieldStopType.SQUARE):
158  p_wfs.fstop = fstop
159  y, x = np.indices((p_wfs._Nfft, p_wfs._Nfft))
160  x -= (p_wfs._Nfft - 1.) / 2.
161  y -= (p_wfs._Nfft - 1.) / 2.
162  focmask = (np.abs(x) <= (fsradius_pixels)) * \
163  (np.abs(y) <= (fsradius_pixels))
164  # fstop_area = p_wfs.fssize**2. #UNUSED
165  else:
166  msg = "p_wfs " + str(n) + ". fstop must be round or square"
167  raise ValueError(msg)
168 
169  # pyr_focmask = np.roll(focmask,focmask.shape[0]/2,axis=0)
170  # pyr_focmask = np.roll(pyr_focmask,focmask.shape[1]/2,axis=1)
171  pyr_focmask = focmask * 1.0 # np.fft.fftshift(focmask*1.0)
172  p_wfs._submask = np.fft.fftshift(pyr_focmask).astype(np.float32)
173  p_wfs_fssize = fssize
174  wfs.d_wfs[n].set_submask(p_wfs._submask)

◆ comp_new_pyr_ampl()

def shesha.ao.wfs.comp_new_pyr_ampl ( int  nwfs,
float  ampli,
list  p_wfss,
conf.Param_tel  p_tel,
int   npts_force = None 
)

Set the pyramid modulation amplitude.

:parameters:

nwfs (int): WFS index

ampli (float) : new amplitude in units of lambda/D

p_wfss (list of Param_wfs) : list of wfs parameters

p_tel (Param_tel) : Telescope parameters

Definition at line 60 of file wfs.py.

60  p_tel : (Param_tel) : Telescope parameters
61  """
62 
63  pwfs = p_wfss[nwfs]
64  nFace = pwfs.nPupils
65 
66  if npts_force is None:
67  if ampli == 0.:
68  pyr_npts = 1
69  elif ampli < 2.:
70  pyr_npts = int(np.ceil(int(2 * 2 * np.pi) / nFace) * nFace)
71  else:
72  pyr_npts = int(np.ceil(int(ampli * 2 * np.pi) / nFace) * nFace)
73  else:
74  pyr_npts = npts_force
75 
76  pixsize = pwfs._qpixsize * CONST.ARCSEC2RAD
77  scale_fact = 2 * np.pi / pwfs._Nfft * (
78  pwfs.Lambda * 1e-6 / p_tel.diam) / pixsize * ampli
79  cx = scale_fact * \
80  np.sin((np.arange(pyr_npts, dtype=np.float32)) * 2. * np.pi / pyr_npts)
81  cy = scale_fact * \
82  np.cos((np.arange(pyr_npts, dtype=np.float32)) * 2. * np.pi / pyr_npts)
83 
84  scale = pwfs.Lambda * 1e-6 / p_tel.diam * ampli * 180. / np.pi * 3600.
85 
86  return cx, cy, scale, pyr_npts
87 
88 

◆ noise_cov()

def shesha.ao.wfs.noise_cov ( int  nw,
conf.Param_wfs  p_wfs,
conf.Param_atmos  p_atmos,
conf.Param_tel  p_tel 
)

Compute the diagonal of the noise covariance matrix for a SH WFS (arcsec^2) Photon (pi^2/2)*(1/Nphotons)*(d/r0)^2 / (2*pi*d/lambda)^2 Electronic (pi^2/3)*(wfs.noise^2/N^2photons)*wfs.npix^2*(wfs.npix*wfs.pixsize*d/lambda)^2 / (2*pi*d/lambda)^2.

:parameters:

nw wfs number

p_wfs (Param_wfs) : wfs settings

p_atmos (Param_atmos) : atmos settings

p_tel (Param_tel) : telescope settings

:return:

cov (np.ndarray(ndim=1,dtype=np.float64)) : noise covariance diagonal

Definition at line 107 of file wfs.py.

107  cov : (np.ndarray(ndim=1,dtype=np.float64)) : noise covariance diagonal
108  """
109  cov = np.zeros(2 * p_wfs._nvalid)
110  if (p_wfs.noise >= 0):
111  ind = np.where(p_wfs._isvalid.T)
112  flux = p_wfs._fluxPerSub[ind[1], ind[0]]
113  Nph = flux * p_wfs._nphotons
114 
115  r0 = (p_wfs.Lambda / 0.5)**(6.0 / 5.0) * p_atmos.r0
116 
117  sig = (np.pi ** 2 / 2) * (1 / Nph) * \
118  (1. / r0) ** 2 # Photon noise in m^-2
119  # Noise variance in rad^2
120  sig /= (2 * np.pi / (p_wfs.Lambda * 1e-6))**2
121  sig *= CONST.RAD2ARCSEC**2
122 
123  Ns = p_wfs.npix # Number of pixel
124  Nd = (p_wfs.Lambda * 1e-6) * CONST.RAD2ARCSEC / p_wfs.pixsize
125  sigphi = (np.pi ** 2 / 3.0) * (1 / Nph ** 2) * (p_wfs.noise) ** 2 * \
126  Ns ** 2 * (Ns / Nd) ** 2 # Phase variance in m^-2
127  # Noise variance in rad^2
128  sigsh = sigphi / (2 * np.pi / (p_wfs.Lambda * 1e-6))**2
129  sigsh *= CONST.RAD2ARCSEC**2 # Electronic noise variance in arcsec^2
130 
131  cov[:len(sig)] = sig + sigsh
132  cov[len(sig):] = sig + sigsh
133 
134  return cov
135 
136