fluxmethods — eddy-covariance methods, published as functions
Copyright (c) 2026 Pedro Henrique Herig Coimbra
Licensed under the EUPL-1.2 (see LICENCE).

Where this code comes from
--------------------------
These modules are the estimators of `onefluxpro`
(https://github.com/pedrohenriquecoimbra/ONEFluxPro), by the same author,
also under the EUPL-1.2, lifted out of it. They are not a reimplementation and
not a rewrite, and that package keeps no copy of them: it registers these
functions and runs these files, read from this repository at the commit it pins.

That is the difference from `miniflux`, which is the same author's *minimal
reimplementation* of the same physics. miniflux answers "what is the smallest
thing that is still a flux program"; fluxmethods answers "give me the method,
not the program". There is nothing for fluxmethods and onefluxpro to disagree
on: a method has one file, and it is the one here.

Methods implemented here, and the work they come from
-----------------------------------------------------
Despiking, MAD            Mauder et al. (2013), Agric. For. Meteorol. 169, 122-135
Despiking, VM97           Vickers & Mahrt (1997), J. Atmos. Ocean. Technol. 14, 512-526
Double/triple rotation    Wilczak et al. (2001), Boundary-Layer Meteorol. 99, 127-150
                          after Tanner & Thurtell (1969)
Planar fit                Wilczak et al. (2001), same work, § 3
Block-average detrending  Moncrieff et al. (2004)
Linear detrending         Rannik & Vesala (1999)
Time-lag maximisation     covariance maximisation, as in EddyPro's CovMax;
                          cf. Fan et al. (1990), Aubinet et al. (2012)
Low-pass look-up (LPFC)   a wind-speed/stability table, as GEddySoft applies it
Block-average high-pass   Moncrieff et al. (2004); Rannik & Vesala (1999)
Sonic path/response loss  Kaimal et al. (1972) cospectrum
Closed-path low-pass      Moore (1986); Foken et al. (2012)
Band-pass (EddyPro)       Moncrieff et al. (1997, 2004), transcribed from the
                          eddypro-engine source
Resampling                no single reference: nearest-neighbour, linear
                          interpolation, block averaging and an FFT resampling,
                          as the acquisition software of a site happens to need.

Known defect, inherited from GEddySoft and kept on purpose
----------------------------------------------------------
`signal.nanlinfit` deletes NaNs and fits against `arange` of what remains, so the
fit runs on a compacted axis while `nandetrend` evaluates it at the original
indices. A straight line with an interior gap does not detrend to zero.

GEddySoft v4.1 does the same thing, in the same two steps (`nanlinfit.py`,
`nandetrend.py`); `core/signal.py` here transcribes it, and onefluxpro holds
that transcription equal to GEddySoft's own code to twelve digits. So this is a
faithful port of upstream's arithmetic, not a bug introduced in either
— and correcting it here would manufacture a divergence rather than fix one.
The fix belongs in GEddySoft's patch bundle.

`tests/test_signal_and_detrending.py` pins the behaviour and names its origin. It
is what should start failing when an upstream fix reaches this port.
