TaylorSwift
The name is in honor of physicist Sir Geoffrey Ingram Taylor. FFT-based (co)spectral analysis for eddy covariance time series.
TaylorSwift implements the standard micrometeorological workflow for computing power spectra and cospectra from high-frequency sonic anemometer and open-path gas analyser data, following Kaimal et al. (1972) conventions.
Features
- Spectral computation — double-rotation, linear detrending, Hamming-windowed FFT, logarithmic frequency binning, area-preserving normalization
- Spectral corrections — block-average, linear-detrend, first-order sensor response, sonic path averaging, sensor separation (Massman 2000; Horst 1997)
- Despiking — iterative UKDE despiking for raw time series (Metzger et al. 2012); rolling IQR, median-RLM, and EWMA methods via
CalcFlux - WPL density correction — Webb-Pearman-Leuning (1980) for open-path CO₂/H₂O fluxes
- Quality control — inertial-subrange slope fitting, stationarity test (Foken & Wichura 1996), Foken 9-class quality flags, ITC tests, outlier detection
- Physical constants — curated constants, surface-type enumerations, and roughness / displacement height helpers
- Flux pipeline — end-to-end
CalcFluxprocessor for IRGASON and KH-20 sensor suites with Polars/pandas compatibility - I/O — fast Campbell Scientific TOA5 reader and multi-file compiler (Polars backend)
- Plotting — publication-quality Kaimal-style spectral and cospectral figures
Installation
pip install taylorswift-spectra
The distribution is named taylorswift-spectra on PyPI (the shorter name was
already taken); the import name is unchanged:
import TaylorSwift
For development:
git clone https://github.com/inkenbrandt/TaylorSwift
cd TaylorSwift
pip install -e ".[dev]"
Quick start
import TaylorSwift as tswift
# --- Configure the site ---
config = tswift.SiteConfig(
z_measurement=3.0, # measurement height [m]
z_canopy=0.3, # canopy height [m]
sampling_freq=20.0, # Hz
averaging_period=30.0 # minutes
)
# --- Load a raw TOA5 file ---
df, meta = tswift.read_toa5("path/to/TOA5_mysite.dat")
# --- Process all 30-min intervals ---
results = tswift.process_file(df, config)
# --- Run quality control ---
results = tswift.run_qc(results)
# --- Plot ---
fig = tswift.plot_cospectra(results)
fig.savefig("cospectra.pdf")
Processing pipeline
TOA5 files
│
▼ tswift.read_toa5() / tswift.compile_toa5()
polars.DataFrame
│
▼ tswift.process_file()
│ ├─ double rotation (mean v = w = 0)
│ ├─ linear detrend
│ ├─ batched FFT (6 signals)
│ ├─ logarithmic frequency binning
│ └─ turbulence statistics (u*, L, z/L, H)
list[SpectralResult]
│
├──▶ corrections.apply_spectral_corrections() (optional)
├──▶ qc.run_qc()
└──▶ plotting.plot_cospectra() / plot_spectra() / plot_ogive()
Module overview
| Module | Contents |
|---|---|
core |
process_interval, process_file — the FFT cospectral pipeline |
cospectra |
SpectralResult, compute_cospectrum, compute_spectrum, log_bin, transfer functions, apply_spectral_corrections, compute_spectral_correction_factor |
config |
SiteConfig, InstrumentConfig, FluxConfig, ProcessingConfig |
io |
read_toa5, compile_toa5, scan_toa5_directory |
corrections |
wpl_correction, webb_pearman_leuning, shadow_correction, enrich_results_with_means |
despike |
ukde_despike, polars_ukde_despike, despike_dataframe, despike_med_mod, mad_outliers, rolling_sigma_filter |
data_quality |
fit_inertial_slope, stationarity_test, run_qc, QualityFlag, DataQuality, quality_filter |
rotations |
rotate_wind (double rotation), coord_rotation, rotate_velocities |
pipelines |
run_irga, run_kh20 — end-to-end flux pipelines for IRGASON and KH-20 |
plotting |
plot_cospectra, plot_spectra, plot_ogive, plot_summary_timeseries |
constants |
SurfaceType, Hemisphere, QualityThreshold, get_displacement_height, get_roughness_length, physical constants |
compat |
CalcFlux — backward-compatible wrapper around the legacy flux API |
Running tests
pytest
# or with coverage:
pytest --cov=TaylorSwift
References
- Kaimal, J.C. et al. (1972). Spectral characteristics of surface-layer turbulence. Quart. J. Roy. Meteor. Soc., 98, 563–589.
- Massman, W.J. (2000). A simple method for estimating frequency response corrections for eddy covariance systems. Agric. For. Meteorol., 104, 185–198.
- Webb, E.K., Pearman, G.I. & Leuning, R. (1980). Correction of flux measurements for density effects. Quart. J. Roy. Meteor. Soc., 106, 85–100.
- Foken, T. & Wichura, B. (1996). Tools for quality assessment of surface-based flux measurements. Agric. For. Meteorol., 78, 83–105.
- Foken, T. et al. (2004). Post-field data quality control. In Handbook of Micrometeorology (pp. 181–208). Springer.
- Metzger, S. et al. (2012). Eddy-covariance flux measurements with a weight-shift microlight aircraft. Atmos. Meas. Tech., 5, 1699–1717.
- Oke, T.R. (1987). Boundary Layer Climates (2nd ed.). Routledge.
- Stull, R.B. (1988). An Introduction to Boundary Layer Meteorology. Springer.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file taylorswift_spectra-0.2.2.tar.gz.
File metadata
- Download URL: taylorswift_spectra-0.2.2.tar.gz
- Upload date:
- Size: 98.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3458bd33685523c37e016c845eef78f5030af23e3b5a052892506602d40fc70a
|
|
| MD5 |
bb9844c2b07ff76d698eba8ee3061965
|
|
| BLAKE2b-256 |
b15bd26d2d27cd338eec7af810cf6e0eb4cbbdc90e4f6863abc3c2059a676cdb
|
Provenance
The following attestation bundles were made for taylorswift_spectra-0.2.2.tar.gz:
Publisher:
publish.yml on inkenbrandt/TaylorSwift
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taylorswift_spectra-0.2.2.tar.gz -
Subject digest:
3458bd33685523c37e016c845eef78f5030af23e3b5a052892506602d40fc70a - Sigstore transparency entry: 2576997068
- Sigstore integration time:
-
Permalink:
inkenbrandt/TaylorSwift@edcb294145ea643f30ce85ed1f4895de833b4ec8 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/inkenbrandt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@edcb294145ea643f30ce85ed1f4895de833b4ec8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file taylorswift_spectra-0.2.2-py3-none-any.whl.
File metadata
- Download URL: taylorswift_spectra-0.2.2-py3-none-any.whl
- Upload date:
- Size: 81.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0956fbd5a2f57dc16e57bdc7ebc2443775eed78a0582f755a9e2158017b65b7a
|
|
| MD5 |
66eeeb664e70abb7e9156ddbf8010b0a
|
|
| BLAKE2b-256 |
1ee9288933c72f9913dcbb872f8fad6868b9a479885741a59d5fd88d42215f53
|
Provenance
The following attestation bundles were made for taylorswift_spectra-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on inkenbrandt/TaylorSwift
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taylorswift_spectra-0.2.2-py3-none-any.whl -
Subject digest:
0956fbd5a2f57dc16e57bdc7ebc2443775eed78a0582f755a9e2158017b65b7a - Sigstore transparency entry: 2576997123
- Sigstore integration time:
-
Permalink:
inkenbrandt/TaylorSwift@edcb294145ea643f30ce85ed1f4895de833b4ec8 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/inkenbrandt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@edcb294145ea643f30ce85ed1f4895de833b4ec8 -
Trigger Event:
push
-
Statement type: