32 #include "../../mxError.hpp"
33 #include "../../math/constants.hpp"
34 #include "../../math/func/jinc.hpp"
47 namespace PSDComponent
56 std::string compName(
int cc );
58 int compNum(
const std::string & name);
79 template<
typename realT>
92 const char * m_id =
"von Karman";
170 template<
class psdParamsT >
183 template<
class psdParamsT >
201 template<
typename iosT>
218 template<
typename realT>
223 template<
typename realT>
234 template<
typename realT>
241 template<
typename realT>
247 template<
typename realT>
253 template<
typename realT>
259 template<
typename realT>
262 return m_scintillation;
265 template<
typename realT>
268 m_scintillation = sc;
271 template<
typename realT>
277 template<
typename realT>
280 if( cc != PSDComponent::phase && cc != PSDComponent::amplitude && cc != PSDComponent::dispPhase && cc != PSDComponent::dispAmplitude )
282 mxError(
"vonKarmanSpectrum::component", MXE_INVALIDARG,
"Unknown component");
290 template<
typename realT>
296 template<
typename realT>
302 template<
typename realT>
303 template<
class psdParamsT >
313 if(par.L_0(layer_i) > 0)
315 k02 = (1)/(par.L_0(layer_i)*par.L_0(layer_i));
319 if(k02 == 0 &&
k == 0)
324 realT Ppiston, Ptiptilt;
326 if( (m_subPiston || m_subTipTilt) )
330 mxError(
"aoAtmosphere", MXE_PARAMNOTSET,
"Diameter D not set for Piston and/or TT subtraction.");
351 return (par.beta(layer_i)*pow(
k*
k+k02, -1*par.alpha(layer_i)/2) + par.beta_0(layer_i) ) * (1.0-Ppiston - Ptiptilt)*sec_zeta;
354 template<
typename realT>
355 template<
class psdParamsT >
364 realT psd = operator()(par, layer_i,
k, secZeta);
366 if( par.nonKolmogorov() ==
false ) psd *= pow( par.lam_0()/lambda, 2);
368 if(psd < 0)
return -1;
372 if(m_component == PSDComponent::phase)
374 psd *= (par.X(
k, lambda, secZeta));
376 else if (m_component == PSDComponent::amplitude)
378 psd *= (par.Y(
k, lambda, secZeta));
380 else if (m_component == PSDComponent::dispPhase)
382 psd *= (par.X_Z(
k, lambda, lambda_wfs, secZeta));
384 else if (m_component == PSDComponent::dispAmplitude)
386 mxError(
"vonKarmanSpectrum::operator()", MXE_NOTIMPL,
"Dispersive-aniso amplitude not implemented");
391 mxError(
"vonKarmanSpectrum::operator()", MXE_INVALIDARG,
"Invalid component specified");
413 template<
typename realT>
414 template<
typename iosT>
417 ios <<
"# PSD Parameters:" <<
'\n';
418 ios <<
"# ID = " << m_id <<
'\n';
419 ios <<
"# D = " << m_D <<
'\n';
420 ios <<
"# subPiston = " << std::boolalpha << m_subPiston <<
'\n';
421 ios <<
"# subTipTilt = " << std::boolalpha << m_subTipTilt <<
'\n';
422 ios <<
"# Scintillation = " << std::boolalpha << m_scintillation <<
'\n';
423 ios <<
"# Component = " << PSDComponent::compName(m_component) <<
'\n';
427 template<
typename realT>
430 using namespace mx::app;
432 config.
add(
"psd.D" ,
"",
"psd.D" , argType::Required,
"psd",
"D",
false,
"real" ,
"Aperture diameter. Used for piston and tip/tilt subtraction.");
433 config.
add(
"psd.subPiston" ,
"",
"psd.subPiston" , argType::Required,
"psd",
"subPiston",
false,
"real" ,
"");
434 config.
add(
"psd.subTipTilt" ,
"",
"psd.subTipTilt" , argType::Required,
"psd",
"subTipTilt",
false,
"real" ,
"");
435 config.
add(
"psd.scintillation",
"",
"psd.scintillation", argType::Required,
"psd",
"scintillation",
false,
"real" ,
"");
436 config.
add(
"psd.component" ,
"",
"psd.component" , argType::Required,
"psd",
"component",
false,
"real" ,
"");
439 template<
typename realT>
444 config(m_D,
"psd.D");
445 config(m_subPiston,
"psd.subPiston");
446 config(m_subTipTilt,
"psd.subTipTilt");
447 config(m_scintillation,
"psd.scintillation");
449 std::string cn = PSDComponent::compName(m_component);
450 config(cn,
"psd.component");
451 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.
constexpr units::realT k()
Boltzmann Constant.
T2 jincN(const T1 &v, const T2 &x)
The JincN function.
T jinc(const T &x)
The Jinc function.
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.
int m_component
If m_scintillation is true, this controls whether phase (0), amplitude (1), or dispersive contrast (2...
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.