diff --git a/pyart/map/_gate_to_grid_map.pyx b/pyart/map/_gate_to_grid_map.pyx index bac6d7bf3d..79925991d1 100644 --- a/pyart/map/_gate_to_grid_map.pyx +++ b/pyart/map/_gate_to_grid_map.pyx @@ -134,10 +134,11 @@ cdef class DistBeamRoI(RoIFunction): z_offset = self.offsets[i, 0] y_offset = self.offsets[i, 1] x_offset = self.offsets[i, 2] - roi = (self.h_factor[0] * ((z - z_offset) / 20.0) + - sqrt((self.h_factor[1] * (y - y_offset))**2 + + roi = (sqrt((self.h_factor[0] * (z - z_offset))**2 + + (self.h_factor[1] * (y - y_offset))**2 + (self.h_factor[2] * (x - x_offset))**2) * - self.beam_factor) + self.beam_factor + ) if roi < self.min_radius: roi = self.min_radius if roi < min_roi: diff --git a/pyart/map/gates_to_grid.py b/pyart/map/gates_to_grid.py index 3ed1d228a5..6b4f59ed51 100644 --- a/pyart/map/gates_to_grid.py +++ b/pyart/map/gates_to_grid.py @@ -35,9 +35,9 @@ def map_gates_to_grid( constant_roi=None, z_factor=0.05, xy_factor=0.02, - min_radius=500.0, + min_radius=250.0, h_factor=(1.0, 1.0, 1.0), - nb=1.5, + nb=1.0, bsp=1.0, dist_factor=(1.0, 1.0, 1.0), **kwargs @@ -95,6 +95,19 @@ def map_gates_to_grid( if len(radars) == 0: raise ValueError("Length of radars tuple cannot be zero") + # set min_radius depending on whether processing ARM radars + try: + if "platform_id" in radars[0].metadata.keys(): + if np.any( + [ + x in radars[0].metadata["platform_id"].lower() + for x in ["sacr", "sapr"] + ] + ): + min_radius = 100.0 + except AttributeError: + pass + skip_transform = False if len(radars) == 1 and grid_origin_alt is None and grid_origin is None: skip_transform = True diff --git a/pyart/map/grid_mapper.py b/pyart/map/grid_mapper.py index 3949707eb7..5ccb75ac07 100644 --- a/pyart/map/grid_mapper.py +++ b/pyart/map/grid_mapper.py @@ -292,9 +292,9 @@ def map_to_grid( constant_roi=None, z_factor=0.05, xy_factor=0.02, - min_radius=500.0, - h_factor=1.0, - nb=1.5, + min_radius=250.0, + h_factor=(1.0, 1.0, 1.0), + nb=1.0, bsp=1.0, **kwargs ): @@ -394,8 +394,10 @@ def map_to_grid( h_factor, nb, bsp, min_radius : float Radius of influence parameters for the built in 'dist_beam' function. The parameter correspond to the height scaling, virtual beam width, - virtual beam spacing, and minimum radius of influence. These - parameters are only used when `roi_func` is 'dist_mean'. + virtual beam spacing, and minimum radius of influence. + NOTE: the default `min_radius` value is smaller for ARM radars + to reflect their higher resolution relative to precipitation radars.. + These parameters are only used when `roi_func` is 'dist_mean'. copy_field_data : bool True to copy the data within the radar fields for faster gridding, the dtype for all fields in the grid will be float64. False will not @@ -436,6 +438,19 @@ def map_to_grid( if len(radars) == 0: raise ValueError("Length of radars tuple cannot be zero") + # set min_radius depending on whether processing ARM radars + try: + if "platform_id" in radars[0].metadata.keys(): + if np.any( + [ + x in radars[0].metadata["platform_id"].lower() + for x in ["sacr", "sapr"] + ] + ): + min_radius = 100.0 + except AttributeError: + pass + skip_transform = False if len(radars) == 1 and grid_origin_alt is None and grid_origin is None: skip_transform = True diff --git a/tests/map/test_gates_to_grid.py b/tests/map/test_gates_to_grid.py index 5417795378..0a3da23fe2 100644 --- a/tests/map/test_gates_to_grid.py +++ b/tests/map/test_gates_to_grid.py @@ -136,11 +136,11 @@ def test_map_to_grid_tiny_grid(): grids = pyart.map.map_gates_to_grid( (radar,), grid_shape=(1, 1, 1), - grid_limits=((-400.0, 400.0), (-900.0, 900.0), (-900, 900)), + grid_limits=((0.0, 300.0), (-800.0, 800.0), (-800, 800)), fields=["reflectivity"], ) assert grids["reflectivity"].shape == (1, 1, 1) - assert abs(np.round(grids["reflectivity"][0]) - 40.0) < 0.01 + assert abs(np.round(grids["reflectivity"][0]) - 40.0) < 5.0 def test_grid_from_radars_gates_to_grid(): diff --git a/tests/map/test_grid_mapper.py b/tests/map/test_grid_mapper.py index ac396090e4..50c5c041e9 100644 --- a/tests/map/test_grid_mapper.py +++ b/tests/map/test_grid_mapper.py @@ -175,11 +175,11 @@ def test_map_to_grid_tiny_grid(): grids = pyart.map.map_to_grid( (radar,), grid_shape=(1, 1, 1), - grid_limits=((-400.0, 400.0), (-900.0, 900.0), (-900, 900)), + grid_limits=((0.0, 300.0), (-800.0, 800.0), (-800, 800)), fields=["reflectivity"], ) assert grids["reflectivity"].shape == (1, 1, 1) - assert int(grids["reflectivity"][0]) == 40 + assert abs(np.round(grids["reflectivity"][0]) - 40.0) < 5.0 def test_map_to_grid_errors(): diff --git a/tests/xradar/test_accessor.py b/tests/xradar/test_accessor.py index 6a0bc60fe4..044df28f47 100644 --- a/tests/xradar/test_accessor.py +++ b/tests/xradar/test_accessor.py @@ -81,9 +81,7 @@ def test_grid(filename=filename): fields=["DBZ"], ) assert_allclose(grid.x["data"], np.arange(-100_000, 120_000, 20_000)) - assert_allclose( - grid.fields["DBZ"]["data"][0, -1, 0], np.array(0.4243435), rtol=1e-03 - ) + assert_allclose(grid.fields["DBZ"]["data"][0, -1, 0], np.array(-0.511), rtol=1e-03) def _check_attrs_similar(grid1, grid2, attr):