yadg.parsers.qftrace package

List of supported file formats:

Submodules

yadg.parsers.qftrace.fit module

Quality factor fitting routines.

List of supported quality factor fitting methods:

Kajfez’s method is the preferred one and hence set as default, with a cutoff set to 0.4.

yadg.parsers.qftrace.fit.kajfez(fvals, fsigs, gvals, absgvals, **kwargs)

Kajfez’s circle-fitting program.

Adapted from Q0REFL.m, which is a part of Kajfez, D.: “Linear fractional curve fitting for measurement of high Q factors”, IEEE Trans. Microwave Theory Techn. 42 (1994) 1149-1153.

This fitting process attempts to fit a circle to a near-circular section of points on a Smith’s chart. It’s robust, quick, and reliable, and produces reasonable error estimates.

Parameters
  • fvals (ndarray) – Nominal values of the frequencies

  • fsigs (ndarray) – Error values of the frequencies

  • gvals (ndarray) – Complex reflection coefficient values, \(\Gamma(f)\).

  • absgvals (ndarray) – Absolute values of the reflection coefficient, \(|\Gamma(f)|\)

Returns

(Q0, f0) – Fitted quality factor and central frequency of the data.

Return type

tuple[uc.ufloat, uc.ufloat]

yadg.parsers.qftrace.fit.lorentz(fvals, fsigs, gvals, absgvals, **kwargs)

Lorentz fit.

Fits a Lorentz function to the pruned data. The \(f_0 = x_0\), and the \(Q_0\) is calculated from \(x_0 / \Delta x = x_0 / (2\gamma)\).

  • This fit starts by fitting a Lorentzian curve in the form \(L(x) = a \frac{\gamma^2}{(x - x_0)^2 + \gamma^2} + c\) to the \(|\Gamma(f)|\) trace, obtaining four parameters (\(a, x_0, \gamma, c\)).

  • The central frequency \(f_0\) is simply \(x_0\).

  • The width of the Lorentzian is given by \(\Delta x = 2\gamma\).

  • The quality factor is determined using \(Q_0 = x_0 / \Delta x\)

  • Uncertainties of \(f_0\) and \(Q_0\) are calculated using the covariance matrix of the fit of \(L(x)\) to \(|\Gamma(f)|\).

Parameters
  • fvals (ndarray) – Nominal values of the frequencies

  • fsigs (ndarray) – Not used

  • gvals (ndarray) – Not used

  • absgvals (ndarray) – Absolute values of the reflection coefficient, \(|\Gamma(f)|\)

Returns

(Q0, f0) – Fitted quality factor and central frequency of the data.

Return type

tuple[uc.ufloat, uc.ufloat]

yadg.parsers.qftrace.fit.naive(fvals, fsigs, gvals, absgvals, **kwargs)

Naive fitting routine.

This fit finds the central frequency \(f_0\), determines the full-width at the half-maximum \(\Delta f_{HM}\) by linear interpolation, and calculates the quality factor using \(Q_0 = f_0 / \Delta f_{HM}\).

  • This fit first normalises the \(|\Gamma(f)|\) trace to values between 0 and 1.

  • The trace is flipped in this process, obtaining \(||\Gamma(f)||\).

  • The \(f_0\) is determined by finding the frequency corresponding to the minimum in \(|\Gamma(f)|\) (that is, the maximum of \(||\Gamma(f)||\)).

  • The full-width-half-maximum (\(\Delta f_{HM}\)) value of the peak is then determined using linear interpolation of the trace, by difference of the \(f\) at the two points where \(||\Gamma(f)|| = 0.5\).

  • Finally, the quality factor is calculated from \(Q_0 = f_0 / \Delta f_{HM}\).

Parameters
  • fvals (ndarray) – Nominal values of the frequencies

  • fsigs (ndarray) – Error values of the frequencies

  • gvals (ndarray) – Not used

  • absgvals (ndarray) – Absolute values of the reflection coefficient, \(|\Gamma(f)|\)

Returns

(Q0, f0) – Fitted quality factor and central frequency of the data.

Return type

tuple[uc.ufloat, uc.ufloat]

yadg.parsers.qftrace.labviewcsv module

File parser for the LabView CSV files generated using Agilent PNA-L N5320C.

This file format includes a header, with the values of bandwith and averaging, and three tab-separated columns containing the frequency \(f\), and the real and imaginary parts of the complex reflection coefficient \(\Gamma(f)\).

Timestamps are determined from file name. One trace per file. As the set-up for which this format was designed always uses the S11 port, the name of the trace is hard-coded to this value.

yadg.parsers.qftrace.labviewcsv.process(fn, encoding='utf-8', timezone='timezone')

VNA reflection trace parser.

Parameters
  • fn (str) – File to process

  • encoding (str) – Encoding of fn, by default “utf-8”.

  • timezone (str) – A string description of the timezone. Default is “localtime”.

Returns

(data, metadata) – Tuple containing the timesteps, metadata, and common data.

Return type

tuple[list, None]

yadg.parsers.qftrace.main module

yadg.parsers.qftrace.main.process(fn, encoding='utf-8', timezone='timezone', tracetype='labview.csv', method='kajfez', height=1.0, distance=5000.0, cutoff=0.4, threshold=1e-06)

VNA reflection trace parser.

This parser processes a VNA log file, containing the complex reflection coefficient data as a function of frequency (\(\Gamma(f)\)). This data is automatically worked up to produce the quality factor \(Q_0\) and the central frequency \(f_0\) of all peaks found in each trace; hence the name qftrace.

Parameters
  • fn (str) – File to process

  • encoding (str) – Encoding of fn, by default “utf-8”.

  • timezone (str) – A string description of the timezone. Default is “localtime”.

  • method (str) – Method used for fitting \(Q_0\) and \(f_0\) to \(\Gamma(f)\) data. One of "naive", "lorentz", or "kajfez". Default is "kajfez".

  • cutoff (float) – Parameter passed to the cutoff-based pruning routine, defining the cutoff threshold for the normalisation. Default is 0.4.

  • threshold (float) – Parameter passed to the gradient-based pruning routine, defining the minimum gradient below which the trace gets pruned. Default is 1e-6.

  • height (float) – Parameter for the peak-picker.

  • distance (float) – Parameter for the peak-picker.

Returns

(data, metadata, fulldate) – Tuple containing the timesteps, metadata, and full date tag. The currently only supported tracetype (“labview.csv”) does not return full date.

Return type

tuple[list, dict, bool]

yadg.parsers.qftrace.prune module

Trace-pruning routines.

To reduce the impact of baseline noise and speed up the fitting of \(Q_0\) to the \(\Gamma(f)\) trace, only smaller sections of the trace are retained around each minimum. Two routines for trace-pruning are provided:

yadg.parsers.qftrace.prune.cutoff(p0, absgamma, cutoff)

Cutoff-based prune.

Parameters
  • p0 (int) – Index of the minimum of absgamma.

  • absgamma (ndarray) – The \(|\Gamma(f)|\) data.

  • cutoff (float) – Normalised height above which the trace is cut off.

Returns

A tuple of the left and right index of the trimmed trace.

Return type

tuple[int, int]

yadg.parsers.qftrace.prune.gradient(p0, absgamma, threshold)

Gradient-based prune.

Parameters
  • p0 (int) – Index of the minimum of absgamma.

  • absgamma (ndarray) – The \(|\Gamma(f)|\) data.

  • threshold (float) – Threshold of the gradient below which the trace is cut off.

Returns

A tuple of the left and right index of the trimmed trace.

Return type

tuple[int, int]