Skip to content

Apply a neighborhood filter with radius r to all elements of UxDataArray #930

Closed

Description

@ahijevyc

Proposed new feature or change:

Apply a neighborhood filter within a circular radius r (in degrees) to a UxDataset or UxDataArray.

Overview

This is kind of like uxarray.UxDataArray.inverse_distance_weighted_remap , but the neighborhood is defined by distance, not a number of nearest neighbors. This is ideally suited for a variable resolution mesh, in which a constant of neighbors doesn't have a constant-sized neighborhood.

This function would share the same logic as uxarray.UxDataArray.subset.bounding_circle to select grid elements in a circular neighborhood, but apply it to all elements in grid, not just one center_coordinate.

Ideally, the filter function func would be a user-defined, but at a minimum would be capable of calculating a neighborhood-maximum. Other possibilities are np.mean, min, np.median and np.percentile.

Expected Usage

import numpy as np

import uxarray

grid_path = "/glade/campaign/mmm/wmr/weiwang/cps/irma3/2020/tk707_conus/init.nc"
data_path = "/glade/campaign/mmm/wmr/weiwang/cps/irma3/mp6/tk707/diag.2017-09-07_09.00.00.nc"
uxds = uxarray.open_mfdataset(
grid_path,
data_path
)

Trim domain

lon_bounds = (-74, -64)
lat_bounds = (18, 24)
uxda = uxds["refl10cm_max"].isel(Time=0).subset.bounding_box(lon_bounds, lat_bounds)
uxda

this is how you use this function to get the maximum value within a 0.25-deg neighborhood of each element.

uxda_smoothed_mean = uxda.apply_neighorhood_filter(func=max, r=0.25)

Activity

  1. moved this from 📚 Backlog to 🏗 In progress in UXarray Developmenton Sep 10, 2024
  2. moved this from 🏗 In progress to 👀 In review in UXarray Developmenton Oct 8, 2024
  3. moved this from 👀 In review to 🏗 In progress in UXarray Developmenton Mar 18, 2025
  4. removed their assignment
    on Sep 9, 2025
  5. moved this from 🏗 In progress to ✅ Done in UXarray Developmenton Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

new featureNew user-facing functionality

Type

No type

Fields

Priority

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions