-
Notifications
You must be signed in to change notification settings - Fork 41
Description
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)
Metadata
Metadata
Labels
Type
Projects
Status