From 4fee030f47f4f450aac512dcbfe0702bef75695a Mon Sep 17 00:00:00 2001 From: "C.-W. HSU" <11950284+chiaweh2@users.noreply.github.com> Date: Tue, 9 Sep 2025 15:11:20 -0600 Subject: [PATCH 1/2] update package docstring --- map_binning/binning.py | 19 ++++++++++++++----- pyproject.toml | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/map_binning/binning.py b/map_binning/binning.py index 0751566..76e8137 100644 --- a/map_binning/binning.py +++ b/map_binning/binning.py @@ -24,8 +24,9 @@ class Binning: ydim_name : str, optional Name of the y (latitude) dimension in the datasets. Default is 'lat'. search_radius : float or None, optional - Radius in degrees to search for high-resolution points around each low-resolution grid point. - If None, the radius is automatically calculated based on the spacing of the low-resolution grid. + Radius in degrees to search for high-resolution points around each + low-resolution grid point. If None, the radius is automatically + calculated based on the spacing of the low-resolution grid. Methods ------- @@ -33,13 +34,21 @@ class Binning: Creates a mapping from each low-resolution grid point to the indices of high-resolution grid points within the specified search radius. + mean_binning() + Applies the binning index to compute the mean of high-resolution data + for each low-resolution grid point. + Examples -------- >>> import xarray as xr >>> from map_binning.binning import Binning >>> ds_high = xr.open_dataset('high_res_data.nc') >>> ds_low = xr.open_dataset('low_res_grid.nc') - >>> binning = Binning(ds_high, ds_low, var_name='temperature') + >>> binning = Binning( + ... ds_high, + ... ds_low, + ... var_name='temperature' + ... ) >>> binned_data = binning.mean_binning(precomputed_binning_index=False) >>> print(binned_data) xr.DataArray with binned mean values on the low-resolution grid. @@ -82,11 +91,11 @@ def create_binning_index(self): # check high-res is having more grid than low-res if len(high_lats) < len(low_lats): raise ValueError( - "High-resolution dataset latitude must have more grid points than low-resolution dataset." + "High-resolution latitude must have more grid points than low-resolution." ) if len(high_lons) < len(low_lons): raise ValueError( - "High-resolution dataset longitude must have more grid points than low-resolution dataset." + "High-resolution longitude must have more grid points than low-resolution." ) # Create meshgrids for high-res points diff --git a/pyproject.toml b/pyproject.toml index 27d870e..06df422 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "map-binning" -version = "0.3.1" +version = "0.3.2" description = "A map binning tool for spatial resampling" authors = [{name = "Chia-Wei Hsu", email = "chiaweh2@uci.edu"}] readme = "README.md" From bc2e8820f46ea982ab801604632e7a023614e49d Mon Sep 17 00:00:00 2001 From: "C.-W. HSU" <11950284+chiaweh2@users.noreply.github.com> Date: Tue, 9 Sep 2025 15:12:24 -0600 Subject: [PATCH 2/2] black it --- map_binning/binning.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/map_binning/binning.py b/map_binning/binning.py index 76e8137..755d812 100644 --- a/map_binning/binning.py +++ b/map_binning/binning.py @@ -25,7 +25,7 @@ class Binning: Name of the y (latitude) dimension in the datasets. Default is 'lat'. search_radius : float or None, optional Radius in degrees to search for high-resolution points around each - low-resolution grid point. If None, the radius is automatically + low-resolution grid point. If None, the radius is automatically calculated based on the spacing of the low-resolution grid. Methods