HELP PLEASE - Filtering Gates / Finding Closest Gates / Gate Filters

194 views
Skip to first unread message

James Strong

unread,
Feb 12, 2017, 5:37:50 PM2/12/17
to Py-ART Users
Hello all,

Glad to be a part of the Py-ART community. We are new here and HOPE you guys can help us with an issue we are having!

We are trying to do the following with Py-ART:
- Read a NEXRAD Level II radar file
- Filter out gates in that file based on reflectivity
- Take a lat/lon and find the closest gates around you to your current location (from the filtered gates)

Reading the file is simple:
radar = pyart.io.read_nexrad_archive('assets/radar/RADAR_FILE_HERE')

We THINK this is the correct way to do a gatefilter:
gatefilter = pyart.correct.GateFilter(radar)
gatefilter
.exclude_below('reflectivity', 40)

The question we have is how do we now take a lat/lon and look for gates closest to that lat/lon inside the gatefilter (since we don't want to have to look through all gates)

Currently to find reflectivity values at a lat/lon we are using sample code from this GitHub issue: https://github.com/ARM-DOE/pyart/issues/448 The problem with this though is it takes a long time to run and doesn't work well if you try to check a ton of points in a row.

Ideally we'd like to be able to:
- input a lat/lon/altitude 
- find the nearest gate to that location
- using the gate filter look for the closest gates to that location that have a reflectivity value > X
- check those gates distance to your current location (ideally we could just get a lat/lon of the gates we find and just calculate distance)

Any help would be GREATLY appreciated.

Thanks,
James Strong
Full-Stack Developer

Jonathan Helmus

unread,
Feb 13, 2017, 11:38:13 AM2/13/17
to pyart...@googlegroups.com
James,

    There are a number of method you can use to search the non-filtered gates from a radar.  The optimal method will depend on your exact use case.  To get you started a boolean array which selects the gates which are not excluded by the gatefilter [1] can be obtained using:

    gate_included = gatefilter.gate_included

This can be used to logically index the gate_latitude and gate_longitude entries to select out just the latitudes and longitudes not excluded by the gatefilter

valid_lats = radar.gate_latitude['data'][gate_included]
valid_lons = radar.gate_longitude['data'][gate_included]

There are numerous method to find the gate in these arrays nearest a give location.  A simple method would be to find the gate which minimizes the square distance in degrees:

sq_dist = (lat - valid_lats) ** 2 + (lon - valid_lons)**2
min_idx = np.argmin(sq_dist)
min_lat = valid_lats[min_idx]
min_lon = valid_lons[min_idx]

If multiple latitude and longitudes were to be examine, using a more efficient data structure to perform the lookup (such as a KD-Tree) may be more effective. 
 
Further reducing the number of gates to search would improve performance.  This could be done by selecting only the lowest sweep using the extract_sweeps [2] method of the Radar class [3], or using a method to combine/reduce the sweeps.

Cheers,

    - Jonathan Helmus

[1] http://arm-doe.github.io/pyart-docs-travis/user_reference/generated/pyart.filters.GateFilter.html
[2] http://arm-doe.github.io/pyart-docs-travis/user_reference/generated/pyart.core.Radar.extract_sweeps.html
[3] http://arm-doe.github.io/pyart-docs-travis/user_reference/generated/pyart.core.Radar.html
--
You received this message because you are subscribed to the Google Groups "Py-ART Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyart-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages