HARMINV(1)

πŸ“¦
version 1.4.2 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ¦‹ NAME πŸ¦‹

harminv β€” the lil program that yanks mode frequencies out of your time-series data, no cap πŸ’…


✨ SYNOPSIS ✨

harminv [OPTION]... [freq-min-freq-max]...

πŸ’– DESCRIPTION πŸ’–

okay so bestie, harminv exists to solve the whole "harmonic inversion" situation: you hand it a time series that's literally just a sum of sinusoids (we call those "modes"), and it pulls out their frequencies and amplitudes. and it can ALSO handle the case where those sinusoids are exponentially decaying, in which case it hands you their decay rates too. iconic behavior honestly 🫢

the way that harminv eats is that it can often hit much greater accuracy and robustness than Fourier-transform methods, basically because it assumes a specific form for the input. it's giving "I know what you are" energy 😌

it uses a low-storage "filter-diagonalization method" (FDM), as described in V. A. Mandelshtam and H. S. Taylor, "Harmonic inversion of time signals," J. Chem. Phys. 107, 6756 (1997). See also erratum, ibid 109, 4128 (1998). πŸ“šβœ¨


🌸 INPUT 🌸

harminv reads in a sequence of whitespace-separated real or complex numbers from standard input, plus command-line arguments indicating one or more frequency ranges to search, and then it outputs the modes it extracts from the data. (it preferentially finds modes in the frequency range you specify, but ngl it may sometimes find additional modes outside of that range. it's just like that πŸ™ˆ) the data should correspond to equally-spaced time intervals, but there is no constraint on the number of points β€” bring as many as you want, queen πŸ‘‘

complex numbers in the input should be expressed in the format RE+IMi (no whitespace, pls and thank u). otherwise, whitespace is ignored. also, comments beginning with # and extending to the end of the line are ignored. so go ahead and annotate, it's fine πŸ’œ

a typical invocation is something like

harminv -t 0.02 1-5 < input.dat

which reads a sequence of samples, spaced at 0.02 time intervals (in ms, say, corresponding to 50 kHz), and searches for modes in the frequency range 1-5 kHz. (see below on units β€” it matters, bestie πŸŽ€)


πŸ‘‘ OUTPUT πŸ‘‘

harminv writes six comma-delimited columns to standard output, one line for each mode: frequency, decay constant, Q, amplitude, phase, and error. each mode corresponds to a function of the form:

amplitude * exp[-i (2 pi frequency t - phase) - decay t]

here, i is sqrt(-1), t is the time (see below for units), and the other parameters in the output columns are:

  • frequency β€” the frequency of the mode. if you don't recognize that from the expression above, you should recall Euler's formula: exp(i x) = cos(x) + i sin(x). note that for complex data, there is a distinction between positive and negative frequencies. both are valid, both are real πŸ’…
  • decay constant β€” the exponential decay constant, indicated by decay in the above formula. the inverse of this is often called the "lifetime" of the mode. the "half-life" is ln(2)/decay.
  • Q β€” a conventional, dimensionless expression of the decay lifetime: Q = pi |frequency| / decay. Q, which stands for "quality factor", is the number of periods for the "energy" in the mode (the squared amplitude) to decay by exp(-2 pi). equivalently, if you look at the power spectrum (|Fourier transform|^2), 1/Q is the fractional width of the peak at half maximum. math girlies rise up ⭐
  • amplitude β€” the (real, positive) amplitude of the sinusoids. lowkey the amplitude (and phase) information generally seems to be less accurate than the frequency and decay constant, so don't come for it too hard 😭
  • phase β€” the phase shift (in radians) of the sinusoids, as given by the formula above.
  • error β€” a crude estimate of the relative error in the (complex) frequency. this is not really an error bar, however, so you should treat it more as a figure of merit (smaller is better) for each mode. it's a vibe check, not a measurement 🧚

πŸ’€ SPURIOUS MODES πŸ’€

typically, harminv will find a number of spurious solutions in addition to the desired solutions, especially if your data are noisy. such solutions are characterized by large errors, small amplitudes, and/or small Q (large decay rates / broad linewidths). you can omit these from the output by the error/Q/amplitude screening options defined below β€” they're your block list, use them 🚫

by default, modes with error > 0.1 and Q < 10 are automatically omitted, but it is likely that you will need to set stricter limits. yes bestie, you're gonna have to be the one to gatekeep πŸ”₯


🌈 UNITS 🌈

the frequency (and decay) values, both input and output, are specified in units of 1/time, where the units of time are determined by the sampling interval dt (the time between consecutive inputs). dt is by default 1, unless you specify it with the -t dt option.

in other words, pick some units (e.g. ms in the example above) and use them to express the time step. then, be consistent and use the inverse of those units (e.g. kHz = 1/ms) for frequency. consistency is the whole plot, ok?

note that the frequency is the usual 1/period definition; it is not the angular frequency. don't mix them up, i'm begging πŸ™


✨ OPTIONS ✨

  • -h β€” display help on the command-line options and usage. the classic cry-for-help flag 🫢
  • -V β€” print the version number and copyright info for harminv.
  • -v β€” enable verbose output, printed to standard output as comment lines (starting with a # character). also, any # comments in the input are echoed to the output. it's chatty, we love that for it πŸ’¬
  • -T β€” specify period-ranges instead of frequency-ranges on the command line (in units of time corresponding to those specified by -t). the output is still frequency and not period, however. sneaky but fine 😌
  • -w β€” specify angular frequencies instead of frequencies, and output angular frequency instead of frequency. (angular frequency is frequency multiplied by 2 pi).
  • -n β€” flip the sign of the frequency (and phase) convention used in harminv. (the sign of the frequency is only important if you have complex-valued input data, in which case the positive and negative frequency amplitudes can differ.)
  • -t dt β€” specify the sampling interval dt; this determines the units of time used throughout the input and output. defaults to 1.0.
  • -d d β€” specify the spectral "density" d to search for modes, where a density of 1 indicates the usual Fourier resolution. that is, the number of basis functions (which sets an upper bound on the number of modes) is given by d times (freq-max - freq-min) times dt times the number of samples in your dataset. a maximum of 300 is used, however, to prevent the matrices from getting too big (you can force a larger number with -f, below). 🫣

note that the frequency resolution of the outputs is not limited by the spectral density, and can generally be much greater than the Fourier resolution. the density determines how many modes, at most, to search for, and in some sense is the density with which the bandwidth is initially "searched" for modes.

the default density is 0.0, which means that the number of basis functions is determined by -f (which defaults to 100). this often corresponds to a much larger density than the usual Fourier resolution, but the resulting singularities in the system matrices are automatically removed by harminv. slay, self-cleaning πŸ’…

  • -f nf β€” specify a lower bound nf on the number of spectral basis functions (defaults to 100), setting a lower bound on the number of modes to search for. this option is often a more convenient way to specify the number of basis functions than the -d option, above, which is why it is the default.

-f also allows you to employ more than 300 basis functions, but careful: the computation time scales as O(N nf) + O(nf^3), where N is the number of samples, and very large matrices can also have degraded accuracy. it's giving "with great power" 😭

  • -s sort β€” specify how the outputs are sorted, where sort is one of frequency/error/Q/decay/amplitude. (only the first character of sort matters.) all sorts are in ascending order. the default is to sort by frequency. a little organization never hurt nobody ✨
  • -e err β€” omit any modes with error (see above) greater than err times the largest error among the computed modes. defaults to no limit.
  • -E err β€” omit any modes with error (see above) greater than err. defaults to 0.1.
  • -F β€” omit any modes with frequencies outside the specified range. (such modes are not necessarily spurious, however. so like, watch out πŸ™ˆ)
  • -a amp β€” omit any modes with amplitude (see above) less than amp times the largest amplitude among the computed modes. defaults to no limit.
  • -A amp β€” omit any modes with amplitude (see above) less than amp. defaults to no limit.
  • -Q q β€” omit any modes with |Q| (see above) less than q. defaults to 10.

πŸ› BUGS πŸ›

send bug reports to S. G. Johnson, stevenj@alum.mit.edu. he wants to hear from you, fr fr πŸ“¬


πŸ’œ AUTHORS πŸ’œ

written by Steven G. Johnson. copyright (c) 2005 by the Massachusetts Institute of Technology.


and that's the whole page, bestie πŸŽ€ this was the harminv(1) manual β€” source is harminv, dated June 4, 2005, and it's serving HARMINV(1) energy to the very end. go extract some modes, you got this πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from