Quality Control

Daisho.threshold_qc!Function
threshold_qc!(sweep::SweepGroup, p::DaishoParameters;
              inputs=["DBZ","VEL","ZDR","KDP","RHOHV","WIDTH","PHIDP"],
              out_suffix="_QC")

Sweep-aware quality-control. For each input field present in sweep.fields, add a thresholded copy named <input>*out_suffix. Gates are set to NaN where any of:

  • SQI < p.qc.sqi_threshold
  • SNR < p.qc.snr_threshold
  • RHOHV < p.qc.rhohv_threshold
  • WIDTH > p.qc.spectrum_width_max

The output field metadata is the input metadata plus is_quality_field=true, qualified_variables=[input_name], and long_name="QC " * <input long_name>. The input field's ancillary_variables is updated to include the new output. Returns sweep.

source
Daisho.fix_SEAPOL_RHOHV!Function
fix_SEAPOL_RHOHV!(volume, moment_dict)

Correct artificially high RHOHV values in SEA-POL radar data caused by noise subtraction.

The LROSE conversion adds a bias of 128 and shifts by -32768 to the RHOHV field stored in UNKNOWN_ID_82. This function recovers the original RHOHV by adding 32640, then rescaling to the range [0, 1] via (value - 1) / 65533.

Arguments

  • volume: Radar volume object containing a moments matrix.
  • moment_dict::Dict{String, Int}: Dictionary mapping moment names to column indices in volume.moments.

Returns

Nothing. The volume.moments RHOHV column is modified in place.

source
Daisho.despeckleFunction
despeckle(speckle, moments, moment_dict, n_gates, n_rays) -> Matrix

Remove small isolated features (speckle) from radar moment data along each radial (range direction).

For each ray, contiguous non-missing segments shorter than or equal to speckle gates are set to missing across all moment fields.

Arguments

  • speckle::Int: Maximum feature size (in gates) to be considered speckle and removed. Must be > 0.
  • moments::Matrix: Radar moment data matrix (gates x moments) to be despecked.
  • moment_dict::Dict{String, Int}: Dictionary mapping moment names to column indices.
  • n_gates::Int: Number of range gates per ray.
  • n_rays::Int: Number of rays (azimuths) in the sweep.

Returns

  • Matrix: The modified moments matrix with speckle features set to missing.
source
Daisho.despeckle_azimuthalFunction
despeckle_azimuthal(speckle, moments, moment_dict, n_gates, n_rays) -> Matrix

Remove small isolated features (speckle) from radar moment data along the azimuthal direction.

For each range gate, contiguous non-missing segments shorter than or equal to speckle rays are set to missing across all moment fields. This is the azimuthal counterpart to despeckle.

Arguments

  • speckle::Int: Maximum feature size (in rays) to be considered speckle and removed. Must be > 0.
  • moments::Matrix: Radar moment data matrix (gates x moments) to be despeckled.
  • moment_dict::Dict{String, Int}: Dictionary mapping moment names to column indices.
  • n_gates::Int: Number of range gates per ray.
  • n_rays::Int: Number of rays (azimuths) in the sweep.

Returns

  • Matrix: The modified moments matrix with azimuthal speckle features set to missing.
source
Daisho.stddev_phidp_thresholdFunction
stddev_phidp_threshold(moments, moment_dict, n_gates, n_rays, window=11, threshold=12) -> Matrix

Apply quality control by removing gates where the local standard deviation of differential phase (PHIDP) exceeds a threshold, indicating noisy or non-meteorological echoes.

A sliding window of size window gates is used to compute the standard deviation of PHIDP along each ray. Negative PHIDP values are wrapped by adding 360 degrees before computation. All moment fields at gates exceeding the threshold are set to missing.

Arguments

  • moments::Matrix: Radar moment data matrix (gates x moments).
  • moment_dict::Dict{String, Int}: Dictionary mapping moment names to column indices (must contain "PHIDP").
  • n_gates::Int: Number of range gates per ray.
  • n_rays::Int: Number of rays (azimuths) in the sweep.
  • window::Int: Size of the sliding window in gates (must be odd, default 11).
  • threshold::Real: Standard deviation threshold in degrees (default 12).

Returns

  • Matrix: The modified moments matrix with noisy PHIDP gates set to missing.
source
Daisho.remove_platform_motion!Function
remove_platform_motion!(volume, moments, moment_dict) -> Matrix

Remove the contribution of platform motion from the Doppler velocity field for ship- or aircraft-mounted radars.

The platform radial velocity is computed from the east-west, north-south, and vertical platform velocity components projected onto each beam's azimuth and elevation angles, then added back to the measured velocity. The corrected velocity is folded back into the Nyquist interval.

Arguments

  • volume: Radar volume object containing range, azimuth, elevation, ew_platform, ns_platform, w_platform, and nyquist_velocity fields.
  • moments::Matrix: Radar moment data matrix (gates x moments).
  • moment_dict::Dict{String, Int}: Dictionary mapping moment names to column indices (must contain "VEL").

Returns

  • Matrix: The modified moments matrix with platform-motion-corrected velocities.
source
Daisho.threshold_dbzFunction
threshold_dbz(volume, raw_moment_dict, qc_moments, qc_moment_dict, dbz_threshold, vel_threshold, sw_threshold) -> Matrix

Remove likely ground clutter by identifying gates with high reflectivity, low velocity, and narrow spectrum width below 500 m height.

Gates exceeding dbz_threshold that also have absolute velocity at or below vel_threshold and spectrum width at or below sw_threshold at heights below 500 m are classified as clutter and set to missing. The "SQI_FOR_MASK" and "PID_FOR_QC" fields are excluded from removal.

Arguments

  • volume: Radar volume object containing moments and metadata needed by get_beam_info.
  • raw_moment_dict::Dict{String, Int}: Dictionary mapping raw moment names to column indices (must contain "DBZ", "VEL", "WIDTH").
  • qc_moments::Matrix: QC radar moment data matrix to be modified (gates x moments).
  • qc_moment_dict::Dict{String, Int}: Dictionary mapping QC moment names to column indices.
  • dbz_threshold::Real: Reflectivity threshold in dBZ above which gates are examined.
  • vel_threshold::Real: Maximum absolute velocity (m/s) for a gate to be classified as clutter.
  • sw_threshold::Real: Maximum spectrum width (m/s) for a gate to be classified as clutter.

Returns

  • Matrix: The modified qc_moments matrix with likely clutter gates set to missing.
source
Daisho.threshold_heightFunction
threshold_height(volume, raw_moment_dict, qc_moments, qc_moment_dict, height_threshold) -> Matrix

Remove radar gates located below a specified height threshold.

All QC moment fields at gates with beam height below height_threshold are set to missing. The "SQI_FOR_MASK" and "PID_FOR_QC" fields are excluded from removal. Gates where DBZ is already missing are skipped.

Arguments

  • volume: Radar volume object containing moments and metadata needed by get_beam_info.
  • raw_moment_dict::Dict{String, Int}: Dictionary mapping raw moment names to column indices (must contain "DBZ").
  • qc_moments::Matrix: QC radar moment data matrix to be modified (gates x moments).
  • qc_moment_dict::Dict{String, Int}: Dictionary mapping QC moment names to column indices.
  • height_threshold::Real: Minimum beam height in meters; gates below this are removed.

Returns

  • Matrix: The modified qc_moments matrix with low-height gates set to missing.
source
Daisho.threshold_terrain_heightFunction
threshold_terrain_height(volume, raw_moment_dict, qc_moments, qc_moment_dict, terrain_threshold, tile_dir) -> Matrix

Remove radar gates located over terrain exceeding a specified elevation threshold using SRTM digital terrain model data.

For each gate, the geographic coordinates are computed via an approximate inverse projection from radar-relative coordinates. The terrain elevation is looked up from pre-loaded SRTM tiles. All QC moment fields at gates over terrain above terrain_threshold meters are set to missing. This function is multi-threaded.

Arguments

  • volume: Radar volume object containing position, moment, and beam geometry data.
  • raw_moment_dict::Dict{String, Int}: Dictionary mapping raw moment names to column indices (must contain "SQI_FOR_MASK", "DBZ").
  • qc_moments::Matrix: QC radar moment data matrix to be modified (gates x moments).
  • qc_moment_dict::Dict{String, Int}: Dictionary mapping QC moment names to column indices.
  • terrain_threshold::Real: Terrain elevation threshold in meters; gates over higher terrain are removed.
  • tile_dir::String: Path to directory containing SRTM .hgt tile files.

Returns

  • Matrix: The modified qc_moments matrix with terrain-blocked gates set to missing.
source
Daisho.add_azimuthal_offsetFunction
add_azimuthal_offset(volume, az_offset) -> Vector

Add a constant azimuthal offset to all rays in a radar volume and wrap to [0, 360) degrees.

This is useful for correcting systematic azimuth biases in radar pointing angles.

Arguments

  • volume: Radar volume object containing an azimuth array.
  • az_offset::Real: Azimuthal offset in degrees to add to every ray.

Returns

  • Vector: The modified azimuth array, wrapped to the range [0, 360) degrees.
source
Daisho.mask_sectorFunction
mask_sector(volume, raw_moment_dict, qc_moments, qc_moment_dict, heading, az_min, az_max, mask_key) -> Matrix

Mask all radar data within a heading-relative azimuthal sector.

Gates whose heading-relative azimuth (earth-relative azimuth minus heading, modulo 360) falls between az_min and az_max are set to missing for all QC moment fields. Gates where mask_key is already missing are skipped.

Arguments

  • volume: Radar volume object containing range, azimuth, and elevation fields.
  • raw_moment_dict::Dict{String, Int}: Dictionary mapping raw moment names to column indices.
  • qc_moments::Matrix: QC radar moment data matrix to be modified (gates x moments).
  • qc_moment_dict::Dict{String, Int}: Dictionary mapping QC moment names to column indices.
  • heading::Vector: Per-ray heading values in degrees.
  • az_min::Real: Minimum heading-relative azimuth of the masked sector in degrees.
  • az_max::Real: Maximum heading-relative azimuth of the masked sector in degrees.
  • mask_key::String: Moment field name used to check if a gate is already masked.

Returns

  • Matrix: The modified qc_moments matrix with gates in the specified sector set to missing.
source
Daisho.smooth_sqiFunction
smooth_sqi(sqi)

Smooth the Signal Quality Index (SQI) field using a Gaussian kernel to help remove second-trip echo.

Warning

This function is not yet implemented and will throw an error if called.

Arguments

  • sqi: SQI data array to be smoothed.

Returns

Not yet implemented.

source