31#include "../../math/constants.hpp"
40#define FITTING_ERROR_NO 0
41#define FITTING_ERROR_ZERO 1
42#define FITTING_ERROR_X 2
43#define FITTING_ERROR_Y 3
62template <
typename _realT,
class _inputSpectT,
typename iosT = std::ostream>
69 typedef _inputSpectT inputSpectT;
185 void d_min(
const std::vector<realT> &nd );
233 template <
typename wfsT>
241 template<
typename wfsT>
318 void ron_wfs(
const std::vector<realT> &nron );
342 void Fbg(
const std::vector<realT> &fbg );
536 void F0( realT nF0 );
559 realT
Fg( realT mag );
876 template <
typename varFuncT>
894 template <
typename imageT,
typename CfuncT>
919 bool normStrehl =
true
926 template <
typename imageT>
947 bool normStrehl =
true
957 template <
typename imageT>
979 bool normStrehl =
true
989 template <
typename imageT>
1011 bool normStrehl =
true
1021 template <
typename imageT>
1043 bool normStrehl =
true
1053 template <
typename imageT>
1077 bool normStrehl =
true
1087 template <
typename imageT>
1109 bool normStrehl =
true
1119 template <
typename imageT>
1140 bool normStrehl =
true
1150 template <
typename imageT>
1172template <
typename realT,
class inputSpectT,
typename iosT>
1178template <
typename realT,
class inputSpectT,
typename iosT>
1187template <
typename realT,
class inputSpectT,
typename iosT>
1190 atm.loadGuyon2005();
1199 npix_wfs( std::vector<realT>( { 12868 } ) );
1200 ron_wfs( std::vector<realT>( { 0.0 } ) );
1201 Fbg( std::vector<realT>( { 0.0 } ) );
1211template <
typename realT,
class inputSpectT,
typename iosT>
1219 npix_wfs( std::vector<realT>( { 9024 } ) );
1220 ron_wfs( std::vector<realT>( { 0.57 } ) );
1221 Fbg( std::vector<realT>( { 0.22 } ) );
1223 d_min( std::vector<realT>( { 6.5 / 48.0 } ) );
1224 minTauWFS( std::vector<realT>( { 1. / 3622. } ) );
1233template <
typename realT,
class inputSpectT,
typename iosT>
1239 F0( 7.6e10 * 368.0 / ( 0.25 *
math::pi<realT>() * 6.5 * 6.5 * ( 1. - 0.29 * 0.29 ) ) );
1247template <
typename realT,
class inputSpectT,
typename iosT>
1257template <
typename realT,
class inputSpectT,
typename iosT>
1263template <
typename realT,
class inputSpectT,
typename iosT>
1266 m_d_min.assign( nd.begin(), nd.end() );
1271template <
typename realT,
class inputSpectT,
typename iosT>
1274 if(
m_d_min.size() < idx + 1 )
1285template <
typename realT,
class inputSpectT,
typename iosT>
1288 if(
m_d_min.size() < idx + 1 )
1296template <
typename realT,
class inputSpectT,
typename iosT>
1302template <
typename realT,
class inputSpectT,
typename iosT>
1310template <
typename realT,
class inputSpectT,
typename iosT>
1316template <
typename realT,
class inputSpectT,
typename iosT>
1324template <
typename realT,
class inputSpectT,
typename iosT>
1330template <
typename realT,
class inputSpectT,
typename iosT>
1331template <
typename wfsT>
1344template <
typename realT,
class inputSpectT,
typename iosT>
1345template <
typename wfsT>
1366template <
typename realT,
class inputSpectT,
typename iosT>
1372template <
typename realT,
class inputSpectT,
typename iosT>
1383template <
typename realT,
class inputSpectT,
typename iosT>
1393template <
typename realT,
class inputSpectT,
typename iosT>
1401template <
typename realT,
class inputSpectT,
typename iosT>
1407template <
typename realT,
class inputSpectT,
typename iosT>
1415template <
typename realT,
class inputSpectT,
typename iosT>
1421template <
typename realT,
class inputSpectT,
typename iosT>
1425 for(
size_t n = 0; n < npix.size(); ++n )
1434template <
typename realT,
class inputSpectT,
typename iosT>
1448template <
typename realT,
class inputSpectT,
typename iosT>
1459template <
typename realT,
class inputSpectT,
typename iosT>
1465template <
typename realT,
class inputSpectT,
typename iosT>
1469 for(
size_t n = 0; n < nron.size(); ++n )
1478template <
typename realT,
class inputSpectT,
typename iosT>
1492template <
typename realT,
class inputSpectT,
typename iosT>
1503template <
typename realT,
class inputSpectT,
typename iosT>
1509template <
typename realT,
class inputSpectT,
typename iosT>
1512 m_Fbg.resize( fbg.size() );
1513 for(
size_t n = 0; n < fbg.size(); ++n )
1522template <
typename realT,
class inputSpectT,
typename iosT>
1525 if(
m_Fbg.size() < idx + 1 )
1536template <
typename realT,
class inputSpectT,
typename iosT>
1539 if(
m_Fbg.size() < idx + 1 )
1547template <
typename realT,
class inputSpectT,
typename iosT>
1553template <
typename realT,
class inputSpectT,
typename iosT>
1557 for(
size_t n = 0; n < ntau.size(); ++n )
1566template <
typename realT,
class inputSpectT,
typename iosT>
1580template <
typename realT,
class inputSpectT,
typename iosT>
1591template <
typename realT,
class inputSpectT,
typename iosT>
1597template <
typename realT,
class inputSpectT,
typename iosT>
1608template <
typename realT,
class inputSpectT,
typename iosT>
1614template <
typename realT,
class inputSpectT,
typename iosT>
1621template <
typename realT,
class inputSpectT,
typename iosT>
1629template <
typename realT,
class inputSpectT,
typename iosT>
1635template <
typename realT,
class inputSpectT,
typename iosT>
1643template <
typename realT,
class inputSpectT,
typename iosT>
1649template <
typename realT,
class inputSpectT,
typename iosT>
1657template <
typename realT,
class inputSpectT,
typename iosT>
1663template <
typename realT,
class inputSpectT,
typename iosT>
1671template <
typename realT,
class inputSpectT,
typename iosT>
1677template <
typename realT,
class inputSpectT,
typename iosT>
1687template <
typename realT,
class inputSpectT,
typename iosT>
1693template <
typename realT,
class inputSpectT,
typename iosT>
1699template <
typename realT,
class inputSpectT,
typename iosT>
1707template <
typename realT,
class inputSpectT,
typename iosT>
1713template <
typename realT,
class inputSpectT,
typename iosT>
1721template <
typename realT,
class inputSpectT,
typename iosT>
1727template <
typename realT,
class inputSpectT,
typename iosT>
1735template <
typename realT,
class inputSpectT,
typename iosT>
1741template <
typename realT,
class inputSpectT,
typename iosT>
1749template <
typename realT,
class inputSpectT,
typename iosT>
1755template <
typename realT,
class inputSpectT,
typename iosT>
1763template <
typename realT,
class inputSpectT,
typename iosT>
1769template <
typename realT,
class inputSpectT,
typename iosT>
1777template <
typename realT,
class inputSpectT,
typename iosT>
1783template <
typename realT,
class inputSpectT,
typename iosT>
1791template <
typename realT,
class inputSpectT,
typename iosT>
1797template <
typename realT,
class inputSpectT,
typename iosT>
1805template <
typename realT,
class inputSpectT,
typename iosT>
1811template <
typename realT,
class inputSpectT,
typename iosT>
1814 return m_F0 * pow( 10.0, -0.4 * mag );
1817template <
typename realT,
class inputSpectT,
typename iosT>
1823template <
typename realT,
class inputSpectT,
typename iosT>
1832template <
typename realT,
class inputSpectT,
typename iosT>
1835 Nph =
Fg() * tau_wfs;
1837 double binfact = 1.0;
1843 binfact = 1. / pow( (realT)b + 1, 2 );
1849 return pow( Nph, 2 ) / (
m_npix_wfs[binidx] * binfact * (
m_Fbg[binidx] * tau_wfs + pow(
m_ron_wfs[binidx], 2 ) ) );
1852template <
typename realT,
class inputSpectT,
typename iosT>
1855 if( m == 0 and n == 0 )
1878template <
typename realT,
class inputSpectT,
typename iosT>
1886template <
typename realT,
class inputSpectT,
typename iosT>
1889 if( m == 0 and n == 0 )
1892 realT k = sqrt( m * m + n * n ) /
m_D;
1909template <
typename realT,
class inputSpectT,
typename iosT>
1917template <
typename realT,
class inputSpectT,
typename iosT>
1920 realT k = sqrt( m * m + n * n ) /
m_D;
1926template <
typename realT,
class inputSpectT,
typename iosT>
1934template <
typename realT,
class inputSpectT,
typename iosT>
1937 return C4var( m, n );
1940template <
typename realT,
class inputSpectT,
typename iosT>
1948template <
typename realT,
class inputSpectT,
typename iosT>
1951 return C5var( m, n );
1954 int mn_max = floor(0.5*
m_D/
d_opt());
1958 for(
int m = -mn_max; m <= mn_max; ++m)
1960 for(
int n = -mn_max; n <= mn_max; ++n)
1962 if(n == 0 && m == 0)
continue;
1972template <
typename realT,
class inputSpectT,
typename iosT>
1975 return C6var( m, n );
1978template <
typename realT,
class inputSpectT,
typename iosT>
1986template <
typename realT,
class inputSpectT,
typename iosT>
1989 return C7var( m, n );
1992template <
typename realT,
class inputSpectT,
typename iosT>
2000template <
typename realT,
class inputSpectT,
typename iosT>
2006 int mn_max = floor(0.5*
m_D/
d_opt());
2010 for(
int m = -mn_max; m <= mn_max; ++m)
2012 for(
int n = -mn_max; n <= mn_max; ++n)
2014 if(n == 0 && m == 0)
continue;
2018 if( m*m + n*n > mn_max*mn_max )
continue;
2029template <
typename realT,
class inputSpectT,
typename iosT>
2048 double binfact = 1.0;
2058 binfact = 1.0 / pow( (realT)( bbin + 1 ), 2 );
2062 realT k = sqrt( m * m + n * n ) /
m_D;
2075 realT a, b, c, d, e;
2078 realT Atmp = 2 * pow( atm.lam_0(), 2 ) * psd( atm, 0, k,
m_secZeta ) / pow(
m_D, 2 ) *
2089 std::vector<std::complex<realT>> x;
2097 for(
int i = 0; i < 4; i++ )
2099 if( real( x[i] ) > 0 && imag( x[i] ) == 0 && real( x[i] ) > tauopt )
2100 tauopt = real( x[i] );
2109template <
typename realT,
class inputSpectT,
typename iosT>
2116template <
typename realT,
class inputSpectT,
typename iosT>
2176 realT bestStrehlOverall = 0;
2181 realT s =
strehl( d, b );
2182 realT bestStrehl = s;
2185 while( d <
m_D / 2 )
2190 if( s < bestStrehl )
2201 if( bestStrehl >= bestStrehlOverall )
2203 bestStrehlOverall = bestStrehl;
2217 realT bestStrehl = s;
2219 while( d <
m_D / 2 )
2228 if( s < bestStrehl )
2249 realT bestStrehl = s;
2252 while( d <
m_D / 2 )
2257 if( s < bestStrehl )
2274template <
typename realT,
class inputSpectT,
typename iosT>
2277 if( m == 0 and n == 0 )
2280 realT k = sqrt( m * m + n * n ) /
m_D;
2283 realT kmin = 1. /
m_D;
2298template <
typename realT,
class inputSpectT,
typename iosT>
2304template <
typename realT,
class inputSpectT,
typename iosT>
2308 int mn_max = floor( 0.5 *
m_D / d );
2320 if( m * m + n * n <= mn_max * mn_max )
2325 if( abs( m ) <= mn_max && abs( n ) <= mn_max )
2339 if( wfeFitting < wfeMeasurement + wfeTimeDelay + wfeChromScintOPD + wfeChromIndex + wfeAnisoOPD )
2345 wfeVar += wfeMeasurement + wfeTimeDelay + wfeChromScintOPD + wfeChromIndex + wfeAnisoOPD;
2356 return exp( -1 *
wfeVar );
2359template <
typename realT,
class inputSpectT,
typename iosT>
2365 int mn_max = floor( 0.5 *
m_D / d );
2385 if( m == 0 && n == 0 )
2393 if( m * m + n * n <= mn_max * mn_max )
2398 if( abs( m ) <= mn_max && abs( n ) <= mn_max )
2412 if( wfeFitting < wfeMeasurement + wfeTimeDelay + wfeChromScintOPD + wfeChromIndex + wfeAnisoOPD )
2443template <
typename realT,
class inputSpectT,
typename iosT>
2452template <
typename realT,
class inputSpectT,
typename iosT>
2461template <
typename realT,
class inputSpectT,
typename iosT>
2462template <
typename varFuncT>
2465 if( m == 0 && n == 0 )
2475 if( doFittingError != FITTING_ERROR_NO )
2477 int mn_max =
m_D / ( 2. *
d_opt() );
2481 if( doFittingError == FITTING_ERROR_ZERO )
2486 realT k = sqrt( m * m + n * n ) /
m_D;
2488 if( doFittingError == FITTING_ERROR_X )
2490 else if( doFittingError == FITTING_ERROR_Y )
2494 std::cerr <<
"Unknown doFittingError\n";
2503 realT var = ( this->*varFunc )( m, n );
2508template <
typename realT,
class inputSpectT,
typename iosT>
2509template <
typename imageT,
typename CfuncT>
2512 int dim1 = im.rows();
2513 int dim2 = im.cols();
2515 int mc = 0.5 * ( dim1 - 1 );
2516 int nc = 0.5 * ( dim2 - 1 );
2518 for(
int i = 0; i < dim1; ++i )
2522 for(
int j = 0; j < dim2; ++j )
2526 im( i, j ) = ( this->*Cfunc )( m, n, normStrehl );
2531template <
typename realT,
class inputSpectT,
typename iosT>
2534 realT k = sqrt( m * m + n * n ) /
m_D;
2540template <
typename realT,
class inputSpectT,
typename iosT>
2547template <
typename realT,
class inputSpectT,
typename iosT>
2548template <
typename imageT>
2554template <
typename realT,
class inputSpectT,
typename iosT>
2557 realT k = sqrt( m * m + n * n ) /
m_D;
2564template <
typename realT,
class inputSpectT,
typename iosT>
2570template <
typename realT,
class inputSpectT,
typename iosT>
2571template <
typename imageT>
2577template <
typename realT,
class inputSpectT,
typename iosT>
2584template <
typename realT,
class inputSpectT,
typename iosT>
2590template <
typename realT,
class inputSpectT,
typename iosT>
2591template <
typename imageT>
2597template <
typename realT,
class inputSpectT,
typename iosT>
2603template <
typename realT,
class inputSpectT,
typename iosT>
2609template <
typename realT,
class inputSpectT,
typename iosT>
2610template <
typename imageT>
2616template <
typename realT,
class inputSpectT,
typename iosT>
2619 realT k = sqrt( m * m + n * n ) /
m_D;
2627template <
typename realT,
class inputSpectT,
typename iosT>
2633template <
typename realT,
class inputSpectT,
typename iosT>
2634template <
typename imageT>
2640template <
typename realT,
class inputSpectT,
typename iosT>
2643 realT k = sqrt( m * m + n * n ) /
m_D;
2651template <
typename realT,
class inputSpectT,
typename iosT>
2657template <
typename realT,
class inputSpectT,
typename iosT>
2658template <
typename imageT>
2664template <
typename realT,
class inputSpectT,
typename iosT>
2670 return C0var( m, n ) * pow( ( ni - nw ) / ( ni - 1 ), 2 );
2673template <
typename realT,
class inputSpectT,
typename iosT>
2679template <
typename realT,
class inputSpectT,
typename iosT>
2680template <
typename imageT>
2686template <
typename realT,
class inputSpectT,
typename iosT>
2689 realT k = sqrt( m * m + n * n ) /
m_D;
2696template <
typename realT,
class inputSpectT,
typename iosT>
2702template <
typename realT,
class inputSpectT,
typename iosT>
2703template <
typename imageT>
2709template <
typename realT,
class inputSpectT,
typename iosT>
2712 ios <<
"# AO Params:\n";
2713 ios <<
"# D = " <<
D() <<
'\n';
2717 ios <<
"# d_min = " <<
d_min( (
size_t)0 );
2718 for(
size_t n = 1; n <
m_d_min.size(); ++n )
2719 ios <<
',' <<
d_min( n );
2723 ios <<
"# d_min = null\n";
2725 ios <<
"# optd = " << std::boolalpha <<
m_optd <<
'\n';
2726 ios <<
"# d_opt_delta = " <<
optd_delta() <<
'\n';
2727 ios <<
"# lam_sci = " <<
lam_sci() <<
'\n';
2728 ios <<
"# F0 = " <<
F0() <<
'\n';
2729 ios <<
"# starMag = " <<
starMag() <<
'\n';
2730 ios <<
"# lam_sci = " <<
lam_sci() <<
'\n';
2731 ios <<
"# zeta = " <<
zeta() <<
'\n';
2732 ios <<
"# lam_wfs = " <<
lam_wfs() <<
'\n';
2736 ios <<
"# npix_wfs = " <<
npix_wfs( (
size_t)0 );
2737 for(
size_t n = 1; n <
npix_wfs().size(); ++n )
2742 ios <<
"# npix_wfs = null\n";
2746 ios <<
"# ron_wfs = " <<
ron_wfs( (
size_t)0 );
2747 for(
size_t n = 1; n <
ron_wfs().size(); ++n )
2752 ios <<
"# ron_wfs = null\n";
2754 if(
Fbg().size() > 0 )
2756 ios <<
"# Fbg = " <<
Fbg( (
size_t)0 );
2757 for(
size_t n = 1; n <
Fbg().size(); ++n )
2758 ios <<
',' <<
Fbg( n );
2762 ios <<
"# Fbg = null\n";
2766 ios <<
"# minTauWFS = " <<
minTauWFS( (
size_t)0 );
2767 for(
size_t n = 1; n <
minTauWFS().size(); ++n )
2772 ios <<
"# minTauWFS = null\n";
2774 ios <<
"# bin_npix = " << std::boolalpha <<
m_bin_npix <<
'\n';
2775 ios <<
"# tauWFS = " <<
tauWFS() <<
'\n';
2776 ios <<
"# optTau = " << std::boolalpha <<
m_optTau <<
'\n';
2777 ios <<
"# deltaTau = " <<
deltaTau() <<
'\n';
2781 ios <<
"# ncp_wfe = " <<
m_ncp_wfe <<
'\n';
2791 atm.dumpAtmosphere( ios );
2798template <
typename realT,
class inputSpectT,
typename iosT>
2801 using namespace mx::app;
2804 config.
add(
"aosys.wfs",
2812 "The WFS type: idealWFS, unmodPyWFS, asympModPyWFS, shwfs, calculatedWFS" );
2813 config.
add(
"aosys.wfs_beta_p",
2821 "The beta_p file path for calcualtedWFS" );
2822 config.
add(
"aosys.wfs_beta_r",
2830 "The beta_r file path for calcualtedWFS" );
2831 config.
add(
"aosys.wfs_sensitivity",
2833 "aosys.wfs_sensitivity",
2839 "Flag indicating that beta_p/beta_r are sensitivities (inverse) [default false]" );
2841 .
add(
"aosys.D",
"",
"aosys.D", argType::Required,
"aosys",
"D",
false,
"real",
"The telescope diameter [m]" );
2842 config.
add(
"aosys.d_min",
2850 "The minimum actuator spacing [m]" );
2851 config.
add(
"aosys.optd",
2859 "Whether or not the actuator spacing is optimized" );
2860 config.
add(
"aosys.optd_delta",
2868 "The fractional change from d_min used in optimization. Set to 1 (default) for integer binnings, > 1 "
2869 "for finer sampling." );
2870 config.
add(
"aosys.F0",
2878 "Zero-mag photon flux, [photons/sec]" );
2879 config.
add(
"aosys.lam_wfs",
2887 "WFS wavelength [m]" );
2888 config.
add(
"aosys.npix_wfs",
2896 "The number of pixels in the WFS" );
2897 config.
add(
"aosys.ron_wfs",
2905 "WFS readout noise [photons/read]" );
2906 config.
add(
"aosys.bin_npix",
2914 "Whether or not WFS pixels are re-binned along with actuator spacing optimization" );
2915 config.
add(
"aosys.Fbg",
2923 "Background counts, [counts/pix/sec]" );
2924 config.
add(
"aosys.tauWFS",
2932 "WFS integration time [s]" );
2933 config.
add(
"aosys.minTauWFS",
2941 "Minimum WFS integration time [s]" );
2942 config.
add(
"aosys.deltaTau",
2951 config.
add(
"aosys.optTau",
2959 "Whether or not the integration time is optimized" );
2960 config.
add(
"aosys.lam_sci",
2968 "Science wavelength [m]" );
2969 config.
add(
"aosys.zeta",
2977 "Zenith distance [rad]" );
2978 config.
add(
"aosys.fit_mn_max",
2986 "Maximum spatial frequency index to use for analysis" );
2987 config.
add(
"aosys.circularLimit",
2989 "aosys.circularLimit",
2995 " Flag to indicate that the spatial frequency limit is circular, not square." );
2996 config.
add(
"aosys.spatialFilter_ku",
2998 "aosys.spatialFilter_ku",
3004 "Spatial filter cutoff frequency in u [m^-1]" );
3005 config.
add(
"aosys.spatialFilter_kv",
3007 "aosys.spatialFilter_kv",
3013 "Spatial filter cutoff frequency in v [m^-1]" );
3014 config.
add(
"aosys.ncp_wfe",
3022 "NCP WFE between 1 lambda/D and fit_mn_max [rad^2]" );
3023 config.
add(
"aosys.ncp_alpha",
3031 "PSD index for NCP WFE" );
3032 config.
add(
"aosys.starMag",
3041 config.
add(
"aosys.starMags",
3049 "A vector of star magnitudes" );
3051 atm.setupConfig( config );
3052 psd.setupConfig( config );
3055template <
typename realT,
class inputSpectT,
typename iosT>
3059 if( config.
isSet(
"aosys.wfs" ) )
3062 config( wfsStr,
"aosys.wfs" );
3064 if( wfsStr ==
"ideal" )
3068 else if( wfsStr ==
"unmodPyWFS" )
3072 else if( wfsStr ==
"asympModPyWFS" )
3076 else if( wfsStr ==
"SHWFS" )
3080 else if( wfsStr ==
"calculatedWFS" )
3085 config( cwfs->m_beta_p_file,
"aosys.wfs_beta_p" );
3086 config( cwfs->m_beta_r_file,
"aosys.wfs_beta_r" );
3087 bool sens = cwfs->m_sensitivity;
3088 config( sens,
"aosys.wfs_sensitivity" );
3089 if( config.isSet(
"aosys.wfs_sensitivity" ) )
3091 cwfs->m_sensitivity = sens;
3105 config( nD,
"aosys.D" );
3106 if( config.
isSet(
"aosys.D" ) )
3110 std::vector<realT> nd_min =
d_min();
3111 config( nd_min,
"aosys.d_min" );
3112 if( config.
isSet(
"aosys.d_min" ) )
3115 bool noptd =
optd();
3116 config( noptd,
"aosys.optd" );
3117 if( config.
isSet(
"aosys.optd" ) )
3121 config( noptd_delta,
"aosys.optd_delta" );
3122 if( config.
isSet(
"aosys.optd_delta" ) )
3126 config( nlam_wfs,
"aosys.lam_wfs" );
3127 if( config.
isSet(
"aosys.lam_wfs" ) )
3131 std::vector<realT> nnpix_wfs =
npix_wfs();
3132 config( nnpix_wfs,
"aosys.npix_wfs" );
3133 if( config.
isSet(
"aosys.npix_wfs" ) )
3137 std::vector<realT> nron_wfs =
ron_wfs();
3138 config( nron_wfs,
"aosys.ron_wfs" );
3139 if( config.
isSet(
"aosys.ron_wfs" ) )
3143 std::vector<realT> nFbg =
Fbg();
3144 config( nFbg,
"aosys.Fbg" );
3145 if( config.
isSet(
"aosys.Fbg" ) )
3149 std::vector<realT> nminTauWFS =
minTauWFS();
3150 config( nminTauWFS,
"aosys.minTauWFS" );
3151 if( config.
isSet(
"aosys.minTauWFS" ) )
3156 config( nbin_npix,
"aosys.bin_npix" );
3157 if( config.
isSet(
"aosys.bin_npix" ) )
3161 realT ntauWFS =
tauWFS();
3162 config( ntauWFS,
"aosys.tauWFS" );
3163 if( config.
isSet(
"aosys.tauWFS" ) )
3168 config( ndeltaTau,
"aosys.deltaTau" );
3169 if( config.
isSet(
"aosys.deltaTau" ) )
3174 config( noptTau,
"aosys.optTau" );
3175 if( config.
isSet(
"aosys.optTau" ) )
3180 config( nlam_sci,
"aosys.lam_sci" );
3181 if( config.
isSet(
"aosys.lam_sci" ) )
3185 realT nzeta =
zeta();
3186 config( nzeta,
"aosys.zeta" );
3187 if( config.
isSet(
"aosys.zeta" ) )
3192 config( fmnm,
"aosys.fit_mn_max" );
3193 if( config.
isSet(
"aosys.fit_mn_max" ) )
3198 config( cl,
"aosys.circularLimit" );
3199 if( config.
isSet(
"aosys.circularLimit" ) )
3204 config( ku,
"aosys.spatialFilter_ku" );
3205 if( config.
isSet(
"aosys.spatialFilter_ku" ) )
3210 config( kv,
"aosys.spatialFilter_kv" );
3211 if( config.
isSet(
"aosys.spatialFilter_kv" ) )
3216 config( nwfe,
"aosys.ncp_wfe" );
3217 if( config.
isSet(
"aosys.ncp_wfe" ) )
3222 config( na,
"aosys.ncp_alpha" );
3223 if( config.
isSet(
"aosys.ncp_alpha" ) )
3228 config( nF0,
"aosys.F0" );
3229 if( config.
isSet(
"aosys.F0" ) )
3234 config( smag,
"aosys.starMag" );
3235 if( config.
isSet(
"aosys.starMag" ) )
3238 const error_t atmosphereStatus = atm.loadConfig( config );
3239 psd.loadConfig( config );
3241 return atmosphereStatus;
Provides a class to specify atmosphere parameters.
Calculate and provide constants related to adaptive optics.
Spatial power spectra used in adaptive optics.
Definitions of various analytic wavefront sensors.
A class to specify atmosphere parameters and perform related calculations.
Describes an analytic adaptive optics (AO) system.
bool circularLimit()
Get the value of the circularLimit flag.
void optTau(bool ot)
Set the value of m_optTau.
realT Fbg(size_t idx)
Get the value of the background flux for a given WFS mode.
void optd_delta(realT odd)
Set the fractional change in actuator spacing for optimization.
void loadMagAOX()
Load parameters corresponding to the MagAO-X system.
void starMag(realT nmag)
Set the value of the Star's magnitude.
void wfsBeta(const wfsT &w)
Set the WFS Beta pointer.
bool bin_npix()
Get the value of the pixel binngin flag.
void wfsBeta(const wfsT *w)
Set the WFS Beta pointer.
void loadGuyon2005()
Load the default parameters from Guyon, 2005 guyon_2005.
bool optd()
Get the value of m_optd.
void circularLimit(bool cl)
Set the value of the circularLimit flag.
void C1Map(imageT &map, bool normStrehl)
Calculate a 2D map of contrast C1.
realT F0()
Get the value of the 0 magnitude photon rate.
realT C5(realT m, realT n, bool normStrehl=true)
Calculate the contrast due to scintilation-amplitude chromaticity.
realT chromScintOPDErrorTotal()
Calculate the wavefront error due to scintillation chromaticity in the OPD over all spatial frequenci...
void C5Map(imageT &map, bool normStrehl)
Calculate a 2D map of contrast C5.
error_t loadConfig(app::appConfigurator &config)
Load the configuration of this class from a configurator.
realT C1(realT m, realT n, bool normStrehl=true)
Calculate the contrast due to uncorrected amplitude, C1.
realT C0var(realT m, realT n)
Calculate the residual variance due to uncorrected phase at a spatial frequency.
realT C_(int m, int n, bool normStrehl, varFuncT varFunc, int doFittingError)
Worker function for raw contrast fuctions.
void ncp_alpha(realT alpha)
Set the value of the non-common path WFE PSD index.
realT d_opt()
Calculate the optimum actuator spacing.
std::vector< realT > d_min()
Get the minimum subaperture sampling for all WFS modes.
realT ncpError()
Calculate the total NCP variance in rad^2.
realT spatialFilter_kv()
Get the value of spatialFilter_kv.
realT zeta()
Get the zenith angle.
void tauWFS(realT ntau)
Set the value of the WFS exposure time.
realT Fg()
Get the photon rate at the current Star magnitude.
void deltaTau(realT ndel)
Set the value of m_deltaTau.
std::vector< realT > minTauWFS()
Get the values of the minimum WFS exposure time.
std::vector< realT > m_npix_wfs
void calcStrehl()
Calculate the component WFE, total WFE, and Strehl ratio.
realT lam_sci()
Get the science wavelength.
realT deltaTau()
Get the value of m_deltaTau.
realT npix_wfs(size_t idx)
Get the number of pixels in the WFS for a given WFS mode.
realT wfeVar()
Get the current value of the total WFE variance.
realT ncp_wfe()
Get the value of the non-common path WFE.
realT tauWFS()
Get the value of the minimum WFS exposure time.
void npix_wfs(int idx, realT npix)
Set the number of pixels in the WFS for a given WFS mode.
std::vector< realT > m_ron_wfs
realT C4(realT m, realT n, bool normStrehl=true)
Calculate the contrast due to scintilation-OPD chromaticity.
realT timeDelayError(realT m, realT n, realT d, int b)
Calculate the time delay at a spatial frequency at the optimum exposure time and the specified actuat...
realT chromIndexErrorTotal()
Calculate the wavefront error due to chromaticity in the index of refraction at a specific spatial fr...
realT strehl(realT d, int b)
Get the Strehl ratio for a given actuator pitch and WFS WFS mode.
realT chromIndexError(int m, int n)
Calculate the wavefront error due to chromaticity in the index of refraction at a given spatial frequ...
void minTauWFS(const std::vector< realT > &ntau)
Set the value of the minimum WFS exposure times.
realT optimumTauWFS(realT m, realT n)
Calculate the optimum exposure time for a given spatial frequency at the optimum actuator spacing.
void D(realT nD)
Set the value of the primary mirror diameter.
void spatialFilter_ku(realT ku)
Set the value of spatialFilter_ku.
realT ncpError(int m, int n)
Calculate the NCP variance at a spatial frequency.
realT C4var(realT m, realT n)
Calculate the residual variance due to scintilation-OPD chromaticity.
realT minTauWFS(size_t idx)
Get the value of the minimum WFS exposure time for a given binning.
realT beta_r(realT m, realT n)
Get the value of beta_r for a spatial frequency.
realT spatialFilter_ku()
Get the value of spatialFilter_ku.
void minTauWFS(size_t idx, realT ntau)
Set a single value of the minimum WFS exposure time for a given WFS mode.
realT ron_wfs(size_t idx)
Get the value of the WFS readout noise for a given WFS mode.
void C7Map(imageT &map, bool normStrehl)
Calculate a 2D map of contrast C7.
realT C7var(realT m, realT n)
Calculate the residual variance due to dispersive anisoplanatism.
void npix_wfs(const std::vector< realT > &npix)
Set the number of pixels in the WFS for each WFS mode.
realT fittingErrorTotal()
Calculate the total fitting error over all uncorrected spatial frequencies.
void C0Map(imageT &map, bool normStrehl)
Calculate a 2D map of contrast C0.
void optd(bool od)
Set whether or not the value of d is optimized or just set to m_d_min.
bool optTau()
Get the value of m_optTau.
void opticalGain(realT og)
Set the value of the Optical Gain.
realT beta_p(realT m, realT n)
Get the value of beta_p for a spatial frequency.
std::vector< realT > m_minTauWFS
realT C5var(realT m, realT n)
Calculate the residual variance due to to scintilation-amplitude chromaticity.
wfs< realT, std::ostream > * m_wfsBeta
realT secZeta()
Get the zecant of the zenith angle.
void lam_wfs(realT nlam)
Set the value of the WFS wavelength.
realT measurementError(realT m, realT n, realT d, int b)
Calculate the measurement noise at a spatial frequency and specified actuator spacing.
void Fbg(int idx, realT fbg)
Set a single value of the background flux for a given WFS mode.
realT dispAnisoOPDErrorTotal()
Calculate the wavefront error due to dispersive anisoplanatism in the OPD over all specific spatial f...
void bin_npix(bool bnp)
Set the value of the pixel binning flag.
void ron_wfs(const std::vector< realT > &nron)
Set the value of the WFS readout noise for each WFS mode.
realT chromScintAmpError(int m, int n)
Calculate the wavefront error due to scintillation chromaticity in amplitude for a given spatial freq...
void C3Map(imageT &map, bool normStrehl)
Calculate a 2D map of contrast C3.
realT C2var(realT m, realT n)
Calculate the residual variance due to measurement and time delay errors in phase/OPD at a spatial fr...
realT Fg(realT mag)
The photon flux at a given star magnitude.
std::vector< realT > Fbg()
Get the value of the background flux for all WFS modes.
realT timeDelayErrorTotal()
Calculate the time delay error over all corrected spatial frequencies.
realT dispAnisoOPDError(int m, int n)
Calculate the wavefront error due to dispersive anisoplanatism in the OPD at a given spatial frequenc...
realT signal2Noise2(realT &Nph, realT tau_wfs, realT d, int b)
Calculate the terms of the signal to noise ratio squared (S/N)^2 for the WFS measurement.
realT C3var(realT m, realT n)
Calculate the residual variance due to measurement and time delay errors in amplitude at a spatial fr...
realT starMag()
Get the value of the Star's magnitude.
realT d_min(size_t idx)
Get the minimum subaperture sampling for a given WFS mode.
void loadGMagAOX()
Load parameters corresponding to the G-MagAO-X system.
void F0(realT nF0)
Set the value of the 0 magnitude photon rate.
realT chromScintAmpError()
Calculate the wavefront error due to scintillation chromaticity in amplitude over all spatial frequen...
std::vector< realT > ron_wfs()
Get the value of the WFS readout noise for all WFS modes.
std::vector< realT > npix_wfs()
Get the number of pixels in the WFS for all WFS modes.
void d_min(const std::vector< realT > &nd)
Set the minimum subaperture sampling for each WFS mode.
realT C7(realT m, realT n, bool normStrehl=true)
Calculate the contrast due to dispersive anisoplanatism.
realT measurementErrorTotal()
Calculate the total measurement error over all corrected spatial frequencies.
void setupConfig(app::appConfigurator &config)
Setup the configurator to configure this class.
realT strehl()
Get the current Strehl ratio.
void ron_wfs(int idx, realT nron)
Set the value of the WFS readout noise for a given bining mode.
void lam_sci(realT nlam)
Set the science wavelength.
void zeta(realT nz)
Set the zenith angle, and its secant.
realT C0(realT m, realT n, bool normStrehl=true)
Calculate the contrast due to uncorrected phase, C0.
realT C1var(realT m, realT n)
Calculate the residual variance due to uncorrected amplitude at a spatial frequency.
void fit_mn_max(int mnm)
Set the value of m_fit_mn_max.
realT ncp_alpha()
Get the value of the non-common path WFE PSD index.
const Eigen::Array< int, -1, -1 > & controlledModes()
Access the array of controlledModes.
realT chromScintOPDError(int m, int n)
Calculate the wavefront error due to scintillation chromaticity in the OPD at a spatial frequency.
void C_Map(imageT &im, CfuncT Cfunc, bool normStrehl)
Worker function for the contrast-map functions.
void ncp_wfe(realT nwfe)
Set the value of the non-common path WFE.
iosT & dumpAOSystem(iosT &ios)
Output current parameters to a stream.
std::vector< realT > m_Fbg
void C4Map(imageT &map, bool normStrehl)
Calculate a 2D map of contrast C4.
realT C6var(realT m, realT n)
Calculate the residual variance due to chromaticity of the index of refraction of air.
realT C2(realT m, realT n, bool normStrehl=true)
Calculate the contrast due to measurement and time delay errors in phase/OPD at a spatial frequency.
void C2Map(imageT &map, bool normStrehl)
Calculate a 2D map of contrast C2().
void Fbg(const std::vector< realT > &fbg)
Set the value of the background fluxes.
realT dispAnisoAmpError()
Calculate the wavefront error due to dispersive anisoplanatism in the amplitude at a specific spatial...
Eigen::Array< int, -1, -1 > m_controlledModes
std::vector< realT > m_d_min
void spatialFilter_kv(realT kv)
Set the value of spatialFilter_kv.
void d_min(int idx, realT nd)
Set the minimum subaperture sampling for a given WFS mode.
realT C6(realT m, realT n, bool normStrehl=true)
Calculate the contrast due to chromaticity of the index of refraction of air.
int fit_mn_max()
Get the value of m_fit_mn_max.
realT opticalGain()
Get the value of the optical gain.
int bin_opt()
Get the value of the optimum binning factor/index.
realT optimumTauWFS(realT m, realT n, realT d, int b)
Calculate the optimum exposure time for a given spatial frequency at a specified actuator spacing.
void C6Map(imageT &map, bool normStrehl)
Calculate a 2D map of contrast C6.
realT lam_wfs()
Get the value of the WFS wavelength.
realT D()
Get the value of the primary mirror diamter.
realT C3(realT m, realT n, bool normStrehl=true)
Calculate the contrast due to measurement and time delay errors in amplitude at a spatial frequency.
realT fittingError(realT m, realT n)
Calculate the fitting error at a specific spatial frequency.
wfs< realT, iosT > * wfsBeta()
Get the WFS Beta pointer.
realT optd_delta()
Get the value of the fractional change in actuator spacing for optimization..
Augments an exception with the source file and line.
error_t
The mxlib error codes.
@ sizeerr
A size was invalid or calculated incorrectly.
@ paramnotset
A parameter was not set.
@ invalidarg
An argument was invalid.
error_t mxlib_error_report(const error_t &code, const std::string &expl, const std::source_location &loc=std::source_location::current())
Print a report to stderr given an mxlib error_t code and explanation and return the code.
void quarticRoots(std::vector< std::complex< realT > > &x, realT a, realT b, realT c, realT d, realT e)
Find the roots of the general quartic equation.
constexpr T pi()
Get the value of pi.
constexpr T two_pi()
Get the value of 2pi.
Declarations of some libarary wide utilities.
MXLIB_DEFAULT_VERBOSITY d
The default verbosity.
iosT & dumpGitStatus(iosT &ios, const std::string &repoName, const std::string &branch, const std::string &sha1, const bool &modified, const std::string §ion="")
Dump the git status of a repository to a stream.
Declares and defines functions for finding roots.
The calculated WFS uses sensitivities provided by FITS files.
The ideal wavefront sensor sensitivity function.
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.
bool isSet(const std::string &name, std::unordered_map< std::string, configTarget > &targets)
Check if a target has been set by the configuration.