Calculate -60 dB points if not found (Analysis)

Allow resizing of popped out square charts
Shortcuts to start (CTRL+W) and stop (ESC) sweeps
pull/44/head
Rune B. Broberg 2019-10-14 19:14:10 +02:00
rodzic a745fede33
commit 8b69cf2979
3 zmienionych plików z 53 dodań i 35 usunięć

Wyświetl plik

@ -199,11 +199,12 @@ class LowPassAnalysis(Analysis):
if sixty_db_location > 0:
sixty_db_cutoff_frequency = self.app.data21[sixty_db_location].freq
self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency))
elif ten_db_location != -1 and twenty_db_location != -1:
ten = self.app.data21[ten_db_location].freq
twenty = self.app.data21[twenty_db_location].freq
sixty_db_frequency = ten * 10 ** (5 * (math.log10(twenty) - math.log10(ten)))
self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_frequency) + " (derived)")
else:
# # We derive 60 dB instead
# factor = 10 * (-54 / decade_attenuation)
# sixty_db_cutoff_frequency = round(six_db_cutoff_frequency + six_db_cutoff_frequency * factor)
# self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency) + " (derived)")
self.sixty_db_label.setText("Not calculated")
if ten_db_location > 0 and twenty_db_location > 0 and ten_db_location != twenty_db_location:
@ -358,14 +359,16 @@ class HighPassAnalysis(Analysis):
break
if sixty_db_location > 0:
sixty_db_cutoff_frequency = self.app.data21[sixty_db_location].freq
self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency))
else:
# # We derive 60 dB instead
# factor = 10 * (-54 / decade_attenuation)
# sixty_db_cutoff_frequency = round(six_db_cutoff_frequency + six_db_cutoff_frequency * factor)
# self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency) + " (derived)")
self.sixty_db_label.setText("Not calculated")
if sixty_db_location > 0:
sixty_db_cutoff_frequency = self.app.data21[sixty_db_location].freq
self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency))
elif ten_db_location != -1 and twenty_db_location != -1:
ten = self.app.data21[ten_db_location].freq
twenty = self.app.data21[twenty_db_location].freq
sixty_db_frequency = ten * 10 ** (5 * (math.log10(twenty) - math.log10(ten)))
self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_frequency) + " (derived)")
else:
self.sixty_db_label.setText("Not calculated")
if ten_db_location > 0 and twenty_db_location > 0 and ten_db_location != twenty_db_location:
octave_attenuation, decade_attenuation = self.calculateRolloff(ten_db_location, twenty_db_location)
@ -610,14 +613,16 @@ class BandPassAnalysis(Analysis):
break
if sixty_db_location > 0:
sixty_db_cutoff_frequency = self.app.data21[sixty_db_location].freq
self.lower_sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency))
else:
# # We derive 60 dB instead
# factor = 10 * (-54 / decade_attenuation)
# sixty_db_cutoff_frequency = round(six_db_cutoff_frequency + six_db_cutoff_frequency * factor)
# self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency) + " (derived)")
self.lower_sixty_db_label.setText("Not calculated")
if sixty_db_location > 0:
sixty_db_cutoff_frequency = self.app.data21[sixty_db_location].freq
self.lower_sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency))
elif ten_db_location != -1 and twenty_db_location != -1:
ten = self.app.data21[ten_db_location].freq
twenty = self.app.data21[twenty_db_location].freq
sixty_db_frequency = ten * 10 ** (5 * (math.log10(twenty) - math.log10(ten)))
self.lower_sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_frequency) + " (derived)")
else:
self.lower_sixty_db_label.setText("Not calculated")
if ten_db_location > 0 and twenty_db_location > 0 and ten_db_location != twenty_db_location:
octave_attenuation, decade_attenuation = self.calculateRolloff(ten_db_location, twenty_db_location)
@ -674,11 +679,12 @@ class BandPassAnalysis(Analysis):
if sixty_db_location > 0:
sixty_db_cutoff_frequency = self.app.data21[sixty_db_location].freq
self.upper_sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency))
elif ten_db_location != -1 and twenty_db_location != -1:
ten = self.app.data21[ten_db_location].freq
twenty = self.app.data21[twenty_db_location].freq
sixty_db_frequency = ten * 10 ** (5 * (math.log10(twenty) - math.log10(ten)))
self.upper_sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_frequency) + " (derived)")
else:
# # We derive 60 dB instead
# factor = 10 * (-54 / decade_attenuation)
# sixty_db_cutoff_frequency = round(six_db_cutoff_frequency + six_db_cutoff_frequency * factor)
# self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency) + " (derived)")
self.upper_sixty_db_label.setText("Not calculated")
if ten_db_location > 0 and twenty_db_location > 0 and ten_db_location != twenty_db_location:
@ -885,11 +891,12 @@ class BandStopAnalysis(Analysis):
if sixty_db_location > 0:
sixty_db_cutoff_frequency = self.app.data21[sixty_db_location].freq
self.lower_sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency))
elif ten_db_location != -1 and twenty_db_location != -1:
ten = self.app.data21[ten_db_location].freq
twenty = self.app.data21[twenty_db_location].freq
sixty_db_frequency = ten * 10 ** (5 * (math.log10(twenty) - math.log10(ten)))
self.lower_sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_frequency) + " (derived)")
else:
# # We derive 60 dB instead
# factor = 10 * (-54 / decade_attenuation)
# sixty_db_cutoff_frequency = round(six_db_cutoff_frequency + six_db_cutoff_frequency * factor)
# self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency) + " (derived)")
self.lower_sixty_db_label.setText("Not calculated")
if ten_db_location > 0 and twenty_db_location > 0 and ten_db_location != twenty_db_location:
@ -947,11 +954,12 @@ class BandStopAnalysis(Analysis):
if sixty_db_location > 0:
sixty_db_cutoff_frequency = self.app.data21[sixty_db_location].freq
self.upper_sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency))
elif ten_db_location != -1 and twenty_db_location != -1:
ten = self.app.data21[ten_db_location].freq
twenty = self.app.data21[twenty_db_location].freq
sixty_db_frequency = ten * 10 ** (5 * (math.log10(twenty) - math.log10(ten)))
self.upper_sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_frequency) + " (derived)")
else:
# # We derive 60 dB instead
# factor = 10 * (-54 / decade_attenuation)
# sixty_db_cutoff_frequency = round(six_db_cutoff_frequency + six_db_cutoff_frequency * factor)
# self.sixty_db_label.setText(NanoVNASaver.formatFrequency(sixty_db_cutoff_frequency) + " (derived)")
self.upper_sixty_db_label.setText("Not calculated")
if ten_db_location > 0 and twenty_db_location > 0 and ten_db_location != twenty_db_location:

Wyświetl plik

@ -50,6 +50,7 @@ class Chart(QtWidgets.QWidget):
minChartHeight = 200
minChartWidth = 200
isPopout = False
popoutRequested = pyqtSignal(object)
def __init__(self, name):
@ -592,11 +593,17 @@ class SquareChart(Chart):
super().__init__(name)
sizepolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.MinimumExpanding)
self.setSizePolicy(sizepolicy)
self.chartWidth = self.width()-40
self.chartHeight = self.height()-40
def resizeEvent(self, a0: QtGui.QResizeEvent) -> None:
self.setFixedWidth(a0.size().height())
self.chartWidth = a0.size().height()-40
self.chartHeight = a0.size().height()-40
if not self.isPopout:
self.setFixedWidth(a0.size().height())
self.chartWidth = a0.size().height()-40
self.chartHeight = a0.size().height()-40
else:
min_dimension = min(a0.size().height(), a0.size().width())
self.chartWidth = self.chartHeight = min_dimension - 40
self.update()

Wyświetl plik

@ -238,8 +238,10 @@ class NanoVNASaver(QtWidgets.QWidget):
self.btnSweep = QtWidgets.QPushButton("Sweep")
self.btnSweep.clicked.connect(self.sweep)
self.btnSweep.setShortcut(QtCore.Qt.Key_W | QtCore.Qt.CTRL)
self.btnStopSweep = QtWidgets.QPushButton("Stop")
self.btnStopSweep.clicked.connect(self.stopSweep)
self.btnStopSweep.setShortcut(QtCore.Qt.Key_Escape)
self.btnStopSweep.setDisabled(True)
btn_layout = QtWidgets.QHBoxLayout()
btn_layout.addWidget(self.btnSweep)
@ -1007,6 +1009,7 @@ class NanoVNASaver(QtWidgets.QWidget):
def popoutChart(self, chart: Chart):
logger.debug("Requested popout for chart: %s", chart.name)
new_chart = self.copyChart(chart)
new_chart.isPopout = True
new_chart.show()
new_chart.setWindowTitle(new_chart.name)