4#include "../../../catch2/catch.hpp"
6#include "../../../cudaTestUtils.hpp"
9#define MX_NO_ERROR_REPORTS
15using namespace mx::AO::sim;
21using namespace mx::improc;
27TEST_CASE(
"Simulate a pyramid sensor on CPU",
"[ao::sim]" )
31 uint32_t pupSz = 56.0;
32 uint32_t wfSz = 256.0;
37 pupil.resize( pupSz, pupSz );
38 pupil.setConstant( 0 );
39 maskCircle( pupil, 0.5 * ( 1.0 * pupSz - 1 ), 1 );
42 realT nphperpix = 1e10 / pupil.sum();
44 wf.setAmplitude( pupil * sqrt( nphperpix ) );
46 fm.resize( pupSz, pupSz );
62 wf.setPhase( fm * 0 );
68 for(
size_t n = 0; n < N; ++n )
74 std::cerr <<
"\nCPU: " << 1.0 * N / ( t1 - t0 ) <<
" fps\n\n";
79 std::cout << s <<
'\n';
84#if defined( MXLIB_CUDA ) || defined( __DOXY_ONLY__ )
89TEST_CASE(
"Simulate a pyramid sensor on GPU",
"[ao::sim]" )
91 if( !mxlibTest::cudaDeviceAvailable() )
93 WARN(
"CUDA runtime is available but no CUDA device is present" );
99 uint32_t pupSz = 56.0;
100 uint32_t wfSz = 256.0;
105 pupil.resize( pupSz, pupSz );
106 pupil.setConstant( 0 );
107 maskCircle( pupil, 0.5 * ( 1.0 * pupSz - 1 ), 1 );
110 realT nphperpix = 1e10 / pupil.sum();
112 wf.setAmplitude( pupil * sqrt( nphperpix ) );
114 fm.resize( pupSz, pupSz );
130 wf.setPhase( fm * 0 );
136 for(
size_t n = 0; n < N; ++n )
142 std::cerr <<
"\nGPU: " << 1.0 * N / ( t1 - t0 ) <<
" fps\n\n";
147 std::cout << s <<
'\n';
149 REQUIRE( s > 9.9e9 );
Provides a class to simulate a CCD.
A Pyramid Sensor Simulation.
realT perStep()
Get the minimum number of modulation steps.
realT lambda()
Get the PyWFS central wavelength.
int wfSz()
Get the wavefront size in pixels.
void detSize(const uint32_t &nrows, const uint32_t &ncols)
Set the detector columns in pixels.
wfsImageT< realT > detectorImage
The image on the detector, resized from m_wfsImage.
detectorT detector
The WFS detector.
realT modRadius()
Get the radius of modulation.
bool senseWavefrontCal(wavefrontT &pupilPlane)
Sense the wavefront aberrations in calibration mode.
uint32_t pupilSz()
Get the pupil size in pixels.
realT D()
Get the telescope diameter.
Tools for using the eigen library for image processing.
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
void maskCircle(arrayT &m, typename arrayT::Scalar xcen, typename arrayT::Scalar ycen, typename arrayT::Scalar rad, typename arrayT::Scalar val, typename arrayT::Scalar pixbuf=0.5)
Mask a circle in an image.
TEST_CASE("Simulate a pyramid sensor on CPU", "[ao::sim]")
Simulate a pyramid sensor on CPU.
typeT get_curr_time()
Get the current system time in seconds.
Declares and defines functions to work with image masks.
Declaration and definition of a standard 4 quadrant pyramid WFS.
Structure containing the phase and amplitude of a wavefront.