Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freezing level masking in LP phase code makes invalid assumptions about scans for RHIs #1536

Open
rcjackson opened this issue Mar 26, 2024 · 0 comments
Labels
Bug Issue in the Code

Comments

@rcjackson
Copy link
Collaborator

  • Py-ART version: 1.18.0
  • Python version: 3.10.9
  • Operating System: Mac OS Ventura 13.2.1

Description

Trying to process KDP and phase with pyart.phase_proc_lp_gf with the following lines of code:

gatefilter = pyart.filters.GateFilter(rad)
gatefilter.exclude_below('normalized_coherent_power', 0.6)
phidp, kdp = pyart.correct.phase_proc_lp_gf(rad, gatefilter=gatefilter, 
                                           debug=True, nowrap=100, fzl=4000.)
rad.add_field('corrected_differential_phase', phidp, replace_existing=True)
rad.add_field('corrected_specific_differential_phase', kdp, replace_existing=True)

The output of the retrieved field is this, all zeros:
wrong_field

Setting the freezing level to 90 km, we get a more realistic KDP:
better_field

This made me suspect the way the freezing level is being masked out of the calculation was causing the issues. The code that does the masking in phase_proc.py:

def det_process_range(radar, sweep, fzl, doc=10):
    """
    Determine the processing range for a given sweep.

    Queues the radar and returns the indices which can be used to slice
    the radar fields and select the desired sweep with gates which are
    below a given altitude.

    Parameters
    ----------
    radar : Radar
        Radar object from which ranges will be determined.
    sweep : int
        Sweep (0 indexed) for which to determine processing ranges.
    fzl : float
        Maximum altitude in meters. The determined range will not include
        gates which are above this limit.
    doc : int, optional
        Minimum number of gates which will be excluded from the determined
        range.

    Returns
    -------
    gate_end : int
        Index of last gate below `fzl` and satisfying the `doc` parameter.
    ray_start : int
        Ray index which defines the start of the region.
    ray_end : int
        Ray index which defined the end of the region.

    """
    # determine the index of the last valid gate
    ranges = radar.range["data"]
    elevation = radar.fixed_angle["data"][sweep]
    radar_height = radar.altitude["data"]
    gate_end = fzl_index(fzl, ranges, elevation, radar_height)
    if doc is not None:
        gate_end = min(gate_end, len(ranges) - doc)
    else:
        gate_end = min(gate_end, len(ranges))

    ray_start = radar.sweep_start_ray_index["data"][sweep]
    ray_end = radar.sweep_end_ray_index["data"][sweep] + 1
    return gate_end, ray_start, ray_end

The problem is the assumption of constant elevation angles for the whole sweep (elevation = radar.fixed_angle["data"][sweep]) . This is fine for PPIs, but not for RHIs. This code will need to calculate the mask for each individual ray for RHIs.

@mgrover1 mgrover1 added the Bug Issue in the Code label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issue in the Code
Projects
None yet
Development

No branches or pull requests

2 participants