Skip to main content

Flexible flux and turbulence calculations from NetCDF files.

Project description

flux_calculations

PyPI version License

Flexible flux and turbulence calculations from NetCDF files: sensible heat flux, momentum flux, and turbulent kinetic energy.


Features

  • NetCDF File Aggregation: Combines multiple NetCDF files into a single data frame for each sensor, simplifying data management.
  • Outlier Removal: Automatically detects and removes outliers beyond 3 standard deviations within a rolling 100-observation window.
  • Advanced Plotting:
    • Visualize 3-dimensional wind data for comprehensive analysis.
    • Generate FFT (Fast Fourier Transform) plots for frequency domain insights.
  • Flexible Flux Calculations:
    • Compute Sensible Heat Flux, Momentum Flux, or Turbulent Kinetic Energy (TKE) using a customizable time window (user-defined in minutes).
    • Plot calculated fluxes for easy interpretation and visualization.
  • User-Friendly Design: Offers intuitive options for data processing, plotting, and analysis, ensuring flexibility and ease of use.

Installation

pip install fluxcalc

To install the latest version from GitHub:

pip install git+https://github.com/jpiot1/flux_calculations.git

‼️‼️‼️ For development (editable) install with tests: ‼️‼️‼️

git clone https://github.com/jpiot1/flux_calculations.git
cd flux_calculations
env=".venv"
python -m venv "$env"
source "$env/bin/activate"
pip install -e '.[dev]'
pytest -q

‼️‼️‼️ Python API ‼️‼️‼️

import xarray as xr
import fluxcalc as fc

# 1. Open dataset
 ds = xr.open_dataset("input.nc").sortby("time")

# 2. Compute wavelet transforms
 row_wt, col_wt, remnant = cf.get_wavelets(ds.copy(), ds.range.values, ds.time.values)

# 3. Detect clouds & precip
 clouds, precip = cf.get_clouds_and_precip(
     ds.beta_att.T.values, ds.range.values, ds.time.values
 )

# 4. Flags and threshold
 fog, cloud, rain, clear = cf.get_flags(
     ds.beta_att.T.values, ds.range.values, ds.time.values
 )
 thresh = cf.get_thresh(remnant, row_wt, col_wt)

# 5. Denoise & extract layers
 clean = cf.remove_noisy_regions(
     ds.beta_att.T.values, thresh, ds.range.values, ds.time.values
 )
 layers = cf.get_layers(clean.values, clean.range.values)

# 6. Write results
 cf.create_file(
     ds, row_wt, col_wt, remnant,
     clouds, precip, fog, rain, cloud, clear,
     clean, layers, ds.overlap_function,
     output_path="output.nc",
     overwrite=True
 )

Contributing

  1. Fork the repo and create a feature branch.
  2. Write code, tests, and update docs.
  3. Follow style: ruff, mypy, pytest.
  4. Submit a pull request.

License

This project is licensed under the GNU Lesser General Public License v2.1 or later. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluxcalc-0.1.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluxcalc-0.1.1-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file fluxcalc-0.1.1.tar.gz.

File metadata

  • Download URL: fluxcalc-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for fluxcalc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 be853d439d4fe0dfc7223f6113b7a9f2c0997986dcb5a3427221d52edfdaa1f1
MD5 7998d2d370703bcb04cf1ce5f145e54d
BLAKE2b-256 a515087127670c86d6c3045596fe4a7ca065be3f869d147035c5f840662347b1

See more details on using hashes here.

File details

Details for the file fluxcalc-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fluxcalc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for fluxcalc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4535bbf374b3135758f3007d2a38e806eaa600adc210c3af0ef2e4dd95c9c521
MD5 b293d94f70ead1a3f8a3ca22f65360c1
BLAKE2b-256 e0a4b9f9e534c0bf8db9a7974cf3f0c0adc0fcb60281964e803fd45771d1dfd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page