ecpet.ecplan module

EC-PeT Planar Fit Module

Planar fit tilt correction implementation for sonic anemometer data following the methodology of Wilczak et al. (2001). Provides comprehensive coordinate system correction to account for non-level instrument mounting and ensure accurate flux measurements in eddy-covariance systems.

The module performs:
  • Planar fit angle calculation (alpha, beta, gamma)

  • 3×3 rotation matrix generation for coordinate transformation

  • Optional yaw correction for mean wind alignment

  • Temporal interval management for planar fit periods

  • Single-run vs. multi-run processing options

  • Vertical wind bias estimation and correction

ecpet.ecplan.planarfit_interval(dowbias, singlerun, interval, pfvalid=0.0, progress=100)

Calculate planar fit tilt correction angles for sonic anemometer data.

Computes tilt correction matrix using the Planar Fit Method following Wilczak et al. (2001). Includes optional yaw correction to align coordinate system with mean wind direction.

Parameters:
  • dowbias (bool) – Whether to compute bias in mean vertical wind

  • singlerun (bool) – Use single run method (individual samples) vs classic method (run means)

  • interval (pandas.DataFrame) – DataFrame containing wind velocity measurements

  • pfvalid (float) – Fraction of valid samples required to include interval in planar fit. Defaults to 0 (include all).

  • progress (int) – Progress reporting weight, defaults to 100

Returns:

Dictionary with rotation matrix and angles

Return type:

dict

Note:

Returns dict containing: - alpha, beta, gamma: tilt angles in degrees - wbias: vertical wind bias - apf_ij: 3x3 rotation matrix elements

Raises:

numpy.linalg.LinAlgError – When planar fit matrix inversion fails

ecpet.ecplan.planarfit_times(conf)

Generate time boundaries for planar fit calculation intervals.

Creates interval boundaries based on configuration settings, handling various time units and edge cases for data period coverage.

Parameters:

conf (object) – Configuration object with planar fit interval settings

Returns:

DataFrame with interval start and end times

Return type:

pandas.DataFrame

Note:

Supports time units: S(econds), M(inutes), H(ours), D(ays), W(eeks). Automatically adjusts interval boundaries to ensure complete coverage of the data period.

ecpet.ecplan.planarfit_to_file(conf, intervals)
ecpet.ecplan.planarfit(conf, intervals)

Main planar fit processing routine for eddy-covariance data.

Orchestrates complete planar fit workflow including interval generation, angle calculation, and result distribution back to measurement intervals.

Parameters:
  • conf (object) – Configuration object with planar fit parameters

  • intervals (pandas.DataFrame) – DataFrame with averaged wind velocity measurements

Returns:

Updated DataFrame with planar fit angles and rotation matrices

Return type:

pandas.DataFrame

Note:

Applies planar fit method following Wilczak et al. (2001) to correct for sonic anemometer tilt. Results are grouped by planar fit intervals and distributed to individual measurement periods.

Workflow: - Generate planar fit time intervals - Group measurement intervals by planar fit periods - Calculate tilt angles for each planar fit interval - Distribute results back to measurement intervals - Write output files if configured