Note
Go to the end to download the full example code.
EddyPro Quality Flags¶
Extract and convert EddyPro quality flags to diive standard format. Understand signal quality, test failures, and data completeness.
Load EddyPro FluxNet data¶
Read example EddyPro output file containing quality test flags.
> Reading file
exampledata_EDDYPRO-FLUXNET-CSV-30MIN_CH-AWS_2022.07_FR-20220127-164245_eddypro_
fluxnet_2022-01-28T112538_adv.csv ...
EddyPro FluxNet data loaded:
Records: 1488
Date range: 2021-07-01 00:15:00 to 2021-07-31 23:45:00
Columns: 488
Signal strength test¶
Identify measurements with poor sensor signal quality. Low signal indicates dust, condensation, or optical drift.
from diive.preprocessing.qaqc import flag_signal_strength_eddypro_test
flag_signal = flag_signal_strength_eddypro_test(
df=df,
signal_strength_col='CUSTOM_SIGNAL_STRENGTH_IRGA72_MEAN',
var_col='FC',
method='discard below',
threshold=99,
idstr='_L41'
)
n_retained = (flag_signal == 0).sum()
n_discarded = (flag_signal == 2).sum()
print("\nSignal Strength Quality Test:")
print(f" Retained: {n_retained} records ({100 * n_retained / (n_retained + n_discarded):.1f}%)")
print(f" Discarded: {n_discarded} records ({100 * n_discarded / (n_retained + n_discarded):.1f}%)")
> SIGNAL STRENGTH TEST: Generating new flag variable
FLAG_L41_FC_SIGNAL_STRENGTH_TEST, newly calculated from output variable
CUSTOM_SIGNAL_STRENGTH_IRGA72_MEAN, with flag 0 (good values) where
CUSTOM_SIGNAL_STRENGTH_IRGA72_MEAN >= 99, flag 2 (bad values) where
CUSTOM_SIGNAL_STRENGTH_IRGA72_MEAN < 99 ...
Signal Strength Quality Test:
Retained: 812 records (99.9%)
Discarded: 1 records (0.1%)
Wind steadiness test¶
Evaluate horizontal wind stability throughout measurement period. Non-stationary wind indicates poor measurement conditions.
from diive.preprocessing.qaqc import flag_steadiness_horizontal_wind_eddypro_test
flag_wind = flag_steadiness_horizontal_wind_eddypro_test(
df=df,
flux='FC',
idstr='_L41'
)
print("\nWind Steadiness Quality Test:")
print(f" Steady: {(flag_wind == 0).sum()}")
print(f" Non-steady: {(flag_wind == 2).sum()}")
> STEADINESS OF HORIZONTAL WIND TEST: Generated new flag variable
FLAG_L41_FC_VM97_NSHW_HF_TEST, values taken from output variable VM97_NSHW_HF,
with flag 0 (good values) where test passed, flag 2 (bad values) where test
failed ...
Wind Steadiness Quality Test:
Steady: 660
Non-steady: 827
Angle of attack test¶
Check if wind approaches anemometer at acceptable angle. Large angles degrade measurement accuracy.
> ANGLE OF ATTACK TEST: Generated new flag variable
FLAG_L41_FC_VM97_AOA_HF_TEST, values taken from output variable VM97_AOA_HF,
with flag 0 (good values) where test passed, flag 2 (bad values) where test
failed ...
Angle of Attack Quality Test:
Acceptable: 1430
Poor angle: 57
Vickers & Mahrt (1997) raw data tests¶
Extract 8 individual quality tests from EddyPro VM97 codes. Tests evaluate stationarity, amplitude, dropout, limits, etc.
from diive.preprocessing.qaqc import flags_vm97_eddypro_fluxnetfile_tests
flags_vm97 = flags_vm97_eddypro_fluxnetfile_tests(
df=df,
flux='FC',
fluxbasevar='CO2',
idstr='_L41',
spikes=True,
amplitude=True,
dropout=True,
abslim=True,
skewkurt_hf=True,
skewkurt_sf=True,
discont_hf=True,
discont_sf=True
)
print("\nVM97 Raw Data Quality Tests (8 individual tests):")
print("-" * 60)
test_info = [
('Spike detection', 'SPIKE_HF'),
('Amplitude resolution', 'AMPLITUDE_RESOLUTION_HF'),
('Dropout detection', 'DROPOUT_HF'),
('Absolute limits', 'ABSOLUTE_LIMITS_HF'),
('Skewness/Kurtosis (hard)', 'SKEWKURT_HF'),
('Skewness/Kurtosis (soft)', 'SKEWKURT_SF'),
('Discontinuities (hard)', 'DISCONTINUITIES_HF'),
('Discontinuities (soft)', 'DISCONTINUITIES_SF'),
]
for test_name, test_suffix in test_info:
flag_col = [col for col in flags_vm97.columns if test_suffix in col][0]
flag_series = flags_vm97[flag_col]
n_pass = (flag_series == 0).sum()
n_fail = (flag_series == 2).sum()
n_warn = (flag_series == 1).sum()
print(f"{test_name:30s} Pass: {n_pass:5d} Fail: {n_fail:5d} Warn: {n_warn:5d}")
> RAW DATA TEST: Generated new flag variable
FLAG_L41_FC_CO2_VM97_SPIKE_HF_TEST, values taken from output variable
CO2_VM97_TEST from position 1, based on CO2, with flag 0 (good values) where
test passed, flag 2 (bad values) where test failed (for hard flags) or flag 1
(ok values) where test failed (for soft flags) ...
> RAW DATA TEST: Generated new flag variable
FLAG_L41_FC_CO2_VM97_AMPLITUDE_RESOLUTION_HF_TEST, values taken from output
variable CO2_VM97_TEST from position 2, based on CO2, with flag 0 (good values)
where test passed, flag 2 (bad values) where test failed (for hard flags) or
flag 1 (ok values) where test failed (for soft flags) ...
> RAW DATA TEST: Generated new flag variable
FLAG_L41_FC_CO2_VM97_DROPOUT_HF_TEST, values taken from output variable
CO2_VM97_TEST from position 3, based on CO2, with flag 0 (good values) where
test passed, flag 2 (bad values) where test failed (for hard flags) or flag 1
(ok values) where test failed (for soft flags) ...
> RAW DATA TEST: Generated new flag variable
FLAG_L41_FC_CO2_VM97_ABSOLUTE_LIMITS_HF_TEST, values taken from output variable
CO2_VM97_TEST from position 4, based on CO2, with flag 0 (good values) where
test passed, flag 2 (bad values) where test failed (for hard flags) or flag 1
(ok values) where test failed (for soft flags) ...
> RAW DATA TEST: Generated new flag variable
FLAG_L41_FC_CO2_VM97_SKEWKURT_HF_TEST, values taken from output variable
CO2_VM97_TEST from position 5, based on CO2, with flag 0 (good values) where
test passed, flag 2 (bad values) where test failed (for hard flags) or flag 1
(ok values) where test failed (for soft flags) ...
> RAW DATA TEST: Generated new flag variable
FLAG_L41_FC_CO2_VM97_SKEWKURT_SF_TEST, values taken from output variable
CO2_VM97_TEST from position 6, based on CO2, with flag 0 (good values) where
test passed, flag 2 (bad values) where test failed (for hard flags) or flag 1
(ok values) where test failed (for soft flags) ...
> RAW DATA TEST: Generated new flag variable
FLAG_L41_FC_CO2_VM97_DISCONTINUITIES_HF_TEST, values taken from output variable
CO2_VM97_TEST from position 7, based on CO2, with flag 0 (good values) where
test passed, flag 2 (bad values) where test failed (for hard flags) or flag 1
(ok values) where test failed (for soft flags) ...
> RAW DATA TEST: Generated new flag variable
FLAG_L41_FC_CO2_VM97_DISCONTINUITIES_SF_TEST, values taken from output variable
CO2_VM97_TEST from position 8, based on CO2, with flag 0 (good values) where
test passed, flag 2 (bad values) where test failed (for hard flags) or flag 1
(ok values) where test failed (for soft flags) ...
VM97 Raw Data Quality Tests (8 individual tests):
------------------------------------------------------------
Spike detection Pass: 1487 Fail: 0 Warn: 0
Amplitude resolution Pass: 0 Fail: 1487 Warn: 0
Dropout detection Pass: 1487 Fail: 0 Warn: 0
Absolute limits Pass: 1486 Fail: 1 Warn: 0
Skewness/Kurtosis (hard) Pass: 647 Fail: 840 Warn: 0
Skewness/Kurtosis (soft) Pass: 386 Fail: 0 Warn: 1101
Discontinuities (hard) Pass: 1486 Fail: 1 Warn: 0
Discontinuities (soft) Pass: 1481 Fail: 0 Warn: 6
Base variable completeness¶
Evaluate data availability for flux calculation. CO2 completeness determines CO2 flux (FC) reliability.
from diive.preprocessing.qaqc import flag_fluxbasevar_completeness_eddypro_test
flag_complete = flag_fluxbasevar_completeness_eddypro_test(
df=df,
flux='FC',
fluxbasevar='CO2',
thres_good=0.99,
thres_ok=0.97,
idstr='_L41'
)
n_good = (flag_complete == 0).sum()
n_ok = (flag_complete == 1).sum()
n_bad = (flag_complete == 2).sum()
print("\nBase Variable (CO2) Completeness:")
print(f" Good (>=99% complete): {n_good}")
print(f" Ok (97-99% complete): {n_ok}")
print(f" Bad (<97% complete): {n_bad}")
> FLUX BASE VARIABLE COMPLETENESS TEST: Generated new flag variable
FLAG_L41_FC_COMPLETENESS_TEST, newly calculated from variable CO2, with flag 0
(good values) where available number of records for CO2 >= 0.99, flag 1 (ok
values) >= 0.97 and < 0.99, flag 2 (bad values) < 0.97...
Base Variable (CO2) Completeness:
Good (>=99% complete): 811
Ok (97-99% complete): 0
Bad (<97% complete): 0
Summary¶
EddyPro quality flags help identify measurement reliability issues. Use these flags to establish data quality thresholds for your analysis.
print("\n" + "=" * 60)
print("Key Takeaways")
print("=" * 60)
print("""
- Signal strength: Optical/sensor quality indicator
- Steadiness: Measurement stationarity check
- Angle of attack: Wind approach angle
- VM97 tests: Statistical tests on raw data (8 types)
- Completeness: Data availability for flux calculation
Combine these into overall quality flag for robust data filtering.
""")
============================================================
Key Takeaways
============================================================
- Signal strength: Optical/sensor quality indicator
- Steadiness: Measurement stationarity check
- Angle of attack: Wind approach angle
- VM97 tests: Statistical tests on raw data (8 types)
- Completeness: Data availability for flux calculation
Combine these into overall quality flag for robust data filtering.
Total running time of the script: (0 minutes 0.654 seconds)