14 #include "nmrspectrumsolver.h"
19 #include "freqestleastsquare.h"
21 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_ZF_FFT[] =
"ZF-FFT";
22 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_MEM_STRICT[] =
"Strict MEM";
23 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_MEM_STRICT_BURG[] =
"Burg+Strict MEM";
24 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_MEM_BURG_AICc[] =
"Burg's MEM AICc";
25 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_MEM_BURG_MDL[] =
"Burg's MEM MDL";
26 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_AR_YW_AICc[] =
"Yule-Walker AR AICc";
27 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_AR_YW_MDL[] =
"Yule-Walker AR MDL";
29 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_MEM_STRICT_EV[] =
"EV+Strict MEM";
30 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_MUSIC_AIC[] =
"MUSIC AIC";
31 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_MUSIC_MDL[] =
"MUSIC MDL";
32 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_EV_AIC[] =
"Eigenvector AIC";
33 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_EV_MDL[] =
"Eigenvector MDL";
34 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_MVDL[] =
"Capon's MVDL(MLM)";
36 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_LS_HQ[] =
"LeastSquare HQ";
37 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_LS_AICc[] =
"LeastSquare AICc";
38 const char SpectrumSolverWrapper::SPECTRUM_SOLVER_LS_MDL[] =
"LeastSquare MDL";
40 const char SpectrumSolverWrapper::WINDOW_FUNC_DEFAULT[] =
"Rect";
41 const char SpectrumSolverWrapper::WINDOW_FUNC_HANNING[] =
"Hanning";
42 const char SpectrumSolverWrapper::WINDOW_FUNC_HAMMING[] =
"Hamming";
43 const char SpectrumSolverWrapper::WINDOW_FUNC_FLATTOP[] =
"Flat-Top";
44 const char SpectrumSolverWrapper::WINDOW_FUNC_BLACKMAN[] =
"Blackman";
45 const char SpectrumSolverWrapper::WINDOW_FUNC_BLACKMAN_HARRIS[] =
"Blackman-Harris";
46 const char SpectrumSolverWrapper::WINDOW_FUNC_KAISER_1[] =
"Kaiser a=3";
47 const char SpectrumSolverWrapper::WINDOW_FUNC_KAISER_2[] =
"Kaiser a=7.2";
48 const char SpectrumSolverWrapper::WINDOW_FUNC_KAISER_3[] =
"Kaiser a=15";
50 SpectrumSolverWrapper::SpectrumSolverWrapper(
const char *name,
bool runtime,
51 const shared_ptr<XComboNode> selector,
const shared_ptr<XComboNode> windowfunc,
52 const shared_ptr<XDoubleNode> windowlength,
bool leastsquareonly)
53 :
XNode(name, runtime), m_selector(selector), m_windowfunc(windowfunc), m_windowlength(windowlength) {
56 tr[ *windowfunc].add(WINDOW_FUNC_DEFAULT);
57 tr[ *windowfunc].add(WINDOW_FUNC_HANNING);
58 tr[ *windowfunc].add(WINDOW_FUNC_HAMMING);
59 tr[ *windowfunc].add(WINDOW_FUNC_BLACKMAN);
60 tr[ *windowfunc].add(WINDOW_FUNC_BLACKMAN_HARRIS);
61 tr[ *windowfunc].add(WINDOW_FUNC_FLATTOP);
62 tr[ *windowfunc].add(WINDOW_FUNC_KAISER_1);
63 tr[ *windowfunc].add(WINDOW_FUNC_KAISER_2);
64 tr[ *windowfunc].add(WINDOW_FUNC_KAISER_3);
69 if( !leastsquareonly) {
70 tr[ *selector].add(SPECTRUM_SOLVER_ZF_FFT);
71 tr[ *selector].add(SPECTRUM_SOLVER_MEM_STRICT);
74 tr[ *selector].add(SPECTRUM_SOLVER_MVDL);
75 tr[ *selector].add(SPECTRUM_SOLVER_EV_MDL);
76 tr[ *selector].add(SPECTRUM_SOLVER_MUSIC_MDL);
78 tr[ *selector].add(SPECTRUM_SOLVER_MEM_BURG_AICc);
79 tr[ *selector].add(SPECTRUM_SOLVER_MEM_BURG_MDL);
80 tr[ *selector].add(SPECTRUM_SOLVER_AR_YW_AICc);
81 tr[ *selector].add(SPECTRUM_SOLVER_AR_YW_MDL);
84 tr[ *selector].add(SPECTRUM_SOLVER_LS_HQ);
85 tr[ *selector].add(SPECTRUM_SOLVER_LS_AICc);
86 tr[ *selector].add(SPECTRUM_SOLVER_LS_MDL);
88 m_lsnOnChanged = tr[ *selector].onValueChanged().connectWeakly(
89 shared_from_this(), &SpectrumSolverWrapper::onSolverChanged);
91 onSolverChanged(shot, selector.get());
94 SpectrumSolverWrapper::~SpectrumSolverWrapper() {
96 trans( *m_windowfunc).clear();
99 trans( *m_selector).clear();
103 SpectrumSolverWrapper::windowFunc(
const Snapshot &shot)
const {
104 FFT::twindowfunc func = &FFT::windowFuncRect;
105 if(shot[ *m_windowfunc]) {
106 if(shot[ *m_windowfunc].to_str() == WINDOW_FUNC_HANNING) func = &FFT::windowFuncHanning;
107 if(shot[ *m_windowfunc].to_str() == WINDOW_FUNC_HAMMING) func = &FFT::windowFuncHamming;
108 if(shot[ *m_windowfunc].to_str() == WINDOW_FUNC_FLATTOP) func = &FFT::windowFuncFlatTop;
109 if(shot[ *m_windowfunc].to_str() == WINDOW_FUNC_BLACKMAN) func = &FFT::windowFuncBlackman;
110 if(shot[ *m_windowfunc].to_str() == WINDOW_FUNC_BLACKMAN_HARRIS) func = &FFT::windowFuncBlackmanHarris;
111 if(shot[ *m_windowfunc].to_str() == WINDOW_FUNC_KAISER_1) func = &FFT::windowFuncKaiser1;
112 if(shot[ *m_windowfunc].to_str() == WINDOW_FUNC_KAISER_2) func = &FFT::windowFuncKaiser2;
113 if(shot[ *m_windowfunc].to_str() == WINDOW_FUNC_KAISER_3) func = &FFT::windowFuncKaiser3;
118 SpectrumSolverWrapper::windowFuncs(std::deque<FFT::twindowfunc> &funcs)
const {
120 funcs.push_back(&FFT::windowFuncRect);
121 funcs.push_back(&FFT::windowFuncHanning);
122 funcs.push_back(&FFT::windowFuncHamming);
123 funcs.push_back(&FFT::windowFuncFlatTop);
124 funcs.push_back(&FFT::windowFuncBlackman);
125 funcs.push_back(&FFT::windowFuncBlackmanHarris);
126 funcs.push_back(&FFT::windowFuncKaiser1);
127 funcs.push_back(&FFT::windowFuncKaiser2);
128 funcs.push_back(&FFT::windowFuncKaiser3);
133 shared_ptr<Payload::WrapperBase> wrapper;
134 bool has_window =
true;
135 bool has_length =
true;
137 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_MEM_BURG_AICc) {
140 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_MEM_BURG_MDL) {
143 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_AR_YW_AICc) {
146 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_AR_YW_MDL) {
150 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_MUSIC_AIC) {
153 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_MUSIC_MDL) {
156 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_EV_AIC) {
159 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_EV_MDL) {
162 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_MVDL) {
163 wrapper.reset(
new Payload::Wrapper<MVDL>(
new MVDL));
165 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_MEM_STRICT_EV) {
170 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_MEM_STRICT) {
171 wrapper.reset(
new Payload::Wrapper<MEMStrict>(
new MEMStrict));
173 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_MEM_STRICT_BURG) {
177 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_LS_HQ) {
180 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_LS_AICc) {
183 if(shot[ *m_selector].to_str() == SPECTRUM_SOLVER_LS_MDL) {
188 wrapper.reset(
new Payload::Wrapper<FFTSolver>(
new FFTSolver));
191 m_windowfunc->setUIEnabled(has_window);
193 m_windowlength->setUIEnabled(has_length);
195 tr[ *
this].m_wrapper = wrapper;