mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
zernikeBasis.hpp
Go to the documentation of this file.
1/** \file zernikeBasis.hpp
2 * \author Jared R. Males (jaredmales@gmail.com)
3 * \brief Generating a Zernike basis.
4 * \ingroup mxAO_files
5 *
6 */
7
8#ifndef __zernikeBasis_hpp__
9#define __zernikeBasis_hpp__
10
11#include "aoPaths.hpp"
15
16namespace mx
17{
18
19namespace AO
20{
21
22/// Make the Zernike basis
23/**
24 * \param [in] basisName the name of the basis (not including the mx::AO path)
25 * \param [in] dim the linear size of the maps, that is they will be dimxdim in size.
26 * \param [in] N is the number of degrees of freedom. Number of modes will be (N+1)(N+1) - 1.
27 *
28 * \tparam realT the real numeric type for calculations
29 */
30template <typename realT>
31void makeZernikeBasis( const std::string &basisName, const std::string &pupilName, int dim, int N )
32{
34
35 rawModes.resize( dim, dim, N );
37
38 std::string pupilFName = mx::AO::path::pupil::pupilFile( pupilName );
39 Eigen::Array<realT, -1, -1> pupil;
40
42 ff.read( pupil, pupilFName );
43
44 realT psum = pupil.sum();
45 realT norm;
46
47 for( int i = 0; i < rawModes.planes(); ++i )
48 {
49 rawModes.image( i ) *= pupil;
50
51 norm = rawModes.image( i ).square().sum() / psum;
52
53 rawModes.image( i ) /= sqrt( norm );
54 }
55
56 // realT p2v;
57 // for(int i=0; i<N; ++i)
58 // {
59 // p2v = rawModes.image(i).maxCoeff() - rawModes.image(i).minCoeff();
60 // rawModes.image(i) /= p2v;
61 // }
62
63 std::string fName = mx::AO::path::basis::modes( basisName, true );
64
65 ff.write( fName, rawModes );
66}
67
68} // namespace AO
69
70} // namespace mx
71
72#endif //__fourierBasis_hpp__
Standardized paths for the mx::AO system.
std::string pupilFile(const std::string &pupilName, bool create=false)
The path for the pupil FITS file.
Definition aoPaths.hpp:323
Class to manage interactions with a FITS file.
Definition fitsFile.hpp:84
error_t read(dataT *data)
Read the contents of the FITS file into an array.
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.
An image cube with an Eigen-like API.
Definition eigenCube.hpp:33
Eigen::Map< Eigen::Array< dataT, Eigen::Dynamic, Eigen::Dynamic > > image(Index n)
Returns a 2D Eigen::Eigen::Map pointed at the specified image.
An image cube with an Eigen API.
Declares and defines a class to work with a FITS file.
int zernikeBasis(cubeT &cube, typename cubeT::Scalar rad=-1, int minj=2)
Fill in an Eigencube-like array with Zernike polynomials in Noll order.
Definition zernike.hpp:506
The mxlib c++ namespace.
Definition mxlib.hpp:37
void makeZernikeBasis(const std::string &basisName, const std::string &pupilName, int dim, int N)
Make the Zernike basis.
Working with the Zernike polynomials.