mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
pywfsSlopeReconstructor_test.cpp
Go to the documentation of this file.
1/** \file pywfsSlopeReconstructor_test.cpp
2 * \brief Tests pyramid-sensor slope reconstruction.
3 */
4#include "../../../catch2/catch.hpp"
5
6#include <filesystem>
7
9
10/** \cond */
11/// Compile the pyramid-sensor slope reconstructor for a representative scalar type.
13/** \endcond */
14
15/** \defgroup pywfsSlopeReconstructor_unit_tests pywfsSlopeReconstructor Unit Tests
16 * \ingroup ao_sim_unit_tests
17 */
18
19namespace unitTest::ao_sim_pywfsSlopeReconstructor_test
20{
21
22/** \cond */
23class pywfsSlopeReconstructor_test : public mx::AO::sim::pywfsSlopeReconstructor<double>
24{
25 public:
26 /// Exposes the loaded quadrant mask for verification.
27 const imageT &quadMask() const
28 {
29 return _quadMask;
30 }
31};
32/** \endcond */
33
34/** \brief Verifies that mx::AO::sim::pywfsSlopeReconstructor::calcMask preserves a configured FITS mask.
35 *
36 * \ingroup pywfsSlopeReconstructor_unit_tests
37 */
38TEST_CASE( "pywfsSlopeReconstructor loads its configured quadrant mask", "[ao::sim::pywfsSlopeReconstructor]" )
39{
40 const std::filesystem::path testDirectory =
41 std::filesystem::temp_directory_path() / "mxlib-pywfsSlopeReconstructor-test";
42 std::filesystem::remove_all( testDirectory );
43 std::filesystem::create_directories( testDirectory );
44
45 const std::filesystem::path previousDirectory = std::filesystem::current_path();
46 std::filesystem::current_path( testDirectory );
47
48 mx::improc::eigenImage<double> expectedMask( 2, 3 );
49 expectedMask << 1, 0, 1, 0, 1, 0;
50
51 const std::filesystem::path maskFile = testDirectory / "quadrant-mask.fits";
53 REQUIRE( fitsFile.write( maskFile.string(), expectedMask ) == mx::error_t::noerror );
54
55 pywfsSlopeReconstructor_test reconstructor;
56 reconstructor.detRows( 8 );
57 reconstructor.detCols( 8 );
58 reconstructor.maskFile( maskFile.string() );
59
60 REQUIRE( reconstructor.measurementSize() == 6 );
61 REQUIRE( reconstructor.quadMask().isApprox( expectedMask ) );
62
63 std::filesystem::current_path( previousDirectory );
64 std::filesystem::remove_all( testDirectory );
65}
66
67} // namespace unitTest::ao_sim_pywfsSlopeReconstructor_test
A Pyramid Wavefront Sensor slope reconstructor.
Class to manage interactions with a FITS file.
Definition fitsFile.hpp:84
error_t write(const dataT *im, int d1, int d2, int d3, fitsHeader< verboseT > *head)
Write the contents of a raw array to the FITS file.
TEST_CASE("Loading aoAtmosphere config settings", "[ao::analysis::aoAtmosphere]")
Verify parsing and validation of atmosphere configuration settings.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
@ noerror
No error has occurred.
Definition error_t.hpp:27
Declares the pyramid-wavefront-sensor slope reconstructor.