42 """ Atmosphere handler for compass simulation
45 is_enable : (bool) : Flag to enable/disable atmophere
47 _atmos : (sutraWrap.Atmos) : Sutra atmos instance
49 _context : (carmaContext) : CarmaContext instance
51 _config : (config module) : Parameters configuration structure module
54 """ Initialize an AtmosCompass component for atmosphere related supervision
57 context : (carmaContext) : CarmaContext instance
59 config : (config module) : Parameters configuration structure module
64 print(
"->atmosphere init")
67 p_targets=self.
_config_config.p_targets)
71 """ Set or unset whether atmos is enabled when running loop
74 enable : (bool) : True to enable, False to disable
78 def set_r0(self, r0 : float, *, reset_seed : int=-1) ->
None:
79 """ Change the current r0 for all layers
82 r0 : (float) : r0 @ 0.5 µm
85 reset_seed : (int): if -1 (default), keep same seed and same screen
86 if 0 random seed is applied and refresh screens
87 if (value) set the given seed and refresh screens
92 ilayer = np.random.randint(1e4)
95 for k
in range(self.
_atmos_atmos.nscreens):
96 self.
_atmos_atmos.set_seed(k, self.
_config_config.p_atmos.seeds[ilayer])
97 self.
_atmos_atmos.refresh_screen(k)
101 def set_wind(self, screen_index : int, *, windspeed : float =
None, winddir : float =
None) ->
None:
102 """ Set new wind information for the given screen
105 screen_index : (int) : Atmos screen to change
108 windspeed : (float) [m/s] : new wind speed of the screen. If None, the wind speed is unchanged
110 winddir : (float) [deg]: new wind direction of the screen. If None, the wind direction is unchanged
112 if windspeed
is not None:
113 self.
_config_config.p_atmos.windspeed[screen_index] = windspeed
114 if winddir
is not None:
115 self.
_config_config.p_atmos.winddir[screen_index] = winddir
117 lin_delta = self.
_config_config.p_geom.pupdiam / self.
_config_config.p_tel.diam * self.
_config_config.p_atmos.windspeed[screen_index] * \
118 np.cos(CONST.DEG2RAD * self.
_config_config.p_geom.zenithangle) * self.
_config_config.p_loop.ittime
119 oldx = self.
_config_config.p_atmos._deltax[screen_index]
120 oldy = self.
_config_config.p_atmos._deltay[screen_index]
121 self.
_config_config.p_atmos._deltax[screen_index] = lin_delta * np.sin(CONST.DEG2RAD * self.
_config_config.p_atmos.winddir[screen_index] + np.pi)
122 self.
_config_config.p_atmos._deltay[screen_index] = lin_delta * np.cos(CONST.DEG2RAD * self.
_config_config.p_atmos.winddir[screen_index] + np.pi)
123 self.
_atmos_atmos.d_screens[screen_index].set_deltax(self.
_config_config.p_atmos._deltax[screen_index])
124 self.
_atmos_atmos.d_screens[screen_index].set_deltay(self.
_config_config.p_atmos._deltay[screen_index])
125 if(oldx * self.
_config_config.p_atmos._deltax[screen_index] < 0):
126 stencilx = np.array(self.
_atmos_atmos.d_screens[screen_index].d_istencilx)
127 n = self.
_config_config.p_atmos.dim_screens[screen_index]
128 stencilx = (n * n - 1) - stencilx
129 self.
_atmos_atmos.d_screens[screen_index].set_istencilx(stencilx)
130 if(oldy * self.
_config_config.p_atmos._deltay[screen_index] < 0):
131 stencily = np.array(self.
_atmos_atmos.d_screens[screen_index].d_istencily)
132 n = self.
_config_config.p_atmos.dim_screens[screen_index]
133 stencily = (n * n - 1) - stencily
134 self.
_atmos_atmos.d_screens[screen_index].set_istencily(stencily)
137 """ Reset the turbulence layers to their original state
140 for k
in range(self.
_atmos_atmos.nscreens):
141 self.
_atmos_atmos.set_seed(k, self.
_config_config.p_atmos.seeds[ilayer])
142 self.
_atmos_atmos.refresh_screen(k)
146 """ Return the selected atmos screen
149 indx : (int) : Index of the turbulent layer to return
152 layer : (np.ndarray) : turbulent layer phase screen
154 return np.array(self.
_atmos_atmos.d_screens[indx].d_screen)
157 """ Move the turbulent layers according to wind speed and direction for a single iteration
Atmosphere handler for compass simulation.
None reset_turbu(self)
Reset the turbulence layers to their original state.
None move_atmos(self)
Move the turbulent layers according to wind speed and direction for a single iteration.
def __init__(self, context, config)
None set_r0(self, float r0, *int reset_seed=-1)
Change the current r0 for all layers.
None enable_atmos(self, bool enable)
Set or unset whether atmos is enabled when running loop.
None set_wind(self, int screen_index, *float windspeed=None, float winddir=None)
Set new wind information for the given screen.
np.ndarray get_atmos_layer(self, int indx)
Return the selected atmos screen.
is_enable
(bool) : Flag to enable/disable atmophere
Numerical constants for shesha and config enumerations for safe-typing.
Initialization of a Atmos object.