gnssrefl.advanced_vegetation_correction module

Advanced vegetation correction model for VWC estimation.

Reference: DOI 10.1007/s10291-015-0462-4

Ported to gnssrefl from original MATLAB in October 2025.

gnssrefl.advanced_vegetation_correction.advanced_vegetation_filter(station, vxyz, subdir='', bin_hours=24, bin_offset=0, pltit=True, fr=20, minvalperbin=10, save_tracks=False)

Advanced vegetation model (model 2)

This function applies the advanced vegetation correction filter to a vxyz array input.

Parameters:
  • station (str) – 4-char GNSS station name

  • vxyz (numpy array) – Full track-level data from vwc (16 columns)

  • subdir (str) – Subdirectory for file organization (default: ‘’)

  • bin_hours (int) – Time bin size for future subdaily support (default: 24)

  • bin_offset (int) – Bin timing offset for future subdaily support (default: 0)

  • pltit (bool) – Whether plots come to the screen

  • fr (int) – Frequency code (1=L1, 5=L5, 20=L2C, default: 20)

  • minvalperbin (int) – Minimum values required per time bin (default: 10)

  • save_tracks (bool) – Save individual track VWC data to files (default: False)

Returns:

Dictionary containing: - ‘mjd’: list of Modified Julian Day values - ‘vwc’: list of VWC values (percentage units, not leveled) - ‘datetime’: list of datetime objects for plotting - ‘bin_starts’: list of bin start hours (subdaily only) or empty list

Return type:

dict

gnssrefl.advanced_vegetation_correction.apply_vegetation_model(station, vxyz, normmet, tracks, sgolnum, sgolply, padlen, pltit, fr, bin_hours, bin_offset, subdir, minvalperbin, save_tracks=False)

Apply Clara’s vegetation filter to compute soil moisture

Parameters:
  • station (str) – Station name

  • vxyz (numpy array) – Original vwc data

  • normmet (numpy array) – Normalized metrics from norm_zero_vxyz

  • tracks (numpy array) – Satellite/quadrant combinations

  • sgolnum (int) – Savgol filter length

  • sgolply (int) – Savgol polynomial order

  • padlen (int) – Padding length

  • pltit (bool) – Show plots

  • fr (int) – Frequency code

  • bin_hours (int) – Time bin size in hours

  • bin_offset (int) – Bin timing offset in hours

  • subdir (str) – Subdirectory for output

  • minvalperbin (int) – Minimum values required per time bin

  • save_tracks (bool) – Save individual track VWC data to files

Returns:

  • final_mjd (list) – MJD values for time-binned averages

  • final_vwc (list) – VWC values for time-binned averages (percentage units, not leveled)

  • final_binstarts (list) – Bin start hours for subdaily data (empty for daily)

gnssrefl.advanced_vegetation_correction.load_clara_model()

Load Clara’s model from the organized model_data directory

Returns:

  • amp_lsp (numpy array) – LSP amplitude features

  • amp_dsnr (numpy array) – DSNR amplitude features

  • delta_heff (numpy array) – Change in effective reflector height

  • veg_correction (numpy array) – Vegetation phase corrections

  • slope_correction (numpy array) – Slope sensitivity corrections

gnssrefl.advanced_vegetation_correction.norm_zero_vxyz(station, vxyz, remoutli, acc_rhdrift, baseperc, zphival, ampvarday, ampvarlimit)

Normalize metrics and remove outliers from vxyz data

This processes the full track-level data from vwc to prepare it for the KNN lookup.

Parameters:
  • station (str) – Station name

  • vxyz (numpy array) – Full track data (16 columns)

  • remoutli (int) – Remove outliers flag

  • acc_rhdrift (int) – Apply RH drift correction

  • baseperc (float) – Percentage for amplitude normalization

  • zphival (float) – Fraction for phase zeroing

  • ampvarday (int) – Days for variance calculation

  • ampvarlimit (float) – Amplitude variance threshold

Returns:

  • tracks (numpy array) – Unique satellite/quadrant combinations

  • metrics_all (numpy array) – Normalized metrics [D_amplsp, D_amp, D_phi, D_RH]

  • vegmast (numpy array) – Vegetation mask

gnssrefl.advanced_vegetation_correction.padClara(obs, Ntrack, men, padlen)

Pad arrays before smoothing (Clara’s method)

Parameters:
  • obs (numpy array) – Observations to pad

  • Ntrack (int) – Number of values in array

  • men (int) – Number of values to use for calculating mean at each end

  • padlen (int) – Padding length on each end

Returns:

padded_obs – Padded version of obs

Return type:

numpy array

gnssrefl.advanced_vegetation_correction.rolling_window(a, window)

Create rolling window view of array for variance calculation

From: https://stackoverflow.com/questions/6811183/rolling-window-for-1d-arrays-in-numpy

gnssrefl.advanced_vegetation_correction.save_individual_track_data(station, track_year, sat_num, avg_az, years, doys, hours, mjds, azimuths, phase_orig, amp_lsp_orig, amp_ls_orig, delta_rh, amp_lsp_smooth, amp_ls_smooth, delta_rh_smooth, phase_veg_corr, slope_corr, slope_final, phase_corrected, vwc_values, subdir, fr)

Save individual track VWC data for efficient re-binning and analysis

This function saves the complete processing chain from raw observations through Clara’s vegetation model corrections to final VWC estimates.

Parameters:
  • station (str) – 4-character station name

  • track_year (int) – Year for the track analysis

  • sat_num (int) – Satellite number

  • avg_az (float) – Track average azimuth (degrees)

  • years (numpy.ndarray) – Year values for each observation

  • doys (numpy.ndarray) – Day of year values for each observation

  • hours (numpy.ndarray) – Hour values for each observation (UTC)

  • mjds (numpy.ndarray) – Modified Julian Date values for each observation

  • azimuths (numpy.ndarray) – Azimuth angles for each observation (degrees)

  • phase_orig (numpy.ndarray) – Original unwrapped phase observations (degrees)

  • amp_lsp_orig (numpy.ndarray) – Original LSP amplitude values

  • amp_ls_orig (numpy.ndarray) – Original LS amplitude values

  • delta_rh (numpy.ndarray) – Delta RH (apriori - measured, meters)

  • amp_lsp_smooth (numpy.ndarray) – Smoothed LSP amplitudes used for model lookup

  • amp_ls_smooth (numpy.ndarray) – Smoothed LS amplitudes used for model lookup

  • delta_rh_smooth (numpy.ndarray) – Smoothed delta RH used for model lookup (meters)

  • phase_veg_corr (numpy.ndarray) – Vegetation phase corrections from Clara’s model (degrees)

  • slope_corr (numpy.ndarray) – Slope sensitivity corrections from Clara’s model

  • slope_final (numpy.ndarray) – Final corrected slope values (1.48 - slope_corr)

  • phase_corrected (numpy.ndarray) – Vegetation-corrected phase (phase_orig - phase_veg_corr)

  • vwc_values (numpy.ndarray) – Final volumetric water content estimates (%)

  • subdir (str) – Subdirectory for output files

  • fr (int) – Frequency code (20 for L2C, etc.)

  • Format (File)

  • -----------

  • total) (Output columns (17)

  • DeltaRHOrig (Year DOY Hour MJD Az PhaseOrig AmpLSPOrig AmpLSOrig)

  • SlopeFinal (AmpLSPSmooth AmpLSSmooth DeltaRHSmooth PhaseVegCorr SlopeCorr)

  • VWC (PhaseCorrected)