3 #include "../../../catch2/catch.hpp"
6 #define MX_NO_ERROR_REPORTS
8 #include "../../../../include/ao/analysis/aoSystem.hpp"
12 using namespace mx::app;
13 using namespace mx::AO::analysis;
20 SCENARIO(
"Loading aoSystem config settings",
"[ao::analysis::aoSystem]" )
22 GIVEN(
"no config file")
25 WHEN(
"verifying the defaults")
28 REQUIRE(aosys.
D() == 0.0);
29 REQUIRE(aosys.
d_min(0) == 0.0);
30 REQUIRE(aosys.
d_opt() == 1e-50);
31 REQUIRE(aosys.
optd() ==
false);
33 REQUIRE(aosys.
wfsBeta()->_id ==
"Ideal WFS");
35 REQUIRE(aosys.
npix_wfs().size() == 1);
36 REQUIRE(aosys.
npix_wfs((
size_t) 0) == 0);
37 REQUIRE(aosys.
ron_wfs().size() == 1);
38 REQUIRE(aosys.
ron_wfs((
size_t) 0) == 0);
39 REQUIRE(aosys.
Fbg().size() == 1);
40 REQUIRE(aosys.
Fbg((
size_t) 0) == 0);
42 REQUIRE(aosys.
minTauWFS((
size_t) 0) == 0);
44 REQUIRE(aosys.
tauWFS() == 0);
46 REQUIRE(aosys.
optTau() ==
true);
48 REQUIRE(aosys.
zeta() == 0);
49 REQUIRE(aosys.
secZeta() == 1.0);
56 REQUIRE(aosys.
F0() == 0.0);
58 REQUIRE(aosys.
Fg() == 0);
59 REQUIRE(aosys.
Fg(2.5) == 0);
63 GIVEN(
"a valid config file")
67 WHEN(
"setting wfs to ideal")
82 REQUIRE(aosys.
wfsBeta()->_id ==
"Ideal WFS");
84 WHEN(
"setting wfs to unmodPyWFS")
100 REQUIRE(aosys.
wfsBeta()->_id ==
"Unmodulated Pyramid");
102 WHEN(
"setting wfs to asympModPyWFS")
117 REQUIRE(aosys.
wfsBeta()->_id ==
"Asymptotic Modulated Pyramid");
119 WHEN(
"setting wfs to SHWFS")
134 REQUIRE(aosys.
wfsBeta()->_id ==
"Shack Hartmann");
136 WHEN(
"typical settings part 1")
142 {
"aosys",
"aosys",
"aosys",
"aosys",
"aosys"},
143 {
"D",
"d_min",
"optd",
"optd_delta",
"lam_wfs"},
144 {
"7.6",
"0.122",
"true",
"0.0037",
"800e-9"}
151 REQUIRE(aosys.
D() == Approx(7.6));
152 REQUIRE(aosys.
d_min(0) == Approx(0.122));
153 REQUIRE(aosys.
optd() ==
true);
154 REQUIRE(aosys.
optd_delta() == Approx(0.0037));
155 REQUIRE(aosys.
lam_wfs() == Approx(800e-9));
157 WHEN(
"typical settings part 2")
162 {
"aosys",
"aosys",
"aosys",
"aosys",
"aosys"},
163 {
"npix_wfs",
"ron_wfs",
"Fbg",
"minTauWFS",
"bin_npix"},
164 {
"100,1001",
"0.5,0.25",
"0.01,0.03",
"0.0001,0.0005",
"false"}
173 REQUIRE(aosys.
ron_wfs(0) == 0.5);
174 REQUIRE(aosys.
ron_wfs(1) == 0.25);
175 REQUIRE(aosys.
Fbg(0) == 0.01);
176 REQUIRE(aosys.
Fbg(1) == 0.03);
181 WHEN(
"typical settings part 3")
186 {
"aosys",
"aosys",
"aosys",
"aosys",
"aosys",
"aosys",
"aosys",
"aosys",
"aosys"},
187 {
"tauWFS",
"deltaTau",
"optTau",
"lam_sci",
"zeta",
"fit_mn_max",
"circularLimit",
"spatialFilter_ku",
"spatialFilter_kv"},
188 {
"0.0007",
"0.0001",
"false",
"802e-9",
"0.15",
"12",
"true",
"50",
"53"}
195 REQUIRE(aosys.
tauWFS() == Approx(0.0007));
196 REQUIRE(aosys.
deltaTau() == Approx(0.0001));
197 REQUIRE(aosys.
optTau() ==
false);
198 REQUIRE(aosys.
lam_sci() == Approx(802e-9));
199 REQUIRE(aosys.
zeta() == Approx(0.15));
200 REQUIRE(aosys.
secZeta() == Approx(1/cos(0.15)));
206 WHEN(
"typical settings part 4")
211 {
"aosys",
"aosys",
"aosys",
"aosys",
"atm"},
212 {
"ncp_wfe",
"ncp_alpha",
"starMag",
"F0",
"r_0"},
213 {
"30e-9",
"2.34",
"8.2",
"5e9",
"0.25"}
220 REQUIRE(aosys.
ncp_wfe() == Approx(30e-9));
221 REQUIRE(aosys.
ncp_alpha() == Approx(2.34));
222 REQUIRE(aosys.
F0() == Approx(5e9));
223 REQUIRE(aosys.
starMag() == Approx(8.2));
224 REQUIRE(aosys.
Fg() == Approx(5e9*pow(10, -0.4*8.2)));
225 REQUIRE(aosys.
Fg(9.0) == Approx(5e9*pow(10, -0.4*9.0)));
226 REQUIRE(aosys.atm.
r_0() == Approx(0.25));
SCENARIO("Loading aoSystem config settings", "[ao::analysis::aoSystem]")
void writeConfigFile(const std::string &fname, const std::vector< std::string > §ions, const std::vector< std::string > &keywords, const std::vector< std::string > &values)
A simple config file writing function, useful for testing.
realT r_0()
Get the value of Fried's parameter r_0 at the reference wavelength lam_0.
Describes an analytic adaptive optics (AO) system.
void optTau(bool ot)
Set the value of m_optTau.
void optd_delta(realT odd)
Set the fractional change in actuator spacing for optimization.
void starMag(realT nmag)
Set the value of the Star's magnitude.
void wfsBeta(const wfsT &w)
Set the WFS Beta pointer.
void circularLimit(bool cl)
Set the value of the circularLimit flag.
void ncp_alpha(realT alpha)
Set the value of the non-common path WFE PSD index.
realT d_opt()
Calculate the optimum actuator spacing.
void tauWFS(realT ntau)
Set the value of the WFS exposure time.
void deltaTau(realT ndel)
Set the value of m_deltaTau.
void minTauWFS(const std::vector< realT > &ntau)
Set the value of the minimum WFS exposure times.
void D(realT nD)
Set the value of the primary mirror diameter.
void spatialFilter_ku(realT ku)
Set the value of spatialFilter_ku.
void npix_wfs(const std::vector< realT > &npix)
Set the number of pixels in the WFS for each WFS mode.
void optd(bool od)
Set whether or not the value of d is optimized or just set to m_d_min.
realT secZeta()
Get the zecant of the zenith angle.
void lam_wfs(realT nlam)
Set the value of the WFS wavelength.
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 Fg(realT mag)
The photon flux at a given star magnitude.
void F0(realT nF0)
Set the value of the 0 magnitude photon rate.
void d_min(const std::vector< realT > &nd)
Set the minimum subaperture sampling for each WFS mode.
void setupConfig(app::appConfigurator &config)
Setup the configurator to configure this class.
void lam_sci(realT nlam)
Set the science wavelength.
void zeta(realT nz)
Set the zenith angle, and its secant.
void fit_mn_max(int mnm)
Set the value of m_fit_mn_max.
void ncp_wfe(realT nwfe)
Set the value of the non-common path WFE.
void Fbg(const std::vector< realT > &fbg)
Set the value of the background fluxes.
void spatialFilter_kv(realT kv)
Set the value of spatialFilter_kv.
void loadConfig(app::appConfigurator &config)
Load the configuration of this class from a configurator.
Class to manage a set of configurable values, and read their values from config/ini files and the com...
int readConfig(const std::string &fname, bool reportFileNotFound=true)
Read and parse a config/ini file, updating the targets.