mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
aoPSDs_test.cpp
1/** \file fileAtmosphere_test.cpp
2 */
3#include "../../../catch2/catch.hpp"
4
5#define MX_NO_ERROR_REPORTS
6
7#include "../../../../include/ao/analysis/aoPSDs.hpp"
8
9typedef double realT;
10
11using namespace mx::app;
12using namespace mx::AO::analysis;
13
14/** Scenario: Loading aoAtmosphere config settings
15 *
16 * Verify parsing of config
17 *
18 * \anchor tests_ao_analysis_aoAtmosphere_config
19 */
20SCENARIO( "Loading aoPSD config settings", "[ao::analysis::aoPSD]" )
21{
22 GIVEN( "a valid config file" )
23 {
24 vonKarmanSpectrum<realT> psd; // This will be cumulative
25
26 WHEN( "all normal settings: phase" )
27 {
28 appConfigurator config;
29
30 writeConfigFile( "aoPSDs.conf",
31 { "psd", "psd", "psd", "psd", "psd" },
32 { "D", "subPiston", "subTipTilt", "scintillation", "component" },
33 { "5.5", "true", "true", "true", "phase" } );
34
35 psd.setupConfig( config );
36 config.readConfig( "aoPSDs.conf" );
37 psd.loadConfig( config );
38
39 REQUIRE( psd.D() == 5.5 );
40 REQUIRE( psd.subPiston() == true );
41 REQUIRE( psd.subTipTilt() == true );
42 REQUIRE( psd.scintillation() == true );
43 REQUIRE( psd.component() == PSDComponent::phase );
44 }
45 WHEN( "all normal settings: amplitude" )
46 {
47 appConfigurator config;
48
49 writeConfigFile( "aoPSDs.conf",
50 { "psd", "psd", "psd", "psd", "psd" },
51 { "D", "subPiston", "subTipTilt", "scintillation", "component" },
52 { "3.5", "false", "false", "false", "amplitude" } );
53
54 psd.setupConfig( config );
55 config.readConfig( "aoPSDs.conf" );
56 psd.loadConfig( config );
57
58 REQUIRE( psd.D() == 3.5 );
59 REQUIRE( psd.subPiston() == false );
60 REQUIRE( psd.subTipTilt() == false );
61 REQUIRE( psd.scintillation() == false );
62 REQUIRE( psd.component() == PSDComponent::amplitude );
63 }
64 WHEN( "all normal settings: dispPhase" )
65 {
66 appConfigurator config;
67
68 writeConfigFile( "aoPSDs.conf",
69 { "psd", "psd", "psd", "psd", "psd" },
70 { "D", "subPiston", "subTipTilt", "scintillation", "component" },
71 { "7.2", "true", "false", "true", "dispPhase" } );
72
73 psd.setupConfig( config );
74 config.readConfig( "aoPSDs.conf" );
75 psd.loadConfig( config );
76
77 REQUIRE( psd.D() == 7.2 );
78 REQUIRE( psd.subPiston() == true );
79 REQUIRE( psd.subTipTilt() == false );
80 REQUIRE( psd.scintillation() == true );
81 REQUIRE( psd.component() == PSDComponent::dispPhase );
82 }
83 WHEN( "all normal settings: dispAmplitude" )
84 {
85 appConfigurator config;
86
87 writeConfigFile( "aoPSDs.conf",
88 { "psd", "psd", "psd", "psd", "psd" },
89 { "D", "subPiston", "subTipTilt", "scintillation", "component" },
90 { "25.4", "false", "true", "false", "dispAmplitude" } );
91
92 psd.setupConfig( config );
93 config.readConfig( "aoPSDs.conf" );
94 psd.loadConfig( config );
95
96 REQUIRE( psd.D() == 25.4 );
97 REQUIRE( psd.subPiston() == false );
98 REQUIRE( psd.subTipTilt() == true );
99 REQUIRE( psd.scintillation() == false );
100 REQUIRE( psd.component() == PSDComponent::dispAmplitude );
101 }
102 }
103}
void writeConfigFile(const std::string &fname, const std::vector< std::string > &sections, const std::vector< std::string > &keywords, const std::vector< std::string > &values)
A simple config file writing function, useful for testing.
Manage calculations using the von Karman spatial power spectrum.
Definition aoPSDs.hpp:84
bool subTipTilt()
Get the value of m_subTipTilt.
Definition aoPSDs.hpp:251
realT D()
Get the value of the diameter m_D.
Definition aoPSDs.hpp:295
void setupConfig(app::appConfigurator &config)
Setup the configurator to configure this class.
Definition aoPSDs.hpp:441
bool subPiston()
Get the value of m_subPiston.
Definition aoPSDs.hpp:239
bool scintillation()
Get the value of m_scintillation.
Definition aoPSDs.hpp:263
void loadConfig(app::appConfigurator &config)
Load the configuration of this class from a configurator.
Definition aoPSDs.hpp:462
int component()
Get the value of m_component.
Definition aoPSDs.hpp:275
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.