Skip to content

Commit d779cc5

Browse files
committed
use mask instead of providing ids
1 parent 2c06357 commit d779cc5

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

pyxlma/lmalib/lma_intercept_rhi.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ def find_points_near_rhi(lma_file, radar_latitude, radar_longitude, radar_altitu
225225
A 1D array representing the distance from the radar RHI scan plane to each filtered LMA point.
226226
lma_alt : `numpy.ndarray`
227227
A 1D array representing the height above the radar of each filtered LMA point.
228-
lma_ids : `numpy.ndarray`
229-
A 1D array representing the event_id of each filtered LMA point.
228+
point_mask : `numpy.ndarray`
229+
A 1D array of booleans representing the VHF points that were included in the return.
230230
"""
231231

232232
radar_azimuth = radar_azimuth % 360
@@ -239,10 +239,9 @@ def find_points_near_rhi(lma_file, radar_latitude, radar_longitude, radar_altitu
239239
lma_alt = projected_lma[:,2]
240240

241241
lma_times = lma_file.event_time.data.astype('datetime64[s]')
242-
points_i_want = (lma_dist < distance_threshold) & (np.abs(lma_times - radar_scan_time).astype(float) < time_threshold)
243-
lma_range = lma_range[points_i_want]
244-
lma_dist = lma_dist[points_i_want]
245-
lma_alt = lma_alt[points_i_want]
246-
lma_ids = lma_file.event_id.data[points_i_want]
242+
point_mask = (lma_dist < distance_threshold) & (np.abs(lma_times - radar_scan_time).astype(float) < time_threshold)
243+
lma_range = lma_range[point_mask]
244+
lma_dist = lma_dist[point_mask]
245+
lma_alt = lma_alt[point_mask]
247246

248-
return lma_range, lma_dist, lma_alt, lma_ids
247+
return lma_range, lma_dist, lma_alt, point_mask

tests/test_intercept_rhi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def test_intercept_rhi():
1111
files_to_read = listdir('examples/data/')
1212
files_to_read = ['examples/data/'+file for file in files_to_read]
1313
dataset, start_date = lma_read.dataset(files_to_read)
14-
lma_radar_range, lma_plane_distance, lma_arl, lma_ids = lma_intercept_rhi.find_points_near_rhi(dataset, 33.56, -101.81, 1600.0, 225, start_date+timedelta(seconds=30), distance_threshold=500, time_threshold=15)
15-
14+
lma_radar_range, lma_plane_distance, lma_arl, event_mask = lma_intercept_rhi.find_points_near_rhi(dataset, 33.56, -101.81, 1600.0, 225, start_date+timedelta(seconds=30), distance_threshold=500, time_threshold=15)
15+
lma_ids = dataset.event_id.isel(number_of_events=np.flatnonzero(event_mask))
1616
true_radar_range = np.array([-24314.95714263, -24255.42134556, -23947.00309296, -24201.07999466,
1717
-24216.22494555, -24209.0779143 , -24252.54770026, -24196.90100367,
1818
-24261.77984816, -24002.07311165, -23977.02349918, -23922.33835871,
@@ -63,4 +63,4 @@ def test_intercept_rhi():
6363
assert np.allclose(lma_radar_range, true_radar_range, atol=1e-3)
6464
assert np.allclose(lma_plane_distance, true_plane_distance, atol=1e-3)
6565
assert np.allclose(lma_arl, true_radar_arl, atol=1e-3)
66-
assert np.allclose(lma_ids, true_lma_ids, atol=1e-1)
66+
assert np.all(lma_ids == true_lma_ids)

0 commit comments

Comments
 (0)