Skip to content

Atmosphere

The Atmosphere class represents a multi-layer atmosphere with Von Kármán statistics.

Each layer is defined with altitude, wind speed/direction, and Cn2 contribution. Layers can be updated, saved to disk, and used to compute the OPD (Optical Path Difference) for various line-of-sight sources.

Attributes: r0 (float): Fried parameter at 500 nm. L0 (float): Outer scale of turbulence. windSpeed (List[float]): Wind speeds per layer. windDirection (List[float]): Wind directions per layer. altitude (List[float]): Altitudes of each layer. fractionalR0 (List[float]): Relative contribution of each layer to turbulence.

queue_listerner instance-attribute

queue_listerner = setup_logging()

logger instance-attribute

logger = getLogger()

external_logger_flag instance-attribute

external_logger_flag = False

hasNotBeenInitialized instance-attribute

hasNotBeenInitialized = True

r0 instance-attribute

r0 = r0

fractionalR0 instance-attribute

fractionalR0 = fractionalR0

L0 instance-attribute

L0 = L0

altitude instance-attribute

altitude = altitude

nLayer instance-attribute

nLayer = len(fractionalR0)

windSpeed instance-attribute

windSpeed = windSpeed

windDirection instance-attribute

windDirection = windDirection

zenith instance-attribute

zenith = zenith * (pi / 180)

tag instance-attribute

tag = 'atmosphere'

wavelength instance-attribute

wavelength = 500 * 1e-09

resolution instance-attribute

resolution = resolution

D instance-attribute

D = D

samplingTime instance-attribute

samplingTime = samplingTime

fov instance-attribute

fov = fov

fov_rad instance-attribute

fov_rad = fov_rad

__init__

__init__(
    r0: float,
    L0: float,
    windSpeed: list,
    fractionalR0: list,
    windDirection: list,
    altitude: list,
    telescope,
    zenith: float = 0.0,
    logger=None,
)

Initialize an Atmosphere object representing layered atmospheric turbulence.

Parameters:

Name Type Description Default
r0 float

Fried parameter at 500 nm [m] and pointing to zenith.

required
L0 float

Outer scale of turbulence [m].

required
windSpeed list of float

Wind speed for each layer [m/s].

required
fractionalR0 list of float

Cn2 profile; fractional contribution to turbulence per layer.

required
windDirection list of float

Wind direction for each layer [degrees].

required
altitude list of float

Altitude of each layer [m].

required
telescope Telescope object

Telescope class instantiation to take certain parameters required for the atmosphere.

required
zenith float, optional, by default 0.0

Zenith angle [degrees] of the telescope during the simulation, to automatically convert the r0 given to the specific conditions.

0.0
logger Logger

Logger instance for this object, by default None.

None

initializeAtmosphere

initializeAtmosphere(randomState=None)

Initialize the atmosphere layers using the telescope linked at construction time.

Parameters:

Name Type Description Default
randomState int or None

Seed for reproducible random number generation, by default None.

None

Returns:

Type Description
bool

True if initialization succeeded, False otherwise.

buildLayer

buildLayer(i_layer, seed=None)

Build and initialize a single atmospheric layer.

Parameters:

Name Type Description Default
i_layer int

Index of the layer to build.

required
seed int

Seed for the random number generator.

None

Returns:

Type Description
LayerClass

The initialized atmospheric layer.

save

save(filename)

Save the state of the atmosphere to a H5 file.

Parameters:

Name Type Description Default
filename str

Path and base filename (with extension) to save the H5.

required

Returns:

Type Description
bool

True if saved successfully, False otherwise.

load

load(filename)

Load an atmosphere configuration from a H5 file.

Parameters:

Name Type Description Default
filename str

Path and base filename (with extension) of the H5 file to load.

required

Returns:

Type Description
bool

True if loaded successfully, False otherwise.

update

update()

Update all atmospheric layers based on wind and time step.

Returns:

Type Description
bool

True if update was successful.

updateLayer

updateLayer(updatedLayer)

Update a single atmospheric layer, shifting the phase screen. ^ +Vy (adds row --> + to the bottom, - to the top) | | |----> +Vx (adds col --> + to the left, - to the right)

Parameters:

Name Type Description Default
updatedLayer LayerClass

The layer to update.

required

Returns:

Type Description
LayerClass

The updated layer.

getOPD

getOPD(src)

Compute the Optical Path Difference (OPD) for a given source.

Parameters:

Name Type Description Default
src Source or ExtendedSource

The light source for which to compute the OPD.

required

Returns:

Type Description
ndarray

OPD values in meters (or list of OPDs if multiple sources).

get_pupil_footprint

get_pupil_footprint(src)

Determine the pupil footprint and discretization offset for a source.

Parameters:

Name Type Description Default
src Source

Light source object.

required

Returns:

Type Description
Tuple[list, list]

A tuple of two lists: pupil footprint per layer and center offset.

project_phase

project_phase(src, pupil_footprint, extra_s)

Project atmospheric phase through layers for a given source.

Parameters:

Name Type Description Default
src Source

Light source object.

required
pupil_footprint list of np.ndarray

Pupil masks per layer.

required
extra_s list

Offset due to discretization for each layer.

required

Returns:

Type Description
list

List of phase screens per layer.

get_phase_layered

get_phase_layered(src, layer, pupil_footprint, extra_s)

Compute phase at a given atmospheric layer for a specific source.

Parameters:

Name Type Description Default
src Source

Light source.

required
layer LayerClass

Atmospheric layer.

required
pupil_footprint ndarray

Pupil mask for the layer.

required
extra_s list

Offset due to discretization.

required

Returns:

Type Description
ndarray

Phase screen for the layer.

get_opd_per_src

get_opd_per_src(src, phase)

Sum up the phases from all layers to compute the OPD for a source.

Parameters:

Name Type Description Default
src Source

Light source.

required
phase list of np.ndarray

Phase per layer for the source.

required

Returns:

Type Description
ndarray

Optical Path Difference (OPD) in meters.

setup_logging

setup_logging(logging_level=logging.WARNING)

__del__

__del__()