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