diff --git a/doc/img/Spectrum_Calibration_buttons.png b/doc/img/Spectrum_Calibration_buttons.png new file mode 100644 index 000000000..2d7407831 Binary files /dev/null and b/doc/img/Spectrum_Calibration_buttons.png differ diff --git a/doc/img/Spectrum_Calibration_buttons.xcf b/doc/img/Spectrum_Calibration_buttons.xcf new file mode 100644 index 000000000..e2a89740a Binary files /dev/null and b/doc/img/Spectrum_Calibration_buttons.xcf differ diff --git a/doc/img/Spectrum_Calibration_dialog.png b/doc/img/Spectrum_Calibration_dialog.png new file mode 100644 index 000000000..569fb447c Binary files /dev/null and b/doc/img/Spectrum_Calibration_dialog.png differ diff --git a/doc/img/Spectrum_Calibration_dialog.xcf b/doc/img/Spectrum_Calibration_dialog.xcf new file mode 100644 index 000000000..903ed0c0e Binary files /dev/null and b/doc/img/Spectrum_Calibration_dialog.xcf differ diff --git a/sdrbase/dsp/spectrumsettings.cpp b/sdrbase/dsp/spectrumsettings.cpp index 1d0502689..713557e33 100644 --- a/sdrbase/dsp/spectrumsettings.cpp +++ b/sdrbase/dsp/spectrumsettings.cpp @@ -303,6 +303,7 @@ void SpectrumSettings::formatTo(SWGSDRangel::SWGObject *swgObject) const swgSpectrum->setWaterfallShare(m_waterfallShare); swgSpectrum->setMarkersDisplay((int) m_markersDisplay); swgSpectrum->setUseCalibration(m_useCalibration ? 1 : 0); + swgSpectrum->setCalibrationInterpMode((int) m_calibrationInterpMode); if (m_histogramMarkers.size() > 0) { @@ -455,6 +456,9 @@ void SpectrumSettings::updateFrom(const QStringList& keys, const SWGSDRangel::SW if (keys.contains("spectrumConfig.useCalibration")) { m_useCalibration = swgSpectrum->getUseCalibration() != 0; } + if (keys.contains("spectrumConfig.calibrationInterpMode")) { + m_calibrationInterpMode = (CalibrationInterpolationMode) swgSpectrum->getCalibrationInterpMode(); + } if (keys.contains("spectrumConfig.histogramMarkers")) { diff --git a/sdrbase/dsp/spectrumsettings.h b/sdrbase/dsp/spectrumsettings.h index f5dfba8e8..0d917848b 100644 --- a/sdrbase/dsp/spectrumsettings.h +++ b/sdrbase/dsp/spectrumsettings.h @@ -48,8 +48,8 @@ public: enum CalibrationInterpolationMode { - CalibInterpLinear, //!< linear power, linear frequency - CalibInterpLogLinear //!< log power, linear frequency + CalibInterpLinear, //!< linear power + CalibInterpLog //!< log power (dB linear) }; int m_fftSize; diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index 1f4433d50..3b0b113d2 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -6159,6 +6159,10 @@ margin-bottom: 20px; "type" : "integer", "description" : "boolean" }, + "calibrationInterpMode" : { + "type" : "integer", + "description" : "Interpolation scheme between points SpectrumSettings::CalibrationInterpolationMode\n * 0 - Linear\n * 1 - Log (dB linear)\n" + }, "histogramMarkers" : { "type" : "array", "items" : { @@ -52000,7 +52004,7 @@ except ApiException as e:
- Generated 2022-01-30T07:47:20.311+01:00 + Generated 2022-02-05T07:11:11.381+01:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml b/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml index 2795c9cd3..7a1308aa8 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml @@ -163,6 +163,12 @@ GLSpectrum: useCalibration: type: integer description: boolean + calibrationInterpMode: + type: integer + description: > + Interpolation scheme between points SpectrumSettings::CalibrationInterpolationMode + * 0 - Linear + * 1 - Log (dB linear) histogramMarkers: type: array items: diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp index e67d5e723..6eb0da297 100644 --- a/sdrgui/gui/glspectrum.cpp +++ b/sdrgui/gui/glspectrum.cpp @@ -2433,7 +2433,7 @@ void GLSpectrum::updateCalibrationPoints() m_calibrationGain = gainLow + interpolationRatio*(gainHigh - gainLow); // linear driven m_calibrationShiftdB = CalcDb::dbPower(m_calibrationGain); } - else if (m_calibrationInterpMode == SpectrumSettings::CalibInterpLogLinear) + else if (m_calibrationInterpMode == SpectrumSettings::CalibInterpLog) { m_calibrationShiftdB = CalcDb::dbPower(gainLow) + interpolationRatio*(CalcDb::dbPower(gainHigh) - CalcDb::dbPower(gainLow)); // log driven diff --git a/sdrgui/gui/glspectrumgui.cpp b/sdrgui/gui/glspectrumgui.cpp index c7f36b739..d77d73abc 100644 --- a/sdrgui/gui/glspectrumgui.cpp +++ b/sdrgui/gui/glspectrumgui.cpp @@ -379,6 +379,7 @@ void GLSpectrumGUI::on_markers_clicked(bool checked) m_glSpectrum->getWaterfallMarkers(), m_glSpectrum->getAnnotationMarkers(), m_glSpectrum->getMarkersDisplay(), + m_calibrationShiftdB, this ); diff --git a/sdrgui/gui/glspectrumgui.ui b/sdrgui/gui/glspectrumgui.ui index 43f83b5e3..85c249475 100644 --- a/sdrgui/gui/glspectrumgui.ui +++ b/sdrgui/gui/glspectrumgui.ui @@ -428,7 +428,7 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - -150 + -200 40 diff --git a/sdrgui/gui/spectrumcalibrationpointsdialog.cpp b/sdrgui/gui/spectrumcalibrationpointsdialog.cpp index b81df40bf..17f20fda4 100644 --- a/sdrgui/gui/spectrumcalibrationpointsdialog.cpp +++ b/sdrgui/gui/spectrumcalibrationpointsdialog.cpp @@ -41,22 +41,24 @@ SpectrumCalibrationPointsDialog::SpectrumCalibrationPointsDialog( m_markerZero(markerZero), m_calibrationPointIndex(0), m_centerFrequency(0), - m_globalCorrection(0.0) + m_globalCorrection(0.0), + m_setElseCorrectGlobal(false) { ui->setupUi(this); ui->calibPointFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->calibPointFrequency->setValueRange(false, 10, -9999999999L, 9999999999L); ui->calibrationGlobalCorr->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); - ui->calibrationGlobalCorr->setValueRange(false, 5, -15000L, 4000L, 2); + ui->calibrationGlobalCorr->setValueRange(false, 5, -20000L, 4000L, 2); ui->relativePower->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); - ui->relativePower->setValueRange(false, 5, -15000L, 4000L, 2); + ui->relativePower->setValueRange(false, 5, -20000L, 4000L, 2); ui->calibratedPower->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); - ui->calibratedPower->setValueRange(false, 5, -15000L, 4000L, 2); + ui->calibratedPower->setValueRange(false, 5, -20000L, 4000L, 2); ui->calibPoint->setMaximum(m_calibrationPoints.size() - 1); ui->calibInterpMode->blockSignals(true); ui->calibInterpMode->setCurrentIndex((int) m_calibrationInterpMode); ui->calibInterpMode->blockSignals(false); ui->calibrationGlobalCorr->setValue(m_globalCorrection * 100.0); + ui->corrOrSet->setText("Cor"); displayCalibrationPoint(); } @@ -91,9 +93,9 @@ void SpectrumCalibrationPointsDialog::displayCalibrationPoint() ui->centerFrequency->setEnabled(true); ui->calibPoint->setValue(m_calibrationPointIndex); ui->calibPointText->setText(tr("%1").arg(m_calibrationPointIndex)); - double powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerRelativeReference); + double powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerRelativeReference, 1e-20); ui->relativePower->setValue(round(powerDB*100.0)); // fixed point 2 decimals - powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerCalibratedReference); + powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerCalibratedReference, 1e-20); ui->calibratedPower->setValue(round(powerDB*100.0)); // fixed point 2 decimals ui->calibPointFrequency->setValue(m_calibrationPoints[m_calibrationPointIndex].m_frequency); } @@ -183,6 +185,17 @@ void SpectrumCalibrationPointsDialog::on_calibPointDuplicate_clicked() displayCalibrationPoint(); } +void SpectrumCalibrationPointsDialog::on_calibPointsSort_clicked() +{ + if (m_calibrationPoints.size() == 0) { + return; + } + + std::sort(m_calibrationPoints.begin(), m_calibrationPoints.end(), calibrationPointsLessThan); + m_calibrationPointIndex = 0; + displayCalibrationPoint(); +} + void SpectrumCalibrationPointsDialog::on_importMarkerZero_clicked() { if ((m_calibrationPoints.size() == 0) || (m_markerZero == nullptr)) { @@ -217,10 +230,26 @@ void SpectrumCalibrationPointsDialog::on_calibrationGlobalCorr_changed(qint64 va m_globalCorrection = value / 100.0; } +void SpectrumCalibrationPointsDialog::on_corrOrSet_toggled(bool checked) +{ + if (checked) { + ui->corrOrSet->setText("Set"); + } else { + ui->corrOrSet->setText("Cor"); + } + + m_setElseCorrectGlobal = checked; +} + void SpectrumCalibrationPointsDialog::on_globalRelativeCorrection_clicked() { - for (auto& calibrationPoint : m_calibrationPoints) { - calibrationPoint.m_powerRelativeReference *= CalcDb::powerFromdB(m_globalCorrection); + for (auto& calibrationPoint : m_calibrationPoints) + { + if (m_setElseCorrectGlobal) { + calibrationPoint.m_powerRelativeReference = CalcDb::powerFromdB(m_globalCorrection); + } else { + calibrationPoint.m_powerRelativeReference *= CalcDb::powerFromdB(m_globalCorrection); + } } displayCalibrationPoint(); @@ -229,8 +258,13 @@ void SpectrumCalibrationPointsDialog::on_globalRelativeCorrection_clicked() void SpectrumCalibrationPointsDialog::on_globalCalibratedCorrection_clicked() { - for (auto& calibrationPoint : m_calibrationPoints) { - calibrationPoint.m_powerCalibratedReference *= CalcDb::powerFromdB(m_globalCorrection); + for (auto& calibrationPoint : m_calibrationPoints) + { + if (m_setElseCorrectGlobal) { + calibrationPoint.m_powerCalibratedReference = CalcDb::powerFromdB(m_globalCorrection); + } else { + calibrationPoint.m_powerCalibratedReference *= CalcDb::powerFromdB(m_globalCorrection); + } } displayCalibrationPoint(); @@ -259,13 +293,14 @@ void SpectrumCalibrationPointsDialog::on_calibPointsExport_clicked() { QTextStream stream; stream.setDevice(&file); - stream << "Frequency,Reference,Absolute\n"; + stream << "Frequency,Relative,Calibrated\n"; for (const auto &calibrationPint : m_calibrationPoints) { + stream << calibrationPint.m_frequency << "," - << calibrationPint.m_powerRelativeReference << "," - << calibrationPint.m_powerCalibratedReference << "\n"; + << CalcDb::dbPower(calibrationPint.m_powerRelativeReference, 1e-20) << "," + << CalcDb::dbPower(calibrationPint.m_powerCalibratedReference, 1e-20) << "\n"; } stream.flush(); @@ -299,7 +334,7 @@ void SpectrumCalibrationPointsDialog::on_calibPointsImport_clicked() QString error; QHash colIndexes = CSV::readHeader( in, - {"Frequency", "Reference", "Absolute"}, + {"Frequency", "Relative", "Calibrated"}, error ); @@ -307,8 +342,8 @@ void SpectrumCalibrationPointsDialog::on_calibPointsImport_clicked() { QStringList cols; int frequencyCol = colIndexes.value("Frequency"); - int referenceCol = colIndexes.value("Reference"); - int absoluteCol = colIndexes.value("Absolute"); + int referenceCol = colIndexes.value("Relative"); + int absoluteCol = colIndexes.value("Calibrated"); m_calibrationPoints.clear(); @@ -316,8 +351,8 @@ void SpectrumCalibrationPointsDialog::on_calibPointsImport_clicked() { m_calibrationPoints.push_back(SpectrumCalibrationPoint()); m_calibrationPoints.back().m_frequency = cols[frequencyCol].toLongLong(); - m_calibrationPoints.back().m_powerRelativeReference = cols[referenceCol].toFloat(); - m_calibrationPoints.back().m_powerCalibratedReference = cols[absoluteCol].toFloat(); + m_calibrationPoints.back().m_powerRelativeReference = CalcDb::powerFromdB(cols[referenceCol].toFloat()); + m_calibrationPoints.back().m_powerCalibratedReference = CalcDb::powerFromdB(cols[absoluteCol].toFloat()); } m_calibrationPointIndex = 0; diff --git a/sdrgui/gui/spectrumcalibrationpointsdialog.h b/sdrgui/gui/spectrumcalibrationpointsdialog.h index 2b186eb34..98fa1da6f 100644 --- a/sdrgui/gui/spectrumcalibrationpointsdialog.h +++ b/sdrgui/gui/spectrumcalibrationpointsdialog.h @@ -53,9 +53,15 @@ private: int m_calibrationPointIndex; qint64 m_centerFrequency; double m_globalCorrection; + bool m_setElseCorrectGlobal; void displayCalibrationPoint(); + static bool calibrationPointsLessThan(const SpectrumCalibrationPoint& m1, const SpectrumCalibrationPoint& m2) + { + return m1.m_frequency < m2.m_frequency; + } + private slots: void on_calibPoint_valueChanged(int value); void on_calibPointAdd_clicked(); @@ -64,9 +70,11 @@ private slots: void on_calibratedPower_changed(qint64 value); void on_calibPointFrequency_changed(qint64 value); void on_calibPointDuplicate_clicked(); + void on_calibPointsSort_clicked(); void on_importMarkerZero_clicked(); void on_centerFrequency_clicked(); void on_calibInterpMode_currentIndexChanged(int index); + void on_corrOrSet_toggled(bool checked); void on_calibrationGlobalCorr_changed(qint64 value); void on_globalRelativeCorrection_clicked(); void on_globalCalibratedCorrection_clicked(); diff --git a/sdrgui/gui/spectrumcalibrationpointsdialog.ui b/sdrgui/gui/spectrumcalibrationpointsdialog.ui index 2b6df6046..c7b72db01 100644 --- a/sdrgui/gui/spectrumcalibrationpointsdialog.ui +++ b/sdrgui/gui/spectrumcalibrationpointsdialog.ui @@ -7,7 +7,7 @@ 0 0 466 - 159 + 162 @@ -198,7 +198,7 @@ - 15 + 24 0 @@ -243,12 +243,6 @@ - - - 32 - 0 - - dB @@ -268,7 +262,7 @@ - 15 + 24 0 @@ -313,12 +307,6 @@ - - - 32 - 0 - - dB @@ -327,6 +315,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -410,6 +411,26 @@ + + + + + 24 + 24 + + + + Sort points by increasing frequency + + + + + + + :/sort.png:/sort.png + + + @@ -480,21 +501,36 @@ - Lin + Linear - LogLin + Log - + + + + 52 + 0 + + + + Correct or set value + Cor + + true + + + false + @@ -524,7 +560,7 @@ Qt::StrongFocus - Correction (dB) + Correction or set (dB) @@ -544,7 +580,7 @@ - Apply gain correction to all relative values + Set or apply correction to all relative values Rel @@ -560,7 +596,7 @@ - Apply gain correction to all calibrated values + Set or apply correction to all calibrated values Cal @@ -606,6 +642,9 @@ :/import.png:/import.png + + true + diff --git a/sdrgui/gui/spectrummarkersdialog.cpp b/sdrgui/gui/spectrummarkersdialog.cpp index a75555e9c..8309d8cb6 100644 --- a/sdrgui/gui/spectrummarkersdialog.cpp +++ b/sdrgui/gui/spectrummarkersdialog.cpp @@ -32,6 +32,7 @@ SpectrumMarkersDialog::SpectrumMarkersDialog( QList& waterfallMarkers, QList& annotationMarkers, SpectrumSettings::MarkersDisplay& markersDisplay, + float calibrationShiftdB, QWidget* parent) : QDialog(parent), ui(new Ui::SpectrumMarkersDialog), @@ -39,6 +40,7 @@ SpectrumMarkersDialog::SpectrumMarkersDialog( m_waterfallMarkers(waterfallMarkers), m_annotationMarkers(annotationMarkers), m_markersDisplay(markersDisplay), + m_calibrationShiftdB(calibrationShiftdB), m_histogramMarkerIndex(0), m_waterfallMarkerIndex(0), m_annotationMarkerIndex(0), @@ -56,8 +58,10 @@ SpectrumMarkersDialog::SpectrumMarkersDialog( ui->aMarkerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->aMarkerFrequency->setValueRange(false, 10, -9999999999L, 9999999999L); ui->aMarker->setMaximum(m_annotationMarkers.size() - 1); - ui->aMarkerBandwidth->setColorMapper(ColorMapper::GrayYellow); + ui->aMarkerBandwidth->setColorMapper(ColorMapper::GrayGreenYellow); ui->aMarkerBandwidth->setValueRange(true, 9, 0, 999999999L); + ui->fixedPower->setColorMapper(ColorMapper::GrayYellow); + ui->fixedPower->setValueRange(false, 4, -2000, 400, 1); ui->showSelect->setCurrentIndex((int) m_markersDisplay); displayHistogramMarker(); displayWaterfallMarker(); @@ -87,7 +91,6 @@ void SpectrumMarkersDialog::displayHistogramMarker() ui->marker->setValue(0); ui->markerText->setText("-"); ui->fixedPower->setValue(0); - ui->fixedPowerText->setText(tr("0.0")); } else { @@ -100,9 +103,8 @@ void SpectrumMarkersDialog::displayHistogramMarker() ui->markerText->setText(tr("%1").arg(m_histogramMarkerIndex)); ui->markerFrequency->setValue(m_histogramMarkers[m_histogramMarkerIndex].m_frequency); ui->powerMode->setCurrentIndex((int) m_histogramMarkers[m_histogramMarkerIndex].m_markerType); - float powerDB = CalcDb::dbPower(m_histogramMarkers[m_histogramMarkerIndex].m_power); + float powerDB = CalcDb::dbPower(m_histogramMarkers[m_histogramMarkerIndex].m_power) + m_calibrationShiftdB; ui->fixedPower->setValue(powerDB*10); - ui->fixedPowerText->setText(QString::number(powerDB, 'f', 1)); int r,g,b,a; m_histogramMarkers[m_histogramMarkerIndex].m_markerColor.getRgb(&r, &g, &b, &a); ui->markerColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b)); @@ -304,14 +306,13 @@ void SpectrumMarkersDialog::on_showMarker_clicked(bool clicked) m_histogramMarkers[m_histogramMarkerIndex].m_show = clicked; } -void SpectrumMarkersDialog::on_fixedPower_valueChanged(int value) +void SpectrumMarkersDialog::on_fixedPower_changed(qint64 value) { if (m_histogramMarkers.size() == 0) { return; } - float powerDB = value / 10.0f; - ui->fixedPowerText->setText(QString::number(powerDB, 'f', 1)); + float powerDB = (value / 10.0f) - m_calibrationShiftdB; m_histogramMarkers[m_histogramMarkerIndex].m_power = CalcDb::powerFromdB(powerDB); emit updateHistogram(); } diff --git a/sdrgui/gui/spectrummarkersdialog.h b/sdrgui/gui/spectrummarkersdialog.h index 6da8d6413..e3872f98d 100644 --- a/sdrgui/gui/spectrummarkersdialog.h +++ b/sdrgui/gui/spectrummarkersdialog.h @@ -39,6 +39,7 @@ public: QList& waterfallMarkers, QList& annotationMarkers, SpectrumSettings::MarkersDisplay& markersDisplay, + float calibrationShiftdB, QWidget* parent = nullptr ); ~SpectrumMarkersDialog(); @@ -52,6 +53,7 @@ private: QList& m_waterfallMarkers; QList& m_annotationMarkers; SpectrumSettings::MarkersDisplay& m_markersDisplay; + float m_calibrationShiftdB; int m_histogramMarkerIndex; int m_waterfallMarkerIndex; int m_annotationMarkerIndex; @@ -71,7 +73,7 @@ private slots: void on_centerFrequency_clicked(); void on_markerColor_clicked(); void on_showMarker_clicked(bool clicked); - void on_fixedPower_valueChanged(int value); + void on_fixedPower_changed(qint64 value); void on_marker_valueChanged(int value); void on_setReference_clicked(); void on_markerAdd_clicked(); diff --git a/sdrgui/gui/spectrummarkersdialog.ui b/sdrgui/gui/spectrummarkersdialog.ui index 1f3b1fc5b..366cf5cd9 100644 --- a/sdrgui/gui/spectrummarkersdialog.ui +++ b/sdrgui/gui/spectrummarkersdialog.ui @@ -431,26 +431,38 @@ - + + + + 0 + 0 + + + + + 32 + 16 + + + + + DejaVu Sans Mono + 12 + + + + PointingHandCursor + + + Qt::StrongFocus + Fixed power (dB) - - -1500 - - - 1500 - - - 1 - - - Qt::Horizontal - - + 32 @@ -458,10 +470,10 @@ - -100.0 + dB - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter diff --git a/sdrgui/spectrumcalibration.md b/sdrgui/spectrumcalibration.md new file mode 100644 index 000000000..3c4171b4c --- /dev/null +++ b/sdrgui/spectrumcalibration.md @@ -0,0 +1,101 @@ +

Spectrum calibration management

+ +The spectrum calibration is controlled by this dialog. It manages the list of calibration points (calibration chart), genaral options and the import/export from/to a .csv file. + +This calibration is an artifact of the spectrum display it does not make any change in the actual levels in the DSP processing. It assumes nothing about the receiving or transmitting chains it is up to the user to run the calibration procedure to make the face power levels match the desired levels. If anything is changed in the receiving or transmitting parameters then the calibration procedure may have to be re-run again. Also it assumes nothing about the units of the calibrated power. Normally one would like to make dBm (or mW) measurements but it is up to the user to assume the actual units. One may want to use dBW or any other custom units therefore the displayed calibrated values will remain unit-less (dB). + +For frequencies between calibration points the shift from relative value to displayed calibration value is interpolated using the next closest calibration points. If only one calibration point is provided then it applies regardless of frequency. The retained frequency for calculation is the center frequency of the spectrum and the shift applied is constant over the spectrum span. When no calibration points are provided turning on calibration correction has no effect. + +

Interface description

+ +![Spectrum calibration dialog](../doc/img/Spectrum_Calibration_dialog.png) + +

1. Select point

+ +Use the rotating button to select the point to edit + +

2. Add/Delete point

+ +Click on the "+" button to add a new point and "-" to remove the current point. + +

3. Relative power

+ +Enter the relative power in dB. This is the power displayed without calibration at this frequency point. + +

4. Calibrated power

+ +Enter the calibrated power in dB. This is the power displayed with calibration at this frequency point. + +

5. Point frequency

+ +This is the frequency of the calibration point + +

6. Point controls

+ +![Spectrum calibration buttons](../doc/img/Spectrum_Calibration_buttons.png) + +

6.1. Sort points

+ +Sort points by increasing frequency + +

6.2. Duplicate point

+ +Append a new point to the list as a copy of the current point. The editor is automatically transferred to the new point. + +

6.3. Import from spectrum marker

+ +Import data (frequency and relative power) from the first histogram marker (marker 0) if it exists. If there are no histogram markers this just does nothing. + +

6.4. Set frequency to center

+ +Sets the point frequency to the center frequency of the spectrum + +

7. Interpolation method

+ +The calibration shift between calibration points is interpolated based on the relative distance in frequency between points. The applied calibration shift is interpolated from the shift of the neighboring points. The interpolation can be: + + - **Linear**: interpolation is linear in terms of power + - **Log**: interpolation is logarithmic in terms of power or linear if the power is expressed in dB + +

8. Apply correction or set value

+ +This button lets you choose how the constant power next (9) is applied to all points + + - **Cor**: applies a correction i.e. the value in (9) is added (in dB) to all points + - **Set**: sets power of all point to the value in (9) + +The correction allows to take roughly into account the reception or transmission gain changes. It is like applying a constant gain over all frequencies. + +You may apply correction to either the relative powers or the calibrated powers. The choice depends on whether you are in a reception or transmission chain (source or sink device set respectively). + +In reception you would apply it to the relative powers as the input power that you measure for calibration remains the same. + +In transmission you would apply it to the calibrated powers as the output power that you measure for calibration actually changes. + +

9. Constant power value in dB

+ +This value is used to set all points to or to be applied as a correction depending on (8). It is used for relative powers (10) or calibrated powers (11) + +

10. Set or apply correction to relative powers

+ +All relative power values are set to value in (9) if "Set" is selected in (8). + +The value in (9) is added (in dB) to all relative power values if "Cor" is selected in (8) + +

11. Set or apply correction to calibrated powers

+ +All calibrated power values are set to value in (9) if "Set" is selected in (8). + +The value in (9) is added (in dB) to all calibrated power values if "Cor" is selected in (8) + +

12. Export calibrated points to .csv

+ +Export the calibrated points to a .csv file. Colums are: + + - **Frequency**: frequency in Hz of the point + - **Relative**: relative power in dB + - **Calibrated**: calibrated power in dB + +

13. Import calibrated points from .csv file

+ +Import the calibrated points from a .csv file in the format described above. diff --git a/swagger/sdrangel/api/swagger/include/GLSpectrum.yaml b/swagger/sdrangel/api/swagger/include/GLSpectrum.yaml index 2a2f6666b..7e003fbfa 100644 --- a/swagger/sdrangel/api/swagger/include/GLSpectrum.yaml +++ b/swagger/sdrangel/api/swagger/include/GLSpectrum.yaml @@ -163,6 +163,12 @@ GLSpectrum: useCalibration: type: integer description: boolean + calibrationInterpMode: + type: integer + description: > + Interpolation scheme between points SpectrumSettings::CalibrationInterpolationMode + * 0 - Linear + * 1 - Log (dB linear) histogramMarkers: type: array items: diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index 1f4433d50..3b0b113d2 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -6159,6 +6159,10 @@ margin-bottom: 20px; "type" : "integer", "description" : "boolean" }, + "calibrationInterpMode" : { + "type" : "integer", + "description" : "Interpolation scheme between points SpectrumSettings::CalibrationInterpolationMode\n * 0 - Linear\n * 1 - Log (dB linear)\n" + }, "histogramMarkers" : { "type" : "array", "items" : { @@ -52000,7 +52004,7 @@ except ApiException as e:
- Generated 2022-01-30T07:47:20.311+01:00 + Generated 2022-02-05T07:11:11.381+01:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp index fe11e43be..d7ca38957 100644 --- a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp @@ -84,6 +84,8 @@ SWGGLSpectrum::SWGGLSpectrum() { m_markers_display_isSet = false; use_calibration = 0; m_use_calibration_isSet = false; + calibration_interp_mode = 0; + m_calibration_interp_mode_isSet = false; histogram_markers = nullptr; m_histogram_markers_isSet = false; waterfall_markers = nullptr; @@ -156,6 +158,8 @@ SWGGLSpectrum::init() { m_markers_display_isSet = false; use_calibration = 0; m_use_calibration_isSet = false; + calibration_interp_mode = 0; + m_calibration_interp_mode_isSet = false; histogram_markers = new QList(); m_histogram_markers_isSet = false; waterfall_markers = new QList(); @@ -198,6 +202,7 @@ SWGGLSpectrum::cleanup() { + if(histogram_markers != nullptr) { auto arr = histogram_markers; for(auto o: *arr) { @@ -295,6 +300,8 @@ SWGGLSpectrum::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&use_calibration, pJson["useCalibration"], "qint32", ""); + ::SWGSDRangel::setValue(&calibration_interp_mode, pJson["calibrationInterpMode"], "qint32", ""); + ::SWGSDRangel::setValue(&histogram_markers, pJson["histogramMarkers"], "QList", "SWGSpectrumHistogramMarker"); @@ -403,6 +410,9 @@ SWGGLSpectrum::asJsonObject() { if(m_use_calibration_isSet){ obj->insert("useCalibration", QJsonValue(use_calibration)); } + if(m_calibration_interp_mode_isSet){ + obj->insert("calibrationInterpMode", QJsonValue(calibration_interp_mode)); + } if(histogram_markers && histogram_markers->size() > 0){ toJsonArray((QList*)histogram_markers, obj, "histogramMarkers", "SWGSpectrumHistogramMarker"); } @@ -699,6 +709,16 @@ SWGGLSpectrum::setUseCalibration(qint32 use_calibration) { this->m_use_calibration_isSet = true; } +qint32 +SWGGLSpectrum::getCalibrationInterpMode() { + return calibration_interp_mode; +} +void +SWGGLSpectrum::setCalibrationInterpMode(qint32 calibration_interp_mode) { + this->calibration_interp_mode = calibration_interp_mode; + this->m_calibration_interp_mode_isSet = true; +} + QList* SWGGLSpectrum::getHistogramMarkers() { return histogram_markers; @@ -828,6 +848,9 @@ SWGGLSpectrum::isSet(){ if(m_use_calibration_isSet){ isObjectUpdated = true; break; } + if(m_calibration_interp_mode_isSet){ + isObjectUpdated = true; break; + } if(histogram_markers && (histogram_markers->size() > 0)){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h index 5d60364e7..51ecd32e6 100644 --- a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h +++ b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h @@ -131,6 +131,9 @@ public: qint32 getUseCalibration(); void setUseCalibration(qint32 use_calibration); + qint32 getCalibrationInterpMode(); + void setCalibrationInterpMode(qint32 calibration_interp_mode); + QList* getHistogramMarkers(); void setHistogramMarkers(QList* histogram_markers); @@ -231,6 +234,9 @@ private: qint32 use_calibration; bool m_use_calibration_isSet; + qint32 calibration_interp_mode; + bool m_calibration_interp_mode_isSet; + QList* histogram_markers; bool m_histogram_markers_isSet;