mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
wooferTweeterDM.hpp
Go to the documentation of this file.
1/** \file
2 * \author Jared R. Males (jaredmales@gmail.com)
3 * \brief
4 * \ingroup mxAO_sim_files
5 *
6 */
7
8#ifndef _wooferTweeterDM_hpp__
9#define _wooferTweeterDM_hpp__
10
11#include "deformableMirror.hpp"
12
13namespace mx
14{
15
16namespace AO
17{
18
19namespace sim
20{
21
22struct wooferTweeterDMSpec
23{
24 std::string name;
25 std::string basisName;
26
27 deformableMirrorSpec woofer;
28 deformableMirrorSpec tweeter;
29
30 int wooferModes;
31
32 wooferTweeterDMSpec()
33 {
34 wooferModes = 0;
35 }
36};
37
38// template<typename floatT>
39// struct wooferTweeterCommand
40// {
41// bool woofer;
42// Eigen::Array< floatT, Eigen::Dynamic, Eigen::Dynamic> wooferVect;
43//
44// bool tweeter;
45// Eigen::Array< floatT, Eigen::Dynamic, Eigen::Dynamic> tweeterVect;
46// };
47
48template <typename _floatT>
49class wooferTweeterDM
50{
51 public:
52 typedef _floatT floatT;
53
54 typedef std::complex<floatT> complexT;
55
56 /// The wavefront data type
57 typedef wavefront<floatT> wavefrontT;
58
59 /// The pupil image type
60 typedef Eigen::Array<floatT, Eigen::Dynamic, Eigen::Dynamic> imageT;
61
62 typedef wooferTweeterDMSpec specT;
63
64 // typedef wooferTweeterCommand<floatT> commandT;
65 // typedef Eigen::Array< floatT, -1, -1> commandT;
66
67 deformableMirror<floatT> woofer;
68 deformableMirror<floatT> tweeter;
69
70 int _wooferModes;
71
72 std::string _name;
73 std::string _basisName;
74
75 public:
76 /// Default c'tor.
77 wooferTweeterDM();
78
79 int initialize( specT &spec, const std::string &pupil );
80
81 /// Get the calibration amplitude.
82 // void calAmp(const std::vector<floatT> & ca);
83 void calAmp( floatT ca );
84
85 void applyMode( wavefrontT &wf, int modeNo, floatT amp, floatT lambda );
86
87 template <typename commandT>
88 void setShape( commandT &commandV );
89
90 void applyShape( wavefrontT &wf, floatT lambda );
91
92 int nModes()
93 {
94 return woofer.nModes() + tweeter.nModes();
95 }
96
97 double t0, t1, t_mm, t_sum;
98
99 std::string name()
100 {
101 return _name;
102 }
103 std::string basisName()
104 {
105 return _basisName;
106 }
107};
108
109template <typename _floatT>
110wooferTweeterDM<_floatT>::wooferTweeterDM()
111{
112 ds9_interface_set_title( &woofer.ds9i_shape, "Woofer_Shape" );
113 ds9_interface_set_title( &woofer.ds9i_phase, "Woofer_Phase" );
114 ds9_interface_set_title( &woofer.ds9i_acts, "Woofer_Acts" );
115 ds9_interface_set_title( &tweeter.ds9i_shape, "Tweeter_Shape" );
116 ds9_interface_set_title( &tweeter.ds9i_phase, "Tweeter_Phase" );
117 ds9_interface_set_title( &tweeter.ds9i_acts, "Tweeter_Acts" );
118
119 t_mm = 0;
120 t_sum = 0;
121}
122
123template <typename _floatT>
124int wooferTweeterDM<_floatT>::initialize( specT &spec, const std::string &pupil )
125{
126
127 _name = spec.name;
128 _basisName = spec.basisName;
129
130 woofer.initialize( spec.woofer, pupil );
131
132 tweeter.initialize( spec.tweeter, pupil );
133
134 _wooferModes = spec.wooferModes;
135}
136
137// template<typename _floatT>
138// void wooferTweeterDM<_floatT>::calAmp(const std::vector<_floatT> & ca)
139// {
140// woofer.calAmp(ca[0]);
141// tweeter.calAmp(ca[1]);
142// }
143
144template <typename _floatT>
145void wooferTweeterDM<_floatT>::calAmp( _floatT ca )
146{
147 woofer.calAmp( ca );
148 tweeter.calAmp( ca );
149}
150
151template <typename _floatT>
152void wooferTweeterDM<_floatT>::applyMode( wavefrontT &wf, int modeNo, floatT amp, floatT lambda )
153{
154
155 if( modeNo < _wooferModes )
156 {
157 woofer.applyMode( wf, modeNo, amp, lambda );
158 }
159 else
160 {
161 tweeter.applyMode( wf, modeNo - _wooferModes, amp, lambda );
162 }
163}
164
165template <typename _floatT>
166template <typename commandT>
167void wooferTweeterDM<_floatT>::setShape( commandT &commandV )
168{
169 // static int called = 0;
170 static commandT avgWoofV;
171
172 commandT woofV, tweetV;
173
174 BREAD_CRUMB;
175 woofV.measurement = commandV.measurement.block( 0, 0, 1, _wooferModes );
176 woofV.iterNo = commandV.iterNo;
177
178 BREAD_CRUMB;
179 // std::cerr << _wooferModes << "\n";
180 // std::cerr << commandV.cols() << "\n";
181
182 tweetV.measurement = commandV.measurement.block( 0, _wooferModes, 1, commandV.measurement.cols() - _wooferModes );
183 tweetV.iterNo = commandV.iterNo;
184
185 BREAD_CRUMB;
186
187 woofer.setShape( woofV );
188
189 // if(called == 0)
190 // {
191 // avgWoofV.measurement = woofV.measurement;
192 // ++called;
193 // }
194 // else if(called == 1)
195 // {
196 // avgWoofV.measurement += woofV.measurement;
197 // avgWoofV.measurement /= (called + 1);
198 //
199 // woofer.setShape(avgWoofV.measurement);
200 // called = 0;
201 // }
202
203 BREAD_CRUMB;
204 tweeter.setShape( tweetV );
205 BREAD_CRUMB;
206}
207
208// static int called = 0;
209//
210// if(commandV.woofer)
211// {
212// woofer.setShape(commandV.wooferVect);
213// }
214//
215// //if(commandV.tweeter)
216// if(called > 50)
217// {
218// tweeter.setShape(commandV.tweeterVect);
219// }
220//
221// ++called;
222//}
223
224template <typename _floatT>
225void wooferTweeterDM<_floatT>::applyShape( wavefrontT &wf, floatT lambda )
226{
227
228 woofer.applyShape( wf, lambda );
229 tweeter.applyShape( wf, lambda );
230}
231
232} // namespace sim
233} // namespace AO
234} // namespace mx
235
236#endif //__deformableMirror_hpp__
The mxlib c++ namespace.
Definition mxError.hpp:106