3#include "../../../catch2/catch.hpp"
5#define MX_NO_ERROR_REPORTS
7#include "../../../../include/ao/analysis/aoAtmosphere.hpp"
11using namespace mx::app;
12using namespace mx::AO::analysis;
20SCENARIO(
"Loading aoAtmosphere config settings",
"[ao::analysis::aoAtmosphere]" )
22 GIVEN(
"a valid config vile" )
26 WHEN(
"all normal settings" )
32 {
"atm",
"atm",
"atm",
"atm",
"atm",
"atm",
"atm",
"atm",
"atm",
"atm" },
33 {
"r_0",
"lam_0",
"L_0",
"l_0",
"layer_z",
"h_obs",
"H",
"layer_Cn2",
"layer_v_wind",
"layer_dir" },
49 REQUIRE( atm.
r_0() == 0.25 );
50 REQUIRE( atm.
lam_0() == 0.4e-9 );
52 REQUIRE( atm.
L_0( 0 ) == 10 );
53 REQUIRE( atm.
L_0( 1 ) == 15 );
54 REQUIRE( atm.
L_0( 2 ) == 22.5 );
56 REQUIRE( atm.
l_0( 0 ) == 0.1 );
57 REQUIRE( atm.
l_0( 1 ) == 0.01 );
58 REQUIRE( atm.
l_0( 2 ) == 0.001 );
60 REQUIRE( atm.
layer_z( 0 ) == 1000 );
61 REQUIRE( atm.
layer_z( 1 ) == 2000 );
62 REQUIRE( atm.
layer_z( 2 ) == 5000 );
64 REQUIRE( atm.
h_obs() == 3002 );
66 REQUIRE( atm.
H() == 2.3 );
68 REQUIRE( atm.
layer_Cn2( 0 ) == Approx( 0.2 ) );
69 REQUIRE( atm.
layer_Cn2( 1 ) == Approx( 0.2 ) );
70 REQUIRE( atm.
layer_Cn2( 2 ) == Approx( 0.6 ) );
76 REQUIRE( atm.
layer_dir( 0 ) == Approx( 0.1 ) );
77 REQUIRE( atm.
layer_dir( 1 ) == Approx( 0.6 ) );
78 REQUIRE( atm.
layer_dir( 2 ) == Approx( 1.6 ) );
80 REQUIRE( atm.
v_wind() == Approx( 19.278644205193533 ) );
81 REQUIRE( atm.
z_mean() == Approx( 3886.4496373530733 ) );
85 WHEN(
"setting v_wind and z_mean" )
90 {
"atm",
"atm",
"atm",
"atm",
"atm",
"atm" },
91 {
"layer_z",
"layer_Cn2",
"layer_v_wind",
"layer_dir",
"v_wind",
"z_mean" },
92 {
"1000,2000,5000",
"1,1,3.0",
"10.5,11.2,23.7",
"0.1,0.6,1.6",
"15.0",
"5001.0" } );
98 REQUIRE( atm.
v_wind() == Approx( 15.0 ) );
99 REQUIRE( atm.
z_mean() == Approx( 5001.0 ) );
103 WHEN(
"setting nonKolmogorov to false" )
107 writeConfigFile(
"aoAtmosphere.conf", {
"atm" }, {
"nonKolmogorov" }, {
"false" } );
115 WHEN(
"setting nonKolmogorov to true" )
119 writeConfigFile(
"aoAtmosphere.conf", {
"atm" }, {
"nonKolmogorov" }, {
"true" } );
128 WHEN(
"setting nonKolmogorov alpha" )
135 writeConfigFile(
"aoAtmosphere.conf", {
"atm" }, {
"alpha" }, {
"4.7" } );
141 REQUIRE( atm.
alpha( 0 ) == Approx( 4.7 ) );
145 WHEN(
"setting nonKolmogorov beta" )
152 writeConfigFile(
"aoAtmosphere.conf", {
"atm" }, {
"beta" }, {
"0.026" } );
158 REQUIRE( atm.
beta( 0 ) == Approx( 0.026 ) );
162 WHEN(
"setting nonKolmogorov beta_0" )
169 writeConfigFile(
"aoAtmosphere.conf", {
"atm" }, {
"beta_0" }, {
"1e-7" } );
175 REQUIRE( atm.
beta_0( 0 ) == Approx( 1e-7 ) );
179 GIVEN(
"command line options" )
183 WHEN(
"setting nonKolmogorov to true" )
186 std::vector<std::string> argvs( 2 );
189 argvs[1] =
"--atm.nonKolmogorov=true";
192 argv[0] = (
char *)argvs[0].data();
193 argv[1] = (
char *)argvs[1].data();
202 WHEN(
"setting nonKolmogorov to true" )
205 std::vector<std::string> argvs( 2 );
208 argvs[1] =
"--atm.nonKolmogorov=false";
211 argv[0] = (
char *)argvs[0].data();
212 argv[1] = (
char *)argvs[1].data();
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.
A class to specify atmosphere parameters and perform related calculations.
realT lam_0()
Get the current value of the reference wavelength.
realT h_obs()
Get the height of the observatory.
realT l_0(const size_t &n)
Get the value of the inner scale for a single layer.
realT layer_dir(const int n)
Get the wind direction of a single layer.
realT L_0(const size_t &n)
Get the value of the outer scale for a single layer.
void nonKolmogorov(const bool &nk)
Set the value of m_nonKolmogorov.
void loadConfig(app::appConfigurator &config)
Load the configuration of this class from a configurator.
realT beta_0(const size_t &n)
Return the PSD constant for a single layer.
realT beta(const size_t &n)
Return the PSD normalization for a single layer.
void setupConfig(app::appConfigurator &config)
Setup the configurator to configure this class.
realT H()
Get the atmospheric scale height.
realT v_wind()
Get the 5/3 moment weighted mean wind speed.
realT layer_Cn2(const int n)
Get the strength of a single layer.
realT alpha(const size_t &n)
Return the PSD index for a single layer.
realT layer_v_wind(const int n)
Get the wind speed of a single layer.
realT z_mean()
Get the weighted mean layer height.
realT r_0()
Get the value of Fried's parameter r_0 at the reference wavelength lam_0.
realT layer_z(const size_t n)
Get the height of a single layer.
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.
void parseCommandLine(int argc, char **argv, const std::string &oneTarget="")
Parse the command line, updating the targets.