jfjoch_viewer: FFT frequency axis 1000x too low
DiffractionExperiment::GetImageTime() returns std::chrono::nanoseconds, but the chart stored its count() as microseconds, so the sampling frequency came out 1000x too small (a 6 ms image time gave a Nyquist of ~0.08 Hz instead of ~83 Hz). Keep the image time in seconds via duration<double>. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c8e2e6ef56
commit
a7a60eb128
2 files changed
+6
-6
No files matched your search
@@ -184,10 +184,10 @@ void JFJochDatasetInfoChartView::loadValues(const std::vector<float> &input, int
|
||||
|
||||
if (dataset != nullptr) {
|
||||
goniometer_axis = dataset->experiment.GetGoniometer();
|
||||
image_time_us = dataset->experiment.GetImageTime().count();
|
||||
image_time_s = std::chrono::duration<double>(dataset->experiment.GetImageTime()).count();
|
||||
} else {
|
||||
goniometer_axis = {};
|
||||
image_time_us = {};
|
||||
image_time_s = {};
|
||||
}
|
||||
|
||||
curr_image = image;
|
||||
@@ -711,7 +711,7 @@ void JFJochDatasetInfoChartView::contextMenuEvent(QContextMenuEvent *event) {
|
||||
actShowFFT->setCheckable(true);
|
||||
actShowFFT->setChecked(m_showFFT);
|
||||
// Require valid sampling interval
|
||||
actShowFFT->setEnabled(!values.empty() && image_time_us > 0.0);
|
||||
actShowFFT->setEnabled(!values.empty() && image_time_s > 0.0);
|
||||
#endif
|
||||
|
||||
QAction *chosen = menu.exec(event->globalPos());
|
||||
@@ -961,7 +961,7 @@ void JFJochDatasetInfoChartView::onHoverLoadTimeout() {
|
||||
void JFJochDatasetInfoChartView::buildFFTChart() {
|
||||
const size_t N = values.size();
|
||||
|
||||
if (N == 0 || !image_time_us.has_value() || image_time_us <= 0.0) {
|
||||
if (N == 0 || !image_time_s.has_value() || image_time_s <= 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1001,7 +1001,7 @@ void JFJochDatasetInfoChartView::buildFFTChart() {
|
||||
m_fftMagnitudes.resize(static_cast<size_t>(nComplex));
|
||||
m_fftFrequenciesHz.resize(static_cast<size_t>(nComplex));
|
||||
|
||||
const double dt = image_time_us.value() * 1e-6; // seconds per sample
|
||||
const double dt = image_time_s.value(); // seconds per sample
|
||||
const double fs = 1.0 / dt; // sampling frequency
|
||||
const double df = fs / static_cast<double>(n); // frequency resolution
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class JFJochDatasetInfoChartView : public QChartView {
|
||||
void setHoverLineY(double y, double snap_to_y);
|
||||
|
||||
std::optional<GoniometerAxis> goniometer_axis;
|
||||
std::optional<float> image_time_us;
|
||||
std::optional<double> image_time_s;
|
||||
|
||||
void updateChart();
|
||||
|
||||
|
||||
Reference in new issue
Block a user