Ft
Ft is the implicitly shared value type that holds a Fourier-transform magnitude spectrum
produced by FtWorker. Like Fid, it uses QSharedDataPointer
so that copies are cheap and a deep copy occurs only when a mutating call is made while
the data is shared.
An Ft stores a QVector<double> of uniformly-spaced magnitude values together with the
frequency-axis metadata needed to reconstruct absolute frequencies: the starting frequency
x0 (MHz), the bin spacing (MHz), and the local-oscillator frequency (MHz).
The absolute frequency of bin i is xFirst() + i * xSpacing(). The spectrum always
runs from low to high frequency in memory, regardless of which sideband the source Fid
used; FtWorker reorders the bins during FFT output so that xFirst() returns
the lowest spectral frequency. The trim(fmin, fmax) method discards out-of-range bins
and updates x0 accordingly, which is used by the sideband co-averaging path to extract
the relevant portion of each per-LO-step spectrum before stitching.
Ft objects are passed as the first argument of the FtWorker::ftDone() signal and
returned directly from FtWorker::doFT(). The FTMW data-viewing widget
(FtmwViewWidget) receives them, updates the frequency-domain plot curves, and passes them
to the peak-finder and overlay system. The user-facing controls that govern FID preprocessing
and spectrum display are described in FTMW Configuration.
API Reference
-
class Ft
Implicitly shared value type that stores a Fourier-transform magnitude spectrum.
Ftholds a uniformly-spaced vector of magnitude values (produced byFtWorker::doFT), together with the frequency axis metadata needed to reconstruct absolute frequency coordinates: the starting frequencyx0(MHz), the uniform spacing (MHz/bin), and the local-oscillator frequency (MHz) used to orient the sideband. The class also caches the minimum and maximum magnitude values so that plots can autoscale without scanning the entire data vector.Like
Fid,Ftuses Qt implicit sharing: copying is cheap and a deep copy occurs only when a mutating operation is called while the data is shared.Public Functions
-
Ft()
Default constructor; creates an empty spectrum with unit spacing and zero offset.
-
explicit Ft(int numPnts, double f0, double spacing, double loFreqMHz)
Constructs a spectrum with pre-allocated storage.
- Parameters:
numPnts – Number of frequency bins to allocate (all initialized to zero).
f0 – Frequency of the first bin in MHz.
spacing – Frequency spacing between consecutive bins in MHz.
loFreqMHz – Local-oscillator frequency used to mark the DC bin for autoScale exclusion (MHz).
-
Ft(const Ft &rhs)
Copy constructor (shallow; increments the shared reference count).
- Parameters:
rhs – Spectrum to copy.
-
Ft &operator=(const Ft &rhs)
Copy-assignment operator.
- Parameters:
rhs – Spectrum to copy.
- Returns:
Reference to this spectrum after assignment.
-
~Ft()
Destructor.
-
void setPoint(int i, double y, double ignoreRange = 0.0)
Sets the magnitude at the specified bin and updates the cached min/max.
If ignoreRange is greater than zero, bins whose frequency falls within ignoreRange MHz of the LO frequency are excluded from the min/max update. This prevents the DC spike from inflating the autoscale range.
- Parameters:
i – Bin index.
y – Magnitude value.
ignoreRange – Frequency half-width (MHz) around the LO to exclude from autoscale tracking.
-
void resize(int n, double ignoreRange = 0.0)
Resizes the data vector and recomputes the cached min/max from the current contents.
- Parameters:
n – New size in bins.
ignoreRange – Frequency half-width (MHz) around the LO to exclude from min/max tracking.
-
double &operator[](int i)
Returns a writable reference to the magnitude at bin i (no min/max update).
- Parameters:
i – Bin index.
- Returns:
Reference to the magnitude value.
-
void reserve(int n)
Reserves storage for at least n bins without changing the logical size.
- Parameters:
n – Number of bins to reserve.
-
void squeeze()
Releases excess capacity in the internal data vector.
-
void setLoFreq(double f)
Sets the local-oscillator reference frequency.
- Parameters:
f – LO frequency in MHz.
-
void setX0(double d)
Sets the frequency of the first bin.
- Parameters:
d – Starting frequency in MHz.
-
void setSpacing(double s)
Sets the frequency spacing between consecutive bins.
- Parameters:
s – Spacing in MHz per bin.
-
void append(double y)
Appends a magnitude value to the end of the spectrum and updates the cached min/max.
- Parameters:
y – Magnitude value to append.
-
void trim(double fmin, double fmax)
Trims the spectrum to the frequency range [fmin, fmax].
Bins outside the range are discarded and the starting frequency
x0is updated to the frequency of the first retained bin. The cached min/max is recomputed from the retained bins.- Parameters:
fmin – Minimum frequency to retain (MHz).
fmax – Maximum frequency to retain (MHz).
-
void setNumShots(quint64 shots)
Sets the number of co-averaged shots represented by this spectrum.
- Parameters:
shots – Shot count.
-
void setData(const QVector<double> d, double yMin, double yMax)
Replaces the data vector and sets the cached min/max explicitly.
Intended for bulk-load scenarios where the caller has already computed the extrema, avoiding an O(n) scan.
- Parameters:
d – New magnitude vector.
yMin – Pre-computed minimum magnitude.
yMax – Pre-computed maximum magnitude.
-
int size() const
Returns the number of frequency bins.
- Returns:
Bin count.
-
bool isEmpty() const
Returns
trueif the spectrum contains no bins.- Returns:
truewhen size() == 0.
-
double at(int i) const
Returns the magnitude at bin i (bounds-checked; aborts on out-of-range).
- Parameters:
i – Bin index.
- Returns:
Magnitude value.
-
double value(int i) const
Returns the magnitude at bin i, or 0.0 if out of range.
- Parameters:
i – Bin index (may be out of range).
- Returns:
Magnitude value, or 0.0.
-
double constFirst() const
Returns the magnitude of the first bin.
- Returns:
Magnitude of bin 0.
-
double constLast() const
Returns the magnitude of the last bin.
- Returns:
Magnitude of bin size()-1.
-
double xAt(int i) const
Returns the frequency of bin i.
- Parameters:
i – Bin index.
- Returns:
Frequency in MHz: x0 + i * spacing.
-
double xFirst() const
Returns the frequency of the first bin (same as x0).
- Returns:
Frequency in MHz.
-
double xLast() const
Returns the frequency of the last bin.
- Returns:
Frequency in MHz: x0 + (size()-1) * spacing.
-
std::pair<double, double> xRange() const
Returns the [min, max] frequency range of the spectrum as a sorted pair.
- Returns:
Pair where
first<=second, both in MHz.
-
double xSpacing() const
Returns the frequency spacing between consecutive bins.
- Returns:
Spacing in MHz per bin.
-
double minFreqMHz() const
Returns the lower edge of the spectrum’s frequency range.
-
double maxFreqMHz() const
Returns the upper edge of the spectrum’s frequency range.
-
double loFreqMHz() const
Returns the local-oscillator reference frequency.
- Returns:
LO frequency in MHz.
-
double yMin() const
Returns the cached minimum magnitude value.
The minimum is tracked incrementally by
setPoint()andappend()and recomputed byresize()andtrim(). Bins near the LO may be excluded depending on the ignoreRange argument passed tosetPoint().- Returns:
Minimum magnitude value.
-
double yMax() const
Returns the cached maximum magnitude value.
Tracked and recomputed alongside
yMin(). Use this for autoscaling plot axes.- Returns:
Maximum magnitude value.
-
QVector<double> xData() const
Builds a vector of frequency values, one per bin.
- Returns:
Vector of frequencies in MHz, indexed from 0 to size()-1.
-
QVector<double> yData() const
Returns a copy of the raw magnitude data vector.
- Returns:
Magnitude values indexed from 0 to size()-1.
-
QVector<QPointF> toVector() const
Builds a QVector of (frequency, magnitude) points suitable for plotting.
- Returns:
XY data vector with one point per bin.
-
quint64 shots() const
Returns the number of co-averaged shots represented by this spectrum.
- Returns:
Shot count set via
setNumShots().
Private Members
-
QSharedDataPointer<FtData> data
Internal implicitly-shared data storage.
-
Ft()