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_thresholdSNR < p.qc.snr_thresholdRHOHV < p.qc.rhohv_thresholdWIDTH > 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.
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 amomentsmatrix.moment_dict::Dict{String, Int}: Dictionary mapping moment names to column indices involume.moments.
Returns
Nothing. The volume.moments RHOHV column is modified in place.
Daisho.despeckle — Function
despeckle(speckle, moments, moment_dict, n_gates, n_rays) -> MatrixRemove 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 modifiedmomentsmatrix with speckle features set tomissing.
Daisho.despeckle_azimuthal — Function
despeckle_azimuthal(speckle, moments, moment_dict, n_gates, n_rays) -> MatrixRemove 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 modifiedmomentsmatrix with azimuthal speckle features set tomissing.
Daisho.stddev_phidp_threshold — Function
stddev_phidp_threshold(moments, moment_dict, n_gates, n_rays, window=11, threshold=12) -> MatrixApply 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, default11).threshold::Real: Standard deviation threshold in degrees (default12).
Returns
Matrix: The modifiedmomentsmatrix with noisy PHIDP gates set tomissing.
Daisho.remove_platform_motion! — Function
remove_platform_motion!(volume, moments, moment_dict) -> MatrixRemove 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 containingrange,azimuth,elevation,ew_platform,ns_platform,w_platform, andnyquist_velocityfields.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 modifiedmomentsmatrix with platform-motion-corrected velocities.
Daisho.threshold_dbz — Function
threshold_dbz(volume, raw_moment_dict, qc_moments, qc_moment_dict, dbz_threshold, vel_threshold, sw_threshold) -> MatrixRemove 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 containingmomentsand metadata needed byget_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 modifiedqc_momentsmatrix with likely clutter gates set tomissing.
Daisho.threshold_height — Function
threshold_height(volume, raw_moment_dict, qc_moments, qc_moment_dict, height_threshold) -> MatrixRemove 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 containingmomentsand metadata needed byget_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 modifiedqc_momentsmatrix with low-height gates set tomissing.
Daisho.threshold_terrain_height — Function
threshold_terrain_height(volume, raw_moment_dict, qc_moments, qc_moment_dict, terrain_threshold, tile_dir) -> MatrixRemove 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.hgttile files.
Returns
Matrix: The modifiedqc_momentsmatrix with terrain-blocked gates set tomissing.
Daisho.add_azimuthal_offset — Function
add_azimuthal_offset(volume, az_offset) -> VectorAdd 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 anazimutharray.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.
Daisho.mask_sector — Function
mask_sector(volume, raw_moment_dict, qc_moments, qc_moment_dict, heading, az_min, az_max, mask_key) -> MatrixMask 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 containingrange,azimuth, andelevationfields.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 modifiedqc_momentsmatrix with gates in the specified sector set tomissing.
Daisho.smooth_sqi — Function
smooth_sqi(sqi)Smooth the Signal Quality Index (SQI) field using a Gaussian kernel to help remove second-trip echo.
Arguments
sqi: SQI data array to be smoothed.
Returns
Not yet implemented.