|
mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
A turbulent atmosphere simulator.
Generate multi-layer phase screens using PSD filtering with the FFT. Manages the shifting and combination of the phase screens (without propagation).
The turbSubHarmonic class provides low-frequency sub-harmonics if desired
The turbLayer class manages the actual interpolation.
add facility for switching interpolators
need to include wrap detection when using subharmonics (e.g. frames needs to be right)
Definition at line 81 of file turbAtmosphere.hpp.
#include <ao/sim/turbAtmosphere.hpp>
Public Member Functions | |
| int | wfPS (realT ps) |
| dummy function for simulatedAOSystem. Does nothing. | |
Construction and Configuration | |
| turbAtmosphere () | |
| Default c'tor. | |
| void | setup (uint32_t wfSz, uint32_t buffSz, aoSystemT *aosys, uint32_t shLevel) |
| Setup the overall atmosphere. | |
| void | wfSz (uint32_t ws) |
| Set the wavefront size. | |
| uint32_t | wfSz () |
| Get the wavefront size. | |
| void | buffSz (uint32_t bs) |
| Set the interpolation buffer size. | |
| uint32_t | buffSz () |
| Get the interpolation buffer size. | |
| void | aosys (aoSystemT *aos) |
| Set the pointer to an AO system object. | |
| aoSystemT * | aosys () |
| Get the pointer to an AO system object. | |
| void | shLevel (uint32_t shl) |
| Set the subharmonic level. | |
| uint32_t | shLevel () |
| Get the subharmonic level. | |
| void | outerSubHarmonics (bool osh) |
| Set whether outer subharmonics are included. | |
| bool | outerSubHarmonics () |
| Get whether outer subharmonics are included. | |
| void | shPreCalc (bool shp) |
| Set whether subharmonic modes are pre-calculated. | |
| bool | shPreCalc () |
| Get whether subharmonic modes are pre-calculated. | |
| void | retain (bool rtn) |
| Set whether memory for screen generation is retained. | |
| bool | retain () |
| Get whether memory for screen generation is retained. | |
| void | forceGen (bool fg) |
| Set whether new screen generation is forced. | |
| bool | forceGen () |
| Get whether new screen generation is forced. | |
| void | dataDir (const std::string &dd) |
| Set the data directory for saving phase screens. | |
| std::string | dataDir () |
| Get the data directory for saving phase screens. | |
| void | setLayers (const std::vector< size_t > &scrnSz) |
| Setup the layers and prepare them for phase screen generation. | |
| void | setLayers (const size_t scrnSz) |
| Setup the layers and prepare them for phase screen generation. | |
| uint32_t | nLayers () |
| Get the number of layers. | |
| turbLayer< aoSystemT > & | layer (uint32_t n) |
| Get a layer. | |
| math::normDistT< realT > & | normVar () |
| Get the random number generator. | |
Screen Generation | |
| void | genLayers () |
| Generate all phase screens. | |
| Public Member Functions inherited from mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > > | |
| void | changed () |
| Increment the counter. | |
| changeT | change () |
| Get the value of the counter. | |
Protected Attributes | |
Configuration Data | |
| uint32_t | m_wfSz { 0 } |
| Size of the wavefront in pixels. | |
| uint32_t | m_buffSz { 0 } |
| Buffer to apply around wavefront for interpolation. | |
| aoSystemT * | m_aosys { nullptr } |
| The AO system object containing all system parameters. | |
| uint32_t | m_shLevel { 0 } |
| bool | m_outerSubHarmonics { true } |
| bool | m_shPreCalc { true } |
| bool | m_retain { false } |
| bool | m_forceGen { true } |
| std::string | m_dataDir |
| imageT * | m_pupil { 0 } |
| A pointer to the pupil mask. | |
| realT | m_timeStep { 0 } |
| Length of each iteration, in seconds. | |
Internal State | |
| std::vector< turbLayer< aoSystemT > > | m_layers |
| Vector of turbulent layers. | |
| std::vector< turbSubHarmonic< turbAtmosphere > > | m_subHarms |
| Sub-harmonic layers. | |
| size_t | m_frames { 0 } |
| Length of the turbulence sequence. | |
| int | m_nWf { 0 } |
| Number of iterations which have occurred. | |
| math::normDistT< realT > | m_normVar |
| Normal random deviate generator. This seeded in the constructor. | |
Additional Inherited Members | |
| Public Types inherited from mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > > | |
| typedef uint64_t | changeT |
| The integer type of the counter. | |
| mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::turbAtmosphere | ( | ) |
| aoSystemT * mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::aosys | ( | ) |
Get the pointer to an AO system object.
Definition at line 402 of file turbAtmosphere.hpp.
References m_aosys.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::aosys | ( | aoSystemT * | aos | ) |
Set the pointer to an AO system object.
see m_aosys
| [in] | aos | the new pointer to an AO system object |
Definition at line 392 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), and m_aosys.
Referenced by setup().
| uint32_t mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::buffSz | ( | ) |
Get the interpolation buffer size.
Definition at line 386 of file turbAtmosphere.hpp.
References m_buffSz.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::buffSz | ( | uint32_t | bs | ) |
Set the interpolation buffer size.
see m_buffSz
| [in] | bs | the new buffer size |
Definition at line 376 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), and m_buffSz.
Referenced by setup().
| std::string mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::dataDir | ( | ) |
Get the data directory for saving phase screens.
Definition at line 500 of file turbAtmosphere.hpp.
References m_dataDir.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::dataDir | ( | const std::string & | dd | ) |
Set the data directory for saving phase screens.
see m_dataDir
| [in] | dd | the new data directory for phase screen saving |
Definition at line 489 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), and m_dataDir.
| bool mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::forceGen | ( | ) |
Get whether new screen generation is forced.
Definition at line 483 of file turbAtmosphere.hpp.
References m_forceGen.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::forceGen | ( | bool | fg | ) |
Set whether new screen generation is forced.
see m_forceGen
| [in] | fg | the new value of the flag controlling whether screen generation is forced |
Definition at line 472 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), and m_forceGen.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::genLayers | ( | ) |
Generate all phase screens.
Loads them from disk if possible and m_forceGen == false.
Deallocates working memory when done, unless m_retain == true.
Definition at line 634 of file turbAtmosphere.hpp.
References mx::ioutils::convertToString(), mx::exception, m_dataDir, m_forceGen, m_layers, m_normVar, m_retain, m_shLevel, m_subHarms, mx::fits::fitsFile< dataT, verboseT >::read(), mx::sizeerr, and mx::fits::fitsFile< dataT, verboseT >::write().
| turbLayer< aoSystemT > & mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::layer | ( | uint32_t | n | ) |
Get a layer.
Definition at line 576 of file turbAtmosphere.hpp.
References mx::exception, mx::invalidarg, and m_layers.
| uint32_t mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::nLayers | ( | ) |
Get the number of layers.
Definition at line 570 of file turbAtmosphere.hpp.
References m_layers.
Referenced by setLayers().
| math::normDistT< typename aoSystemT::realT > & mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::normVar | ( | ) |
Get the random number generator.
Definition at line 587 of file turbAtmosphere.hpp.
References m_normVar.
| bool mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::outerSubHarmonics | ( | ) |
Get whether outer subharmonics are included.
Definition at line 434 of file turbAtmosphere.hpp.
References m_outerSubHarmonics.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::outerSubHarmonics | ( | bool | osh | ) |
Set whether outer subharmonics are included.
| [in] | osh | the new value of flag controlling outer subharmonics |
Definition at line 424 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), and m_outerSubHarmonics.
| bool mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::retain | ( | ) |
Get whether memory for screen generation is retained.
Definition at line 466 of file turbAtmosphere.hpp.
References m_retain.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::retain | ( | bool | rtn | ) |
Set whether memory for screen generation is retained.
see m_retain
| [in] | rtn | the new value of the flag controlling whether memory is retained |
Definition at line 456 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), and m_retain.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::setLayers | ( | const size_t | scrnSz | ) |
Setup the layers and prepare them for phase screen generation.
This sets all layer phase screens to be the same size.
| [in] | scrnSz | the screen sizes for all layers. |
Definition at line 555 of file turbAtmosphere.hpp.
References mx::exception, m_aosys, mx::paramnotset, and setLayers().
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::setLayers | ( | const std::vector< size_t > & | scrnSz | ) |
Setup the layers and prepare them for phase screen generation.
The number of entries in scrnSz must mach the number of layers in the atmosphere of m_aosys.
| [in] | scrnSz | the screen sizes for each layer. |
Definition at line 506 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), mx::exception, mx::invalidarg, m_aosys, m_layers, m_outerSubHarmonics, m_shLevel, m_shPreCalc, m_subHarms, nLayers(), and mx::paramnotset.
Referenced by setLayers().
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::setup | ( | uint32_t | wfSz, |
| uint32_t | buffSz, | ||
| aoSystemT * | aosys, | ||
| uint32_t | shLevel ) |
Setup the overall atmosphere.
| [in] | wfSz | The size of the wavefront in pixels. |
| [in] | buffSz | The size of the interpolation buffer to use. |
| [in] | aosys | Pointer to an AO System. See m_aosys. |
| [in] | shLevel | number of subharmonic levels to use. 0 turns off subharmonics. See m_shLevel. |
Definition at line 351 of file turbAtmosphere.hpp.
| uint32_t mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::shLevel | ( | ) |
Get the subharmonic level.
Definition at line 418 of file turbAtmosphere.hpp.
References m_shLevel.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::shLevel | ( | uint32_t | shl | ) |
Set the subharmonic level.
see m_shLevel
| [in] | shl | the new subharmonic level |
Definition at line 408 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), and m_shLevel.
Referenced by setup().
| bool mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::shPreCalc | ( | ) |
Get whether subharmonic modes are pre-calculated.
Definition at line 450 of file turbAtmosphere.hpp.
References m_shPreCalc.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::shPreCalc | ( | bool | shp | ) |
Set whether subharmonic modes are pre-calculated.
see m_shPreCalc
| [in] | shp | the new value of flag controlling subharmonic mode precalculation |
Definition at line 440 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), and m_shPreCalc.
| int mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::wfPS | ( | realT | ps | ) |
dummy function for simulatedAOSystem. Does nothing.
Definition at line 781 of file turbAtmosphere.hpp.
| uint32_t mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::wfSz | ( | ) |
Get the wavefront size.
Definition at line 370 of file turbAtmosphere.hpp.
References m_wfSz.
| void mx::AO::sim::turbAtmosphere< aoSystemT, verboseT >::wfSz | ( | uint32_t | ws | ) |
Set the wavefront size.
see m_wfSz
| [in] | ws | the new wavefront size |
Definition at line 360 of file turbAtmosphere.hpp.
References mx::base::changeable< turbAtmosphere< _aoSystemT, mx::verbose::d > >::changed(), and m_wfSz.
Referenced by setup().
|
protected |
The AO system object containing all system parameters.
Definition at line 99 of file turbAtmosphere.hpp.
Referenced by aosys(), aosys(), setLayers(), and setLayers().
|
protected |
Buffer to apply around wavefront for interpolation.
Definition at line 97 of file turbAtmosphere.hpp.
|
protected |
Specifies a path where phase screens are stored. Leaving this unset or "" is equivalent to m_forceGen` == true`.
Definition at line 126 of file turbAtmosphere.hpp.
Referenced by dataDir(), dataDir(), and genLayers().
|
protected |
Force generation of new screens if true. Note that this class does not presently do any checks of saved screens to verify they match the current configuration. Set to true with caution.
Definition at line 119 of file turbAtmosphere.hpp.
Referenced by forceGen(), forceGen(), and genLayers().
|
protected |
Length of the turbulence sequence.
Definition at line 143 of file turbAtmosphere.hpp.
|
protected |
Vector of turbulent layers.
Definition at line 139 of file turbAtmosphere.hpp.
Referenced by genLayers(), layer(), nLayers(), and setLayers().
|
protected |
Normal random deviate generator. This seeded in the constructor.
Definition at line 147 of file turbAtmosphere.hpp.
Referenced by turbAtmosphere(), genLayers(), and normVar().
|
protected |
Number of iterations which have occurred.
Definition at line 145 of file turbAtmosphere.hpp.
|
protected |
Whether or not the outer subharmonics are included. See turbSubHarmonic.
Definition at line 105 of file turbAtmosphere.hpp.
Referenced by outerSubHarmonics(), outerSubHarmonics(), and setLayers().
|
protected |
A pointer to the pupil mask.
Definition at line 130 of file turbAtmosphere.hpp.
|
protected |
Whether or not to retain working memory after screen generation. One would set to true if many screens will be calculated in monte carlo fashion. For a standard case of one set of screens being shifted by wind velocity, this should be false to minimize memory use.
Definition at line 113 of file turbAtmosphere.hpp.
Referenced by genLayers(), retain(), and retain().
|
protected |
Number of subharmonic levels. 0 means no subharmonics. Generally only 1 level is needed to obtain good Tip/Tilt results. See turbSubHarmonic.
Definition at line 101 of file turbAtmosphere.hpp.
Referenced by genLayers(), setLayers(), shLevel(), and shLevel().
|
protected |
Whether or not to pre-calculate the subharmonic modes. This is a trade of speed vs. memory use. See turbSubHarmonic.
Definition at line 109 of file turbAtmosphere.hpp.
Referenced by setLayers(), shPreCalc(), and shPreCalc().
|
protected |
Sub-harmonic layers.
Definition at line 141 of file turbAtmosphere.hpp.
Referenced by genLayers(), and setLayers().
|
protected |
Length of each iteration, in seconds.
Definition at line 132 of file turbAtmosphere.hpp.
|
protected |
Size of the wavefront in pixels.
Definition at line 95 of file turbAtmosphere.hpp.