32#include "../../mxError.hpp"
33#include "../../math/constants.hpp"
34#include "../../math/func/jinc.hpp"
58std::string compName(
int cc );
60int compNum(
const std::string &name );
82template <
typename realT>
97 const char *m_id =
"von Karman";
174 template <
class psdParamsT>
188 template <
class psdParamsT>
206 template <
typename iosT>
224template <
typename realT>
229template <
typename realT>
240template <
typename realT>
246template <
typename realT>
252template <
typename realT>
258template <
typename realT>
264template <
typename realT>
267 return m_scintillation;
270template <
typename realT>
273 m_scintillation = sc;
276template <
typename realT>
282template <
typename realT>
285 if( cc != PSDComponent::phase && cc != PSDComponent::amplitude && cc != PSDComponent::dispPhase &&
286 cc != PSDComponent::dispAmplitude )
296template <
typename realT>
302template <
typename realT>
308template <
typename realT>
309template <
class psdParamsT>
319 if( par.L_0( layer_i ) > 0 )
321 k02 = ( 1 ) / ( par.L_0( layer_i ) * par.L_0( layer_i ) );
326 if( k02 == 0 && k == 0 )
331 realT Ppiston, Ptiptilt;
333 if( ( m_subPiston || m_subTipTilt ) )
360 return ( par.beta( layer_i ) * pow( k * k + k02, -1 * par.alpha( layer_i ) / 2 ) + par.beta_0( layer_i ) ) *
361 ( 1.0 - Ppiston - Ptiptilt ) * sec_zeta;
364template <
typename realT>
365template <
class psdParamsT>
375 realT psd = operator()( par, layer_i, k, secZeta );
377 if( par.nonKolmogorov() ==
false )
379 psd *= pow( par.lam_0() / lambda, 2 );
385 if( m_scintillation )
387 if( m_component == PSDComponent::phase )
389 psd *= ( par.X( k, lambda, secZeta ) );
391 else if( m_component == PSDComponent::amplitude )
393 psd *= ( par.Y( k, lambda, secZeta ) );
395 else if( m_component == PSDComponent::dispPhase )
397 psd *= ( par.X_Z( k, lambda, lambda_wfs, secZeta ) );
399 else if( m_component == PSDComponent::dispAmplitude )
401 mxError(
"vonKarmanSpectrum::operator()",
MXE_NOTIMPL,
"Dispersive-aniso amplitude not implemented" );
428template <
typename realT>
429template <
typename iosT>
432 ios <<
"# PSD Parameters:" <<
'\n';
433 ios <<
"# ID = " << m_id <<
'\n';
434 ios <<
"# D = " << m_D <<
'\n';
435 ios <<
"# subPiston = " << std::boolalpha << m_subPiston <<
'\n';
436 ios <<
"# subTipTilt = " << std::boolalpha << m_subTipTilt <<
'\n';
437 ios <<
"# Scintillation = " << std::boolalpha << m_scintillation <<
'\n';
438 ios <<
"# Component = " << PSDComponent::compName( m_component ) <<
'\n';
442template <
typename realT>
445 using namespace mx::app;
455 "Aperture diameter. Used for piston and tip/tilt subtraction." );
456 config.
add(
"psd.subPiston",
"",
"psd.subPiston", argType::Required,
"psd",
"subPiston",
false,
"real",
"" );
457 config.
add(
"psd.subTipTilt",
"",
"psd.subTipTilt", argType::Required,
"psd",
"subTipTilt",
false,
"real",
"" );
459 "psd.scintillation",
"",
"psd.scintillation", argType::Required,
"psd",
"scintillation",
false,
"real",
"" );
460 config.
add(
"psd.component",
"",
"psd.component", argType::Required,
"psd",
"component",
false,
"real",
"" );
463template <
typename realT>
468 config( m_D,
"psd.D" );
469 config( m_subPiston,
"psd.subPiston" );
470 config( m_subTipTilt,
"psd.subTipTilt" );
471 config( m_scintillation,
"psd.scintillation" );
473 std::string cn = PSDComponent::compName( m_component );
474 config( cn,
"psd.component" );
475 component( PSDComponent::compNum( cn ) );
Provides a class to specify atmosphere parameters.
Calculate and provide constants related to adaptive optics.
@ dispAmplitude
The amplitude component of dispersive anisoplanatism.
@ dispPhase
The phase component of dispersive anisoplanatism.
@ amplitude
The amplitude.
#define mxError(esrc, ecode, expl)
This reports an mxlib specific error.
T2 jincN(const T1 &v, const T2 &x)
The JincN function.
T jinc(const T &x)
The Jinc function.
constexpr floatT six_fifths()
Return 6/5 in the specified precision.
#define MXE_INVALIDARG
An argument was invalid.
#define MXE_PARAMNOTSET
A parameter was not set.
#define MXE_NOTIMPL
A component or technique is not implemented.
Manage calculations using the von Karman spatial power spectrum.
bool subTipTilt()
Get the value of m_subTipTilt.
realT D()
Get the value of the diameter m_D.
realT operator()(psdParamsT &par, size_t layer_i, realT k, realT sec_zeta)
Get the value of the PSD at spatial frequency k and a zenith distance.
iosT & dumpPSD(iosT &ios)
Get the fitting error for an actuator spacing d.
void setupConfig(app::appConfigurator &config)
Setup the configurator to configure this class.
bool subPiston()
Get the value of m_subPiston.
realT m_D
Diameter used for piston and tip/tilt subtraction, in m. Default is 1 m.
vonKarmanSpectrum()
Default Constructor.
bool scintillation()
Get the value of m_scintillation.
void loadConfig(app::appConfigurator &config)
Load the configuration of this class from a configurator.
int component()
Get the value of m_component.
bool m_subTipTilt
flag controlling whether tip and tilt are subtracted from the PSD. Default is false.
bool m_scintillation
flag controlling whether or not scintillation is included
bool m_subPiston
flag controlling whether piston is subtracted from the PSD. Default is true.
Class to manage a set of configurable values, and read their values from config/ini files and the com...
void add(const configTarget &tgt)
Add a configTarget.