15 #include "ui_nmrspectrumform.h"
16 #include "nmrspectrum.h"
21 #include "nmrspectrumbase_impl.h"
23 REGISTER_TYPE(
XDriverList, NMRSpectrum,
"NMR field-swept spectrum measurement");
26 XNMRSpectrum::XNMRSpectrum(
const char *name,
bool runtime,
27 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
30 "MagnetPS", false, ref(tr_meas), meas->drivers(), true)),
31 m_centerFreq(create<
XDoubleNode>(
"CenterFreq", false)),
32 m_resolution(create<
XDoubleNode>(
"Resolution", false)),
35 m_fieldFactor(create<
XDoubleNode>(
"FieldFactor", false)),
36 m_residualField(create<
XDoubleNode>(
"ResidualField", false)) {
39 m_form->setWindowTitle(i18n(
"NMR Spectrum - ") +
getLabel() );
41 tr[ *m_spectrum].setLabel(0,
"Field [T]");
42 tr[ *tr[ *m_spectrum].axisx()->label()] = i18n(
"Field [T]");
44 tr[ *centerFreq()] = 20;
45 tr[ *resolution()] = 0.001;
46 tr[ *fieldFactor()] = 1;
47 tr[ *maxValue()] = 5.0;
48 tr[ *minValue()] = 3.0;
52 xqcon_create<XQLineEditConnector>(m_centerFreq, m_form->m_edFreq),
53 xqcon_create<XQLineEditConnector>(m_resolution, m_form->m_edResolution),
54 xqcon_create<XQLineEditConnector>(m_minValue, m_form->m_edMin),
55 xqcon_create<XQLineEditConnector>(m_maxValue, m_form->m_edMax),
56 xqcon_create<XQLineEditConnector>(m_fieldFactor, m_form->m_edFieldFactor),
57 xqcon_create<XQLineEditConnector>(m_residualField, m_form->m_edResidual),
58 xqcon_create<XQComboBoxConnector>(m_magnet, m_form->m_cmbFieldEntry, ref(tr_meas)),
62 tr[ *centerFreq()].onValueChanged().connect(m_lsnOnCondChanged);
63 tr[ *resolution()].onValueChanged().connect(m_lsnOnCondChanged);
64 tr[ *minValue()].onValueChanged().connect(m_lsnOnCondChanged);
65 tr[ *maxValue()].onValueChanged().connect(m_lsnOnCondChanged);
66 tr[ *fieldFactor()].onValueChanged().connect(m_lsnOnCondChanged);
67 tr[ *residualField()].onValueChanged().connect(m_lsnOnCondChanged);
72 return (node == m_residualField.get()) || (node == m_fieldFactor.get()) || (node == m_resolution.get());
75 XNMRSpectrum::checkDependencyImpl(
const Snapshot &shot_this,
78 shared_ptr<XMagnetPS> magnet__ = shot_this[ *magnet()];
79 shared_ptr<XDMM> dmm__ = shot_this[ *magnet()];
80 shared_ptr<XQDPPMS> ppms__ = shot_this[ *magnet()];
81 if( !(magnet__ || dmm__ || ppms__))
return false;
82 if(emitter == magnet__.get())
return false;
83 if(emitter == dmm__.get())
return false;
84 if(emitter == ppms__.get())
return false;
89 double res = fabs(shot_this[ *resolution()] / shot_this[ *maxValue()] * shot_this[ *centerFreq()]);
90 res = std::min(res, fabs(shot_this[ *resolution()] / shot_this[ *minValue()] * shot_this[ *centerFreq()]));
95 double freq = -log(shot_this[ *maxValue()]) * shot_this[ *centerFreq()];
96 freq = std::min(freq, -log(shot_this[ *minValue()]) * shot_this[ *centerFreq()]);
101 double freq = -log(shot_this[ *maxValue()]) * shot_this[ *centerFreq()];
102 freq = std::max(freq, -log(shot_this[ *minValue()]) * shot_this[ *centerFreq()]);
107 shared_ptr<XMagnetPS> magnet__ = shot_this[ *magnet()];
108 shared_ptr<XDMM> dmm__ = shot_this[ *magnet()];
109 shared_ptr<XQDPPMS> ppms__ = shot_this[ *magnet()];
110 shared_ptr<XNMRPulseAnalyzer> pulse__ = shot_this[ *pulse()];
112 assert( magnet__ || dmm__ || ppms__);
115 field = shot_others[ *magnet__].magnetField();
118 field = shot_others[ *dmm__].value();
121 field = shot_others[ *ppms__].magnetField();
124 field *= shot_this[ *fieldFactor()];
125 field += shot_this[ *residualField()];
127 return -log(field) * shot_this[ *centerFreq()] * 1e6;
130 XNMRSpectrum::getValues(
const Snapshot &shot_this, std::vector<double> &values)
const {
131 int wave_size = shot_this[ *
this].wave().size();
132 double min__ = shot_this[ *
this].min();
133 double res = shot_this[ *
this].res();
134 double cfreq = shot_this[ *centerFreq()];
135 values.resize(wave_size);
136 for(
unsigned int i = 0; i < wave_size; i++) {
137 double freq = min__ + i * res;
138 values[i] = exp( -freq * 1e-6 / cfreq);